Skip to content

Commit 30537fd

Browse files
committedJul 13, 2024·
.
1 parent 6fab971 commit 30537fd

File tree

6 files changed

+68
-2
lines changed

6 files changed

+68
-2
lines changed
 

‎README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@ python -m venv venv
1414
# Install the requirements
1515
pip install -r requirements.txt
1616

17-
# Run the check script (to execute against all of our domains)
18-
./check.bash
17+
# Run the bulk validator script
18+
./z_validate sites/example.txt
19+
./z_validate sites/acme.txt
1920

2021
# Run the POC against a single URL
2122
./poc.py -u https://samdjames.uk
23+
24+
# For unpatched sites, run a very BASIC compromised check (dump script srcs)
25+
# And run a diff against old detected scripts each execution
26+
./z_compromise_check sites/example.txt
2227
```
2328

‎requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
fake_useragent
22
requests
33
rich_click
4+
beautifulsoup4

‎scripts.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
from bs4 import BeautifulSoup
3+
import requests
4+
import sys
5+
6+
domain=sys.argv[1]
7+
print(f"Checking: {domain}")
8+
9+
response = requests.get(domain)
10+
doc = BeautifulSoup(response.text, features="html.parser")
11+
12+
links = doc.find_all('script', {"src": True})
13+
for link in links:
14+
if link['src'].startswith(domain) == False:
15+
print(link['src'])

‎sites/example.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://www.example.com
2+
https://www.example2.com

‎z_compromise_check

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
set -o pipefail
4+
5+
mkdir -p var/scripts
6+
7+
echo "Url Input: $1"
8+
[[ -z "$1" || ! -f "$1" ]] && echo "[!] Err: Please provide a filepath to the urls" && exit 255
9+
10+
for site in $(cat $1); do
11+
FN="var/scripts/$(echo "$site" | md5).txt"
12+
TMP=$(mktemp)
13+
./scripts.py $site | tee -a $TMP
14+
15+
diff $FN $TMP
16+
17+
if [ "$?" != "0" ]; then
18+
echo -e "\033[41m\033[1;37m[!!!!] CHANGE DETECTED\033[0m"
19+
# cat $TMP | mail -s "CosmicSting Monitor - Change Detected: $site" example@example.com
20+
fi
21+
22+
rm -f $FN
23+
mv $TMP $FN
24+
echo ""
25+
echo ""
26+
done

‎z_validate

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -o pipefail
4+
5+
echo "Url Input: $1"
6+
[[ -z "$1" || ! -f "$1" ]] && echo "[!] Err: Please provide a filepath to the urls" && exit 255
7+
8+
for site in $(cat $1); do
9+
RC="999"
10+
echo "Validating: $site"
11+
while [ "$RC" != "0" ]; do
12+
./poc.py -f /etc/passwd -u $site 2>/dev/null | tail -n1
13+
RC="$?"
14+
sleep 2
15+
done
16+
echo ""
17+
done

0 commit comments

Comments
 (0)
Please sign in to comment.