Overview
Binary Recombination is the process of preparing a Proone executable for a target host after successful Break and Enter (BNE). This enables decentralized propagation - each instance can infect hosts of different architectures without requiring binary distribution servers.Executable Structure
A Proone executable consists of three parts:Alignment
All sections are aligned toPRNE_BIN_ALIGNMENT boundaries for performance and parsing consistency.
Recombination Process
The diagram below illustrates recombination when a Linux/ARMv4T host infects a Linux/SH4 target:Process Steps
- Extract target ELF - Decompress the entire BA stream, extract the target architecture’s ELF
- Copy DVault - DVault is identical across all architectures, copy as-is
- Update BA index - Remove target arch entry, add host arch entry
- Rebuild BA stream - Recompress all executables into new BA
The entire compressed stream is decompressed and recompressed for each recombination. This maximizes compression efficiency but adds CPU overhead during infection.
Recombination API
Context Structure
Starting Recombination
PRNE_PACK_RC_OK- Recombination initialized successfullyPRNE_PACK_RC_INVAL- Invalid parametersPRNE_PACK_RC_NO_ARCH- Target architecture not in archivePRNE_PACK_RC_ERRNO- Memory allocation failurePRNE_PACK_RC_Z_ERR- zlib initialization error
Reading Recombined Binary
Recombination Scenarios
Scenario 1: Same Architecture
When host and target architectures match:Scenario 2: Different Architecture
When architectures differ:- Locate target binary in BA index
- Initialize decompressor (inflate) for BA stream
- Initialize compressor (deflate) for new BA stream
- Stream transformation:
- Read target ELF from decompressor
- Write target ELF to output
- Copy DVault with updated appendix
- Build new BA index (replace target with host)
- Recompress remaining binaries
Scenario 3: Architecture Compatibility Fallback
State Machine
The recombination reader uses a state machine with multiple read functions:State: pack_rcb_eeread_f (Extract ELF)
Decompress and extract target ELF from BA stream.
- Seek to target binary offset (discard bytes)
- Extract target binary (output bytes)
- Transition to
pack_rcb_dvread_fwhen complete
State: pack_rcb_dvread_f (DVault + Index)
Write DVault and generate new BA index.
- Output DVault bytes
- Generate alignment padding
- Build new BA header
- Add host’s ELF to index (if
selfprovided) - Add all other binaries except target to index
- Transition to
pack_rcb_rpread_f
State: pack_rcb_rpread_f (Recompress)
Recompress remaining binaries into new BA stream.
- Inflate old BA stream
- Deflate into new BA stream
- Skip target binary (already extracted)
- Include host binary (from memory)
- Include all other binaries
State: pack_rcb_nullread_f (EOF)
Recombination complete, return EOF.
Memory and CPU Considerations
Memory Usage
Recombination requires:- Host executable in memory (~500KB - 2MB)
- DVault in memory (~10KB - 100KB)
- Decompression state (
z_stream): ~300KB - Compression state (
z_stream): ~300KB - Working buffers: ~8KB
CPU Usage
Compression at level 9 is CPU-intensive:- Deflate: ~5-10 MB/s on embedded ARM (200-500 MHz)
- Inflate: ~10-20 MB/s on same hardware
- Same arch (pass-through): < 1 second
- Different arch (recompress 10MB BA): 10-30 seconds on embedded device
Error Handling
Pack Result Codes
Common Failures
PRNE_PACK_RC_NO_ARCH: Target architecture not in Binary Archive
- Resolution: Try compatibility fallback with
prne_start_bin_rcb_compat() - If still fails, target cannot be infected
PRNE_PACK_RC_FMT_ERR: Binary Archive corrupted
- Indicates memory corruption or incomplete BA
- Fatal - instance may need restart
PRNE_PACK_RC_Z_ERR: zlib error during compression/decompression
- Check return from BNE worker
- May indicate memory pressure
Nybin Format
The complete appended binary data (DVault + BA) is called “nybin”:Design Philosophy
From the spec (lines 217-232):“Proone parses its own executable in order to locate the appended data during the initialisation process. Having located the data, Proone then proceeds to load the DVault and the binary archive (BA).”
“If the target host is a different platform and the BA contains the executable for that platform, a process is initiated for creation of the executable for the target host.”This self-contained design enables:
- No central infrastructure - No binary distribution servers to take down
- Resilient propagation - Each instance is a complete infection source
- Cross-platform infection - ARM bot can infect x86 targets and vice versa
Source Files
src/pack.h- Recombination API definitionssrc/pack.c:466- Recombination implementationsrc/bne.c- Break and Enter worker (uses recombination)
