Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for pip install #208

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
*.rdb
*sublime*
venv/
scripts/
/scripts/
build/
*.egg-info
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[project]
name = "recon-ng"
description = "Open Source Intelligence gathering tool"
authors = [{ name = "Tim Tomes" }]
requires-python = ">=3.6"
readme = "README.md"
license = { file = "LICENSE" }
dynamic = ["dependencies", "version"]

[tool.setuptools.dynamic]
dependencies = { file = "REQUIREMENTS" }
version = { attr = "recon._version.__version__" }

[project.scripts]
recon-cli = "recon.scripts.cli:main"
recon-ng = "recon.scripts.ng:main"
recon-web = "recon.scripts.web:main"

[build-system]
requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta"
88 changes: 2 additions & 86 deletions recon-cli
Original file line number Diff line number Diff line change
@@ -1,89 +1,5 @@
#!/usr/bin/env python3

import argparse
import sys
# prevent creation of compiled bytecode files
sys.dont_write_bytecode = True
from recon.core import base
from recon.core.framework import Colors
from recon.scripts.cli import main

def output(string):
print(f"{Colors.B}[*]{Colors.N} {string}")

def recon_cli(args):
# process toggle flag arguments
flags = {
'check': args.check if not args.stealth else False,
'analytics': args.analytics if not args.stealth else False,
'marketplace': args.marketplace if not args.stealth else False,
}
# instantiate framework
x = base.Recon(**flags)
options = [base.Mode.CLI]
if args.workspace:
options.append(args.workspace)
x.start(*options)
# set given workspace
if args.workspace:
x._init_workspace(args.workspace)
print(f"WORKSPACE => {args.workspace}")
# run given global commands
for command in args.global_commands:
print(f"GLOBAL COMMAND => {command}")
x.onecmd(command)
# set given global options
for option in args.goptions:
param = ' '.join(option.split('='))
x._do_options_set(param)
# if requested, show global options and exit
if args.gshow:
x._do_options_list('')
return
# if requested, show modules and exit
if args.show_modules:
x._do_modules_search('')
return
# exit if module not specified
if not args.module:
output('No module provided.')
return
# load the module
y = x._do_modules_load(args.module)
# exit if module not successfully loaded
if not y: return
print(f"MODULE => {args.module}")
# run given module commands
for command in args.module_commands:
print(f"MODULE COMMAND => {command}")
y.onecmd(command)
# set given module options
for option in args.options:
param = ' '.join(option.split('='))
y._do_options_set(param)
# if requested, show module options and exit
if args.show:
y._do_options_list('')
return
if args.run:
# run the module
y.do_run(None)

description = f"%(prog)s - {base.__author__}"
parser = argparse.ArgumentParser(description=description)
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-version', help='disable version check', dest='check', default=True, action='store_false')
parser.add_argument('--no-analytics', help='disable analytics reporting', dest='analytics', default=True, action='store_false')
parser.add_argument('--no-marketplace', help='disable remote module management', dest='marketplace', default=True, action='store_false')
parser.add_argument('--stealth', help='disable all passive requests (--no-*)', dest='stealth', default=False, action='store_true')
parser.add_argument('--version', help='displays the current version', action='version', version=base.__version__)
args = parser.parse_args()
recon_cli(args)
main()
57 changes: 2 additions & 55 deletions recon-ng
Original file line number Diff line number Diff line change
@@ -1,58 +1,5 @@
#!/usr/bin/env python3

import argparse
import re
import sys
# prevent creation of compiled bytecode files
sys.dont_write_bytecode = True
from recon.core import base
from recon.core.framework import Colors
from recon.scripts.ng import main

def recon_ui(args):
# set up command completion
try:
import readline
except ImportError:
print(f"{Colors.R}[!] Module 'readline' not available. Tab complete disabled.{Colors.N}")
else:
import rlcompleter
if 'libedit' in readline.__doc__:
readline.parse_and_bind('bind ^I rl_complete')
else:
readline.parse_and_bind('tab: complete')
readline.set_completer_delims(re.sub('[/-]', '', readline.get_completer_delims()))
# for possible future use to format command completion output
#readline.set_completion_display_matches_hook(display_hook)
# process toggle flag arguments
flags = {
'check': args.check if not args.stealth else False,
'analytics': args.analytics if not args.stealth else False,
'marketplace': args.marketplace if not args.stealth else False,
'accessible' : args.accessible
}
# instantiate framework
x = base.Recon(**flags)
# check for and run script session
if args.script_file:
x._do_script_execute(args.script_file)
# launch the interactive session
options = [base.Mode.CONSOLE]
if args.workspace:
options.append(args.workspace)
try:
x.start(*options)
except KeyboardInterrupt:
print('')

description = f"%(prog)s - {base.__author__}"
parser = argparse.ArgumentParser(description=description)
parser.add_argument('-w', help='load/create a workspace', metavar='workspace', dest='workspace', action='store')
parser.add_argument('-r', help='load commands from a resource file', metavar='filename', dest='script_file', action='store')
parser.add_argument('--no-version', help='disable version check', dest='check', default=True, action='store_false')
parser.add_argument('--no-analytics', help='disable analytics reporting', dest='analytics', default=True, action='store_false')
parser.add_argument('--no-marketplace', help='disable remote module management', dest='marketplace', default=True, action='store_false')
parser.add_argument('--stealth', help='disable all passive requests (--no-*)', dest='stealth', default=False, action='store_true')
parser.add_argument('--accessible', help='Use accessible outputs when available', dest='accessible', default=False, action='store_true')
parser.add_argument('--version', help='displays the current version', action='version', version=base.__version__)
args = parser.parse_args()
recon_ui(args)
main()
13 changes: 2 additions & 11 deletions recon-web
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
#!/usr/bin/env python3

from recon.core.web import create_app
import argparse
from recon.scripts.web import main

parser = argparse.ArgumentParser()
parser.add_argument('--host', default='127.0.0.1', help="IP address to listen on")
parser.add_argument('--port', default=5000, help="port to bind the web server to")

args = parser.parse_args()

app = create_app()
if __name__ == '__main__':
app.run(host=args.host, port=args.port)
main()
1 change: 1 addition & 0 deletions recon/_version.py
4 changes: 1 addition & 3 deletions recon/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
# import framework libs
from recon.core import framework
from recon.core.constants import BANNER, BANNER_SMALL

# set the __version__ variable based on the VERSION file
exec(open(os.path.join(Path(os.path.abspath(__file__)).parents[2], 'VERSION')).read())
from recon._version import __version__

# using stdout to spool causes tab complete issues
# therefore, override print function
Expand Down
90 changes: 90 additions & 0 deletions recon/scripts/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env python3

import argparse
import sys
# prevent creation of compiled bytecode files
sys.dont_write_bytecode = True
from recon.core import base
from recon.core.framework import Colors

def output(string):
print(f"{Colors.B}[*]{Colors.N} {string}")

def recon_cli(args):
# process toggle flag arguments
flags = {
'check': args.check if not args.stealth else False,
'analytics': args.analytics if not args.stealth else False,
'marketplace': args.marketplace if not args.stealth else False,
}
# instantiate framework
x = base.Recon(**flags)
options = [base.Mode.CLI]
if args.workspace:
options.append(args.workspace)
x.start(*options)
# set given workspace
if args.workspace:
x._init_workspace(args.workspace)
print(f"WORKSPACE => {args.workspace}")
# run given global commands
for command in args.global_commands:
print(f"GLOBAL COMMAND => {command}")
x.onecmd(command)
# set given global options
for option in args.goptions:
param = ' '.join(option.split('='))
x._do_options_set(param)
# if requested, show global options and exit
if args.gshow:
x._do_options_list('')
return
# if requested, show modules and exit
if args.show_modules:
x._do_modules_search('')
return
# exit if module not specified
if not args.module:
output('No module provided.')
return
# load the module
y = x._do_modules_load(args.module)
# exit if module not successfully loaded
if not y: return
print(f"MODULE => {args.module}")
# run given module commands
for command in args.module_commands:
print(f"MODULE COMMAND => {command}")
y.onecmd(command)
# set given module options
for option in args.options:
param = ' '.join(option.split('='))
y._do_options_set(param)
# if requested, show module options and exit
if args.show:
y._do_options_list('')
return
if args.run:
# run the module
y.do_run(None)

def main():
description = f"%(prog)s - {base.__author__}"
parser = argparse.ArgumentParser(description=description)
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-version', help='disable version check', dest='check', default=True, action='store_false')
parser.add_argument('--no-analytics', help='disable analytics reporting', dest='analytics', default=True, action='store_false')
parser.add_argument('--no-marketplace', help='disable remote module management', dest='marketplace', default=True, action='store_false')
parser.add_argument('--stealth', help='disable all passive requests (--no-*)', dest='stealth', default=False, action='store_true')
parser.add_argument('--version', help='displays the current version', action='version', version=base.__version__)
args = parser.parse_args()
recon_cli(args)
59 changes: 59 additions & 0 deletions recon/scripts/ng.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env python3

import argparse
import re
import sys
# prevent creation of compiled bytecode files
sys.dont_write_bytecode = True
from recon.core import base
from recon.core.framework import Colors

def recon_ui(args):
# set up command completion
try:
import readline
except ImportError:
print(f"{Colors.R}[!] Module 'readline' not available. Tab complete disabled.{Colors.N}")
else:
import rlcompleter
if 'libedit' in readline.__doc__:
readline.parse_and_bind('bind ^I rl_complete')
else:
readline.parse_and_bind('tab: complete')
readline.set_completer_delims(re.sub('[/-]', '', readline.get_completer_delims()))
# for possible future use to format command completion output
#readline.set_completion_display_matches_hook(display_hook)
# process toggle flag arguments
flags = {
'check': args.check if not args.stealth else False,
'analytics': args.analytics if not args.stealth else False,
'marketplace': args.marketplace if not args.stealth else False,
'accessible' : args.accessible
}
# instantiate framework
x = base.Recon(**flags)
# check for and run script session
if args.script_file:
x._do_script_execute(args.script_file)
# launch the interactive session
options = [base.Mode.CONSOLE]
if args.workspace:
options.append(args.workspace)
try:
x.start(*options)
except KeyboardInterrupt:
print('')

def main():
description = f"%(prog)s - {base.__author__}"
parser = argparse.ArgumentParser(description=description)
parser.add_argument('-w', help='load/create a workspace', metavar='workspace', dest='workspace', action='store')
parser.add_argument('-r', help='load commands from a resource file', metavar='filename', dest='script_file', action='store')
parser.add_argument('--no-version', help='disable version check', dest='check', default=True, action='store_false')
parser.add_argument('--no-analytics', help='disable analytics reporting', dest='analytics', default=True, action='store_false')
parser.add_argument('--no-marketplace', help='disable remote module management', dest='marketplace', default=True, action='store_false')
parser.add_argument('--stealth', help='disable all passive requests (--no-*)', dest='stealth', default=False, action='store_true')
parser.add_argument('--accessible', help='Use accessible outputs when available', dest='accessible', default=False, action='store_true')
parser.add_argument('--version', help='displays the current version', action='version', version=base.__version__)
args = parser.parse_args()
recon_ui(args)
14 changes: 14 additions & 0 deletions recon/scripts/web.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python3

from recon.core.web import create_app
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--host', default='127.0.0.1', help="IP address to listen on")
parser.add_argument('--port', default=5000, help="port to bind the web server to")

args = parser.parse_args()

app = create_app()
def main():
app.run(host=args.host, port=args.port)