1+ #!/usr/bin/env python3
2+
3+ import os
4+ import json
5+
6+ R = '\033 [31m' # red
7+ G = '\033 [32m' # green
8+ C = '\033 [36m' # cyan
9+ W = '\033 [0m' # white
10+
11+ def misc (win ):
12+ print ('\n ' , end = '' )
13+ misc_scripts = []
14+ for (dirpath , dirname , filenames ) in os .walk ('scripts/windows/misc' ):
15+ misc_scripts .extend (filenames )
16+ for item in misc_scripts :
17+ print (G + '[{}] ' .format (misc_scripts .index (item )) + W + item )
18+
19+ while True :
20+ try :
21+ misc_choice = input (G + '\n fs[windows/misc] > ' + W )
22+
23+ if misc_choice == 'clear' :
24+ os .system ('clear' )
25+ elif misc_choice == 'back' :
26+ return win ()
27+ elif misc_choice == 'help' :
28+ return misc (win )
29+ elif misc_choice == '' :
30+ pass
31+ elif misc_choice == 'exit' or misc_choice == 'quit' :
32+ subp .call (['systemctl' , 'stop' , 'ssh.service' ])
33+ subp .call (['pkill' , 'php' ])
34+ exit ()
35+ elif int (misc_choice ) <= len (misc_scripts ) - 1 :
36+ with open ('conf/misc_scripts.json' , 'r' ) as json_file :
37+ options = json .load (json_file )
38+ chosen = misc_scripts [int (misc_choice )]
39+
40+ for k ,v in options .items ():
41+ if k in chosen :
42+ desc = v ['desc' ]
43+ url_state = v ['url' ]
44+ server_state = v ['server' ]
45+ print ('\n ' , end = '' )
46+ print (G + '[+]' + C + ' Script : ' + W + chosen + '\n ' )
47+ print (G + '[+]' + C + ' Info : ' + W + desc + '\n ' )
48+ if url_state == 1 :
49+ misc .misc_url = input (G + '[+]' + C + ' URL : ' + W )
50+ else :
51+ pass
52+ if server_state == 1 :
53+ misc .misc_host = input (G + '[+]' + C + ' Server Host : ' + W )
54+ misc .misc_port = input (G + '[+]' + C + ' Server Port : ' + W )
55+ misc .misc_fname = input (G + '[+]' + C + ' Filename (with extension) : ' + W )
56+ script_path = '/scripts/windows/misc/' + chosen
57+ misc_output (script_path , chosen , url_state , server_state )
58+ else :
59+ print ('\n ' + R + '[-]' + C + ' Invalid Input...' + W )
60+ pass
61+ except ValueError :
62+ print ('\n ' + R + '[-]' + C + ' Invalid Input...' + W )
63+ pass
64+
65+ def misc_output (script_path , chosen , url_state , server_state ):
66+ base_path = os .getcwd () + script_path
67+ outfile_path = os .getcwd () + '/output/{}' .format (chosen )
68+
69+ if url_state == 1 :
70+ with open (base_path , 'r' ) as file :
71+ filedata = file .read ()
72+
73+ filedata = filedata .replace ('URL' , misc .misc_url )
74+
75+ with open ('output/{}' .format (chosen ), 'w' ) as file :
76+ file .write (filedata )
77+ else :
78+ os .system ('cp {} {}' .format (base_path , outfile_path ))
79+
80+ if server_state == 1 :
81+ with open (base_path , 'r' ) as file :
82+ filedata = file .read ()
83+
84+ filedata = filedata .replace ('HOST' , misc .misc_host )
85+ filedata = filedata .replace ('PORT' , misc .misc_port )
86+ filedata = filedata .replace ('FILENAME' , misc .misc_fname )
87+
88+ with open ('output/{}' .format (chosen ), 'w' ) as file :
89+ file .write (filedata )
90+
91+ print (G + '[+]' + C + ' Script Generated : ' + W + outfile_path )
0 commit comments