-
Notifications
You must be signed in to change notification settings - Fork 1
/
recon-cli
executable file
·80 lines (76 loc) · 3.37 KB
/
recon-cli
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
#!/usr/bin/env python
import argparse
import sys
# prevent creation of compiled bytecode files
sys.dont_write_bytecode = True
# prep python path for base module
sys.path.insert(1, sys.path[0]+'/core/')
sys.path.insert(1, sys.path[0]+'/libs/')
import base
from framework import Colors
def output(string):
print('%s[*]%s %s' % (Colors.B, Colors.N, string))
def recon_cli(args):
x = base.Recon(mode=base.Mode.CLI)
# check for and run version check
if args.check:
if not x.version_check(): return
# set given workspace
if args.workspace:
x.init_workspace(args.workspace)
print('WORKSPACE => %s' % (args.workspace))
# run given global commands
for command in args.global_commands:
print('GLOBAL COMMAND => %s' % (command))
x.onecmd(command)
# set given global options
for option in args.goptions:
param = ' '.join(option.split('='))
x.do_set(param)
# if requested, show global options and exit
if args.gshow:
x.do_show('options')
return
# if requested, show modules and exit
if args.show_modules:
x.do_show('modules')
return
# exit if module not specified
if not args.module:
output('No module provided.')
return
# load the module
y = x.do_load(args.module)
# exit if module not successfully loaded
if not y: return
print('MODULE => %s' % (args.module))
# run given module commands
for command in args.module_commands:
print('MODULE COMMAND => %s' % (command))
y.onecmd(command)
# set given module options
for option in args.options:
param = ' '.join(option.split('='))
y.do_set(param)
# if requested, show module options and exit
if args.show:
y.do_show('options')
return
if args.run:
# run the module
y.do_run(None)
description = '%%(prog)s - %s %s' % (base.__author__, base.__email__)
parser = argparse.ArgumentParser(description=description, version=base.__version__)
parser.add_argument('-w', help='load/create a workspace', metavar='workspace', dest='workspace', action='store')
parser.add_argument('-C', help='runs a command at the global context', metavar='command', dest='global_commands' ,default=[], action='append')
parser.add_argument('-c', help='runs a command at the module context (pre-run)', metavar='command', dest='module_commands' ,default=[], action='append')
parser.add_argument('-G', help='show available global options', dest='gshow', default=False, action='store_true')
parser.add_argument('-g', help='set a global option (can be used more than once)', metavar='name=value', dest='goptions', default=[], action='append')
parser.add_argument('-M', help='show modules', dest='show_modules', default=False, action='store_true')
parser.add_argument('-m', help='specify the module', metavar='module', dest='module', action='store')
parser.add_argument('-O', help='show available module options', dest='show', default=False, action='store_true')
parser.add_argument('-o', help='set a module option (can be used more than once)', metavar='name=value', dest='options', default=[], action='append')
parser.add_argument('-x', help='run the module', dest='run', default=False, action='store_true')
parser.add_argument('--no-check', help='disable version check', dest='check', default=True, action='store_false')
args = parser.parse_args()
recon_cli(args)