Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3af1532

Browse files
committed
Implementation for Issue #54
1 parent 5af6ca5 commit 3af1532

2 files changed

Lines changed: 62 additions & 3 deletions

File tree

lib/core/settings.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,40 @@
247247
"rollback ", ),
248248
}
249249

250+
# items displayed in basic help (-h) output
251+
BASIC_HELP_ITEMS = (
252+
"url",
253+
"googleDork",
254+
"data",
255+
"cookie",
256+
"randomAgent",
257+
"proxy",
258+
"testParameter",
259+
"dbms",
260+
"level",
261+
"risk",
262+
"tech",
263+
"getBanner",
264+
"getCurrentUser",
265+
"getCurrentDb",
266+
"getPasswordHashes",
267+
"getTables",
268+
"getColumns",
269+
"getSchema",
270+
"dumpTable",
271+
"dumpAll",
272+
"db",
273+
"tbl",
274+
"col",
275+
"osShell",
276+
"osPwn",
277+
"batch",
278+
"checkTor",
279+
"flushSession",
280+
"tor",
281+
"wizard"
282+
)
283+
250284
# string representation for NULL value
251285
NULL = "NULL"
252286

lib/parse/cmdline.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from lib.core.common import getUnicode
1717
from lib.core.data import logger
1818
from lib.core.defaults import defaults
19+
from lib.core.settings import BASIC_HELP_ITEMS
1920
from lib.core.settings import IS_WIN
2021
from lib.core.settings import VERSION_STRING
2122

@@ -30,6 +31,10 @@ def cmdLineParser():
3031
parser = OptionParser(usage=usage, version=VERSION_STRING)
3132

3233
try:
34+
parser.add_option("--hh", dest="advancedHelp",
35+
action="store_true",
36+
help="Show advanced help")
37+
3338
parser.add_option("-v", dest="verbose", type="int",
3439
help="Verbosity level: 0-6 (default %d)" % defaults.verbose)
3540

@@ -666,22 +671,42 @@ def cmdLineParser():
666671
parser.add_option_group(general)
667672
parser.add_option_group(miscellaneous)
668673

674+
# Dirty hack for making a short option -hh
675+
_ = parser.get_option("--hh")
676+
_._short_opts = ["-hh"]
677+
_._long_opts = []
678+
669679
args = []
670680

671681
for arg in sys.argv:
672682
args.append(getUnicode(arg, system=True))
673683

684+
# Hide non-basic options in basic help case
685+
for i in xrange(len(sys.argv)):
686+
if sys.argv[i] == '-hh':
687+
sys.argv[i] = '-h'
688+
elif sys.argv[i] == '-h':
689+
for group in parser.option_groups[:]:
690+
found = False
691+
for option in group.option_list:
692+
if option.dest not in BASIC_HELP_ITEMS:
693+
option.help = SUPPRESS_HELP
694+
else:
695+
found = True
696+
if not found:
697+
parser.option_groups.remove(group)
698+
674699
(args, _) = parser.parse_args(args)
675700

676-
for i in xrange(len(sys.argv)-1):
701+
# Expand given mnemonic options (e.g. -z "ign,flu,bat")
702+
for i in xrange(len(sys.argv) - 1):
677703
if sys.argv[i] == '-z':
678704
expandMnemonics(sys.argv[i+1], parser, args)
679-
break
680705

681706
if not any((args.direct, args.url, args.logFile, args.bulkFile, args.googleDork, args.configFile, \
682707
args.requestFile, args.updateAll, args.smokeTest, args.liveTest, args.realTest, args.wizard, args.dependencies, args.purgeOutput)):
683708
errMsg = "missing a mandatory option (-d, -u, -l, -m, -r, -g, -c, --wizard, --update, --purge-output or --dependencies), "
684-
errMsg += "use -h for help"
709+
errMsg += "use -h for basic help and -hh for advanced help"
685710
parser.error(errMsg)
686711

687712
return args

0 commit comments

Comments
 (0)