-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathformbook_decoder.py
More file actions
51 lines (40 loc) · 1.56 KB
/
formbook_decoder.py
File metadata and controls
51 lines (40 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import pyshark
import requests
from collections import defaultdict, Counter
# === CONFIG ===
pcap_file = 'formbook.pcapng'
timeout = 5
# === PARSING DEL PCAP ===
domain_uri_counter = defaultdict(Counter)
cap = pyshark.FileCapture(pcap_file, display_filter='http.request.method == "GET"')
for pkt in cap:
try:
http = pkt.http
host = http.host
uri = http.request_uri
domain_uri_counter[host][uri] += 1
except AttributeError:
continue
cap.close()
# === SUSPICIOUS DOMAIN EXTRACTION === #
suspicious_domains = []
print("Possible C2 domains (same requests repeated):\n")
for domain, uri_counter in domain_uri_counter.items():
for uri, count in uri_counter.items():
if count > 1:
print(f"[+] {domain} --> {uri} -> {count} volte")
if domain not in suspicious_domains:
suspicious_domains.append(domain)
# === CHECK HTTP LOREM IPSUM OR INCIDUNT UT LABORE ===
print("\nChecking the homepage of the suspicious domains...\n")
for domain in suspicious_domains:
try:
url = f"http://{domain}"
response = requests.get(url, timeout=timeout)
txt = response.text.lower()
if ("incididunt ut labore" in txt) or ("lorem ipsum" in txt):
print(f"{domain} contains 'Lorem Ipsum' or 'Incidunt ut labore' → **HIGHLY PROBABLE C2 DOMAINS**")
else:
print(f"[ ] {domain} doesn't contain 'Lorem Ipsum' or 'Incidunt ut labore'")
except Exception as e:
print(f"[x] Error on {domain}: {e}")