10
10
import sys
11
11
import time
12
12
13
- import lib .cli .colors as colors
14
- import lib .cli .console as console
15
- import lib .tools .baidu as baidu
16
- import lib .tools .exploits as ExecExp
13
+ import lib .tools .exploits as exploit_exec
14
+ from lib .cli import colors , console
15
+ from lib .tools import zoomeye , baidu
17
16
from lib .cli .console import debug_except , input_check , check_kill_process
18
- from lib .tools import zoomeye
19
17
20
18
21
19
class SessionParameters :
@@ -24,17 +22,22 @@ class SessionParameters:
24
22
define some global parameters
25
23
'''
26
24
27
- INIT_DIR = os .getcwd ()
28
- OUT_DIR = INIT_DIR + '/output'
29
- PROXY_CONF = INIT_DIR + \
30
- '/data/proxy.conf'
31
- USE_PROXY = True
32
- IP_LIST = INIT_DIR + \
33
- '/data/ip_list.txt'
34
- PROXY_BIN = INIT_DIR + \
35
- '/tools/ss-proxy'
36
- SS_CONFIG = INIT_DIR + \
37
- '/data/ss.json'
25
+ def __init__ (self ):
26
+ self .init_dir = os .getcwd ()
27
+ self .out_dir = self .init_dir + '/output'
28
+ self .proxy_conf = self .init_dir + \
29
+ '/data/proxy.conf'
30
+ self .use_proxy = True
31
+ self .ip_list = self .init_dir + \
32
+ '/data/ip_list.txt'
33
+ self .proxy_bin = self .init_dir + \
34
+ '/tools/ss-proxy'
35
+ self .ss_config = self .init_dir + \
36
+ '/data/ss.json'
37
+
38
+
39
+ # Needed for scanner session later
40
+ SESSION = SessionParameters ()
38
41
39
42
40
43
def list_exp ():
@@ -78,40 +81,40 @@ def execute(cmd):
78
81
\n [*] Target: {}\
79
82
\n [*] Proxy config: {}' .format (
80
83
os .getcwd (),
81
- SessionParameters . INIT_DIR ,
82
- SessionParameters . IP_LIST ,
83
- SessionParameters . PROXY_CONF ) +
84
+ SESSION . init_dir ,
85
+ SESSION . ip_list ,
86
+ SESSION . proxy_conf ) +
84
87
colors .END )
85
88
elif cmd .startswith ('target' ):
86
89
target = '' .join (cmd .split ()[1 :])
87
- if not target in os .listdir (SessionParameters . INIT_DIR + '/data' ):
90
+ if not target in os .listdir (SESSION . init_dir + '/data' ):
88
91
return
89
92
print (colors .BLUE + '[i] Target changed to {}' .format (target ))
90
- SessionParameters . IP_LIST = SessionParameters . INIT_DIR + \
93
+ SESSION . ip_list = SESSION . init_dir + \
91
94
'/data/' + target
92
95
elif cmd == 'init' or cmd == 'i' :
93
96
print (colors .CYAN +
94
97
'[*] Going back to init_dir...' + colors .END )
95
- os .chdir (SessionParameters . INIT_DIR )
98
+ os .chdir (SESSION . init_dir )
96
99
elif cmd .startswith ('baidu' ):
97
100
try :
98
101
command = cmd .strip ().split ()
99
102
dork = command [1 ]
100
103
count = int (command [2 ])
101
- os .chdir (SessionParameters . OUT_DIR )
104
+ os .chdir (SESSION . out_dir )
102
105
print (colors .PURPLE + '[*] Searching on Baidu...' + colors .END )
103
106
baidu .spider (dork , count )
104
107
except (IndexError , EOFError , KeyboardInterrupt , SystemExit ):
105
108
return
106
109
elif cmd == 'proxy' :
107
- if not os .path .exists (SessionParameters . SS_CONFIG ):
110
+ if not os .path .exists (SESSION . ss_config ):
108
111
console .print_error (
109
- '[-] Please make sure {} exists' .format (SessionParameters . SS_CONFIG ))
112
+ '[-] Please make sure {} exists' .format (SESSION . ss_config ))
110
113
try :
111
114
subprocess .Popen (
112
- [SessionParameters . PROXY_BIN ,
115
+ [SESSION . proxy_bin ,
113
116
'-c' ,
114
- SessionParameters . SS_CONFIG ],
117
+ SESSION . ss_config ],
115
118
stderr = subprocess .PIPE , stdout = subprocess .PIPE , shell = False )
116
119
except BaseException as err :
117
120
console .print_error (
@@ -171,11 +174,8 @@ def attack():
171
174
'''
172
175
handles attack command
173
176
'''
174
-
175
- if input_check ('[?] Do you wish to use proxychains? [y/n] ' , choices = ['y' , 'n' ]) == 'y' :
176
- SessionParameters .USE_PROXY = True
177
- else :
178
- SessionParameters .USE_PROXY = False
177
+ SESSION .use_proxy = input_check (
178
+ '[?] Do you wish to use proxychains? [y/n] ' , choices = ['y' , 'n' ]) == 'y'
179
179
answ = input_check (
180
180
'\n [?] Do you wish to use\
181
181
\n \n [a] built-in exploits\
@@ -204,11 +204,11 @@ def attack():
204
204
elif answ == '1' :
205
205
console .print_error ('\n [-] Under development' )
206
206
elif answ == '0' :
207
- scanner (ExecExp .weblogic ())
207
+ scanner (exploit_exec .weblogic ())
208
208
elif answ == '3' :
209
- scanner (ExecExp .s2_045 ())
209
+ scanner (exploit_exec .s2_045 ())
210
210
elif answ == '4' :
211
- scanner (ExecExp .witbe ())
211
+ scanner (exploit_exec .witbe ())
212
212
except BaseException :
213
213
console .print_error ("[-] We have an error executing exploit" )
214
214
debug_except ()
@@ -296,19 +296,19 @@ def scanner(scanner_args):
296
296
# looks ugly, but since it works well, im not planning a rewrite
297
297
_ , work_path , exec_path , custom_args , jobs = scanner_args [0 ], \
298
298
scanner_args [1 ], scanner_args [2 ], scanner_args [3 ], scanner_args [4 ]
299
- if SessionParameters . USE_PROXY :
299
+ if SESSION . use_proxy :
300
300
e_args = [
301
301
'proxychains4' ,
302
302
'-q' ,
303
303
'-f' ,
304
- SessionParameters . PROXY_CONF ,
304
+ SESSION . proxy_conf ,
305
305
'./' + exec_path ]
306
306
else :
307
307
e_args = ['./' + exec_path ]
308
308
e_args += custom_args
309
309
e_args += ['-t' ]
310
310
try :
311
- target_list = open (SessionParameters . IP_LIST )
311
+ target_list = open (SESSION . ip_list )
312
312
except BaseException as exc :
313
313
console .print_error ('[-] Error occured: {}\n ' .format (exc ))
314
314
debug_except ()
@@ -359,7 +359,7 @@ def scanner(scanner_args):
359
359
console .print_error ('[-] Error when running scanner' )
360
360
debug_except ()
361
361
os .system ('clear' )
362
- os .chdir (SessionParameters . INIT_DIR )
362
+ os .chdir (SESSION . init_dir )
363
363
console .print_success ('\n [+] All done!\n ' )
364
364
print (console .INTRO )
365
365
@@ -376,7 +376,7 @@ def main():
376
376
colors .END )).strip ()
377
377
if answ .lower () == 'n' :
378
378
os .system ("ls data" )
379
- SessionParameters . IP_LIST = SessionParameters . INIT_DIR + '/data/' + \
379
+ SESSION . ip_list = SESSION . init_dir + '/data/' + \
380
380
input_check (
381
381
'[=] Choose your target IP list, eg. ip_list.txt ' ,
382
382
choices = os .listdir ('data' ))
0 commit comments