Create 2024-07-28-Analysis-memory-access-pattern-has-never-been-easie…#12
Create 2024-07-28-Analysis-memory-access-pattern-has-never-been-easie…#12torusrxxx wants to merge 4 commits into
Conversation
|
I think it's a nice post, but it would be good to have some example application/crackme and some screenshots/diagrams. I'm happy to work on that, just need a good example use case that people would resonate with. |
|
I don't have time to write a crackme tutorial now, there isn't any crackme on my Github profile. Finding a good example use case shouldn't be hard. For example, it makes it possible to dump a self modifying executable even when you don't know OEP before tracing. It also accelerates many common operations, like jumping to the last iteration of a loop. This feature aligns with the general trend that you just leave the computer to record everything, have a cup of coffee, and then analyze the trace recording with more powerful tools available: the default xref analysis can never be better than this one based on tracing. |
|
Didn't forget about this, just need to find some time to create screenshots to add to the post and then share it on social media. |
|
Half a year later, it's no longer news |
|
My apologies, I completely forgot about this post 🤦♂️. |
|
It looks like more and more users are interested in this technology! |
|
Totally forgot about it again 😅 If you're good with publishing it as-is I can adjust the filename and publish it. For me it reads a bit like a 'wall of text' without any concrete use case or screenshots etc, but up to you! |
|
If you have a better idea, I'm looking forward to that. I'm not a good crackme tutorial writer. |
|
For me personally the issue is that I have never actually used x64dbg's tracing myself outside of testing it/reproducing bugs, so it's a bit difficult to come up with examples 😅 I obviously see the use of the memory view, we could demo that easily with some basic XOR encryption thingy and then show that you can see the memory update 'live' and you click through the trace. For the cross-reference search I already struggle a bit to find a realistic use case. Would the idea be to breakpoint on some API (WriteFile) where you get the address of the buffer and then do a cross-reference to that address in the trace? In practice nobody will trace more than 1-10 million instructions (which takes 2-20 minutes). You would instead look at the call stack on the breakpoint to try and reduce the scope of the analysis. For the pattern search one idea I came up with is where a Ages ago there was a 'Run trace' tutorial posted on the OllyDbg website (https://ollydbg.de/Tut_rtr.htm) there the use case is that the stack was wiped and a crash was difficult to recover, but even this post mentions needing 10 minutes to collect the trace 😬 Did you use the tracing for some personal reverse engineering projects? Could be helpful to come up with a simpler example that could fit in the post... Edit: a friend of mine also mentioned 'catching a buffer overrun' as a potentially practical example. Could be a simple arena allocator and then something like: overflow_buf = arena.allocate(100)
hello_buf = arena.allocate(25)
strcpy(hello_buf, "Hello!")
puts(hello_buf)
something_long(overflow_buf)
puts(hello_buf) # prints something else nowThen you can jump to the last write on |
|
So what happened? |
|
I intended to use the pattern search in trace with a private signature database like Yara. It instantly identifies known features no matter where it appears. But first you need to compile such a list (cryptographic constants etc), which is outside the scope of a tutorial. Cross-reference search is to interactively follow the access pattern of a variable, like finding references in Visual Studio. |
|
I have been busy with work and other projects and completely forgot about the post. Without a clearly-motivated use case it feels a bit lacking, but if you want I'm okay with publishing it as-is. |
|
I'm not creating a crackme for this as I'm busy with other priorities. If you are busy as well, then nothing can be done :( . |
|
Currently, x64dbg trace viewer doesn't care the actual access size of the instruction, and always treat the access size is the pointer size. It can be improved by relating the memory address to the disassembled operand, but that's currently not supported, and will likely be slower to build the index. Proper exception handling was in the roadmap that never started. It remains unsupported, but since it still works, the current status is more like it is bugged and not tested. |
|
Thank you for your samples and contributions! |
|
I just pushed two attempts at fixing both issues and it seems to work much better now! |
|
Also spent some time to update the post, fix some grammar and add a section with the concrete examples in the front. I think I found another bug, because searching for |
|
The tracer doesn't capture the entire memory dump at the start of trace file. It assumes memory is unchanged if the traced instruction doesn't touch the memory. It interacts with partial dump indexing in an interesting way: the content in the memory dump shows 00's for a buffer that isn't used, but if you click at the last instruction to force indexing the entire trace and come back, then the content isn't 00's anymore because the tracer now knows the content from the future. In practice this difference is mostly harmless, it only happens in unused buffers. The tracer partially mitigate this issue by always capturing pointer-sized accesses. If the memory access size is 1 byte, the tracer still record the remaining bytes in the trace file. It then knows content past the end of the buffer. When the actual access size of the operand is enforced, the tracer discards saved information, and this changes the behavior because tracer now forgot the unused byte past the end of the buffer. |
|
The issue with |


…r-now.md