-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.py
123 lines (103 loc) · 3.99 KB
/
shell.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env python3
#-*- coding:utf-8 -*-
import os
import sys
from encode import Encode
#--------------------- DEFINITIONS ---------------------
platform_list = []
crypt = Encode()
try:
with open("hashes.txt", "r") as f:
read = f.readlines()
except FileNotFoundError:
os.system("touch hashes.txt")
with open("hashes.txt", "r") as f:
read = f.readlines()
read = "".join(read).split("$")
for platform in read[3::2]:
platform_list.append(platform)
#--------------------- FUNCTIONS ---------------------
def lists():
try:
with open("hashes.txt", "r") as f:
read = f.readlines()
read = "".join(read).split("$")
final_platform = platform_list[-1]
if read[-2] != final_platform:
#x= -2
platform_list.append(read[-2])
# If you're enter more than one argument, without command list, it gives only last one argument.
# In the following rows, will update soon.
"""
x = (read.index(read[-2]) - read.index(final_platform))*(-2)
while read[x] != final_platform:
x+=2
platform_list.append(read[x])
"""
print("All platforms in following line!\n")
for i in platform_list:
print(i.capitalize())
if read[-2] != platform_list[-1]:
print(read[-2].capitalize())
print()
except IndexError:
print("There are no platforms here :) Please add new platform using \"new\" ")
def shell():
while True:
command = input("shell> ").lstrip(" ").rstrip(" ")
if command == "help":
print("""
Following commands will be useful to you.
clear - clear the screen
list - list all saved platforms
new - create new platform
del - delete platform
getpw - give password of platform
restart - restart the program
exit - exit the program
""")
elif command == "clear":
os.system("clear")
print("\t\tEasytoman Shell\t\t")
elif command == "list":
lists()
elif command == "new":
platform = input("Please enter the platform name (twitter,facebook etc.) > ")
platform = platform.lower()
word = input("Word > ")
key = input("Key > ")
crypt.encode_save(word,key,platform)
print("Successfully added new platform!")
elif command == "getpw":
platform_name = input("Please enter the platform name (twitter,facebook etc.) > ").lower()
word = input("Word (Sensitive) > ")
key = input("Key (Sensitive) > ")
if crypt.isplatform_hash(word, key, platform_name):
print("\n\nYour " + str(platform_name).capitalize() + "'s password is " + "\"" + crypt.encode_algorithm_main(word,key) + "\" (without quotes)\n\n")
else:
print("Wrong word or key!")
elif command == "restart":
os.system("clear")
os.system("exit")
os.system("./easytoman.py")
elif command == "del":
lists()
option = input("Please enter the platform name you want to delete\n")
yesno = input("You're removing {} 's password.Are you sure ? y/n ".format(option))
if yesno == "y":
if option in platform_list:
line = platform_list.index(option) +1
with open("hashes.txt", "r") as f:
readfile = f.readlines()
readfile.remove(readfile[int(line)])
with open("hashes.txt","w") as file:
file.write("".join(readfile))
print("Successful.But, if you enter \"list\", maybe the platform still visible.Forget about it. :)")
elif yesno == "n":
pass
else:
print("Wrong value!")
elif command == "exit":
sys.exit()
else:
print("Command not found!")