ex:vcode:start
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| ex:vcode:start [2023/04/10 20:51] – ebaer | ex:vcode:start [2023/07/31 05:51] (current) – titannet | ||
|---|---|---|---|
| Line 68: | Line 68: | ||
| # x86 function prolog: push ebp, mov ebp, esp | # x86 function prolog: push ebp, mov ebp, esp | ||
| # [ebp+8] == local variable | # [ebp+8] == local variable | ||
| + | |||
| + | # dd esp -> first address on stack == return pointer | ||
| + | # dd ebp -> old base pointer | ||
| + | # dd poi(ebp+8) | ||
| + | |||
| </ | </ | ||
| Line 136: | Line 141: | ||
| + | </ | ||
| + | ====== Heap2-2 ====== | ||
| + | |||
| + | |||
| + | <code c> | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | // Use after free example, original code from https:// | ||
| + | |||
| + | #define SERVICE_SIZE 32 | ||
| + | |||
| + | struct AuthStruct { | ||
| + | char name[32]; | ||
| + | int is_authenticated; | ||
| + | }; | ||
| + | |||
| + | struct AuthStruct *auth; | ||
| + | char *service; | ||
| + | |||
| + | int main(int argc, char **argv) | ||
| + | { | ||
| + | char line[128]; | ||
| + | |||
| + | while(1) { | ||
| + | printf(" | ||
| + | if(fgets(line, | ||
| + | | ||
| + | if(strncmp(line, | ||
| + | auth = malloc(sizeof(*auth)); | ||
| + | memset(auth, | ||
| + | if(strlen(line + 5) < 31) { | ||
| + | strcpy(auth-> | ||
| + | } | ||
| + | } | ||
| + | if(strncmp(line, | ||
| + | free(auth); | ||
| + | } | ||
| + | if(strncmp(line, | ||
| + | service = malloc(SERVICE_SIZE); | ||
| + | strcpy(service, | ||
| + | } | ||
| + | if(strncmp(line, | ||
| + | if(auth-> | ||
| + | printf(" | ||
| + | } else { | ||
| + | printf(" | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | } | ||
| </ | </ | ||
ex/vcode/start.1681152700.txt.gz · Last modified: 2023/04/10 20:51 by ebaer
