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

Maat: Sleigh raised a bad data exception: r0x00000002: Unable to resolve constructor #165

Open
PatrickAlphaC opened this issue Feb 22, 2023 · 2 comments

Comments

@PatrickAlphaC
Copy link

You can also see this question on stack exchange eth.

I'm running the maat symbolic executor on my Linux instance with the following code.

Command I ran to get my binary code:

gcc myFile.c -o myFile.out

myFile.c

#include <stdio.h>

int main(int argc, char** argv)
{
    printf("Argument starts with: '%c'\n", argv[1][0]);
    return 42;
}

Maat python code:

from maat import MaatEngine, ARCH, OS, BIN
m = MaatEngine(ARCH.X64, OS.LINUX)
m.load("./myFile.out", BIN.ELF64, args=[b"hello"], load_interp=False)
m.run()

However, running this is getting me the following error:

$ python3 symbolic.py 
[Warning] Couldn't find library 'libc.so.6': skipping import
[Warning] Missing imported function: __cxa_finalize
[Info] Adding object './myFile.out' to virtual fs at '/./myFile.out'
[Error] Sleigh failed to decode instructions in basic block starting at 0x2. Raised the following error: "Sleigh raised a bad data exception: r0x00000002: Unable to resolve constructor"
[Error] Lifter error: MaatEngine::get_asm_inst(): failed to lift instructions

Am I doing something wrong?

Versions:

Python 3.10.6
gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Ubuntu 22.04.1 LTS
pymaat==0.6.9
@PatrickAlphaC
Copy link
Author

PatrickAlphaC commented Feb 22, 2023

Attempted to solve using information from the discussion here

Updated the code to:

from maat import MaatEngine, ARCH, OS, BIN

m = MaatEngine(ARCH.X64, OS.LINUX)

m.load("./myFile.out", BIN.ELF64, args=[b"hello"], libdirs=['/usr/lib/x86_64-linux-gnu', '/usr/lib64'], load_interp=False)m.run()

Got this new error:

[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol ''
[Warning] Missing imported data: _dl_argv (skipping relocation)
[Warning] Missing imported data: __libc_enable_secure (skipping relocation)
[Warning] Missing imported data: __libc_stack_end (skipping relocation)
[Warning] Missing imported data: _rtld_global_ro (skipping relocation)
[Warning] LoaderLIEF: unsupported X86 relocation type: 18 for symbol '__libc_dlerror_result'
[Warning] Missing imported data: _rtld_global (skipping relocation)
[Warning] Missing imported data: _rtld_global (skipping relocation)
[Info] Adding object './myFile.out' to virtual fs at '/./myFile.out'
[Error] MaatEngine::process_store(): Caught memory exception: Writing at address 0x0 in page that doesn't have W flag set
[Error] Unexpected error when processing IR instruction, aborting...

@caprinux
Copy link

Anyone managed to find a solution for this?

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