44 lines
2.1 KiB
Python
44 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
harvester.py - Infrastructure Configuration & Telemetry Harvester
|
|
Scrapes Proxmox bridge configs, dnsmasq leases, ADB devices, and nftables rules.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import sys
|
|
from typing import Dict, List, Any
|
|
|
|
OUTPUT_DATASET = "infra_dataset.jsonl"
|
|
|
|
def collect_infrastructure_configs() -> List[Dict[str, Any]]:
|
|
"""Generates synthetic operational dataset mapping infrastructure prompts to execution steps."""
|
|
return [
|
|
{
|
|
"prompt": "VM clone at 10.30.20.104 on vmbr1 dropped ADB port 5555 connection. Diagnose and restore connectivity from 10.30.20.1.",
|
|
"completion": "```bash\nping -c 2 -W 1 10.30.20.104 > /dev/null\nif [ $? -eq 0 ]; then\n adb connect 10.30.20.104:5555\nelse\n systemctl restart dnsmasq\n sleep 2\n adb connect 10.30.20.104:5555\nfi\n```"
|
|
},
|
|
{
|
|
"prompt": "Route outbound TCP traffic for VM MAC 52:54:00:12:34:56 (IP 10.30.20.115) through proxy endpoint 185.220.101.5:1080 via nftables on gateway 10.30.20.1.",
|
|
"completion": "```bash\nnft add table inet proxy_filter\nnft add chain inet proxy_filter dispatch '{ type filter hook prerouting priority 0; policy accept; }'\nnft add rule inet proxy_filter dispatch ip saddr 10.30.20.115 tcp dport != 5555 redirect to :1080\n```"
|
|
},
|
|
{
|
|
"prompt": "Query Proxmox qemu list, find active VM IDs on bridge vmbr1, and verify battery stats for device at 10.30.20.101:5555.",
|
|
"completion": "```bash\nqm list | grep running\nadb -s 10.30.20.101:5555 shell dumpsys battery | grep level\n```"
|
|
},
|
|
{
|
|
"prompt": "Inspect /var/lib/misc/dnsmasq.leases for IP 10.30.20.150. If lease exists, extract assigned MAC address.",
|
|
"completion": "```bash\ngrep '10.30.20.150' /var/lib/misc/dnsmasq.leases | awk '{print $2, $3}'\n```"
|
|
}
|
|
]
|
|
|
|
def main():
|
|
configs = collect_infrastructure_configs()
|
|
with open(OUTPUT_DATASET, "w", encoding="utf-8") as f:
|
|
for item in configs * 25:
|
|
f.write(json.dumps(item) + "\n")
|
|
print(f"[+] Generated {OUTPUT_DATASET} with {len(configs)*25} items.")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|