mirror of
https://github.com/reiyua/Gelos80Sniff.git
synced 2026-01-20 08:17:47 +00:00
Implement basic comment corrrections and implement a verbal list of each IP scanned within the network for debug
This commit is contained in:
parent
33f9feb1fe
commit
6d24950a85
1 changed files with 41 additions and 18 deletions
|
|
@ -1,20 +1,30 @@
|
||||||
# © Rayyan Hodges, TAFE NSW, Gelos Enterprises, DataTrust 2025
|
# © Rayyan Hodges, TAFE NSW, Gelos Enterprises, DataTrust 2025
|
||||||
# rayyan.hodges@studytafensw.edu.au
|
# rayyan.hodges@studytafensw.edu.au
|
||||||
# This program is coded in Python and designed to scan the local network for any clients connected that have port 80 open.
|
# This program is coded in Python and designed to scan the local network for any clients connected that have port 80 open.
|
||||||
# If a machine is found to have port 80 open, proceed to use programs like GoBuster and dirb to check for hidden directories without proper security in place and exploit.
|
# If a machine is found to have port 80 open, it proceeds to use programs like GoBuster to check for hidden directories.
|
||||||
# Results are exported to a TXT file for convenience.
|
# Results are exported to a TXT file for convenience.
|
||||||
|
|
||||||
# Import required python modules
|
# Import required python modules
|
||||||
import nmap
|
import nmap # pip install python-nmap
|
||||||
import subprocess
|
import subprocess
|
||||||
import os # integrate with operating system to make, manipulate and save the file.
|
import os # Integrates with the OS for file operations
|
||||||
|
import signal
|
||||||
|
|
||||||
# Function to validate user specified IP range and check IP address connectivity
|
# Timeout Exception Handling
|
||||||
|
class TimeoutException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def handler(signum, frame):
|
||||||
|
raise TimeoutException("Nmap scan timed out!")
|
||||||
|
|
||||||
|
|
||||||
|
# Function to validate user-specified IP range and check IP address connectivity
|
||||||
def validate_ip_range(ip_range):
|
def validate_ip_range(ip_range):
|
||||||
print(f"Validating IP address range: {ip_range}")
|
print(f"Validating IP address range: {ip_range}")
|
||||||
scanner = nmap.PortScanner()
|
scanner = nmap.PortScanner()
|
||||||
try:
|
try:
|
||||||
scanner.scan(hosts=ip_range, arguments='-sn') # Ping scan to validate range
|
scanner.scan(hosts=ip_range, arguments='-sn') # Ping scan to validate the range
|
||||||
if scanner.all_hosts():
|
if scanner.all_hosts():
|
||||||
print("IP address range is valid and reachable.")
|
print("IP address range is valid and reachable.")
|
||||||
return True
|
return True
|
||||||
|
|
@ -25,28 +35,41 @@ def validate_ip_range(ip_range):
|
||||||
print(f"Error validating IP range: {e}")
|
print(f"Error validating IP range: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Function to perform the network scan and identify open ports
|
|
||||||
|
# Function to perform the network scan and echo results IP by IP
|
||||||
def perform_scan(ip_range):
|
def perform_scan(ip_range):
|
||||||
print(f"Starting network scan on {ip_range}...")
|
print(f"Starting network scan on {ip_range}...\n")
|
||||||
scanner = nmap.PortScanner()
|
scanner = nmap.PortScanner()
|
||||||
scanner.scan(hosts=ip_range, arguments='-p 1-1024')
|
try:
|
||||||
results = {}
|
scanner.scan(hosts=ip_range, arguments='-p 1-1024')
|
||||||
for host in scanner.all_hosts():
|
results = {}
|
||||||
open_ports = scanner[host]['tcp'].keys() if 'tcp' in scanner[host] else []
|
|
||||||
if open_ports:
|
for host in scanner.all_hosts():
|
||||||
results[host] = open_ports
|
print(f"Scanning IP address: {host}")
|
||||||
print(f"Open ports on {host}: {open_ports}")
|
open_ports = scanner[host]['tcp'].keys() if 'tcp' in scanner[host] else []
|
||||||
return results
|
if open_ports:
|
||||||
|
print(f" --> Open ports on {host}: {list(open_ports)}")
|
||||||
|
results[host] = open_ports
|
||||||
|
else:
|
||||||
|
print(f" --> No open ports found on {host}.")
|
||||||
|
|
||||||
|
return results
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error during network scan: {e}")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
# Function to run Gobuster if port 80 is open
|
# Function to run Gobuster if port 80 is open
|
||||||
def run_gobuster(ip):
|
def run_gobuster(ip):
|
||||||
print(f"Running web enumeration on {ip} (port 80)...")
|
print(f"\nRunning web enumeration on {ip} (port 80)...")
|
||||||
output_file = f"gobuster_results_{ip.replace('.', '_')}.txt"
|
output_file = f"gobuster_results_{ip.replace('.', '_')}.txt"
|
||||||
command = f"gobuster dir -u http://{ip} -w /path/to/wordlist.txt -o {output_file}"
|
command = f"gobuster dir -u http://{ip} -w /path/to/wordlist.txt -o {output_file}"
|
||||||
subprocess.run(command, shell=True)
|
subprocess.run(command, shell=True)
|
||||||
print(f"Enumeration complete. Results saved to {output_file}.")
|
print(f"Enumeration complete. Results saved to {output_file}.")
|
||||||
return output_file
|
return output_file
|
||||||
|
|
||||||
|
|
||||||
# Main function to handle the process
|
# Main function to handle the process
|
||||||
def main():
|
def main():
|
||||||
while True:
|
while True:
|
||||||
|
|
@ -70,7 +93,7 @@ def main():
|
||||||
output_file = run_gobuster(ip)
|
output_file = run_gobuster(ip)
|
||||||
|
|
||||||
# Offer to save results
|
# Offer to save results
|
||||||
choice = input("Do you want to save the Gobuster results? (yes/no): ").strip().lower()
|
choice = input("\nDo you want to save the Gobuster results? (yes/no): ").strip().lower()
|
||||||
if choice == "yes":
|
if choice == "yes":
|
||||||
save_path = input("Enter the directory to save the results: ")
|
save_path = input("Enter the directory to save the results: ")
|
||||||
if os.path.isdir(save_path):
|
if os.path.isdir(save_path):
|
||||||
|
|
@ -83,6 +106,6 @@ def main():
|
||||||
|
|
||||||
print("Process complete. Terminating.")
|
print("Process complete. Terminating.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue