.
This commit is contained in:
1 parent
93d65bb2be
commit
cbd46cc96f
7 files changed
+222
-16
No files matched your search
@@ -17,7 +17,7 @@ import shutil
|
||||
import re
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
SCANFOLDER=os.path.join(os.path.dirname(sys.argv[0]),"recons_scans")
|
||||
KEYWORDS = [".txt", "pass", "creds", "user", ".dic", "hash", "<!--"]
|
||||
KEYWORDS = [".txt", "pass", "creds", "user", ".dic", "hash", "<!--","admin"]
|
||||
services=[]
|
||||
CRITICS_PORTS=[21,1234,4444,9000,5000,88,139,445]
|
||||
CRITICS_SERVICES=["kerberos","redis","microsoft-ds","ldap","netbios-ssn"]
|
||||
@@ -50,6 +50,7 @@ TIPS = [
|
||||
CONFIG_FOLDER = f"/home/coder/.config/recon"
|
||||
if not os.path.isdir(SCANFOLDER):
|
||||
os.makedirs(SCANFOLDER)
|
||||
os.chdir(SCANFOLDER)
|
||||
if not os.path.isdir(CONFIG_FOLDER):
|
||||
os.makedirs(CONFIG_FOLDER)
|
||||
if not os.path.isfile(os.path.join(CONFIG_FOLDER, "wordlists.txt")):
|
||||
@@ -172,7 +173,7 @@ def detect_service(ip, port, timeout=3):
|
||||
s.sendall(http_req.encode())
|
||||
resp = _safe_recv(s, 8192)
|
||||
if resp and resp.startswith("HTTP/"):
|
||||
info["service"] = info.get("service") or "http"
|
||||
info["service"] = "http"
|
||||
info["banner"] = (info["banner"] or "") + "\n" + resp.splitlines()[0]
|
||||
# try to extract Server header
|
||||
m = _server_header_re.search(resp)
|
||||
@@ -193,7 +194,7 @@ def detect_service(ip, port, timeout=3):
|
||||
with ctx.wrap_socket(s, server_hostname=ip) as ss:
|
||||
cert = ss.getpeercert()
|
||||
# presence of cert => TLS-enabled service (https or other tls)
|
||||
info["service"] = info.get("service") or "tls"
|
||||
info["service"] = info["service"] or "tls"
|
||||
info["extra"]["tls_subject"] = cert.get("subject")
|
||||
info["extra"]["tls_issuer"] = cert.get("issuer")
|
||||
# sometimes certificate commonName contains hostname only; no version
|
||||
@@ -350,7 +351,7 @@ def tcp_scan(
|
||||
print(f"\n[!] Scan complete. Found {len(open_ports)} open ports.")
|
||||
return sorted(open_ports)
|
||||
def udp_scan(
|
||||
ip, start_port=1, end_port=7000, timeout=0.4, max_threads=os.cpu_count() * 50
|
||||
ip, start_port=1, end_port=65535, timeout=0.4, max_threads=os.cpu_count() * 50
|
||||
):
|
||||
open_ports = []
|
||||
lock = Lock()
|
||||
@@ -377,14 +378,18 @@ def udp_scan(
|
||||
def _gobuster_probe(args):
|
||||
"""
|
||||
Worker for multiprocessing pool.
|
||||
Args: (target, directory, ssl)
|
||||
Args: (target,port, directory, ssl)
|
||||
Returns: tuple (url, matches, short_content) or None
|
||||
"""
|
||||
target, directory, ssl = args
|
||||
target,port, directory, ssl = args
|
||||
directory = directory.strip()
|
||||
if not directory:
|
||||
return None
|
||||
url = f"https://{target}/{directory}" if ssl else f"http://{target}/{directory}"
|
||||
if port == 80 or port == 443:
|
||||
url = f"https://{target}/{directory}" if ssl else f"http://{target}/{directory}"
|
||||
else:
|
||||
url="http://" if not ssl == True else "https://"
|
||||
url+=f"{target}:{port}/{directory}"
|
||||
try:
|
||||
# Each process creates its own short-lived request
|
||||
r = requests.get(url, timeout=5)
|
||||
@@ -408,6 +413,7 @@ def _gobuster_probe(args):
|
||||
|
||||
def gobuster(
|
||||
target,
|
||||
port=80,
|
||||
ssl=False,
|
||||
rapport=None,
|
||||
wordlist_path=WORDLIST,
|
||||
@@ -437,7 +443,7 @@ def gobuster(
|
||||
worker_count = processes if (processes and processes > 0) else max(2, cpu)
|
||||
|
||||
# build args for pool
|
||||
tasks = [(target, d, ssl) for d in dirs]
|
||||
tasks = [(target,port, d, ssl) for d in dirs]
|
||||
|
||||
results = []
|
||||
try:
|
||||
@@ -568,6 +574,11 @@ def subdnsfind(target):
|
||||
print(f"port: {Colors.ORANGE}{service['port']}{Colors.END} | service: {Colors.ORANGE}{service['service']}{Colors.END} | version: {service['version']}\n")
|
||||
else:
|
||||
print(f"port: {service['port']} | service: {service['service']} | version: {service['version']}\n")
|
||||
if "http" in service['service']:
|
||||
gobuster(target,service['port'],ssl=False,rapport=rapport)
|
||||
if "https" in service['service']:
|
||||
gobuster(target,service['port'],ssl=True,rapport=rapport)
|
||||
|
||||
safe_target = re.sub(r"[^a-zA-Z0-9_.-]", "_", subdomain)
|
||||
output_file = f"gobuster_{safe_target}.txt"
|
||||
|
||||
@@ -595,7 +606,6 @@ def subdnsfind(target):
|
||||
rapport.append(f"\n {subdomain} ROBOTS.txt content:\n{robots_content}")
|
||||
analyze_entries(target, robots_content.splitlines(), rapport)
|
||||
|
||||
gobuster(target, ssl=use_https, rapport=rapport)
|
||||
rapport.append(f"\n\n {subdomain} GOBUSTER DIRECTORY SCAN")
|
||||
if os.path.exists(output_file):
|
||||
with open(output_file, "r") as f:
|
||||
@@ -639,7 +649,7 @@ def main():
|
||||
|
||||
try:
|
||||
ip = socket.gethostbyname(target)
|
||||
result = re.compile('\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b').match(target)
|
||||
result = re.compile(r'\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b').match(target)
|
||||
if not result:
|
||||
isdomain=True
|
||||
print("\nDomain mode detected ")
|
||||
@@ -668,12 +678,18 @@ def main():
|
||||
rapport += [f"{port}/UDP" for port in open_ports]
|
||||
|
||||
for service in services:
|
||||
if service['port'] in CRITICS_PORTS or service['service'] in CRITICS_SERVICES:
|
||||
print(f"port: {Colors.RED}{service['port']}{Colors.END} | service: {Colors.RED}{service['service']}{Colors.END} | version: {service['version']}\n")
|
||||
elif service['port'] in MID_PORTS or service['service'] in MID_SERVICES:
|
||||
print(f"port: {Colors.ORANGE}{service['port']}{Colors.END} | service: {Colors.ORANGE}{service['service']}{Colors.END} | version: {service['version']}\n")
|
||||
else:
|
||||
print(f"port: {service['port']} | service: {service['service']} | version: {service['version']}\n")
|
||||
if service['port'] in CRITICS_PORTS or service['service'] in CRITICS_SERVICES:
|
||||
print(f"port: {Colors.RED}{service['port']}{Colors.END} | service: {Colors.RED}{service['service']}{Colors.END} | version: {service['version']}\n")
|
||||
elif service['port'] in MID_PORTS or service['service'] in MID_SERVICES:
|
||||
print(f"port: {Colors.ORANGE}{service['port']}{Colors.END} | service: {Colors.ORANGE}{service['service']}{Colors.END} | version: {service['version']}\n")
|
||||
else:
|
||||
print(f"port: {service['port']} | service: {service['service']} | version: {service['version']}\n")
|
||||
if "http" in service['service']:
|
||||
gobuster(target,service['port'],ssl=False,rapport=rapport)
|
||||
if "https" in service['service']:
|
||||
gobuster(target,service['port'],ssl=True,rapport=rapport)
|
||||
|
||||
|
||||
safe_target = re.sub(r"[^a-zA-Z0-9_.-]", "_", target)
|
||||
output_file = f"gobuster_{safe_target}.txt"
|
||||
|
||||
|
||||
Reference in new issue
Block a user