update
This commit is contained in:
1 parent
2ec2017511
commit
fdf236743d
1 file changed
+68
-29
@@ -18,6 +18,7 @@ import ssl
|
|||||||
import shutil
|
import shutil
|
||||||
import re
|
import re
|
||||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
|
from urllib.request import urlopen
|
||||||
SCANFOLDER=os.path.join(os.path.dirname(sys.argv[0]),"recons_scans")
|
SCANFOLDER=os.path.join(os.path.dirname(sys.argv[0]),"recons_scans")
|
||||||
KEYWORDS = [".txt", "pass", "creds", "user", ".dic", "hash", "<!--","admin","THM"]
|
KEYWORDS = [".txt", "pass", "creds", "user", ".dic", "hash", "<!--","admin","THM"]
|
||||||
services=[]
|
services=[]
|
||||||
@@ -48,8 +49,8 @@ TIPS = [
|
|||||||
f"for further enumeration install the projectdiscovery.io suits (subfinder, nuclei, katana and httpx)"
|
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/{getpass.getuser()}/.config/recon"
|
||||||
CONFIG_FOLDER = f"/home/coder/.config/recon"
|
#CONFIG_FOLDER = f"/home/coder/.config/recon"
|
||||||
if not os.path.isdir(SCANFOLDER):
|
if not os.path.isdir(SCANFOLDER):
|
||||||
os.makedirs(SCANFOLDER)
|
os.makedirs(SCANFOLDER)
|
||||||
os.chdir(SCANFOLDER)
|
os.chdir(SCANFOLDER)
|
||||||
@@ -89,10 +90,8 @@ else:
|
|||||||
)
|
)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
lines = r.content.decode().splitlines()
|
lines = r.content.decode().splitlines()
|
||||||
for line in lines[:30]:
|
cleaned = [l for l in lines[:30] if not l.startswith("#")]
|
||||||
if line.startswith("#"):
|
f.writelines(l + "\n" for l in cleaned)
|
||||||
lines.remove(line)
|
|
||||||
f.writelines(lines)
|
|
||||||
print("dirbuster list have been downloaded successfully !")
|
print("dirbuster list have been downloaded successfully !")
|
||||||
wordlist = os.path.join(CONFIG_FOLDER, "dirbuster.txt")
|
wordlist = os.path.join(CONFIG_FOLDER, "dirbuster.txt")
|
||||||
else:
|
else:
|
||||||
@@ -329,27 +328,47 @@ def scan_port(ip, port, timeout, open_ports, lock,tcp=True):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
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(
|
def tcp_scan(
|
||||||
ip, start_port=1, end_port=65535, timeout=0.5, max_threads=os.cpu_count() * 50
|
ip, start_port=1, end_port=65535, timeout=0.5, max_threads=os.cpu_count() * 50
|
||||||
):
|
):
|
||||||
open_ports = []
|
open_ports = []
|
||||||
lock = Lock()
|
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")
|
print(f"\n[+] Starting multi-threaded TCP scan on {ip} (ports {start_port}-{end_port})\n")
|
||||||
|
|
||||||
with ThreadPoolExecutor(max_workers=max_threads) as executor:
|
with ThreadPoolExecutor(max_workers=max_threads) as executor:
|
||||||
# Submit all tasks and keep track of the 'future' objects
|
|
||||||
futures = [
|
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)
|
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):
|
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.")
|
print(f"\n[!] Scan complete. Found {len(open_ports)} open ports.")
|
||||||
return sorted(open_ports)
|
return sorted(open_ports)
|
||||||
def udp_scan(
|
def udp_scan(
|
||||||
@@ -358,21 +377,24 @@ def udp_scan(
|
|||||||
open_ports = []
|
open_ports = []
|
||||||
lock = Lock()
|
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:
|
with ThreadPoolExecutor(max_workers=max_threads) as executor:
|
||||||
# Submit all tasks and keep track of the 'future' objects
|
|
||||||
futures = [
|
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)
|
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):
|
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.")
|
print(f"\n[!] Scan complete. Found {len(open_ports)} open ports.")
|
||||||
return sorted(open_ports)
|
return sorted(open_ports)
|
||||||
|
|
||||||
@@ -387,11 +409,11 @@ def _gobuster_probe(args):
|
|||||||
directory = directory.strip()
|
directory = directory.strip()
|
||||||
if not directory:
|
if not directory:
|
||||||
return None
|
return None
|
||||||
if port == 80 or port == 443:
|
scheme = "https" if ssl else "http"
|
||||||
url = f"https://{target}/{directory}" if ssl else f"http://{target}/{directory}"
|
if (ssl and port == 443) or (not ssl and port == 80):
|
||||||
|
url = f"{scheme}://{target}/{directory}"
|
||||||
else:
|
else:
|
||||||
url="http://" if not ssl == True else "https://"
|
url = f"{scheme}://{target}:{port}/{directory}"
|
||||||
url+=f"{target}:{port}/{directory}"
|
|
||||||
try:
|
try:
|
||||||
# Each process creates its own short-lived request
|
# Each process creates its own short-lived request
|
||||||
r = requests.get(url, timeout=5)
|
r = requests.get(url, timeout=5)
|
||||||
@@ -402,9 +424,17 @@ def _gobuster_probe(args):
|
|||||||
for keyword in KEYWORDS:
|
for keyword in KEYWORDS:
|
||||||
for line in r.text.splitlines():
|
for line in r.text.splitlines():
|
||||||
if keyword in line:
|
if keyword in line:
|
||||||
for _ in blacklist:
|
start = 0
|
||||||
if not _ in line:
|
while True:
|
||||||
matches.append(line.strip())
|
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
|
# return short content when small to avoid huge memory transfer
|
||||||
short_content = r.text if len(r.text) < 1000 else None
|
short_content = r.text if len(r.text) < 1000 else None
|
||||||
return (url, matches, short_content)
|
return (url, matches, short_content)
|
||||||
@@ -415,7 +445,7 @@ def _gobuster_probe(args):
|
|||||||
|
|
||||||
def gobuster(
|
def gobuster(
|
||||||
target,
|
target,
|
||||||
port=80,
|
port=None,
|
||||||
ssl=False,
|
ssl=False,
|
||||||
rapport=None,
|
rapport=None,
|
||||||
wordlist_path=WORDLIST,
|
wordlist_path=WORDLIST,
|
||||||
@@ -429,6 +459,8 @@ def gobuster(
|
|||||||
- wordlist_path: path to wordlist file
|
- wordlist_path: path to wordlist file
|
||||||
- processes: number of worker processes (defaults to cpu_count())
|
- processes: number of worker processes (defaults to cpu_count())
|
||||||
"""
|
"""
|
||||||
|
if port is None:
|
||||||
|
port = 443 if ssl else 80
|
||||||
print("[*] Starting Gobuster scan (multiprocessing)...")
|
print("[*] Starting Gobuster scan (multiprocessing)...")
|
||||||
safe_target = re.sub(r"[^a-zA-Z0-9_.-]", "_", target)
|
safe_target = re.sub(r"[^a-zA-Z0-9_.-]", "_", target)
|
||||||
output_file = f"gobuster_{safe_target}.txt"
|
output_file = f"gobuster_{safe_target}.txt"
|
||||||
@@ -644,6 +676,12 @@ def main():
|
|||||||
{Colors.END}
|
{Colors.END}
|
||||||
{Colors.YELLOW}[+] Created by NOTRUNIT{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))
|
print("Tips : " + random.choice(TIPS))
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
target = sys.argv[1]
|
target = sys.argv[1]
|
||||||
@@ -669,8 +707,9 @@ def main():
|
|||||||
print(f"IP: {ip}")
|
print(f"IP: {ip}")
|
||||||
rapport.append(f"Scanning {ip}")
|
rapport.append(f"Scanning {ip}")
|
||||||
open_ports_tcp = tcp_scan(target)
|
open_ports_tcp = tcp_scan(target)
|
||||||
threads.append([threading.Thread(target=nmap_full_scan,args=(target,open_ports_tcp)),"NMAP FULL SCAN"])
|
if len(open_ports_tcp) > 0:
|
||||||
threads[-1][0].start()
|
threads.append([threading.Thread(target=nmap_full_scan,args=(target,open_ports_tcp)),"NMAP FULL SCAN"])
|
||||||
|
threads[-1][0].start()
|
||||||
|
|
||||||
rapport.append("\nTCP OPEN PORTS:")
|
rapport.append("\nTCP OPEN PORTS:")
|
||||||
rapport += [f"{port}/TCP" for port in open_ports_tcp]
|
rapport += [f"{port}/TCP" for port in open_ports_tcp]
|
||||||
|
|||||||
Reference in new issue
Block a user