mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-31 14:26:29 -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)
|
||||
|
||||
Reference in New Issue
Block a user