reformat files

This commit is contained in:
2025-04-18 15:04:22 +02:00
parent ca58ac86a4
commit 582ef21042
5 changed files with 1042 additions and 704 deletions

View File

@ -1,34 +1,59 @@
#!/usr/bin/python3
''' This Script decrypt Wireguardfiles for Wirepy users '''
""" This Script decrypt Wireguardfiles for Wirepy users """
import os
from subprocess import check_call
from pathlib import Path
import shutil
uname = Path('/tmp/.loguser')
from pathlib import Path
from subprocess import check_call
with open(uname, 'r') as f:
uname = Path("/tmp/.loguser")
with open(uname, "r") as f:
logname = f.readline()
''' Dirname "tlecdewg" = Tunnel Encrypt Decrypt Wireguard '''
dirname = Path('/tmp/tlecdcwg/')
keyfile = Path(f'/home/{logname}/.config/wire_py/pbwgk.pem')
pkeyfile = '/usr/local/etc/ssl/pwgk.pem'
""" Dirname "tlecdewg" = Tunnel Encrypt Decrypt Wireguard """
dirname = Path("/tmp/tlecdcwg/")
keyfile = Path(f"/home/{logname}/.config/wire_py/pbwgk.pem")
pkeyfile = "/usr/local/etc/ssl/pwgk.pem"
if not keyfile.is_file():
check_call(['openssl', 'rsa', '-in', pkeyfile, '-out', keyfile, '-outform', 'PEM', '-pubout'])
check_call(
[
"openssl",
"rsa",
"-in",
pkeyfile,
"-out",
keyfile,
"-outform",
"PEM",
"-pubout",
]
)
shutil.chown(keyfile, 1000, 1000)
dirname2 = ('/home/' + logname + '/.config/wire_py/')
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')
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', pkeyfile, '-in', detunnels, '-out', extpath])
shutil.chown(extpath, 1000, 1000)
tlname2 = detunnels[:-4] + ".conf"
extpath = str(dirname) + "/" + tlname2
check_call(
[
"openssl",
"pkeyutl",
"-decrypt",
"-inkey",
pkeyfile,
"-in",
detunnels,
"-out",
extpath,
]
)
shutil.chown(extpath, 1000, 1000)