hn.today

Linux C2 from Scratch 0x01: Virtualising Your Malware

jm33.me3 points0 comments
Screenshot of Linux C2 from Scratch 0x01: Virtualising Your Malware

The tutorial builds a software-emulated RISC-V machine as a way to run Linux malware payloads without mapping the payload itself as executable memory. Its motivation is that Beacon Object Files normally need anonymous executable pages, which can be flagged through calls such as mmap or mprotect and entries in /proc/<pid>/maps; W^X does not remove that signal. Instead, guest instructions sit in a 64 MiB read-write memory arena and an interpreter executes them. The interpreter’s shared library is executable, but the guest payload remains data. Because the guest has no MMU, attempts to change memory permissions do nothing, and new mappings are also read-write. This changes the detection surface rather than removing it: guest system calls still reach the host kernel. Interpretation is orders of magnitude slower, a trade-off the author considers acceptable for one-off tasks such as scanning.

The explanation introduces the CPU, memory, registers, instruction sets, and the distinction between hardware virtualisation and software emulation before detailing the guest. The host is x86-64 Linux; the guest uses RV32IMA, a 32-bit RISC-V instruction set, implemented by the mini-rv32ima interpreter. Its CPU state is a small structure of registers, a program counter, and control registers, while guest memory is a byte array beginning at address 0x80000000. The lesson assumes only C and shell experience, and says the interpreter can be used across several Linux agent architectures. Its broader case is that implementing a VM is a practical way to learn operating-system internals, especially loaders, stacks, instruction decoding, and the syscall boundary.

Read on jm33.me0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Security

The Front Page · Nov 27, 2026

The Front Page · Nov 27, 2026

A card skimmer hidden in third-party marketing and cookie-consent tools affected five online stores before Black Friday, while the number of shoppers exposed remains unknown. ESA’s Hera mission found that NASA’s DART impact left Dimorphos with a huge crater and tumbling boulders; the roundup also covers AI assistant gossip and other tech news. (hndocs.org)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.