mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-28 12:56:28 -04:00
Rebranding step 2
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# external modules
|
||||
# internal modules
|
||||
|
||||
import sshync
|
||||
from os import system as term
|
||||
from os import system
|
||||
from os import remove
|
||||
from os import environ
|
||||
from shutil import move
|
||||
@@ -15,12 +14,16 @@ import random
|
||||
import string
|
||||
|
||||
|
||||
# internal modules
|
||||
# custom modules
|
||||
|
||||
def clear():
|
||||
print('\n' * 100)
|
||||
|
||||
|
||||
def term(cmd):
|
||||
_ = system(cmd)
|
||||
|
||||
|
||||
def string_found(string1, string2):
|
||||
if search(r"\b" + escape(string1) + r"\b", string2):
|
||||
return True
|
||||
@@ -66,7 +69,7 @@ def encryptfolder():
|
||||
# argument - filter the argument to usable text
|
||||
|
||||
argument = str(argv).replace('[', '', 1).replace(']', '', 1).replace(',', '').replace("'", '') \
|
||||
.replace(' ', '', 1).replace('/usr/bin/', '', 1).replace('rpass', '', 1)
|
||||
.replace(' ', '', 1)
|
||||
|
||||
# help
|
||||
|
||||
@@ -113,7 +116,7 @@ if argument == 'version' or argument == '-v':
|
||||
print('/ /')
|
||||
print('/ rpass Copyright (C) 2021 Randall Winkhart /')
|
||||
print('/ /')
|
||||
print('/ Version 2021.10.18.mr5.1 /')
|
||||
print('/ Version 2021.11.01.mr5.1 /')
|
||||
print('/ The Notetaker Update /')
|
||||
print('/ /')
|
||||
print('////////////////////////////////////////////////////////\n')
|
||||
@@ -138,9 +141,17 @@ if argument == 'show c':
|
||||
if argument == 'config':
|
||||
try:
|
||||
print()
|
||||
directorychoice = str(input('Would you like to use the default entry directory (~/.rpass-store/)? (Y/n) '))
|
||||
if directorychoice == 'n' or directorychoice == 'N':
|
||||
print('\nFormat: /this/path/ends/with/a/slash/\n')
|
||||
directory = str(input('Please input a custom directory: '))
|
||||
open("/var/lib/rpass/rpass-dir", 'w').write(directory + '\n')
|
||||
else:
|
||||
open("/var/lib/rpass/rpass-dir", 'w').write('/home/' + environ.get('USER') + '/.rpass-store/' + '\n')
|
||||
print()
|
||||
devicetype = str(input('Will this be a client, server, or offline device? (C/s/o) '))
|
||||
if devicetype == 's' or devicetype == 'S':
|
||||
open("/var/lib/rpass/rpass-device", 'w').write(devicetype)
|
||||
open("/var/lib/rpass/rpass-ssh", 'w').write('\n\n\n\n' + devicetype)
|
||||
print('\nMake sure the ssh service is running and properly configured.\n')
|
||||
print('Configuration complete!\n')
|
||||
else:
|
||||
@@ -171,7 +182,7 @@ if argument == 'config':
|
||||
term('gpg -r ' + str(gpgid) + ' -e ' + '/var/lib/rpass/lock')
|
||||
remove('/var/lib/rpass/lock')
|
||||
if devicetype == 'o' or devicetype == 'O':
|
||||
open("/var/lib/rpass/rpass-device", 'w').write(devicetype)
|
||||
open("/var/lib/rpass/rpass-ssh", 'w').write('\n\n\n\n' + devicetype)
|
||||
print('\nConfiguration complete!\n')
|
||||
elif devicetype != 's' and devicetype != 'S':
|
||||
devicetype = 'c'
|
||||
@@ -192,9 +203,8 @@ if argument == 'config':
|
||||
directoryssh = str(input('What directory is the server using?: '))
|
||||
else:
|
||||
directoryssh = ('/home/' + usernamessh + '/.rpass-store/')
|
||||
open("/var/lib/rpass/rpass-device", 'w').write(devicetype)
|
||||
sshync.make_profile('/var/lib/rpass/rpass.sshync', '/home/' + environ.get('USER') + '/.rpass-store/',
|
||||
directoryssh, '/home/' + environ.get('USER') + '/.ssh/rpass', ip, port, usernamessh)
|
||||
open("/var/lib/rpass/rpass-ssh", 'w').write(usernamessh + '\n' + ip + '\n' + port + '\n' + directoryssh +
|
||||
'\n' + devicetype)
|
||||
print('\nConfiguration complete!\n')
|
||||
except KeyboardInterrupt:
|
||||
print('\n\nConfiguration cancelled.\n')
|
||||
@@ -210,20 +220,23 @@ if argument == '':
|
||||
# import userdata
|
||||
|
||||
try:
|
||||
devicetype = open('/var/lib/rpass/rpass-device').read().strip()
|
||||
gpgid = open("/var/lib/rpass/rpass-gpg").read().strip()
|
||||
sshinfo = sshync.get_profile('/var/lib/rpass/rpass.sshync')
|
||||
sshinfo = open("/var/lib/rpass/rpass-ssh").readlines()
|
||||
usernamessh = sshinfo[0].replace('\n', '')
|
||||
ip = sshinfo[1].replace('\n', '')
|
||||
port = sshinfo[2].replace('\n', '')
|
||||
directory = str(sshinfo[3].replace('\n', ''))
|
||||
directoryssh = sshinfo[4].replace('\n', '')
|
||||
directoryssh = sshinfo[3].replace('\n', '')
|
||||
devicetype = sshinfo[4].replace('\n', '')
|
||||
except (FileNotFoundError, IndexError):
|
||||
usernamessh, ip, port, directoryssh, devicetype = (0, 0, 0, 0, 0)
|
||||
directory = ''
|
||||
try:
|
||||
gpgid = open("/var/lib/rpass/rpass-gpg").read().strip()
|
||||
directory = open("/var/lib/rpass/rpass-dir").read().strip()
|
||||
term('mkdir -p ' + directory)
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print("Not all necessary configuration files are present. Please run 'rpass config'!")
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
devicetype, sshinfo, directory, directoryssh, ip, port, usernamessh = [0, 0, 0, 0, 0, 0, 0]
|
||||
exit()
|
||||
|
||||
# no argument
|
||||
@@ -292,7 +305,6 @@ if argument == 'add note' or argument == 'add -n':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('add')
|
||||
|
||||
if argument == 'add password' or argument == 'add -p':
|
||||
try:
|
||||
@@ -336,12 +348,10 @@ if argument == 'add password' or argument == 'add -p':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('add')
|
||||
|
||||
if argument == 'add folder' or argument == 'add -f':
|
||||
newfolder = str(input('Name of new folder: '))
|
||||
term('mkdir ' + "'" + directory + newfolder + "'")
|
||||
open("/var/lib/rpass/mod_time", 'w').write('add')
|
||||
|
||||
# edit
|
||||
|
||||
@@ -379,7 +389,6 @@ if argument == 'edit rename' or argument == 'edit relocate' or argument == 'edit
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('edit')
|
||||
|
||||
if argument == 'edit username' or argument == 'edit -u':
|
||||
try:
|
||||
@@ -422,7 +431,6 @@ if argument == 'edit username' or argument == 'edit -u':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('edit')
|
||||
|
||||
if argument == 'edit password' or argument == 'edit -p':
|
||||
try:
|
||||
@@ -465,7 +473,6 @@ if argument == 'edit password' or argument == 'edit -p':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('edit')
|
||||
|
||||
if argument == 'edit url' or argument == 'edit -l':
|
||||
try:
|
||||
@@ -508,7 +515,6 @@ if argument == 'edit url' or argument == 'edit -l':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('edit')
|
||||
|
||||
if argument == 'edit note' or argument == 'edit -n':
|
||||
try:
|
||||
@@ -550,7 +556,6 @@ if argument == 'edit note' or argument == 'edit -n':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('edit')
|
||||
|
||||
# copy
|
||||
|
||||
@@ -588,7 +593,6 @@ if argument == 'copy username' or argument == 'copy -u':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('copy')
|
||||
|
||||
if argument == 'copy password' or argument == 'copy -p':
|
||||
try:
|
||||
@@ -615,7 +619,6 @@ if argument == 'copy password' or argument == 'copy -p':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('copy')
|
||||
|
||||
if argument == 'copy url' or argument == 'copy -l':
|
||||
try:
|
||||
@@ -642,7 +645,6 @@ if argument == 'copy url' or argument == 'copy -l':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('copy')
|
||||
|
||||
if argument == 'copy note' or argument == 'copy -n':
|
||||
try:
|
||||
@@ -669,7 +671,6 @@ if argument == 'copy note' or argument == 'copy -n':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('copy')
|
||||
|
||||
# gen
|
||||
|
||||
@@ -716,7 +717,6 @@ if argument == 'gen':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('gen')
|
||||
|
||||
if argument == 'gen update' or argument == 'gen -u':
|
||||
try:
|
||||
@@ -765,7 +765,6 @@ if argument == 'gen update' or argument == 'gen -u':
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('gen')
|
||||
|
||||
# remove
|
||||
|
||||
@@ -806,7 +805,6 @@ if argument == 'remove' or argument == '-rm':
|
||||
print('The file you requested to delete does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('rm')
|
||||
|
||||
if argument.__contains__('-rm') or string_found('remove', argument) or string_found('add', argument) or \
|
||||
string_found('edit', argument) or string_found('gen', argument) or string_found('copy', argument) or \
|
||||
@@ -830,4 +828,7 @@ if devicetype == 'c':
|
||||
if argument.__contains__('-rm') or string_found('remove', argument) or string_found('add', argument) or \
|
||||
string_found('edit', argument) or string_found('gen', argument) or argument == 'sync' or argument == '-s':
|
||||
print('Syncing entries with other device(s)...\n')
|
||||
sshync.run_profile('/var/lib/rpass/rpass.sshync')
|
||||
term('rsync -v -H -r -l -t -p -e ' + '"ssh -i ~/.ssh/rpass -p ' + port + '" ' + directory + ' ' +
|
||||
usernamessh + '@' + ip + ':' + directoryssh)
|
||||
term('rsync -v -H -r -l -t -p --delete -e ' + '"ssh -i ~/.ssh/rpass -p ' + port + '" ' + usernamessh
|
||||
+ '@' + ip + ':' + directoryssh + ' ' + directory)
|
||||
|
||||
@@ -0,0 +1,833 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# external modules
|
||||
|
||||
import sshync
|
||||
from os import system as term
|
||||
from os import remove
|
||||
from os import environ
|
||||
from shutil import move
|
||||
from shutil import rmtree
|
||||
from sys import argv
|
||||
from re import search
|
||||
from re import escape
|
||||
import random
|
||||
import string
|
||||
|
||||
|
||||
# internal modules
|
||||
|
||||
def clear():
|
||||
print('\n' * 100)
|
||||
|
||||
|
||||
def string_found(string1, string2):
|
||||
if search(r"\b" + escape(string1) + r"\b", string2):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def replace_line(file_name, line_num, text):
|
||||
xlines = open(file_name, 'r').readlines()
|
||||
xlines[line_num] = text
|
||||
open(file_name, 'w').writelines(xlines)
|
||||
|
||||
|
||||
def edit_note():
|
||||
lines = open('/dev/shm/' + shmfolder + '/' + shmentry).readlines()
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(lines[0:3])
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry + '-n', 'w').writelines(lines[4:-2])
|
||||
term('nano /dev/shm/' + shmfolder + '/' + shmentry + '-n')
|
||||
edit_notes = open('/dev/shm/' + shmfolder + '/' + shmentry + '-n').read()
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'a').write('\n' + edit_notes + '\n\n')
|
||||
|
||||
|
||||
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():
|
||||
term('gpg -r ' + str(gpgid) + ' -e ' + "'" + '/dev/shm/' + shmfolder + '/' + shmentry + "'")
|
||||
move('/dev/shm/' + shmfolder + '/' + shmentry + '.gpg', directory + entryname.replace('/', '', 1) + '.gpg')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
|
||||
|
||||
def encryptfolder():
|
||||
term('gpg -r ' + str(gpgid) + ' -e ' + "'" + '/dev/shm/' + shmfolder + '/' + shmentry + "'")
|
||||
move('/dev/shm/' + shmfolder + '/' + shmentry + '.gpg', directory + folder + '/' + folderentry + '.gpg')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
|
||||
|
||||
# argument - filter the argument to usable text
|
||||
|
||||
argument = str(argv).replace('[', '', 1).replace(']', '', 1).replace(',', '').replace("'", '') \
|
||||
.replace(' ', '', 1).replace('/usr/bin/', '', 1).replace('rpass', '', 1).replace('./', '', 1).replace('.py', '', 1)
|
||||
|
||||
# help
|
||||
|
||||
if argument == 'help' or argument == '--help' or argument == '-h':
|
||||
print('\nrpass Copyright (C) 2021 Randall Winkhart')
|
||||
print("This program comes with ABSOLUTELY NO WARRANTY; for details type `rpass show w'.\nThis is free software, "
|
||||
"and you are welcome to redistribute it under certain conditions; type `rpass show c' for details.")
|
||||
print('\nUSAGE: rpass [/<entry name>] [OPTION] [FLAG]\n')
|
||||
print('Options: ')
|
||||
print('help/--help/-h bring up this menu')
|
||||
print('version/-v display rpass version info')
|
||||
print('config configure rpass')
|
||||
print('add add an entry')
|
||||
print('gen generate a new password')
|
||||
print('edit edit an existing entry')
|
||||
print('copy copy details of an entry to your clipboard')
|
||||
print('remove/-rm delete an existing entry')
|
||||
print('sync/-s manually sync the entry directory via rsync\n')
|
||||
print('Flags:')
|
||||
print('add:')
|
||||
print(' password/-p add a password entry')
|
||||
print(' note/-n add a note entry')
|
||||
print(' folder/-f add a new folder for entries')
|
||||
print('edit:')
|
||||
print(' rename/relocate/-r rename or relocate an entry')
|
||||
print(' username/-u change the username of an entry')
|
||||
print(' password/-p change the password of an entry')
|
||||
print(' note/-n change the note attached to an entry')
|
||||
print(' url/-l change the url attached to an entry')
|
||||
print('copy:')
|
||||
print(' username/-u copy the username of an entry to your clipboard')
|
||||
print(' password/-p copy the password of an entry to your clipboard')
|
||||
print(' url/-l copy the URL of an entry to your clipboard')
|
||||
print(' note/-n copy the note of an entry to your clipboard')
|
||||
print('gen:')
|
||||
print(' update/-u generate a password for an existing entry\n')
|
||||
print("Tip: You can quickly read an entry with 'rpass /<entry name>'!")
|
||||
print("When specifying entry names, do not include the file extension! '.gpg' is assumed!\n")
|
||||
|
||||
# version info
|
||||
|
||||
if argument == 'version' or argument == '-v':
|
||||
print('\n////////////////////////////////////////////////////////')
|
||||
print('/ /')
|
||||
print('/ rpass Copyright (C) 2021 Randall Winkhart /')
|
||||
print('/ /')
|
||||
print('/ Version 2021.10.18.mr5.1 /')
|
||||
print('/ The Notetaker Update /')
|
||||
print('/ /')
|
||||
print('////////////////////////////////////////////////////////\n')
|
||||
|
||||
# licensing info
|
||||
|
||||
if argument == 'show w':
|
||||
clear()
|
||||
print('This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;')
|
||||
print('without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.')
|
||||
print('See the GNU General Public License for more details.')
|
||||
print('\nhttps://opensource.org/licenses/GPL-3.0\n')
|
||||
|
||||
if argument == 'show c':
|
||||
clear()
|
||||
print('This program is free software: you can redistribute it and/or modify it under the terms of the GNU General')
|
||||
print('Public License as published by the Free Software Foundation, either version 3 of the License,')
|
||||
print('or (at your option) any later version.\n')
|
||||
|
||||
# config
|
||||
|
||||
if argument == 'config':
|
||||
try:
|
||||
print()
|
||||
devicetype = str(input('Will this be a client, server, or offline device? (C/s/o) '))
|
||||
if devicetype == 's' or devicetype == 'S':
|
||||
open("/var/lib/rpass/rpass-device", 'w').write(devicetype)
|
||||
print('\nMake sure the ssh service is running and properly configured.\n')
|
||||
print('Configuration complete!\n')
|
||||
else:
|
||||
gpgid = ''
|
||||
print()
|
||||
gpgpresent = str(input(
|
||||
'rpass requires the use of a unique gpg key. Do you already have one you are willing to use? (y/N) '))
|
||||
if gpgpresent == 'y' or gpgpresent == 'Y':
|
||||
print()
|
||||
gpgid = str(input('Please input the ID of your gpg key: '))
|
||||
open("/var/lib/rpass/rpass-gpg", 'w').write(gpgid + '\n')
|
||||
else:
|
||||
print()
|
||||
gpggen = str(
|
||||
input('Would you like to generate one now? Note that if you choose not to do this, you will have '
|
||||
'to re-run "rpass config" to specify a gpg key when you acquire one (Y/n) '))
|
||||
if gpggen == 'n' or gpggen == 'N':
|
||||
exit()
|
||||
else:
|
||||
term('gpg --full-generate-key')
|
||||
print()
|
||||
gpgid = str(input('Please input the ID of your gpg key: '))
|
||||
open("/var/lib/rpass/rpass-gpg", 'w').write(gpgid + '\n')
|
||||
try:
|
||||
open('/var/lib/rpass/lock', 'x').write('locked')
|
||||
except FileExistsError:
|
||||
pass
|
||||
term('gpg -r ' + str(gpgid) + ' -e ' + '/var/lib/rpass/lock')
|
||||
remove('/var/lib/rpass/lock')
|
||||
if devicetype == 'o' or devicetype == 'O':
|
||||
open("/var/lib/rpass/rpass-device", 'w').write(devicetype)
|
||||
print('\nConfiguration complete!\n')
|
||||
elif devicetype != 's' and devicetype != 'S':
|
||||
devicetype = 'c'
|
||||
print('\nMake sure the ssh service on the remote server is running and properly configured.\n')
|
||||
sshgen = str(input('rsync support requires a unique ssh key. Would you like to have this '
|
||||
'automatically generated? (Y/n) '))
|
||||
if sshgen != 'n' and sshgen != 'N':
|
||||
term('ssh-keygen -t ed25519 -f ~/.ssh/rpass')
|
||||
print('\nExample input: 10.10.10.10:9999\n')
|
||||
ip_port = str(input('What is the IP and ssh port of the remote server? '))
|
||||
print()
|
||||
ip, sep, port = ip_port.partition(':')
|
||||
usernamessh = str(input('What is the username of the remote server? '))
|
||||
print('\nDefault directory: ' + '/home/' + usernamessh + '/.rpass-store/\n')
|
||||
directoryssh = str(input('Is the remote server using the default password directory? (Y/n) '))
|
||||
if directoryssh == 'n' or directoryssh == 'N':
|
||||
print('\nFormat: /this/path/ends/with/a/slash/\n')
|
||||
directoryssh = str(input('What directory is the server using?: '))
|
||||
else:
|
||||
directoryssh = ('/home/' + usernamessh + '/.rpass-store/')
|
||||
open("/var/lib/rpass/rpass-device", 'w').write(devicetype)
|
||||
sshync.make_profile('/var/lib/rpass/rpass.sshync', '/home/' + environ.get('USER') + '/.rpass-store/',
|
||||
directoryssh, '/home/' + environ.get('USER') + '/.ssh/rpass', ip, port, usernamessh)
|
||||
print('\nConfiguration complete!\n')
|
||||
except KeyboardInterrupt:
|
||||
print('\n\nConfiguration cancelled.\n')
|
||||
exit()
|
||||
|
||||
# startup help
|
||||
|
||||
if argument == '':
|
||||
clear()
|
||||
print("Use 'help', '--help', or '-h' to see a list of commands.\n")
|
||||
print('rpass is currently early software with very little polish\n')
|
||||
|
||||
# import userdata
|
||||
|
||||
try:
|
||||
devicetype = open('/var/lib/rpass/rpass-device').read().strip()
|
||||
gpgid = open("/var/lib/rpass/rpass-gpg").read().strip()
|
||||
sshinfo = sshync.get_profile('/var/lib/rpass/rpass.sshync')
|
||||
usernamessh = sshinfo[0].replace('\n', '')
|
||||
ip = sshinfo[1].replace('\n', '')
|
||||
port = sshinfo[2].replace('\n', '')
|
||||
directory = str(sshinfo[3].replace('\n', ''))
|
||||
directoryssh = sshinfo[4].replace('\n', '')
|
||||
term('mkdir -p ' + directory)
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print("Not all necessary configuration files are present. Please run 'rpass config'!")
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
devicetype, sshinfo, directory, directoryssh, ip, port, usernamessh = [0, 0, 0, 0, 0, 0, 0]
|
||||
exit()
|
||||
|
||||
# no argument
|
||||
|
||||
if argument == '':
|
||||
try:
|
||||
print()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
readentry = str(input('Entry to read: '))
|
||||
clear()
|
||||
term('gpg -d ' + directory + "'" + readentry.replace('/', '', 1) + "'" + '.gpg')
|
||||
print()
|
||||
except KeyboardInterrupt:
|
||||
print('\n\nSelection cancelled.\n')
|
||||
exit()
|
||||
|
||||
# read shortcut
|
||||
|
||||
if argument.startswith('/'):
|
||||
if argument.replace('/', '', 1).__contains__('/'):
|
||||
folder, sep, folderentry = argument.replace('/', '', 1).partition('/')
|
||||
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d ' + directory + "'" + argument.replace('/', '', 1) + '.gpg' + "'")
|
||||
|
||||
# add
|
||||
|
||||
if argument == 'add':
|
||||
print('\nUSAGE: rpass add [FLAG]')
|
||||
print('Flags:')
|
||||
print('add:')
|
||||
print(' password/-p add a password entry')
|
||||
print(' note/-n add a note entry')
|
||||
print(' folder/-f add a new folder for entries\n')
|
||||
|
||||
if argument == 'add note' or argument == 'add -n':
|
||||
try:
|
||||
clear()
|
||||
entryname = str(input('Name of note: '))
|
||||
except KeyboardInterrupt:
|
||||
entryname, notes = (0, 0)
|
||||
print('\n\nEntry add cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
term('nano /dev/shm/' + shmfolder + '/' + shmentry + '-n')
|
||||
notes = open('/dev/shm/' + shmfolder + '/' + shmentry + '-n', 'r').read()
|
||||
try:
|
||||
if entryname.startswith('/'): # check if user input contains slashes
|
||||
if entryname.replace('/', '', 1).__contains__('/'): # create folder and entry if there are two slashes
|
||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines('\n\n\n\n' + notes + '\n\n')
|
||||
encryptfolder()
|
||||
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
||||
else: # create entry if there is only one slash
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines('\n\n\n\n' + notes + '\n\n')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
||||
else: # create entry if there are no slashes
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines('\n\n\n\n' + notes + '\n\n')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The folder you requested to access does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('add')
|
||||
|
||||
if argument == 'add password' or argument == 'add -p':
|
||||
try:
|
||||
clear()
|
||||
entryname = str(input('Name of service: '))
|
||||
username = str(input('Username: '))
|
||||
password = str(input('Password: '))
|
||||
url = str(input('URL: '))
|
||||
except KeyboardInterrupt:
|
||||
entryname, username, password, url, notes = (0, 0, 0, 0, 0)
|
||||
print('\n\nEntry add cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
add_note = input('Add a note to this entry? (y/N) ')
|
||||
if add_note == 'y' or add_note == 'Y':
|
||||
term('nano /dev/shm/' + shmfolder + '/' + shmentry + '-n')
|
||||
notes = open('/dev/shm/' + shmfolder + '/' + shmentry + '-n', 'r').read()
|
||||
else:
|
||||
notes = ''
|
||||
try:
|
||||
if entryname.startswith('/'):
|
||||
if entryname.replace('/', '', 1).__contains__('/'):
|
||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + password + '\n' + url
|
||||
+ '\n\n' + notes + '\n\n')
|
||||
encryptfolder()
|
||||
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
||||
else:
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + password + '\n' + url
|
||||
+ '\n\n' + notes + '\n\n')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
||||
else:
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + password + '\n' + url
|
||||
+ '\n\n' + notes + '\n\n')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The folder you requested to access does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('add')
|
||||
|
||||
if argument == 'add folder' or argument == 'add -f':
|
||||
newfolder = str(input('Name of new folder: '))
|
||||
term('mkdir ' + "'" + directory + newfolder + "'")
|
||||
open("/var/lib/rpass/mod_time", 'w').write('add')
|
||||
|
||||
# edit
|
||||
|
||||
if argument == 'edit':
|
||||
print('\nUSAGE: rpass edit [FLAG]')
|
||||
print('Flags:')
|
||||
print('edit:')
|
||||
print(' rename/relocate/-r rename or relocate an entry')
|
||||
print(' username/-u change the username of an entry')
|
||||
print(' password/-p change the password of an entry')
|
||||
print(' url/-l change the url attached to an entry')
|
||||
print(' note/-n change the note attached to an entry\n')
|
||||
|
||||
if argument == 'edit rename' or argument == 'edit relocate' or argument == 'edit -r':
|
||||
try:
|
||||
clear()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
entryname = str(input('What file would you like to edit? '))
|
||||
newname = str(input('New Name: '))
|
||||
if entryname.startswith('/'):
|
||||
if entryname.replace('/', '', 1).__contains__('/'):
|
||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||
move(directory + folder + '/' + folderentry + '.gpg', directory + '/' + newname + '.gpg')
|
||||
else:
|
||||
move(directory + entryname.replace('/', '', 1) + '.gpg',
|
||||
directory + newname.replace('/', '', 1) + '.gpg')
|
||||
else:
|
||||
move(directory + entryname + '.gpg', directory + newname + '.gpg')
|
||||
except KeyboardInterrupt:
|
||||
print('\n\nEdit cancelled.\n')
|
||||
exit()
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('edit')
|
||||
|
||||
if argument == 'edit username' or argument == 'edit -u':
|
||||
try:
|
||||
clear()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
entryname = str(input('What file would you like to edit? '))
|
||||
username = str(input('New Username: '))
|
||||
except KeyboardInterrupt:
|
||||
entryname, username = (0, 0)
|
||||
print('\n\nEdit cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
try:
|
||||
if entryname.startswith('/'):
|
||||
if entryname.replace('/', '', 1).__contains__('/'):
|
||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
||||
folder + '/' + folderentry + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 0, username + '\n')
|
||||
remove(directory + folder + '/' + folderentry + '.gpg')
|
||||
encryptfolder()
|
||||
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
||||
entryname.replace('/', '', 1) + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 0, username + '\n')
|
||||
remove(directory + entryname.replace('/', '', 1) + '.gpg')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + entryname + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 0, username + '\n')
|
||||
remove(directory + entryname + '.gpg')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('edit')
|
||||
|
||||
if argument == 'edit password' or argument == 'edit -p':
|
||||
try:
|
||||
clear()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
entryname = str(input('What file would you like to edit? '))
|
||||
password = str(input('New Password: '))
|
||||
except KeyboardInterrupt:
|
||||
entryname, password = (0, 0)
|
||||
print('\n\nEdit cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
try:
|
||||
if entryname.startswith('/'):
|
||||
if entryname.replace('/', '', 1).__contains__('/'):
|
||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
||||
folder + '/' + folderentry + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 1, password + '\n')
|
||||
remove(directory + folder + '/' + folderentry + '.gpg')
|
||||
encryptfolder()
|
||||
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
||||
entryname.replace('/', '', 1) + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 1, password + '\n')
|
||||
remove(directory + entryname.replace('/', '', 1) + '.gpg')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + entryname + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 1, password + '\n')
|
||||
remove(directory + entryname + '.gpg')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('edit')
|
||||
|
||||
if argument == 'edit url' or argument == 'edit -l':
|
||||
try:
|
||||
clear()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
entryname = str(input('What file would you like to edit? '))
|
||||
url = str(input('New URL: '))
|
||||
except KeyboardInterrupt:
|
||||
entryname, url = (0, 0)
|
||||
print('\n\nEdit cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
try:
|
||||
if entryname.startswith('/'):
|
||||
if entryname.replace('/', '', 1).__contains__('/'):
|
||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
||||
folder + '/' + folderentry + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 2, url + '\n')
|
||||
remove(directory + folder + '/' + folderentry + '.gpg')
|
||||
encryptfolder()
|
||||
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
||||
entryname.replace('/', '', 1) + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 2, url + '\n')
|
||||
remove(directory + entryname.replace('/', '', 1) + '.gpg')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + entryname + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 2, url + '\n')
|
||||
remove(directory + entryname + '.gpg')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('edit')
|
||||
|
||||
if argument == 'edit note' or argument == 'edit -n':
|
||||
try:
|
||||
clear()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
entryname = str(input('What file would you like to edit? '))
|
||||
except KeyboardInterrupt:
|
||||
entryname, notes = (0, 0)
|
||||
print('\n\nEdit cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
try:
|
||||
if entryname.startswith('/'):
|
||||
if entryname.replace('/', '', 1).__contains__('/'):
|
||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
||||
folder + '/' + folderentry + '.gpg')
|
||||
edit_note()
|
||||
remove(directory + folder + '/' + folderentry + '.gpg')
|
||||
encryptfolder()
|
||||
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
||||
entryname.replace('/', '', 1) + '.gpg')
|
||||
edit_note()
|
||||
remove(directory + entryname.replace('/', '', 1) + '.gpg')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + entryname + '.gpg')
|
||||
edit_note()
|
||||
remove(directory + entryname + '.gpg')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('edit')
|
||||
|
||||
# copy
|
||||
|
||||
if argument == 'copy':
|
||||
print('\nUSAGE: rpass copy [FLAG]')
|
||||
print('Flags:')
|
||||
print('copy:')
|
||||
print(' username/-u copy the username of an entry to your clipboard')
|
||||
print(' password/-p copy the password of an entry to your clipboard')
|
||||
print(' url/-l copy the URL of an entry to your clipboard')
|
||||
print(' note/-n copy the note of an entry to your clipboard\n')
|
||||
|
||||
if argument == 'copy username' or argument == 'copy -u':
|
||||
try:
|
||||
print()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
readentry = str(input('Entry to copy: '))
|
||||
except KeyboardInterrupt:
|
||||
readentry = 0
|
||||
print('\n\nCopy cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
try:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
||||
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
||||
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
||||
term('wl-copy ' + "'" + copyline[0].replace('\n', '') + "'")
|
||||
else:
|
||||
term('echo -n ' + "'" + copyline[0].replace('\n', '') + "'" + ' | xclip -sel c')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('copy')
|
||||
|
||||
if argument == 'copy password' or argument == 'copy -p':
|
||||
try:
|
||||
print()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
readentry = str(input('Entry to copy: '))
|
||||
except KeyboardInterrupt:
|
||||
readentry = 0
|
||||
print('\n\nCopy cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
try:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
||||
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
||||
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
||||
term('wl-copy ' + "'" + copyline[1].replace('\n', '').replace("'", "'\\''") + "'")
|
||||
else:
|
||||
term('echo -n ' + "'" + copyline[1].replace('\n', '').replace("'", "'\\''") + "'" + ' | xclip -sel c')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('copy')
|
||||
|
||||
if argument == 'copy url' or argument == 'copy -l':
|
||||
try:
|
||||
print()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
readentry = str(input('Entry to copy: '))
|
||||
except KeyboardInterrupt:
|
||||
readentry = 0
|
||||
print('\n\nCopy cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
try:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
||||
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
||||
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
||||
term('wl-copy ' + "'" + copyline[2].replace('\n', '') + "'")
|
||||
else:
|
||||
term('echo -n ' + "'" + copyline[2].replace('\n', '') + "'" + ' | xclip -sel c')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('copy')
|
||||
|
||||
if argument == 'copy note' or argument == 'copy -n':
|
||||
try:
|
||||
print()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
readentry = str(input('Entry to copy: '))
|
||||
except KeyboardInterrupt:
|
||||
readentry = 0
|
||||
print('\n\nCopy cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
try:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + readentry + '.gpg')
|
||||
copyline = open('/dev/shm/' + shmfolder + '/' + shmentry, 'r').readlines()
|
||||
if environ.get('WAYLAND_DISPLAY') == 'wayland-0':
|
||||
term('wl-copy ' + "'" + copyline[4].replace('\n', '') + "'")
|
||||
else:
|
||||
term('echo -n ' + "'" + copyline[4].replace('\n', '') + "'" + ' | xclip -sel c')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('copy')
|
||||
|
||||
# gen
|
||||
|
||||
if argument == 'gen':
|
||||
try:
|
||||
clear()
|
||||
entryname = str(input('Name of service: '))
|
||||
username = str(input('Username: '))
|
||||
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) '))
|
||||
if passtype != 's':
|
||||
passtype = string.ascii_letters + string.digits + string.punctuation
|
||||
if passtype == 's':
|
||||
passtype = string.ascii_letters + string.digits
|
||||
passgen = ''.join(random.SystemRandom().choice(passtype) for _ in range(passlength))
|
||||
url = str(input('URL: '))
|
||||
notes = str(input('Additional notes: '))
|
||||
except KeyboardInterrupt:
|
||||
entryname, username, passgen, url, notes = (0, 0, 0, 0, 0)
|
||||
print('\n\nEntry generation cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
try:
|
||||
if entryname.startswith('/'):
|
||||
if entryname.replace('/', '', 1).__contains__('/'):
|
||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + passgen + '\n' + url
|
||||
+ '\n' + notes + '\n\n')
|
||||
encryptfolder()
|
||||
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
||||
else:
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + passgen + '\n' + url
|
||||
+ '\n' + notes + '\n\n')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
||||
else:
|
||||
open('/dev/shm/' + shmfolder + '/' + shmentry, 'w').writelines(username + '\n' + passgen + '\n' + url
|
||||
+ '\n' + notes + '\n\n')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The folder you requested to access does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('gen')
|
||||
|
||||
if argument == 'gen update' or argument == 'gen -u':
|
||||
try:
|
||||
clear()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
entryname = str(input('Which password would you like to re-generate? '))
|
||||
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) '))
|
||||
except KeyboardInterrupt:
|
||||
entryname, passlength, passtype = (0, 0, 0)
|
||||
print('\n\nEntry generation cancelled.\n')
|
||||
exit()
|
||||
shmfolder, shmentry = shmgen()
|
||||
try:
|
||||
if passtype != 's':
|
||||
passtype = string.ascii_letters + string.digits + string.punctuation
|
||||
if passtype == 's':
|
||||
passtype = string.ascii_letters + string.digits
|
||||
passgen = ''.join(random.SystemRandom().choice(passtype) for _ in range(passlength))
|
||||
if entryname.startswith('/'):
|
||||
if entryname.replace('/', '', 1).__contains__('/'):
|
||||
folder, sep, folderentry = entryname.replace('/', '', 1).partition('/')
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
||||
folder + '/' + folderentry + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 1, passgen + '\n')
|
||||
remove(directory + folder + '/' + folderentry.replace('/', '', 1) + '.gpg')
|
||||
encryptfolder()
|
||||
term('gpg -d ' + directory + folder + '/' + "'" + folderentry + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory +
|
||||
entryname.replace('/', '', 1) + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 1, passgen + '\n')
|
||||
remove(directory + entryname.replace('/', '', 1) + '.gpg')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname.replace('/', '', 1) + '.gpg' + "'")
|
||||
else:
|
||||
term('gpg -d --output /dev/shm/' + shmfolder + '/' + shmentry + ' ' + directory + entryname + '.gpg')
|
||||
replace_line('/dev/shm/' + shmfolder + '/' + shmentry, 1, passgen + '\n')
|
||||
remove(directory + entryname + '.gpg')
|
||||
encrypt()
|
||||
term('gpg -d ' + directory + "'" + entryname + '.gpg' + "'")
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to edit does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
rmtree('/dev/shm/' + shmfolder)
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('gen')
|
||||
|
||||
# remove
|
||||
|
||||
if argument == 'remove' or argument == '-rm':
|
||||
clear()
|
||||
term('cd ' + directory + '; ls -1 *')
|
||||
print()
|
||||
try:
|
||||
entryname = str(input('What would you like to delete? '))
|
||||
try:
|
||||
term('gpg -d --output /dev/shm/rpass.lock /var/lib/rpass/lock.gpg')
|
||||
unlocker = open('/dev/shm/rpass.lock', 'r').readlines()
|
||||
remove('/dev/shm/rpass.lock')
|
||||
except FileNotFoundError:
|
||||
print('\nAccess denied.\n')
|
||||
exit()
|
||||
if entryname.startswith('/'):
|
||||
if entryname.replace('/', '', 1).__contains__('/'):
|
||||
if devicetype == 'c':
|
||||
term('ssh -p ' + port + ' ' + usernamessh + '@' + ip + ' "' + ' rm -rf ' + "'" + directoryssh +
|
||||
entryname.replace('/', '', 1) + '.gpg' + "'" + '"')
|
||||
remove(directory + entryname.replace('/', '', 1) + '.gpg')
|
||||
else:
|
||||
if devicetype == 'c':
|
||||
term('ssh -p ' + port + ' ' + usernamessh + '@' + ip + ' "' + ' rm -rf ' + "'" + directoryssh +
|
||||
entryname.replace('/', '', 1) + "'" + '"')
|
||||
rmtree(directory + entryname.replace('/', '', 1))
|
||||
else:
|
||||
if devicetype == 'c':
|
||||
term('ssh -p ' + port + ' ' + usernamessh + '@' + ip + ' "' + ' rm -rf ' + "'" + directoryssh +
|
||||
entryname + '.gpg' + "'" + '"')
|
||||
remove(directory + entryname + '.gpg')
|
||||
except KeyboardInterrupt:
|
||||
print('\n\nDeletion cancelled.\n')
|
||||
exit()
|
||||
except FileNotFoundError:
|
||||
print('\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||
print('The file you requested to delete does not exist!')
|
||||
print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n')
|
||||
exit()
|
||||
open("/var/lib/rpass/mod_time", 'w').write('rm')
|
||||
|
||||
if argument.__contains__('-rm') or string_found('remove', argument) or string_found('add', argument) or \
|
||||
string_found('edit', argument) or string_found('gen', argument) or string_found('copy', argument) or \
|
||||
string_found('/', argument) or argument == 'sync' or argument == '-s' or argument == '' or argument == 'help' \
|
||||
or argument == '--help' or argument == '-h' or argument == 'version' or argument == '-v' or argument == \
|
||||
'config' or argument == 'show w' or argument == 'show c':
|
||||
pass
|
||||
else:
|
||||
print('\n!!!!!!!!!!!!!!!')
|
||||
print('Argument error!')
|
||||
print('!!!!!!!!!!!!!!!')
|
||||
print("\nUse 'help', '--help', or '-h' to see a list of commands.\n")
|
||||
|
||||
# permissions - applied pre-sync to ensure permissions are correct before upload
|
||||
|
||||
term('find ' + directory + ' -type d -exec chmod -R 700 {} +')
|
||||
term('find ' + directory + ' -type f -exec chmod -R 600 {} +')
|
||||
|
||||
# rsync - ran at end of program to ensure all files are properly synced
|
||||
if devicetype == 'c':
|
||||
if argument.__contains__('-rm') or string_found('remove', argument) or string_found('add', argument) or \
|
||||
string_found('edit', argument) or string_found('gen', argument) or argument == 'sync' or argument == '-s':
|
||||
print('Syncing entries with other device(s)...\n')
|
||||
sshync.run_profile('/var/lib/rpass/rpass.sshync')
|
||||
Reference in New Issue
Block a user