Vault7: CIA Hacking Tools Revealed
Owner: User #71477
Modifying/expanding PEPrivilege Escalation section to fit payloads
This does not seem like it's going to work. You can modify the data in the section, but (at least for 64 bit) the references from the .text code section are using pointers that are the distance from the end of the instruction to the variable data, in memory (after load). I cannot find any pointers to this offset, so we won't be able to find it at runtime. For example, the load of the 0xaaaaaaaa padding is done with a movsxd r13, <offset> instruction.
4c 63 2d 5a 19 00 00
where 0x0000195a is the offset from the end of the movsxd 7-byte instruction to the beginning of the pad of 0xaaaaaaaa.
To make this work, we would need a list of every place this type of offset is used, and then modify each offset to reflect where we moved the padding. I assumed this would be a relocation section, but I can't find the relocations. I think this is because I am compiling not as an executable DLL, but as a resource DLL (without an ENTRY).
Instead, I think I will create several pre-compiled sizes of payload padding DLLs. Inefficient, but it should work.
Creating many padding-sizes of pre-compiled binaries
The embedding process places an operator-controlled payload and a FLEA into a SILVERFISH. The SILVERFISH should accept two binaries. The FLEA will be embedded with the PAYLOAD by SILVERFISH at runtime on target.
Lets work with the PAYLOAD being 1MB at most.
PAYLOAD padding should be sized as:
- 1 MB
The FLEA will contain the PAYLOAD, so we'll need to account for around 50k plus the max of 1MB:
- 1 MB
This will require building a FLEA for each potential PAYLOAD size, and a SILVERFISH for each possible combination of PAYLOAD and FLEA. However, since your FLEA will have to contain the PAYLOAD, a SILVERFISH with larger PAYLOAD padding than FLEA padding will be invalid. So, for the above sizes, we would need:
- 7 FLEA builds (named as flea.<PAYLOAD>.dll, flea.10.dll)
- 28 SILVERFISH builds (named as silverfish.<FLEA>-<PAYLOAD>.dll; e.g. silverfish.10-5.dll:
For generating these, we'll want a Python script to create the header files for
- "blankspace2.h" and "blankspace.h" in SILVERFISH
- "blankspace.h" in FLEA
Dumping assembly with objdump
Commands for dumping binary from DLLDynamic Link Library and using objdump (linux) to display Intel assembly
dd if=SilverFish.dll of=out.dll skip=3840 bs=1 count=256 objdump -D -S -l -b binary -M intel -m i386:x86-64 out.dll