JonathanSalwan / Triton

Triton is a dynamic binary analysis library. Build your own program analysis tools, automate your reverse engineering, perform software verification or just emulate code.
https://triton-library.github.io
Apache License 2.0
3.4k stars 524 forks source link

Examples in C++ #1223

Closed Nitr0-G closed 1 year ago

Nitr0-G commented 1 year ago

Hello everyone!!

Where can I see examples of writing deobfuscators using triton in c++? There are catastrophically few examples in C++ in the examples folder

JonathanSalwan commented 1 year ago

At least there are some...

Nitr0-G commented 1 year ago

At least there are some...

If I figure out Triton, there may be more examples ;) Even a whole deobfuscator =) But so far everything is going very tight

SweetVishnya commented 1 year ago

https://github.com/quarkslab/qsynthesis

JonathanSalwan commented 1 year ago

https://github.com/JonathanSalwan/Triton/wiki#deobfuscation

Nitr0-G commented 1 year ago

https://github.com/JonathanSalwan/Triton/wiki#deobfuscation

https://github.com/quarkslab/qsynthesis

Thank you!!!

How can I declare an array with obfuscated expressions in c++? https://ibb.co/MhfVvdN https://ibb.co/bQ8SqqL

In the case of this code, I get an error

int main() {
    triton::Context ctx;
    engines::symbolic::SharedSymbolicExpression obfs_expr{};

    ctx.setArchitecture(ARCH_X86_64);
    ctx.setAstRepresentationMode(ast::representations::PYTHON_REPRESENTATION);

    auto x = ctx.newSymbolicVariable(8, "x");
    auto y = ctx.newSymbolicVariable(8, "y");
    auto z = ctx.newSymbolicVariable(32, "z");
    auto c = ctx.newSymbolicVariable(32, "c");

    obfs_expr[2] = {
        x+y,
        z-c
    };

    return 0;
}
Nitr0-G commented 1 year ago

How can I output a synthesis string if it is not converted? https://ibb.co/HT6PQgL https://ibb.co/HgBvJyS

I get a "magnificent nothing" when I output it this way, otherwise what I get in synthesis is not converted

ctx.setAstRepresentationMode(ast::representations::PYTHON_REPRESENTATION);
printf("\nOut: %s",(string)ctx.synthesize(al,NULL,NULL,NULL));//Doesn't work
printf("\nOut: %s",ctx.synthesize(al,NULL,NULL,NULL));//magnificent nothing
cout << "\n Out: " << ctx.synthesize(al, NULL, NULL, NULL);//Doesn't work

The same

ctx.setAstRepresentationMode(ast::representations::PYTHON_REPRESENTATION);
auto RES = ctx.synthesize(al,NULL,NULL,NULL);
printf("\nOut: %s",(string)RES;//Doesn't work
printf("\nOut: %s",RES);//magnificent nothing
cout << "\n Out: " << RES;//Doesn't work

;-@JonathanSalwan ;-@JonathanSalwan Comment puis-je sortir une chaîne de synthèse si elle n'est pas convertie? https://ibb.co/HT6PQgL https://ibb.co/HgBvJyS J'obtiens un "magnifique rien" quand je le sors de cette façon, sinon ce que j'obtiens en synthèse n'est pas converti

ctx.setAstRepresentationMode(ast::representations::PYTHON_REPRESENTATION);
printf("\nOut: %s",(string)ctx.synthesize(al,NULL,NULL,NULL));//Ne fonctionne pas
printf("\nOut: %s",ctx.synthesize(al,NULL,NULL,NULL));//magnifique rien
cout << "\n Out: " << ctx.synthesize(al, NULL, NULL, NULL);//Ne fonctionne pas

Le même

ctx.setAstRepresentationMode(ast::representations::PYTHON_REPRESENTATION);
auto RES = ctx.synthesize(al,NULL,NULL,NULL);
printf("\nOut: %s",(string)RES;//Ne fonctionne pas
printf("\nOut: %s",RES);//magnifique rien
cout << "\n Out: " << RES;//Ne fonctionne pas

;-@SweetVishnya ;-@SweetVishnya Как я могу вывести эту злоебучую строку?! https://ibb.co/HT6PQgL https://ibb.co/HgBvJyS Ниже примеры, где я получаю нихуя,

ctx.setAstRepresentationMode(ast::representations::PYTHON_REPRESENTATION);
printf("\nOut: %s",(string)ctx.synthesize(al,NULL,NULL,NULL));//Не работает
printf("\nOut: %s",ctx.synthesize(al,NULL,NULL,NULL));//Нихуя
cout << "\n Out: " << ctx.synthesize(al, NULL, NULL, NULL);//Не работает

Такая же хуйня

ctx.setAstRepresentationMode(ast::representations::PYTHON_REPRESENTATION);
auto RES = ctx.synthesize(al,NULL,NULL,NULL);
printf("\nOut: %s",(string)RES;//Не работает
printf("\nOut: %s",RES);//Нихуя
cout << "\n Out: " << RES;//Не работает
Nitr0-G commented 1 year ago

I beat that bitch! EXAMPLE USING TRITON IN OBSUCATED CODE ON C++(rewritten code from here https://github.com/JonathanSalwan/Triton/issues/1074(specifically - chapter "Working on obfuscated trace (emulate the code)")) https://pastebin.com/LZjqJf00 - Triton using example on c++

@JonathanSalwan Please add to the examples folder so the location!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!: https://github.com/JonathanSalwan/Triton/tree/master/src/examples/cpp