-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sigma.py
99 lines (87 loc) · 2.93 KB
/
Sigma.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
"""
this is the main activity(interface) of the program
"""
from core import Sigma
import sys
import adapter
import os
Sigma = Sigma()
flags_list = [
"-h", "--help",
"-nuke", "--nuke"
]
def Nuker():
print("THIS IS SIGMA NUKER PLEASE PROCEED WITH CAUTION")
print("THIS FEATURE IS PREVIEW ONLY, SO IT WONT DO ANY DAMAGE")
Directory = str(input("Please enter the directory to nuke (type \"thisdir\" to nuke this directory): "))
if Directory.lower() == "thisdir":
Directory = os.getcwd()
import utils
files = utils.list_files(Directory)
print("Nuking " + Directory)
print("files : " + str(files))
def isFlag(arg):
if arg.startswith(("-" , "--")):
return True
else:
return False
def main():
arguments = sys.argv
#the arguments[0] is the name of the file
try:
if len(arguments) == 1:
cli_mode()
else:
for args in arguments:
if isFlag(args):
try:
if args in flags_list:
print("flag : " + args)
print("value : " + arguments[arguments.index(args)+1])
print()
else:
raise Exception("Invalid {} flag".format(args))
except IndexError:
print("flag : " + args + " value : no value")
except Exception as e:
print("Something went wrong : ", e)
#print("Number of arguments:", len(arguments))
#print("The arguments are:" , str(arguments))
def cli_mode():
print("########## SIGMA CLI MODE ##########")
while True:
try:
print("\nPlease enter a command : ")
command = str(input(">>> "))
command.strip()
print()#jarak
if command == "exit":
print("Goodbye")
break
elif command == "help":
print("###### Commands ######")
print("exit : exit the program")
print("help : show the help")
print("encode : encode a message or file")
print("decode : decode a message or file")
print("nuke : nuke a directory")
elif command == "encode":
try:
adapter.Encoder()
except KeyboardInterrupt:
continue
elif command == "decode":
adapter.Decoder()
elif command == "nuke":
Nuker()
else:
print("Command not found / invalid command : " + command + "\n")
except KeyboardInterrupt:
print("Goodbye")
sys.exit()
except Exception as e:
print("Something went wrong : ", e + "\n")
if __name__ == "__main__":
main()
#print(os.listdir("D:\\"))
#adapter.nuke("D:\\dummy_folder\\", Sigma)