96 lines
3.2 KiB
Python
96 lines
3.2 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Hunt for recoverable Secure Preferences / Cookies backups for ops-neko profiles."""
|
|
import sys
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
SH = r"""
|
|
set -e
|
|
echo "===== Secure Preferences sizes ====="
|
|
for i in 1 2; do
|
|
p=/opt/douyinWEB/backend/data/ops_neko/profiles/$i/Default
|
|
echo "--- $i ---"
|
|
ls -la "$p/Secure Preferences" "$p/Preferences" 2>/dev/null
|
|
wc -c "$p/Secure Preferences" 2>/dev/null
|
|
echo "content:"; cat "$p/Secure Preferences"; echo
|
|
# any bak/old copies nearby
|
|
find "$p" -maxdepth 2 -iname '*secure*' -o -iname '*prefer*' 2>/dev/null | head -40
|
|
ls -la "$p"/.* 2>/dev/null | head -20 || true
|
|
done
|
|
|
|
echo "===== search host for larger Secure Preferences copies ====="
|
|
find /opt/douyinWEB /tmp /var/tmp /home/eric -name 'Secure Preferences' 2>/dev/null | while read f; do
|
|
sz=$(wc -c < "$f")
|
|
echo "$sz $f"
|
|
done | sort -n | tail -30
|
|
|
|
echo "===== Accounts dirs ====="
|
|
for i in 1 2; do
|
|
echo "--- profile $i Accounts ---"
|
|
find /opt/douyinWEB/backend/data/ops_neko/profiles/$i/Default/Accounts -type f 2>/dev/null | head -30
|
|
ls -la /opt/douyinWEB/backend/data/ops_neko/profiles/$i/Default/Accounts 2>/dev/null
|
|
done
|
|
|
|
echo "===== cookie auth names ====="
|
|
for i in 1 2; do
|
|
python3 - <<PY
|
|
import sqlite3
|
|
from pathlib import Path
|
|
fp=Path("/opt/douyinWEB/backend/data/ops_neko/profiles/$i/Default/Cookies")
|
|
con=sqlite3.connect(f"file:{fp}?mode=ro", uri=True)
|
|
cur=con.cursor()
|
|
cur.execute("select host_key, name, length(encrypted_value), length(value) from cookies order by host_key, name")
|
|
rows=cur.fetchall()
|
|
print("profile $i all cookies:")
|
|
for r in rows:
|
|
print(" ", r)
|
|
authish=[r for r in rows if any(x in r[1] for x in ("SID","HSID","SSID","SAPISID","APISID","SESSION","LOGIN","OSID","LSID"))]
|
|
print("authish", authish)
|
|
con.close()
|
|
PY
|
|
done
|
|
|
|
echo "===== other neko profiles (non-ops) with google login? ====="
|
|
find /opt/douyinWEB/backend/data -path '*/Default/Preferences' 2>/dev/null | head -40
|
|
for pref in /opt/douyinWEB/backend/data/neko/profiles/*/Default/Preferences; do
|
|
[ -f "$pref" ] || continue
|
|
python3 - <<PY
|
|
import json
|
|
from pathlib import Path
|
|
p=Path("$pref")
|
|
d=json.loads(p.read_text(encoding="utf-8", errors="replace"))
|
|
ai=d.get("account_info") or []
|
|
emails=[]
|
|
if isinstance(ai, list):
|
|
emails=[a.get("email") for a in ai if isinstance(a, dict) and a.get("email")]
|
|
sp=p.parent/"Secure Preferences"
|
|
print(p.parent.parent.name, "emails", emails, "secure_bytes", sp.stat().st_size if sp.exists() else None)
|
|
PY
|
|
done
|
|
|
|
echo "===== snapshots/zfs/restic? ====="
|
|
zfs list 2>/dev/null | head || echo no_zfs
|
|
ls /opt/douyinWEB/backend/data/ops_neko/profiles/
|
|
# docker volume backups
|
|
ls /var/lib/docker/volumes 2>/dev/null | head
|
|
"""
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("107.173.30.245", 4014, "eric", "4669805", timeout=40, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_hunt_ops_bak.sh", "wb") as f:
|
|
f.write(SH.encode())
|
|
sftp.close()
|
|
_i, o, e = c.exec_command("echo 4669805 | sudo -S -p '' bash /tmp/_hunt_ops_bak.sh", timeout=180)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|