I want to somehow get the "number of assembler instructions executed" from a binary file. Consider the following code snippet:
if(password[0] == 'p') { if(password[1] == 'a') { ...... printf("Correct Password\n"); } }
Then, if I would run the program, for example. "abc" this will not occupy the first branch, so fewer instructions will be executed. If I type "pbc", it will occupy the first branch, so a little more (about 4-5) instructions will be executed. (This is some research for CTF (Capture the Flag) files). Therefore, my idea is not to change the binary code and try to understand the algorithm, but I use a faster approach when counting the number of assembler instructions executed for different settings (for example, different characters or password lengths, etc., to see, I can whether I take another branch using a different input, thereby creating additional assembler instructions).
My main idea would be to write a simple debugger by simply placing int3 after the current instruction, increasing the counter there, the disassembler of the next instruction and placing int3 right after this instruction (a strong simplified version of my idea).
Is there any program / library / ... that has already done this? (Because I see that some problems arise when a program deals with signals, ...)
(I already tried using high precision timers to measure time, but it was a complete failure due to a difference of only 4-5 instructions)
source share