Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qiling offset values are different from GDB #1505

Open
rommarius opened this issue Nov 3, 2024 · 2 comments
Open

Qiling offset values are different from GDB #1505

rommarius opened this issue Nov 3, 2024 · 2 comments

Comments

@rommarius
Copy link

ql = Qiling('./PATH_TO_ELF'], '/', verbose=QL_VERBOSE.DISABLED, multithread=True)
ql.hook_code(self._disassemble_address)
q.run()

def _disassemble_address(self, ql, address, size) -> None:
        print(hex(address))

0x7fffb7e4c1b5
0x7fffb7e4c1b6
0x4014e5
0x4014ea

when i iterate over all instruction, than i don't get the same addresses like in gdb and calculate offset or call a specified function in memory becomes impossible.
can someone help me?

Thanks :)

@rommarius
Copy link
Author

rommarius commented Nov 3, 2024

when i stopped modify my _dissassemle_address function like:

def _disassemble_address(self, ql, address, size) -> None:
    if hex(address) = "0x401466":    
        print(hex(address))

it can't still find the instruction that i needed.

00007fffb7e4c1b3 [[mmap] libc.so.6     + 0x0381b3]  75 02                jne                  0x7fffb7e4c1b7
[=] [Thread 2000]	00007fffb7e4c1b5 [[mmap] libc.so.6     + 0x0381b5]  c9                   leave                
[=] [Thread 2000]	00007fffb7e4c1b6 [[mmap] libc.so.6     + 0x0381b6]  c3                   ret                  
[=] [Thread 2000]	00000000004014e5 [TCPForkSocketServer_64Bit + 0x0004e5]  be 01 00 00 00       mov                  esi, 1
[=] [Thread 2000]	00000000004014ea [TCPForkSocketServer_64Bit + 0x0004ea]  bf 11 00 00 00       mov                  edi, 0x11

There are only a few of the TCPForkSocketServer elf file.

@elicn
Copy link
Member

elicn commented Nov 3, 2024

Hi there.
The 7fff... addresses you see are typically ELF interpreter or loaded libc shared object, they are not part of your executable. Most of the times users will not be interested in debugging these. Because of that, Qiling attaches the debugger only after they run and when it is about to hit the primary binary entry point. If you have something specific on your mind, we can try and help you get there.

BTW - your hook has a bug: it compares between two operands with a single = instead of two: ==.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants