Imagine you are reverse engineering a software. This software uses a library, which is obfuscated and encrypted. The library contains a function, lets call it secret_function
. This function is a pure function (i.e. it doesn't have any side effect and when called with the same arguments it returns always the same output).
Assuming i can call secret_function
how may times i want, with whichever arguments i want, but i can't peek at the implementation, is it possible to build an equivalent function in another language (python for example), only analyzing the input and output values?
This is an example implementation of secret_function
:
int secret_function(int a, int b) {
if (a == 234) {
return b*2 - a;
}
return a*b;
}
A way to archive this i thought of is to call the function with every possible argument, (in the example 2^32 * 2^32, assuming a 32 bit int) and store all of them, to return them based on the arguments, like a giant lookup table. But this doesn't seem very efficient, if at all possible.
UPDATE: You can assume that the function is working with fixed size arguments. So no strings or variable length arrays.