1
1
from argparse import ArgumentParser
2
2
import os .path
3
3
4
- class cli_helper (object ):
4
+
5
+ class CliHelper (object ):
5
6
@staticmethod
6
7
def readable_file (parser , arg ):
7
8
if not os .path .exists (arg ):
8
9
parser .error ("The file %s does not exist!" % arg )
9
10
else :
10
- return open (arg , 'r' ) # return an open file handle
11
+ return open (arg , 'r' ) # return an open file handle
11
12
12
13
13
- class cli_argument_parser (object ):
14
+ class CliArgumentParser (object ):
14
15
def __init__ (self ):
15
16
self ._parser = self .setup_parser ()
16
17
@@ -21,94 +22,97 @@ def parse(self, argv):
21
22
def setup_parser ():
22
23
parser = ArgumentParser ()
23
24
24
- parser .add_argument ("-t" ,
25
- dest = "target_hosts" ,
26
- required = True ,
27
- help = "Set a target range of addresses to target. Ex 10.11.1.1-255" )
28
-
29
- parser .add_argument ("-o" ,
30
- dest = "output_directory" ,
31
- required = True ,
32
- help = "Set the output directory. Ex /root/Documents/labs/" )
33
-
34
- parser .add_argument ("-w" ,
35
- dest = "wordlist" ,
36
- required = False ,
37
- help = "Set the wordlist to use for generated commands. Ex /usr/share/wordlist.txt" ,
38
- default = False )
39
-
40
- parser .add_argument ("-p" ,
41
- dest = "port" ,
42
- required = False ,
43
- help = "Set the port to use. Leave blank to use discovered ports. Useful to force virtual host scanning on non-standard webserver ports." ,
44
- default = 80 )
45
-
46
- parser .add_argument ("--pingsweep" ,
47
- dest = "ping_sweep" ,
48
- action = "store_true" ,
49
- help = "Write a new target.txt by performing a ping sweep and discovering live hosts." ,
50
- default = False )
51
-
52
- parser .add_argument ("--dns" ,"--dnssweep" ,
53
- dest = "find_dns_servers" ,
54
- action = "store_true" ,
55
- help = "Find DNS servers from a list of targets." ,
56
- default = False )
57
-
58
- parser .add_argument ("--services" ,
59
- dest = "perform_service_scan" ,
60
- action = "store_true" ,
61
- help = "Perform service scan over targets." ,
62
- default = False )
63
-
64
- parser .add_argument ("--hostnames" ,
65
- dest = "hostname_scan" ,
66
- action = "store_true" ,
67
- help = "Attempt to discover target hostnames and write to 0-name.txt and hostnames.txt." ,
68
- default = False )
69
-
70
- parser .add_argument ("--snmp" ,
71
- dest = "perform_snmp_walk" ,
72
- action = "store_true" ,
73
- help = "Perform service scan over targets." ,
74
- default = False )
75
-
76
- parser .add_argument ("--quick" ,
77
- dest = "quick" ,
78
- action = "store_true" ,
79
- required = False ,
80
- help = "Move to the next target after performing a quick scan and writing first-round recommendations." ,
81
- default = False )
82
-
83
- parser .add_argument ("--virtualhosts" ,
84
- dest = "virtualhosts" ,
85
- action = "store_true" ,
86
- required = False ,
87
- help = "Attempt to discover virtual hosts using the specified wordlist." ,
88
- default = False )
89
-
90
- parser .add_argument ('--ignore-http-codes' ,
91
- dest = 'ignore_http_codes' ,
92
- type = str ,
93
- help = 'Comma separated list of http codes to ignore with virtual host scans.' ,
94
- default = '404' )
95
-
96
- parser .add_argument ('--ignore-content-length' ,
97
- dest = 'ignore_content_length' ,
98
- type = int ,
99
- help = 'Ignore content lengths of specificed amount. This may become useful when a server returns a static page on every virtual host guess.' ,
100
- default = 0 )
101
-
102
- parser .add_argument ("--quiet" ,
103
- dest = "quiet" ,
104
- action = "store_true" ,
105
- help = "Supress banner and headers to limit to comma dilimeted results only." ,
106
- default = False )
107
-
108
- parser .add_argument ("--no-udp" ,
109
- dest = "no_udp_service_scan" ,
110
- action = "store_true" ,
111
- help = "Disable UDP services scan over targets." ,
112
- default = False )
113
- return parser
114
-
25
+ parser .add_argument ("-t" ,
26
+ dest = "target_hosts" ,
27
+ required = True ,
28
+ help = "Set a target range of addresses to target. Ex 10.11.1.1-255" )
29
+
30
+ parser .add_argument ("-o" ,
31
+ dest = "output_directory" ,
32
+ required = True ,
33
+ help = "Set the output directory. Ex /root/Documents/labs/" )
34
+
35
+ parser .add_argument ("-w" ,
36
+ dest = "wordlist" ,
37
+ required = False ,
38
+ help = "Set the wordlist to use for generated commands. Ex /usr/share/wordlist.txt" ,
39
+ default = False )
40
+
41
+ parser .add_argument ("-p" ,
42
+ dest = "port" ,
43
+ required = False ,
44
+ help = "Set the port to use. Leave blank to use discovered ports. "
45
+ "Useful to force virtual host scanning on non-standard webserver ports." ,
46
+ default = 80 )
47
+
48
+ parser .add_argument ("--pingsweep" ,
49
+ dest = "ping_sweep" ,
50
+ action = "store_true" ,
51
+ help = "Write a new target.txt by performing a ping sweep and discovering live hosts." ,
52
+ default = False )
53
+
54
+ parser .add_argument ("--dns" , "--dnssweep" ,
55
+ dest = "find_dns_servers" ,
56
+ action = "store_true" ,
57
+ help = "Find DNS servers from a list of targets." ,
58
+ default = False )
59
+
60
+ parser .add_argument ("--services" ,
61
+ dest = "perform_service_scan" ,
62
+ action = "store_true" ,
63
+ help = "Perform service scan over targets." ,
64
+ default = False )
65
+
66
+ parser .add_argument ("--hostnames" ,
67
+ dest = "hostname_scan" ,
68
+ action = "store_true" ,
69
+ help = "Attempt to discover target hostnames and write to 0-name.txt and hostnames.txt." ,
70
+ default = False )
71
+
72
+ parser .add_argument ("--snmp" ,
73
+ dest = "perform_snmp_walk" ,
74
+ action = "store_true" ,
75
+ help = "Perform service scan over targets." ,
76
+ default = False )
77
+
78
+ parser .add_argument ("--quick" ,
79
+ dest = "quick" ,
80
+ action = "store_true" ,
81
+ required = False ,
82
+ help = "Move to the next target after performing a quick scan and writing "
83
+ "first-round recommendations." ,
84
+ default = False )
85
+
86
+ parser .add_argument ("--virtualhosts" ,
87
+ dest = "virtualhosts" ,
88
+ action = "store_true" ,
89
+ required = False ,
90
+ help = "Attempt to discover virtual hosts using the specified wordlist." ,
91
+ default = False )
92
+
93
+ parser .add_argument ('--ignore-http-codes' ,
94
+ dest = 'ignore_http_codes' ,
95
+ type = str ,
96
+ help = 'Comma separated list of http codes to ignore with virtual host scans.' ,
97
+ default = '404' )
98
+
99
+ parser .add_argument ('--ignore-content-length' ,
100
+ dest = 'ignore_content_length' ,
101
+ type = int ,
102
+ help = 'Ignore content lengths of specificed amount. '
103
+ 'This may become useful when a server returns a static page on '
104
+ 'every virtual host guess.' ,
105
+ default = 0 )
106
+
107
+ parser .add_argument ("--quiet" ,
108
+ dest = "quiet" ,
109
+ action = "store_true" ,
110
+ help = "Supress banner and headers to limit to comma dilimeted results only." ,
111
+ default = False )
112
+
113
+ parser .add_argument ("--no-udp" ,
114
+ dest = "no_udp_service_scan" ,
115
+ action = "store_true" ,
116
+ help = "Disable UDP services scan over targets." ,
117
+ default = False )
118
+ return parser
0 commit comments