I want to somehow get the "number of executed assembler instructions" from a binary. Consider the following piece of code:
if(password[0] == 'p') {
if(password[1] == 'a') {
......
printf("Correct Password\n");
}
}
Then if I would start the program with e.g. "abc" it would not take the first branch, thus it would execute less instructions. If I put in "pbc" it would take the first branch, thus it would execute a little bit more (about 4-5) instructions. (This is some Research for CTF (Capture The Flag) files). So my idea is instead of reversing a binary and trying to understand the algorithm, I use the faster approach in counting the number of executed assembler instructions for different setups (like different characters or password lengths and so on to see if I can take another branch using another input thus creating more assembler instructions).
My basic idea would be to write a simple debugger just placing a int3 after the current Instruction, increment there a counter, disassembler the next instruction and place a int3 right after this instruction (strong simplified version of my idea).
Is there any program/library/... which already done that stuff? (Because I see some problemens when the program deals with signals, ...)
(I already tried using high precises timers to measure the time, but that was a complete fail because of the difference are just 4-5 instructions)