Compare commits
No commits in common. "0d0d50b061790178328f57a51c9041f9a49ed0b8" and "0351216f3475cc623ae6d5167a595151d47e7d2b" have entirely different histories.
0d0d50b061
...
0351216f34
6 changed files with 147 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
/serve/config.txt
|
||||
/logs
|
||||
|
|
|
|||
26
flash.sh
26
flash.sh
|
|
@ -1,20 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SSH_OPTS="-o StrictHostKeychecking=no"
|
||||
if ! curl -s -f http://127.0.0.1:8080/config.txt > /dev/null; then
|
||||
echo "!!!!!!!!!!!!! please start server"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SSH_OPTS="-o StrictHostKeyChecking=no"
|
||||
|
||||
ssh $SSH_OPTS root@192.168.42.6 "cli request system zeroize"
|
||||
|
||||
echo "sleeping for 10"
|
||||
echo "sleeping for 80s, then ping until up"
|
||||
|
||||
sleep 10
|
||||
|
||||
./serve.sh &
|
||||
sleep 80
|
||||
|
||||
while true;
|
||||
do
|
||||
if ping -w 1 -c 1 192.168.42.6 > /dev/null then
|
||||
if ping -w 1 -c 1 192.168.42.6 > /dev/null; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "collecting logs"
|
||||
|
||||
dir="./logs/$(date +"%Y%m%d_%H%M%S")-zeroize"
|
||||
|
||||
mkdir -p "$dir"
|
||||
|
||||
touch "$dir/zeroize"
|
||||
|
||||
cp "./serve/config.txt" "$dir/"
|
||||
cp ./flash.sh "$dir"
|
||||
|
||||
echo "finished"
|
||||
|
|
|
|||
24
powercut.sh
Executable file
24
powercut.sh
Executable file
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo "sleeping for 80s, then ping until up"
|
||||
|
||||
sleep 80
|
||||
|
||||
while true;
|
||||
do
|
||||
if ping -w 1 -c 1 192.168.42.6 > /dev/null; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "collecting logs"
|
||||
|
||||
dir="./logs/$(date +"%Y%m%d_%H%M%S")-powercut"
|
||||
|
||||
mkdir -p "$dir"
|
||||
|
||||
touch "$dir/powercut"
|
||||
|
||||
cp ./powercut.sh "$dir"
|
||||
|
||||
echo "finished"
|
||||
28
reboot.sh
Executable file
28
reboot.sh
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SSH_OPTS="-o StrictHostKeyChecking=no"
|
||||
|
||||
ssh $SSH_OPTS root@192.168.42.6 "reboot"
|
||||
|
||||
echo "sleeping for 80s, then ping until up"
|
||||
|
||||
sleep 80
|
||||
|
||||
while true;
|
||||
do
|
||||
if ping -w 1 -c 1 192.168.42.6 > /dev/null; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "collecting logs"
|
||||
|
||||
dir="./logs/$(date +"%Y%m%d_%H%M%S")-reboot"
|
||||
|
||||
mkdir -p "$dir"
|
||||
|
||||
touch "$dir/reboot"
|
||||
|
||||
cp ./reboot.sh "$dir"
|
||||
|
||||
echo "finished"
|
||||
76
script.py
76
script.py
|
|
@ -1,11 +1,11 @@
|
|||
from time import sleep
|
||||
|
||||
from scapy.all import ICMP, IP, Dot1Q, Ether, sendp
|
||||
from scapy.all import ICMP, IP, Dot1Q, Ether, sendp, AsyncSniffer, wrpcap
|
||||
from tqdm import tqdm
|
||||
|
||||
a = AsyncSniffer(iface="enp5s0d1", filter="icmp")
|
||||
a.start()
|
||||
for i in tqdm(range(1, 4095)):
|
||||
for i in tqdm(range(0, 4095)):
|
||||
sendp(
|
||||
Ether(dst="00:02:c9:27:10:73", src="00:f0:cb:ef:e0:3b")
|
||||
/ Dot1Q(vlan=i)
|
||||
|
|
@ -14,6 +14,76 @@ for i in tqdm(range(1, 4095)):
|
|||
iface="enp2s0",
|
||||
verbose=False,
|
||||
)
|
||||
print("Wrapping up and waiting for last packets")
|
||||
sleep(1)
|
||||
plist = a.stop()
|
||||
print(plist)
|
||||
|
||||
seen = [False for i in range(4095)]
|
||||
icmpid = [False for i in range(4095)]
|
||||
|
||||
def pprint(seen):
|
||||
last = None
|
||||
s = ""
|
||||
for k, v in enumerate(seen):
|
||||
if v and last is None:
|
||||
last = k
|
||||
s += str(k)
|
||||
if not v and last is not None:
|
||||
if k-1 == last:
|
||||
s += ","
|
||||
else:
|
||||
s += f"-{k-1},"
|
||||
last = None
|
||||
if last is not None and last < k:
|
||||
s += f"-{k}"
|
||||
return s + "\n"
|
||||
|
||||
|
||||
for p in plist:
|
||||
if Dot1Q in p:
|
||||
vlan = int(p[Dot1Q].vlan)
|
||||
seen[vlan] = True
|
||||
if ICMP in p and p[ICMP].id == vlan:
|
||||
icmpid[vlan] = True
|
||||
|
||||
print("Icmp correspondance")
|
||||
print(pprint(icmpid))
|
||||
print("Seen vlans")
|
||||
print(pprint(seen))
|
||||
|
||||
print("Collecting :")
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + "-test"
|
||||
log_dir = Path("./logs") / timestamp
|
||||
log_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(log_dir / "seen_vlans.txt", "w") as f:
|
||||
f.write(pprint(seen))
|
||||
|
||||
with open(log_dir / "seen_icmp_ids.txt", "w") as f:
|
||||
f.write(pprint(icmpid))
|
||||
|
||||
shutil.copy(Path("./script.py"), log_dir / "script.py")
|
||||
|
||||
print(" - [x] script.py")
|
||||
|
||||
with open(log_dir / "egress.pcap", "wb") as file:
|
||||
wrpcap(file, plist)
|
||||
|
||||
print(" - [x] pcap")
|
||||
|
||||
cmd_config = ["ssh", "-o", "StrictHostKeyChecking=no", "root@192.168.42.6", "cli show config"]
|
||||
cmd_rsi = ["ssh", "-o", "StrictHostKeyChecking=no", "root@192.168.42.6", "cli request support information"]
|
||||
|
||||
result = subprocess.run(cmd_config, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
||||
|
||||
with open(log_dir / "config.txt", "w") as f:
|
||||
f.write(result.stdout)
|
||||
|
||||
print(" - [x] config")
|
||||
|
||||
print("Finished, saved to", log_dir)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ system {
|
|||
ssh-ed25519 "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFdDnSl3cyWil+S5JiyGqOvBR3wVh+lduw58S5WvraoL maurice@fekda"; ## SECRET-DATA
|
||||
ssh-ed25519 "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIGmU7yEOCGuGNt4PlQbzd0Cms1RePpo8yEA7Ij/+TdA foo@bar"; ## SECRET-DATA
|
||||
ssh-ed25519 "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDz9zePZXeH96RotT+xl4ux2kOh3qIp94txtcMjsf3vx foo@bar"; ## SECRET-DATA
|
||||
ssh-ed25519 "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIBicEt7xV6tjMURJO/dXbxF0VGE3RtxuFaE7ba+1qSN root@elnath"; ## SECRET-DATA
|
||||
}
|
||||
services {
|
||||
netconf {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue