This commit is contained in:
benji.benji committed 2026-08-31 22:05:36 +02:00
1 parent 2ec2017511
commit fdf236743d
1 file changed
+66 -27
+66 -27
View File
@@ -18,6 +18,7 @@ import ssl
import shutil
import re
from concurrent.futures import ThreadPoolExecutor, as_completed
from urllib.request import urlopen
SCANFOLDER=os.path.join(os.path.dirname(sys.argv[0]),"recons_scans")
KEYWORDS = [".txt", "pass", "creds", "user", ".dic", "hash", "<!--","admin","THM"]
services=[]
@@ -48,8 +49,8 @@ TIPS = [
f"for further enumeration install the projectdiscovery.io suits (subfinder, nuclei, katana and httpx)"
]
#CONFIG_FOLDER = f"/home/{getpass.getuser()}/.config/recon"
CONFIG_FOLDER = f"/home/coder/.config/recon"
CONFIG_FOLDER = f"/home/{getpass.getuser()}/.config/recon"
#CONFIG_FOLDER = f"/home/coder/.config/recon"
if not os.path.isdir(SCANFOLDER):
os.makedirs(SCANFOLDER)
os.chdir(SCANFOLDER)
@@ -89,10 +90,8 @@ else:
)
if r.status_code == 200:
lines = r.content.decode().splitlines()
for line in lines[:30]:
if line.startswith("#"):
lines.remove(line)
f.writelines(lines)
cleaned = [l for l in lines[:30] if not l.startswith("#")]
f.writelines(l + "\n" for l in cleaned)
print("dirbuster list have been downloaded successfully !")
wordlist = os.path.join(CONFIG_FOLDER, "dirbuster.txt")
else:
@@ -329,27 +328,47 @@ def scan_port(ip, port, timeout, open_ports, lock,tcp=True):
except Exception:
pass
def ping_check(ip, count=3, timeout=2):
try:
result = subprocess.run(
["ping", "-c", str(count), "-W", str(timeout), ip],
capture_output=True, text=True, timeout=count * timeout + 5,
)
if result.returncode == 0:
match = re.search(r"(?:time|temps)[=:]?([\d.]+)\s*ms", result.stdout)
if match:
latency = float(match.group(1))
print(f"[+] {ip} is reachable (avg latency: {latency}ms)")
return latency
except Exception:
pass
print(f"[-] Ping check for {ip} failed or unreachable, using higher timeout")
return 2000.0
def tcp_scan(
ip, start_port=1, end_port=65535, timeout=0.5, max_threads=os.cpu_count() * 50
):
open_ports = []
lock = Lock()
latency = ping_check(ip)
if latency > 500:
effective_timeout = max(timeout, latency / 1000)
print(f"[!] High latency detected ({latency}ms), using timeout={effective_timeout}s")
else:
effective_timeout = timeout
print(f"\n[+] Starting multi-threaded TCP scan on {ip} (ports {start_port}-{end_port})\n")
with ThreadPoolExecutor(max_workers=max_threads) as executor:
# Submit all tasks and keep track of the 'future' objects
futures = [
executor.submit(scan_port, ip, port, timeout, open_ports, lock)
executor.submit(scan_port, ip, port, effective_timeout, open_ports, lock)
for port in range(start_port, end_port + 1)
]
# This line ensures we wait for all threads to complete
# 'as_completed' is optional here but good for tracking progress
for future in as_completed(futures):
future.result() # This will also raise exceptions if any occurred in the thread
future.result()
# Execution only reaches here once all threads are done
print(f"\n[!] Scan complete. Found {len(open_ports)} open ports.")
return sorted(open_ports)
def udp_scan(
@@ -358,21 +377,24 @@ def udp_scan(
open_ports = []
lock = Lock()
print(f"\n[+] Starting multi-threaded TCP scan on {ip} (ports {start_port}-{end_port})\n")
latency = ping_check(ip)
if latency > 500:
effective_timeout = max(timeout, latency / 1000)
print(f"[!] High latency detected ({latency}ms), using timeout={effective_timeout}s")
else:
effective_timeout = timeout
print(f"\n[+] Starting multi-threaded UDP scan on {ip} (ports {start_port}-{end_port})\n")
with ThreadPoolExecutor(max_workers=max_threads) as executor:
# Submit all tasks and keep track of the 'future' objects
futures = [
executor.submit(scan_port, ip, port, timeout, open_ports, lock,False)
executor.submit(scan_port, ip, port, effective_timeout, open_ports, lock, False)
for port in range(start_port, end_port + 1)
]
# This line ensures we wait for all threads to complete
# 'as_completed' is optional here but good for tracking progress
for future in as_completed(futures):
future.result() # This will also raise exceptions if any occurred in the thread
future.result()
# Execution only reaches here once all threads are done
print(f"\n[!] Scan complete. Found {len(open_ports)} open ports.")
return sorted(open_ports)
@@ -387,11 +409,11 @@ def _gobuster_probe(args):
directory = directory.strip()
if not directory:
return None
if port == 80 or port == 443:
url = f"https://{target}/{directory}" if ssl else f"http://{target}/{directory}"
scheme = "https" if ssl else "http"
if (ssl and port == 443) or (not ssl and port == 80):
url = f"{scheme}://{target}/{directory}"
else:
url="http://" if not ssl == True else "https://"
url+=f"{target}:{port}/{directory}"
url = f"{scheme}://{target}:{port}/{directory}"
try:
# Each process creates its own short-lived request
r = requests.get(url, timeout=5)
@@ -402,9 +424,17 @@ def _gobuster_probe(args):
for keyword in KEYWORDS:
for line in r.text.splitlines():
if keyword in line:
for _ in blacklist:
if not _ in line:
matches.append(line.strip())
start = 0
while True:
pos = line.find(keyword, start)
if pos == -1:
break
ctx_start = max(0, pos - 32)
ctx_end = min(len(line), pos + len(keyword) + 32)
snippet = line[ctx_start:ctx_end].strip()
if not any(b in snippet for b in blacklist) and snippet not in matches:
matches.append(snippet)
start = pos + 1
# return short content when small to avoid huge memory transfer
short_content = r.text if len(r.text) < 1000 else None
return (url, matches, short_content)
@@ -415,7 +445,7 @@ def _gobuster_probe(args):
def gobuster(
target,
port=80,
port=None,
ssl=False,
rapport=None,
wordlist_path=WORDLIST,
@@ -429,6 +459,8 @@ def gobuster(
- wordlist_path: path to wordlist file
- processes: number of worker processes (defaults to cpu_count())
"""
if port is None:
port = 443 if ssl else 80
print("[*] Starting Gobuster scan (multiprocessing)...")
safe_target = re.sub(r"[^a-zA-Z0-9_.-]", "_", target)
output_file = f"gobuster_{safe_target}.txt"
@@ -644,6 +676,12 @@ def main():
{Colors.END}
{Colors.YELLOW}[+] Created by NOTRUNIT{Colors.END}
""")
data = str(urlopen('http://checkip.dyndns.com/').read())
ip = re.compile(r'Address: (\d+\.\d+\.\d+\.\d+)').search(data).group(1)
print("Your Public IP Address is:", ip)
print("Tips : " + random.choice(TIPS))
if len(sys.argv) > 1:
target = sys.argv[1]
@@ -669,6 +707,7 @@ def main():
print(f"IP: {ip}")
rapport.append(f"Scanning {ip}")
open_ports_tcp = tcp_scan(target)
if len(open_ports_tcp) > 0:
threads.append([threading.Thread(target=nmap_full_scan,args=(target,open_ports_tcp)),"NMAP FULL SCAN"])
threads[-1][0].start()