diff --git a/flash.sh b/flash.sh index 6f50ee3..4df4e6f 100755 --- a/flash.sh +++ b/flash.sh @@ -20,4 +20,15 @@ do 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" diff --git a/script.py b/script.py index 026a5bd..eda71e9 100644 --- a/script.py +++ b/script.py @@ -50,3 +50,40 @@ 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)