reformat files
This commit is contained in:
@ -1,25 +1,37 @@
|
||||
#!/usr/bin/python3
|
||||
''' This Script encrypt Wireguardfiles for Wirepy users for more Security'''
|
||||
""" This Script encrypt Wireguardfiles for Wirepy users for more Security"""
|
||||
|
||||
import os
|
||||
from subprocess import check_call
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
|
||||
uname = Path('/tmp/.loguser')
|
||||
uname = Path("/tmp/.loguser")
|
||||
|
||||
with open(uname, 'r') as f:
|
||||
with open(uname, "r") as f:
|
||||
logname = f.readline()
|
||||
|
||||
keyfile = Path(f'/home/{logname}/.config/wire_py/pbwgk.pem')
|
||||
dirname = Path('/tmp/tlecdcwg/')
|
||||
pkeyfile = '/usr/local/etc/ssl/pwgk.pem'
|
||||
keyfile = Path(f"/home/{logname}/.config/wire_py/pbwgk.pem")
|
||||
dirname = Path("/tmp/tlecdcwg/")
|
||||
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)
|
||||
|
||||
|
||||
if dirname.exists():
|
||||
tl = os.listdir(str(dirname))
|
||||
cpth = str(keyfile)
|
||||
@ -27,9 +39,22 @@ if not keyfile.is_file():
|
||||
|
||||
if keyfile.exists() and len(tl) != 0:
|
||||
for tunnels in tl:
|
||||
sourcetl = str(dirname) + '/' + tunnels
|
||||
tlname = cryptfiles + tunnels[:-5] + '.dat'
|
||||
check_call(['openssl', 'pkeyutl', '-encrypt', '-inkey', keyfile, '-pubin', '-in', sourcetl, '-out', tlname])
|
||||
sourcetl = str(dirname) + "/" + tunnels
|
||||
tlname = cryptfiles + tunnels[:-5] + ".dat"
|
||||
check_call(
|
||||
[
|
||||
"openssl",
|
||||
"pkeyutl",
|
||||
"-encrypt",
|
||||
"-inkey",
|
||||
keyfile,
|
||||
"-pubin",
|
||||
"-in",
|
||||
sourcetl,
|
||||
"-out",
|
||||
tlname,
|
||||
]
|
||||
)
|
||||
|
||||
else:
|
||||
|
||||
@ -40,10 +65,19 @@ else:
|
||||
|
||||
if keyfile.exists() and len(tl) != 0:
|
||||
for tunnels in tl:
|
||||
sourcetl = str(dirname) + '/' + tunnels
|
||||
tlname = cryptfiles + tunnels[:-5] + '.dat'
|
||||
check_call(['openssl', 'pkeyutl', '-encrypt', '-inkey', keyfile, '-pubin', '-in', sourcetl, '-out', tlname])
|
||||
|
||||
|
||||
|
||||
|
||||
sourcetl = str(dirname) + "/" + tunnels
|
||||
tlname = cryptfiles + tunnels[:-5] + ".dat"
|
||||
check_call(
|
||||
[
|
||||
"openssl",
|
||||
"pkeyutl",
|
||||
"-encrypt",
|
||||
"-inkey",
|
||||
keyfile,
|
||||
"-pubin",
|
||||
"-in",
|
||||
sourcetl,
|
||||
"-out",
|
||||
tlname,
|
||||
]
|
||||
)
|
||||
|
Reference in New Issue
Block a user