From bytecode to bytes: automated magic packet generation
Blog post from Cloudflare
Linux malware often leverages Berkeley Packet Filter (BPF) socket programs to clandestinely monitor network traffic, with some utilizing these filters to stay inactive until triggered by a specific packet. The complexity of reverse-engineering these programs manually can hinder security research, so symbolic execution, using tools like the Z3 theorem prover, has been explored to automate the process of generating the necessary packet to activate such threats. A particular focus is on the BPFDoor malware, used by China-based threat actors for cyberespionage, which exploits BPF to maintain stealthy network footholds. The post discusses a tool developed to quickly analyze BPF instructions and craft the corresponding network packet, significantly cutting down the time required for manual analysis. This tool uses symbolic execution to trace successful paths within the BPF logic, allowing analysts to understand and replicate the packet requirements for activating backdoors like BPFDoor. The research aims to further the community's capability in handling complex BPF instructions and has been made available as open-source to encourage additional advancements in this area.