Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
45 lines (38 loc) · 785 Bytes

File metadata and controls

45 lines (38 loc) · 785 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Filename: pushstack.c
Author: Daniel Sauder
Website: http://govolution.wordpress.com/
License: http://creativecommons.org/licenses/by-sa/3.0/
- generate asm code that pushes a given string on the stack in reverse order
- fill up with empty spaces if neccessary
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
if(argv[1]==NULL)
{
printf("usage: pushstack \"foo bar\"\n");
return 0;
}
char *buf=argv[1];
int l=strlen(buf);
int x;
// fill with spaces if neccessary
int ll=4-(l%4);
if (ll!=4)
{
printf("push 0x");
for (x=0;x<ll;x++)
printf("20");
}
// printf asm code to screen
for (x=l; x>0; x--)
{
if ((x%4)==0) printf("push 0x");
printf("%02X",buf[x-1]);
if ((x%4)==1) printf("\n");
}
printf("\n");
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.