Skip to content

Commit 0b03f7b

Browse files
authored
Added packaging constructs to allow installation using pip or pipx (Tib3rius#48)
* Restructured program to enable packaging. Moved main into its own function and resolved global dependency issues. Configured pyproject.toml * Restructured configuration management such that configuration files are stored in the default user configuration directory for the OS they're using, utilising appdirs * Added exclusion for byte compiled python files * Removed build files from version control * Restructured config file initialisation into a function so that it can be called by the entrypoint main() function * Resolved issues updating global variables from within function scope. Added global identifiers to global variables to make them more readily identifiable as such * Formatting revision * Updated documentation to reflect package installation instructions and usage * Grammatical revision to improve instructional clarity * Added default sudo for udp scans to prompt for password to elevate privileges * Added an installation command for all required packages to the README * Added manual installation instructions, clarification of oscp vm limitations installing pip3, and instructions on how to elevate privileges when installed with pipx * Formatting revision to improve clarity of instructions and added requirements.txt * Removed hardcoded sudo commands from default scan configurations * Changed suggestion to add alias to .bashrc to .profile as this is what's used by default in kali to set initial temrinal conditions * Fixed error in manual installation that would have resulted in installing python2 packages
1 parent d5b3122 commit 0b03f7b

11 files changed

+407
-63
lines changed

.gitignore

+139
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.pyc
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
.Python
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
cover/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
db.sqlite3-journal
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
.pybuilder/
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# IPython
83+
profile_default/
84+
ipython_config.py
85+
86+
# pyenv
87+
# For a library or package, you might want to ignore these files since the code is
88+
# intended to run in multiple environments; otherwise, check them in:
89+
# .python-version
90+
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
99+
__pypackages__/
100+
101+
# Celery stuff
102+
celerybeat-schedule
103+
celerybeat.pid
104+
105+
# SageMath parsed files
106+
*.sage.py
107+
108+
# Environments
109+
.env
110+
.venv
111+
env/
112+
venv/
113+
ENV/
114+
env.bak/
115+
venv.bak/
116+
117+
# Spyder project settings
118+
.spyderproject
119+
.spyproject
120+
121+
# Rope project settings
122+
.ropeproject
123+
124+
# mkdocs documentation
125+
/site
126+
127+
# mypy
128+
.mypy_cache/
129+
.dmypy.json
130+
dmypy.json
131+
132+
# Pyre type checker
133+
.pyre/
134+
135+
# pytype static type analyzer
136+
.pytype/
137+
138+
# Cython debug symbols
139+
cython_debug/

README.md

+91-11
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,66 @@ AutoRecon was inspired by three tools which the author used during the OSCP labs
2626

2727
## Requirements
2828

29-
* Python 3
30-
* colorama
31-
* toml
29+
- Python 3
30+
- `python3-pip`
31+
- `pipx` (optional, but recommended)
3232

33-
Once Python 3 is installed, pip3 can be used to install the other requirements:
33+
### Python 3
34+
35+
If you don't have these installed, and are running Kali Linux, you can execute the following:
3436

3537
```bash
36-
$ pip3 install -r requirements.txt
38+
$ sudo apt install python3
39+
$ sudo apt install python3-pip
3740
```
3841

39-
Several people have indicated that installing pip3 via apt on the OSCP Kali version makes the host unstable. In these cases, pip3 can be installed by running the following commands:
42+
Additionally, if you experience any issues with the stability of the `python3-pip` installation (as reported by a number of people installing `pip3` via `apt` on the OSCP distribution of Kali), you can install it manually as follows:
4043

4144
```bash
4245
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
4346
$ python3 get-pip.py
4447
```
4548

46-
The "pip3" command should now be usable.
49+
The `pip3` command should now be usable.
50+
51+
### `pipx`
52+
53+
Further, it's recommended you use `pipx` to manage your python packages; this installs each python package in it's own virtualenv, and makes it available in the global context, which avoids conflicting package dependencies and the resulting instability. To summarise the installation instructions:
54+
55+
```bash
56+
$ python3 -m pip install --user pipx
57+
$ python3 -m pipx ensurepath
58+
```
59+
60+
Note that if you want to elevate privileges to run a program installed with `pipx`, with `sudo`, you have two options:
61+
62+
1. Append the appropriate path to your execution command, using _one_ of the following examples (recommended):
63+
64+
```bash
65+
$ sudo env "PATH=$PATH" autorecon [OPTIONS]
66+
$ sudo $(which autorecon) [OPTIONS]
67+
```
68+
69+
To make this easier, you could add the following alias to your `~/.profile` (or equivalent):
70+
71+
```
72+
alias sudo="sudo env \"PATH=$PATH\""
73+
```
74+
75+
2. Add the `pipx` binary path to the `secure_path` set in `/etc/sudoers`
76+
77+
```bash
78+
sudo visudo /etc/sudoers
79+
```
80+
81+
Update the `secure_path` directive as follows:
82+
```
83+
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/kali/.local/bin"
84+
```
85+
86+
If you're not using Kali Linux, make sure to adjust the path to the relevant user. Further detail on the installation of `pipx` is available in their installation instructions available [here](https://pipxproject.github.io/pipx/installation/). Please refer to this for any issues you experience.
87+
88+
### Supporting packages
4789

4890
Several commands used in AutoRecon reference the SecLists project, in the directory /usr/share/seclists/. You can either manually download the SecLists project to this directory (https://github.com/danielmiessler/SecLists), or if you are using Kali Linux (**highly recommended**) you can run the following:
4991

@@ -75,12 +117,50 @@ whatweb
75117
wkhtmltoimage
76118
```
77119

120+
On Kali Linux, you can ensure these are all installed using the following command:
121+
122+
```bash
123+
$ sudo apt install curl enum4linux gobuster nbtscan nikto nmap onesixtyone oscanner smbclient smbmap smtp-user-enum snmp sslscan sipvicious tnscmd10g whatweb wkhtmltopdf
124+
```
125+
126+
## Installation
127+
128+
Ensure you have all of the requirements installed as per the previous section.
129+
130+
### Using `pipx` (recommended)
131+
132+
```bash
133+
$ pipx install git+https://github.com/Tib3rius/AutoRecon.git
134+
```
135+
136+
### Using `pip`
137+
138+
```bash
139+
$ python3 -m pip install git+https://github.com/Tib3rius/AutoRecon.git
140+
```
141+
142+
### Manual
143+
144+
If you'd prefer not to use `pip` or `pipx`, you can always still install and execute `autorecon.py` manually as a script. First install the dependencies:
145+
146+
```bash
147+
$ python3 -m pip install -r requirements.txt
148+
```
149+
150+
You will then be able to run the `autorecon.py` script (from `<AUTORECON_ROOT_DIR>/src/autorecon`):
151+
152+
```bash
153+
$ python3 autorecon.py [OPTIONS] 127.0.0.1
154+
```
155+
156+
See detailed usage options below.
157+
78158
## Usage
79159

80160
AutoRecon uses Python 3 specific functionality and does not support Python 2.
81161

82162
```
83-
usage: autorecon.py [-h] [-t TARGET_FILE] [-ct <number>] [-cs <number>]
163+
usage: autorecon [-h] [-t TARGET_FILE] [-ct <number>] [-cs <number>]
84164
[--profile PROFILE_NAME] [-o OUTPUT_DIR] [--single-target]
85165
[--only-scans-dir] [--heartbeat HEARTBEAT]
86166
[--nmap NMAP | --nmap-append NMAP_APPEND] [-v]
@@ -135,7 +215,7 @@ optional arguments:
135215
**Scanning a single target:**
136216

137217
```
138-
python3 autorecon.py 127.0.0.1
218+
$ autorecon 127.0.0.1
139219
[*] Scanning target 127.0.0.1
140220
[*] Running service detection nmap-full-tcp on 127.0.0.1
141221
[*] Running service detection nmap-top-20-udp on 127.0.0.1
@@ -183,7 +263,7 @@ Note that the actual command line output will be colorized if your terminal supp
183263
**Scanning multiple targets**
184264

185265
```
186-
python3 autorecon.py 192.168.1.100 192.168.1.1/30 localhost
266+
$ autorecon 192.168.1.100 192.168.1.1/30 localhost
187267
[*] Scanning target 192.168.1.100
188268
[*] Scanning target 192.168.1.1
189269
[*] Scanning target 192.168.1.2
@@ -208,7 +288,7 @@ AutoRecon supports multiple targets per scan, and will expand IP ranges provided
208288
**Scanning multiple targets with advanced options**
209289

210290
```
211-
python3 autorecon.py -ct 2 -cs 2 -vv -o outputdir 192.168.1.100 192.168.1.1/30 localhost
291+
$ autorecon -ct 2 -cs 2 -vv -o outputdir 192.168.1.100 192.168.1.1/30 localhost
212292
[*] Scanning target 192.168.1.100
213293
[*] Scanning target 192.168.1.1
214294
[*] Running service detection nmap-quick on 192.168.1.100 with nmap -vv --reason -Pn -sV -sC --version-all -oN "/root/outputdir/192.168.1.100/scans/_quick_tcp_nmap.txt" -oX "/root/outputdir/192.168.1.100/scans/_quick_tcp_nmap.xml" 192.168.1.100

poetry.lock

+42
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[virtualenvs]
2+
create = true

pyproject.toml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[tool.poetry]
2+
name = "autorecon"
3+
version = "1.0.0"
4+
description = "A multi-threaded network reconaissance tool which performs automated enumeration of services"
5+
authors = ["Tib3rius"]
6+
license = "GPL-3.0-only"
7+
readme = "README.md"
8+
homepage = "https://github.com/Tib3rius/AutoRecon"
9+
repository = "https://github.com/Tib3rius/AutoRecon"
10+
packages = [
11+
{include = "autorecon", from = "src"},
12+
]
13+
14+
[tool.poetry.dependencies]
15+
python = "^3.7"
16+
toml = "^0.10.0"
17+
colorama = "^0.4.3"
18+
appdirs = "^1.4.3"
19+
20+
[tool.poetry.dev-dependencies]
21+
22+
23+
[tool.poetry.scripts]
24+
autorecon = 'autorecon.autorecon:main'
25+
26+
[build-system]
27+
requires = ["poetry>=0.12"]
28+
build-backend = "poetry.masonry.api"

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
colorama
22
toml
3+
appdirs

src/autorecon/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)