question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PE code cave disassembly

See original GitHub issue

Multiple ShadowHammer samples decrypt their shellcode via a function called from ___crtExitProcess(). The screenshot below is MD5 cdb0a09067877f30189811c7aea3f253. exit_proc

SUB_0051b908 cannot be viewed because it lies within a 511-byte code cave within the .text section. Ghidra sets the .text section boundary based on the VirtualSize (0x0011A801) as shown in the screenshot below. The RawSize of the .text section is 0x0011AA00. ghidra_mem_map

For reference, IDA Pro’s segmentation is shown below. It appears to treat everything up to the next section as part of the .text section and attempts to disassemble it. ida_mem_map

Expanding the .text section in Ghidra’s memory map does not cause it to re-read the file’s bytes and undefined bytes are displayed. Outside of modifying the sample’s PE header, is there a way to force Ghidra to read and disassemble these bytes?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:13

github_iconTop GitHub Comments

2reactions
ryanmkurtzcommented, Apr 4, 2019

We’ll have to discuss how to best handle this generically. I’ll leave this open as an enhancement request.

1reaction
0x6d696368commented, Apr 8, 2019

So the extra bytes at the end of the section in the file are actually code and not just all zeros? Do you know if that’s common?

The extra bytes are code. It’s a small shellcode. It is basically the whole malicious part of the binary. I assume it was placed in that code cave with good reason. It’s a malware technique.

Not sure how common, because IDA automatically will include the code outside the .text section into the analysis. But if you are dealing with malware things like that are to be expected and a good tool should handle them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Art of Anti Detection 2 – PE Backdoor Manufacturing
Code Caves : A code cave is a piece of code that is written to another process's memory by another program. The code...
Read more >
Backdooring Portable Executables (PE) - Ap3x Security
Essentially a “code cave” is a section in the applications executable that has an allocated section for certain code to run then to...
Read more >
Backdooring PE Files with Shellcode - Red Team Notes
The purpose of this lab is to learn the Portable Executable (PE) backdooring technique by adding a new readable/writable/executable code section with our ......
Read more >
R4ndom's Tutorial #22: Code Caves and PE Sections
Here's how it works: First, we find an area in the binary that is not being used. This will be our 'cave'. We...
Read more >
Backdoring PE files using code caves : OSCE/CTP Module ...
Backdoring PE files using code caves : OSCE/CTP Module 0x03 (OSCE Preparation) ... Hello Readers, This post will cover Backdooring of P.E file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found