Debugging
Capabilities
Both gdb and the executable being debugged must haveCAP_NET_RAW set for BNE (Binary Network Exploitation) to work properly.
Platform-Specific Behaviors
Erasing Command-Line Arguments
Proone instance processes may look suspicious because the cmdline string contains long base64 strings. Modification of cmdline is platform-specific. Linux: Zero-fill allmain() argv elements after index 0, as per ps(1):
command with all its arguments as a string. Modifications to the arguments may be shown.This allows Proone to hide its command-line arguments from process listings after startup.
Querying Link-Local Addresses
Linux: Usegetifaddrs(3) to query link-local addresses.
Known Issues and Bugs
Musl SOCKETCALL Bug
In early development, Musl was considered for the libc implementation due to its benefits over uClibc. However, development encountered a critical bug:- Issue: Musl SOCKETCALL bug
- Resolution: Abandoned Musl immediately after discovery
- Current: Using alternative libc implementations
Mbed TLS getrandom() Blocks
Issue: Mbed TLS #3551 Mbed TLS usesgetrandom() to initialize CTR_DRBG contexts. On systems where the function is not available, the library falls back to /dev/urandom, which never blocks. This contrasts with the blocking behavior of getrandom().
Solution:
Implemented prne_mbedtls_entropy_init() to modify the factory function for creating CTR_DRBG contexts so the library always uses /dev/urandom.
Pthsem’s Improper Use of FD_SET()
CallingFD_SET() with a negative fd value is undefined behavior. Pthsem uses select() for internal scheduling and doesn’t check fd values in pth_poll().
Problem:
Calling pth_poll() with pollfd containing negative fds results in undefined behavior because values are propagated to FD_SET(). uClibc crashes with SIGBUS, while Glibc on x86 handles it gracefully.
Solution:
Implemented prne_pth_poll() which transparently filters out pollfd elements with negative fd values before passing to pth_poll().
Optimization Opportunities
Use Lightweight Crypto
RSA keys are at least 2048 bits long, increasing executable size. Consider using elliptic-curve based alternatives to reduce binary size. Potential savings:- Smaller key sizes with equivalent security
- Faster operations on embedded devices
- Reduced memory footprint
Put Mbed TLS on Diet
The build is not lightweight because Mbed TLS library is extensive. Proone is tested using default Mbed TLS config included in Buildroot, but size reduction may be achieved by disabling unnecessary features: Features to disable:- Threading support
- DTLS (Datagram TLS)
- TLS Renegotiation
- ZLIB compression
Don’t Build Clean-up Code
Disabling clean-up code for release builds is a widely accepted technique to reduce code size. Rationale:- Proone does not expect user intervention
- SIGINT handling is for debugging purposes only
- Removing signal handling provides additional size reduction
Using SSH Subchannel for Binary Transfer
Data transfer over SSH sessions can be optimized by using separate SSH channels. Current method: Uses commands likeecho and base64 available on the host. This is slow and expensive, even for regular PCs, but it’s the only feasible method for telnet connections.
Proposed optimization for SSH:
Once command availability is checked, open a separate channel for data transfer:
- Significantly faster transfers
- Lower CPU usage
- No encoding overhead
Threading Model
Cooperative vs. Preemptive Threading
Proone employs cooperative threading to:- Limit execution to one physical thread
- Ease programming complexity
Switching to Real Threads?
Potential benefits:- Multithread embedded devices could benefit from reduced context switching
- Regular PCs could easily run 100+ BNE workers in parallel
- Need to limit thread count (worst case: large number of BNE workers)
- Increased complexity in synchronization
- Potential for deadlocks and race conditions
Architecture Notes
ARM Architecture Assignments
Codes are assigned for architectures with major changes per “industry standard”: ARMV4T:- First and oldest architecture Linux supports
- Thumb variant chosen (almost all ARM CPUs run Linux with Thumb enabled)
- Major improvements: hardware floating point (hfp)
- More hfp registers
- 64-bit address space
- Note: 64-bit kernel requires
CONFIG_COMPATto run 32-bit executables - Assumed most AARCH64 devices have
CONFIG_COMPATenabled (no major penalty)
Extinct Architectures
Proone recognizes architectures that have gone “extinct”: SH4:- Defined to honor Mirai’s choice of architectures
- No longer prevalent in embedded devices
- Lack prevalence in embedded devices
- SPARC not assigned but was targeted by Mirai
- Supported by Linux kernel
- No actual products powered by ARC run Linux
Security and Evasion
Evading Packet Sniffing
Lawful interception is conducted in most countries. Law enforcement uses malware characteristics to filter traffic. Proone’s Observable Characteristics:- SYN packets to remote port 64420 (in ephemeral port range)
- ALPN string “prne-htbt” in TLS hello messages
- Client and server certificates in TLS hello messages
- Crafted SYN packets followed by RST packets if remote port is open
- Bogus ICMPv6 packets multicast to link-local network
Risky Binary Upgrade
Fromexecve(2) man page:
In most cases where execve() fails, control returns to the original executable image, and the caller of execve() can then handle the error. However, in (rare) cases (typically caused by resource exhaustion), failure may occur past the point of no return: the original executable image has been torn down, but the new image could not be completely built. In such cases, the kernel kills the process with a SIGSEGV (SIGKILL until Linux 3.17) signal.Risk: Binary upgrade via
exec() from main process can result in loss of control over hosts.
Justification:
Acceptable risk because the host doesn’t have to maintain both old and new images. Memory is a scarce commodity on embedded devices!
Ephemeral Presence
Making a Linux virus “permanent” faces many challenges:Challenges
-
No unified startup system
- Multiple init implementations: Sys V, Systemd, Buildroot, OpenWrt
- Many are shell script based with slight differences
-
Root filesystem overlays
- Possible to overlay root with ramdisk
- Changes lost after reboot
-
Battery-backed volatile memory
- Some devices use volatile memory for frequently changing files
- Appears as normal block devices (mtd/ide/scsi/nvme)
- Contents lost on power loss
Philosophy
It’s not worth it. People rarely do routine hardware resets of embedded devices, especially poorly made products. Even if they do, other instances on the network can reinfect the device.Lineage Tracing
org_id and instance_id can be used to trace instance lineage.
With proone-hostinfod
- Collect host info from instances
- Analyze collected data
- Build family tree tracing back to instances with zeroed-out
org_id
Visualization
Write a simple script to output visual representation:Ideas for Future Development
”Organic” Credential Dictionary
Rather than relying solely on the cred dict, program instances to try randomly generated combos. Concept:- Try a few random combos before cred dict
- If random combo works, save it in memory
- During htbt m2m (machine-to-machine), exchange saved combos
- If both parties found same combo, add to cred dict with lowest weight
- If combo exists, increment weight value
- Instance ability to manipulate cred dict (stored in dvault)
- Additional code size
- Chance of getting random combo is slim
- Two instances getting same combo and exchanging is even slimmer
Best Practices from Experience
- Test on target platforms - Don’t assume standard library behavior
- Check all fds - Negative fds can cause undefined behavior
- Use framework wrappers -
prne_pth_poll()instead ofpth_poll() - Read /dev/urandom directly - Avoid
getrandom()blocking issues - Profile on embedded devices - Performance characteristics differ significantly
- Consider memory constraints - Embedded devices have very limited RAM
- Plan for failure - Resource exhaustion is common on embedded systems
See Also
- Memory Management - Framework allocation functions
- Resource Allocation - Ownership patterns and structures
