Wire-Py/ssl_decrypt.py

28 lines
874 B
Python
Executable File

#!/usr/bin/python3
''' This Script decrypt Wireguardfiles for Wirepy users '''
import os
from subprocess import check_call
from pathlib import Path
import shutil
uname = Path('/tmp/.loguser')
with open(uname, 'r') as f:
logname = f.readline()
''' Dirname "tlecdewg" = Tunnel Encrypt Decrypt Wireguard '''
dirname = Path('/tmp/tlecdcwg/')
keyfile = '/usr/local/etc/ssl/pwgk.pem'
dirname2 = ('/home/' + logname + '/.config/wire_py/')
detl = os.listdir(dirname2)
os.chdir(dirname2)
detl.remove('keys')
detl.remove('settings')
if os.path.exists(dirname2 + 'pbwgk.pem'):
detl.remove('pbwgk.pem')
for detunnels in detl:
tlname2 = detunnels[:-4] + '.conf'
extpath = str(dirname) + '/' + tlname2
check_call(['openssl', 'pkeyutl', '-decrypt', '-inkey', keyfile, '-in', detunnels, '-out', extpath])
shutil.chown(extpath, 1000, 1000)