-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.py
executable file
·278 lines (233 loc) · 10.5 KB
/
main.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/usr/bin/python
# New Arg Parse and Cipher Call
# created by : Fyzz | C0SM0 | Soul
# imports
import argparse
from ast import For
from multiprocessing.context import ForkServerProcess
import mods.bits as b
import importlib
import readline
import sys
import os
from colorama import Fore, Back, Style
import string
# gets list of available ciphers
def get_ciphers():
output_list = []
directory = os.fsencode(b.cipher)
for file in os.listdir(directory):
filename = os.fsdecode(file)
output_list.append(filename[:-3])
return output_list
# updates skeletonkey
def update():
cmd_prefix = f'{Fore.GREEN}[~] {Fore.RESET}'
print("\n[*] Checking for updates...")
# get latest version nubmer
os.system("curl https://raw.githubusercontent.com/CosmodiumCS/SkeletonKey/main/version.txt| tee ~/.SkeletonKey/latest.txt")
# save version nubmers to memory
current_version = float(open(f"{b.local_path}/version.txt", "r").read())
latest_version = float(open (f"{b.local_path}/latest.txt", "r").read())
# remove version number file
os.system("rm -rf ~/.SkeletonKey/latest.txt")
# if new version is available, update
if latest_version > current_version:
print("\n[+] Update found")
print(cmd_prefix + "Update SkeletonKey? [y/n]\n")
# user input, option
option = input(f"{b.header}")
# update
if option == "y":
os.system("sh ~/.SkeletonKey/resources/update.sh")
else:
print("\n[+] SkeletonKey already up to date")
# output function
def output(data, output):
if data:
if data[1] == True and data[1]:
# file
if output and ".png" not in output:
with open(output, 'w') as f:
f.write(data[0])
print(f'{b.SUCCESS}[✓] File Output Successful{b.END}')
# command line interface
else:
print(f'\n{b.SUCCESS}[✓] Output:{b.END}\n{data[0]}\n')
else:
# exception
print(f'\n{b.FAIL}[✖] Failed:{b.END}\n{data[0]}\n')
# uninstalls skeletonkey
def remove():
cmd_prefix = f'{Fore.RED}[~] {Fore.RESET}'
# confirmation
print("\n" + cmd_prefix + "Are you sure you want to remove SkeletonKey? [y/n]\n")
# user input
option = input(b.header)
# delete SkeletonKey
if option == "y":
os.system("rm -rf ~/.SkeletonKey")
# command line interface
def cli(args_exist):
cmd_prefix = f'{Fore.CYAN}[~] {Fore.RESET}'
# default arguments
if args_exist:
if sys.argv[1] in ['-h', '--help']:
print(b.help_menu)
elif sys.argv[1] in ['-u', '--update']:
update()
elif sys.argv[1] in ['-rm', '--remove', '--uninstall']:
remove()
elif '+' in sys.argv:
text = sys.argv[sys.argv.index('-t') + 1]
sys.argv[sys.argv.index('-t') + 1] = f'"{text}"'
args = " ".join(sys.argv[1:])
layers = args.split(' + ')
text = ''
for index, layer in enumerate(layers):
if index == 0:
os.system(f'python3 ~/.SkeletonKey/main.py {layer} -lay')
elif index != len(layers) - 1:
try:
with open('temp_storage.txt', 'r') as temp:
layerd_storage = temp.read()
except Exception:
pass
else:
os.system(f'python3 ~/.SkeletonKey/main.py {layer} -t "{layerd_storage}" -lay')
else:
try:
with open('temp_storage.txt', 'r') as temp:
layerd_storage = temp.read()
except Exception:
pass
else:
os.system(f'python3 ~/.SkeletonKey/main.py {layer} -t "{layerd_storage}"')
os.remove('temp_storage.txt')
else:
parser = argparse.ArgumentParser(add_help=False, usage="")
parser.add_argument('cipher', type=str)
parser.add_argument('-e', '--encode', dest='encode', action='store_true')
parser.add_argument('-d', '--decode', dest='decode', action='store_true')
parser.add_argument('-b', '--brute', dest='brute', action='store_true')
parser.add_argument('-i', '--inputFile', dest='inputFile', type=str)
parser.add_argument('-ii', '--inputImage', dest='inputImage', type=str)
parser.add_argument('-o', '--output', dest='output', type=str)
parser.add_argument('-t', '--text', help='String Input\n', dest='text', type=str)
parser.add_argument('-k', '--key', help='Str Key\n', dest='key', type=str)
parser.add_argument('-s', '--salt', help='Hash Salt\n', dest='salt', type=str)
parser.add_argument('-nc', '--nonce', help='Int Nonce\n', dest='nonce', type=int)
parser.add_argument('-md', '--mode', dest='mode', type=str)
parser.add_argument('-iv', dest='iv', type=str)
parser.add_argument('-c', '--channel', dest='channel', type=str)
parser.add_argument('-ex', '--exclude', help='Exclude Character\n', dest='exclude', type=str)
parser.add_argument('-w', '--wordlist', help='Wordlist File\n', dest='wordlist', type=str)
parser.add_argument('-r', '--range', help='Range\n', dest='range', type=str)
# code transcripts
parser.add_argument('-words', '--words', help='Filter out words\n', action='store_true')
parser.add_argument('-lingo', '--lingo', help='Specify language ("lingo")', type=str, default='en_US')
parser.add_argument('-a', '--alphabet', help='Specify custom alphabet\n', type=str, default=string.ascii_uppercase)
# parser.add_argument('-a', '--alphabet', help='Specify custom alphabet\n', type=str)
# Layered Encryption
parser.add_argument('-lay', '--layerd', dest='layerd', action='store_true')
# Google Translate
parser.add_argument('-tr', '--translate', dest='translate', action='store_true')
parser.add_argument('-lang', '--languages', dest='lang', action='store_true')
parser.add_argument('-src', '--src', help='Source Language code\n', dest='src', type=str)
parser.add_argument('-dest', '--dest', help='Destination Language code\n', dest='dest', type=str)
# Static Encryption
parser.add_argument('-f', '--file', help="Give a file path\n", dest='file', type=str)
parser.add_argument('-iw', '--image_width', help="Image width used for SE", dest="image_width", type=int)
#parser.add_argument('-m', '--mono', help="Make SE use monocromatic mode", dest="mono", action="store_true")
# cryptographic payloads
parser.add_argument('-g', '--generate', help='Choose Payload Generation Method\n', dest='generate', type=str)
parser.add_argument('-p', '--payload', help='Choose Payload\n', dest='payload', type=str)
parser.add_argument('-wc', '--webcredentials', dest='webcredentials', action='store_true')
args = parser.parse_args()
# reads input files for argument parsing
if args.inputFile:
with open(args.inputFile, 'r') as tmpFileVar:
args.text = tmpFileVar.read()
# reads input file for wordlist
if args.wordlist:
with open(args.wordlist, 'r') as tmpFileVar:
args.wordlist = tmpFileVar.read().split('\n')
args.wordlist = list(filter(lambda x : len(x) > 0, args.wordlist))
# execute skeletonkey libraries
try:
module = importlib.import_module(f'ciphers.{args.cipher}')
except Exception:
print(
f"{b.FAIL}\n{Fore.RED}"
+ f"[✖] Cipher May Not Exist\nTry 'key -h' to see all ciphers{b.END}\n"
+ Fore.RESET
)
else:
func = None
if args.layerd:
if args.encode:
layerd_storage = module.encode(args)[0]
with open('temp_storage.txt', 'w') as temp:
temp.write(layerd_storage)
elif args.decode:
layerd_storage = module.decode(args)[0]
with open('temp_storage.txt', 'w') as temp:
temp.write(layerd_storage)
else:
output(["For now '-tr' or '-b' can only be the final step in layerd encryption", False], False)
try:
os.remove('temp_storage.txt')
except Exception:
pass
elif args.encode:
func = module.encode
elif args.decode:
func = module.decode
elif args.brute:
func = module.brute
elif args.translate:
func = module.translate
elif args.lang:
output(module.languages(), args.output)
elif args.payload:
func = module.payload
else:
print(Fore.CYAN + module.help_menu + Fore.RESET)
if func:
output(func(args), args.output)
else:
# display banner
print(b.banner)
print(f'{cmd_prefix}Type "help" for help menu :')
# loop code
while True:
# get user input
user_input = input(b.header)
# display help menu
if user_input == 'help':
print(b.help_menu)
elif user_input == 'version':
print(b.version)
elif user_input in ['exit', 'quit']:
exit()
break
elif user_input == 'update':
update()
elif user_input in ['uninstall', 'remove']:
remove()
elif user_input.split(' ')[0] not in get_ciphers():
os.system(user_input)
else:
os.system(f'python3 ~/.SkeletonKey/main.py {user_input.replace("key", "")}')
# main code
def main():
try:
sys.argv[1]
except IndexError:
args_exist = False
else:
args_exist = True
cli(args_exist)
# executes main code
if __name__ == '__main__':
main()