Skip to content

Commit

Permalink
Merge pull request #35 from andrewk10/develop
Browse files Browse the repository at this point in the history
Sprint3 - v0.2.0 Release
  • Loading branch information
andrewk10 authored Mar 20, 2022
2 parents 9d424e2 + e5611f9 commit 5726a43
Show file tree
Hide file tree
Showing 19 changed files with 1,072 additions and 408 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
sample: # This is the name of the workflow, feel free to change it to better match your workflow.
autocompliance-workflow:
# Inside the workflow, you define the jobs you want to run.
jobs:
- build-and-test
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL - Feature"

on:
push:
branches: [ wiki_and_documentation_establishment ]
branches: [ 14-finish-test_net_propagationpy-and-add-proper-logging ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ wiki_and_documentation_establishment ]
branches: [ 14-finish-test_net_propagationpy-and-add-proper-logging ]
schedule:
- cron: '34 22 * * 4'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-app-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Python Application - Feature

on:
push:
branches: [ wiki_and_documentation_establishment ]
branches: [ 14-finish-test_net_propagationpy-and-add-proper-logging ]
pull_request:
branches: [ wiki_and_documentation_establishment ]
branches: [ 14-finish-test_net_propagationpy-and-add-proper-logging ]

jobs:
build:
Expand Down
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.idea/workspace.xml
.idea/git_toolbox_prj.xml
.idea/
**/__pycache__
.coverage
htmlcov/
2 changes: 1 addition & 1 deletion dev_setup.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
# Linux setup for running the scripts locally.
python3 -m pip install ipykernel paramiko scapy pytest requests
python3 -m pip install --upgrade pip ipykernel paramiko scapy pytest requests coverage
15 changes: 11 additions & 4 deletions docs/wiki/usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ The script will take in the following parameters:

Example usage would look like this:
```
./net_attack.py -t my_ip_list.txt -p 22,23,25,80 -u admin -f my_password_list.txt
./net_attack.py -t ip_list.txt -p 22 -u root -f passwords.txt
./net_attack.py -t ip_list.txt -p 22 -u root -f passwords.txt -d test.txt
./net_attack.py -L -p 22,23 -u root -f passwords.txt -P
# Running the propagation script across numerous services (SSH, Telnet, Web)
./main.py -t src/test_files/ip_list.txt -p 22,23,25,80 -u admin -f src/test_files/passwords_list.txt
# Running the propagation script just across SSH
./main.py -t src/test_files/ip_list.txt -p 22 -u root -f src/test_files/passwords_list.txt
# Running the propagation script just across SSH and spreading a specific file.
./main.py -t src/test_files/ip_list.txt -p 22 -u root -f src/test_files/passwords_list.txt -d src/test_files/file.txt
# Running the propagation script across SSH and Telnet but acquiring IPs through a local scan and then subsequently self propagating.
./main.py -L -p 22,23 -u root -f src/test_files/passwords_list.txt -P
```
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
scapy>=2.4.5
scapy
ipykernel
paramiko
scapy>=2.4.5
pytest
requests>=2.27.0
requests
coverage
pyinstaller
6 changes: 6 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Linux setup for running the scripts locally.
# See; https://coverage.readthedocs.io/en/6.3.2/
coverage run -m pytest
coverage report
coverage html
Binary file not shown.
Binary file removed src/__pycache__/net_propagation.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/strings.cpython-310.pyc
Binary file not shown.
Binary file not shown.
74 changes: 41 additions & 33 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
#!/usr/bin/python3
# TODO: Change method names and reread some comments like here for example, not
# attacking, propagating and protecting more like. (Andrew)

# Importing logging to safely log sensitive, error or debug info.
import logging
# Importing net_propagation for propagating across the network.
import net_propagation
# Importing strings for use of the external strings resources.
import strings
# Importing sys to make OS calls and use OS level utilities.
import sys

"""
- Importing logging to safely log sensitive, error or debug info.
- Importing net_propagation for propagating across the network.
- Importing strings for use of the external strings resources.
- Importing sys to make OS calls and use OS level utilities.
"""

"""
===PLEASE READ===
This main function itself has more specific, low level commenting.
"""


def main():
"""
This main function controls all the things.
This main function is what initially runs when AutoCompliance runs.
"""
# These arguments are passed in by the end user.
arguments = sys.argv

# If there is no arguments then just print the help menu and exit.
if arguments.__len__():
net_propagation.exit_and_show_instructions()
sys.exit(-1)

# Just initialising this for use later.
transfer_file_filename = ""
transfer_file_filename = strings.BLANK_STRING

# Validating and assigning values based on arguments passed in.
valid_values = net_propagation.checking_arguments(arguments)
# If they are valid values...
if valid_values is None:
# Show the user instructions and exit gracefully.
net_propagation.exit_and_show_instructions()
sys.exit(-1)

ip_list, target_ports, target_username, passwords_filename = \
net_propagation.checking_arguments(arguments)
# Else...
else:
# Assign them...
ip_list, target_ports, target_username, passwords_filename = \
valid_values

# The end user specified a local scan must be executed, the result of the
# local scan will extend the current ip_list.
if "-L" in arguments:
if strings.ARGUMENT_SCAN_LOCAL_NETWORKS in arguments:
logging.info(strings.PERFORMING_LOCAL_SCAN)
ip_list.extend(net_propagation.gathering_local_ips(ip_list))

Expand All @@ -46,41 +53,42 @@ def main():
password_list = \
net_propagation.convert_file_to_list(passwords_filename)
except RuntimeError:
# Uh oh, file doesn't exist, alert the user and exit gracefully, so
# they can either fix their mistake or repent their sins.
# File doesn't exist, alert the user and exit gracefully, so
# they can possibly fix their mistake.
net_propagation.file_error_handler()
sys.exit()
sys.exit(-1)

# If the user wants to transfer a file, this stuff should be done...
if "-d" in arguments:
if strings.ARGUMENT_SPECIFIC_PROPAGATION_FILE in arguments:
try:
# Again making sure the transfer file actually exits, just like
# the password file above.
net_propagation.validate_file_exists(transfer_file_filename)
# if it does though we assign the filename to the name out of scope
# If it does though we assign the filename to the name out of scope
# above.
transfer_file_filename = arguments[arguments.index("-d") + 1]
transfer_file_filename = arguments[arguments.index(
strings.ARGUMENT_SPECIFIC_PROPAGATION_FILE) + 1]
except RuntimeError:
# File doesn't exist, throw an error and give the usual slap across
# the wrist.
# File doesn't exist, throw an error and give the user a chance to
# try again.
net_propagation.file_error_handler()
sys.exit()
sys.exit(-1)
# Removing duplicate entries in the IP address list, can come from
# combining local scan with given IP addresses in an ip address file among
# other things and silliness.
# combining local scan with given IP addresses in an ip address file for
# example. This would be a user error, we're just handling that.
ip_list = list(dict.fromkeys(ip_list))
# Removing IPs from the IP list that can't be pinged from the host machine
# of the script.
ip_list = net_propagation.remove_unreachable_ips(ip_list)
# Getting a list of ports by splitting the target ports specified by the
# user on the comma.
ports = target_ports.split(",")
ports = target_ports.split(strings.COMMA)
# Cycling through every IP in the IP list...
for ip in ip_list:
# And then using all user specified ports against that specific IP...
for port in ports:
# Try to spread :D
net_propagation.try_attack(ip, port, target_username,
# Try to spread using services and actions.
net_propagation.try_action(ip, port, target_username,
password_list, transfer_file_filename,
arguments)

Expand Down
Loading

0 comments on commit 5726a43

Please sign in to comment.