mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-03 15:47:18 -04:00
optimized /dev/shm string generation
This commit is contained in:
+22
-85
@@ -30,6 +30,15 @@ def replace_line(file_name, line_num, text):
|
|||||||
out.close()
|
out.close()
|
||||||
|
|
||||||
|
|
||||||
|
def shmgen():
|
||||||
|
shmfoldergen = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
||||||
|
for _ in range(random.randint(10, 30)))
|
||||||
|
shmentrygen = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
||||||
|
for _ in range(random.randint(10, 30)))
|
||||||
|
term('mkdir -p /dev/shm/' + shmfoldergen)
|
||||||
|
return shmfoldergen, shmentrygen
|
||||||
|
|
||||||
|
|
||||||
def encrypt():
|
def encrypt():
|
||||||
term('gpg -r ' + str(gpgid) + ' -e ' + "'" + '/dev/shm/' + shmfolder + '/' + shmentry + "'")
|
term('gpg -r ' + str(gpgid) + ' -e ' + "'" + '/dev/shm/' + shmfolder + '/' + shmentry + "'")
|
||||||
move('/dev/shm/' + shmfolder + '/' + shmentry + '.gpg', directory + entryname.replace('/', '', 1) + '.gpg')
|
move('/dev/shm/' + shmfolder + '/' + shmentry + '.gpg', directory + entryname.replace('/', '', 1) + '.gpg')
|
||||||
@@ -121,7 +130,7 @@ if argument == 'version' or argument == '-v':
|
|||||||
print('/ /')
|
print('/ /')
|
||||||
print('/ rpass Copyright (C) 2021 Randall Winkhart /')
|
print('/ rpass Copyright (C) 2021 Randall Winkhart /')
|
||||||
print('/ /')
|
print('/ /')
|
||||||
print('/ Version 2021.09.12.pr4 /')
|
print('/ Version 2021.09.14.pr4 /')
|
||||||
print('/ The Housekeeping Update (Pt. 1) /')
|
print('/ The Housekeeping Update (Pt. 1) /')
|
||||||
print('/ /')
|
print('/ /')
|
||||||
print('////////////////////////////////////////////////////////')
|
print('////////////////////////////////////////////////////////')
|
||||||
@@ -279,13 +288,7 @@ if argument == 'add note' or argument == 'add -n':
|
|||||||
clear()
|
clear()
|
||||||
entryname = str(input('Name of note: '))
|
entryname = str(input('Name of note: '))
|
||||||
notes = str(input('Contents of note: '))
|
notes = str(input('Contents of note: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
if entryname.startswith('/'):
|
if entryname.startswith('/'):
|
||||||
if entryname.replace('/', '', 1).__contains__('/'):
|
if entryname.replace('/', '', 1).__contains__('/'):
|
||||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||||
@@ -311,13 +314,7 @@ if argument == 'add password' or argument == 'add -p':
|
|||||||
password = str(input('Password: '))
|
password = str(input('Password: '))
|
||||||
url = str(input('URL: '))
|
url = str(input('URL: '))
|
||||||
notes = str(input('Additional notes: '))
|
notes = str(input('Additional notes: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
if entryname.startswith('/'):
|
if entryname.startswith('/'):
|
||||||
if entryname.replace('/', '', 1).__contains__('/'):
|
if entryname.replace('/', '', 1).__contains__('/'):
|
||||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||||
@@ -375,13 +372,7 @@ if argument == 'edit username' or argument == 'edit -u':
|
|||||||
print()
|
print()
|
||||||
entryname = str(input('What file would you like to edit? '))
|
entryname = str(input('What file would you like to edit? '))
|
||||||
username = str(input('New Username: '))
|
username = str(input('New Username: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
if entryname.startswith('/'):
|
if entryname.startswith('/'):
|
||||||
if entryname.replace('/', '', 1).__contains__('/'):
|
if entryname.replace('/', '', 1).__contains__('/'):
|
||||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||||
@@ -411,13 +402,7 @@ if argument == 'edit password' or argument == 'edit -p':
|
|||||||
print()
|
print()
|
||||||
entryname = str(input('What file would you like to edit? '))
|
entryname = str(input('What file would you like to edit? '))
|
||||||
password = str(input('New Password: '))
|
password = str(input('New Password: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
if entryname.startswith('/'):
|
if entryname.startswith('/'):
|
||||||
if entryname.replace('/', '', 1).__contains__('/'):
|
if entryname.replace('/', '', 1).__contains__('/'):
|
||||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||||
@@ -447,13 +432,7 @@ if argument == 'edit url' or argument == 'edit -l':
|
|||||||
print()
|
print()
|
||||||
entryname = str(input('What file would you like to edit? '))
|
entryname = str(input('What file would you like to edit? '))
|
||||||
url = str(input('New URL: '))
|
url = str(input('New URL: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
if entryname.startswith('/'):
|
if entryname.startswith('/'):
|
||||||
if entryname.replace('/', '', 1).__contains__('/'):
|
if entryname.replace('/', '', 1).__contains__('/'):
|
||||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||||
@@ -483,13 +462,7 @@ if argument == 'edit note' or argument == 'edit -n':
|
|||||||
print()
|
print()
|
||||||
entryname = str(input('What file would you like to edit? '))
|
entryname = str(input('What file would you like to edit? '))
|
||||||
notes = str(input('New Note: '))
|
notes = str(input('New Note: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
if entryname.startswith('/'):
|
if entryname.startswith('/'):
|
||||||
if entryname.replace('/', '', 1).__contains__('/'):
|
if entryname.replace('/', '', 1).__contains__('/'):
|
||||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||||
@@ -531,13 +504,7 @@ if argument == 'copy username' or argument == 'copy -u':
|
|||||||
term('cd ~/.rpass-store; ls -1 *')
|
term('cd ~/.rpass-store; ls -1 *')
|
||||||
print()
|
print()
|
||||||
readentry = str(input('Entry to copy: '))
|
readentry = str(input('Entry to copy: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
||||||
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
||||||
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
||||||
@@ -551,13 +518,7 @@ if argument == 'copy password' or argument == 'copy -p':
|
|||||||
term('cd ~/.rpass-store; ls -1 *')
|
term('cd ~/.rpass-store; ls -1 *')
|
||||||
print()
|
print()
|
||||||
readentry = str(input('Entry to copy: '))
|
readentry = str(input('Entry to copy: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
||||||
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
||||||
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
||||||
@@ -571,13 +532,7 @@ if argument == 'copy url' or argument == 'copy -l':
|
|||||||
term('cd ~/.rpass-store; ls -1 *')
|
term('cd ~/.rpass-store; ls -1 *')
|
||||||
print()
|
print()
|
||||||
readentry = str(input('Entry to copy: '))
|
readentry = str(input('Entry to copy: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
||||||
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
||||||
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
||||||
@@ -591,13 +546,7 @@ if argument == 'copy note' or argument == 'copy -n':
|
|||||||
term('cd ~/.rpass-store; ls -1 *')
|
term('cd ~/.rpass-store; ls -1 *')
|
||||||
print()
|
print()
|
||||||
readentry = str(input('Entry to copy: '))
|
readentry = str(input('Entry to copy: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
||||||
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
||||||
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
||||||
@@ -621,13 +570,7 @@ if argument == 'gen':
|
|||||||
passgen = ''.join(random.SystemRandom().choice(passtype) for _ in range(passlength))
|
passgen = ''.join(random.SystemRandom().choice(passtype) for _ in range(passlength))
|
||||||
url = str(input('URL: '))
|
url = str(input('URL: '))
|
||||||
notes = str(input('Additional notes: '))
|
notes = str(input('Additional notes: '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
if entryname.startswith('/'):
|
if entryname.startswith('/'):
|
||||||
if entryname.replace('/', '', 1).__contains__('/'):
|
if entryname.replace('/', '', 1).__contains__('/'):
|
||||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||||
@@ -653,13 +596,7 @@ if argument == 'gen update' or argument == 'gen -u':
|
|||||||
entryname = str(input('Which password would you like to re-generate? '))
|
entryname = str(input('Which password would you like to re-generate? '))
|
||||||
passlength = int(input('How many characters should be in the password? '))
|
passlength = int(input('How many characters should be in the password? '))
|
||||||
passtype = str(input('Should the password be simple (for compatibility) or complex (for security)? (s/C) '))
|
passtype = str(input('Should the password be simple (for compatibility) or complex (for security)? (s/C) '))
|
||||||
# generate random strings for /dev/shm
|
shmfolder, shmentry = shmgen()
|
||||||
shmfolder = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
shmentry = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits)
|
|
||||||
for _ in range(random.randint(10, 30)))
|
|
||||||
term('mkdir -p /dev/shm/' + shmfolder)
|
|
||||||
# end string and folder generation
|
|
||||||
if passtype != 's':
|
if passtype != 's':
|
||||||
passtype = string.ascii_letters + string.digits + string.punctuation
|
passtype = string.ascii_letters + string.digits + string.punctuation
|
||||||
if passtype == 's':
|
if passtype == 's':
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
|
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
|
||||||
|
|
||||||
rpass-2021.09.08.pr4
|
rpass-2021.09.14.pr4
|
||||||
|
|
||||||
The Housekeeping Update (Pt. 1) - Fourth public release of rpass
|
The Housekeeping Update (Pt. 1) - Fourth public release of rpass
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ making any major changes in the future.
|
|||||||
|
|
||||||
New features:
|
New features:
|
||||||
|
|
||||||
- added initial clipboard (password copy) support
|
- added clipboard support for copying entry information
|
||||||
**overhaul error messages using exceptions
|
**overhaul error messages using exceptions
|
||||||
**add exceptions for unknown arguments
|
**add exceptions for unknown arguments
|
||||||
**make clean, colorful file list by exporting to document and removing extensions
|
**make clean, colorful file list by exporting to document and removing extensions
|
||||||
@@ -21,6 +21,7 @@ Changes:
|
|||||||
- fixed gpg decryption warnings
|
- fixed gpg decryption warnings
|
||||||
- added version info argument
|
- added version info argument
|
||||||
- re-ordered config wizard for better rsync support
|
- re-ordered config wizard for better rsync support
|
||||||
|
- optimized code for random string generation in /dev/shm
|
||||||
**optimize code (specifically for when there is no folder but there is a slash)
|
**optimize code (specifically for when there is no folder but there is a slash)
|
||||||
**fix rsync delete on upload
|
**fix rsync delete on upload
|
||||||
**properly comment the code
|
**properly comment the code
|
||||||
|
|||||||
Reference in New Issue
Block a user