Last active
December 20, 2015 13:29
-
-
Save azat/6138699 to your computer and use it in GitHub Desktop.
test-gdb-jump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#define CREATE_PAYLOAD(name) \ | |
void name() { \ | |
for (int i = 0; i < 10; ++i) { \ | |
printf("Function: %s (%i)\n", __FUNCTION__, i); \ | |
} \ | |
} | |
CREATE_PAYLOAD(foo) | |
CREATE_PAYLOAD(bar) | |
CREATE_PAYLOAD(baz) | |
int main(int argc, char **argv) | |
{ | |
foo(); | |
bar(); | |
baz(); | |
return EXIT_SUCCESS; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# This script will skip call of "foo" function | |
# | |
function call_addr() | |
{ | |
objdump -D ./ex | egrep 'callq.*'$1'' | tr -d : | awk '{printf "0x%s", $1}' | |
} | |
FOO_CALL_ADDR=$(call_addr foo) | |
BAR_CALL_ADDR=$(call_addr bar) | |
gdb \ | |
-ex "start" \ | |
-ex "break *$FOO_CALL_ADDR" \ | |
-ex "continue" \ | |
-ex "jump *$BAR_CALL_ADDR" \ | |
-ex "quit" \ | |
\ | |
./ex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#gcc -Wl,--gc-sections -ffunction-sections -g3 -std=c99 -O0 -o ex ex.c | |
gcc -ffunction-sections -g3 -std=c99 -O0 -o ex ex.c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment