-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaslrDemo.c
70 lines (39 loc) · 1.4 KB
/
aslrDemo.c
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// A few versions of a C program I worte, playing with formatting, trying to demonstrate ASLR
// A good way to check against a binary is with the command,'ldd <ELF> | grep libc'
// Description by line
// Signal prepocessor with # to include standard i/o header file for printf function
// main() is normally the starting function. int indicates main accepts an integer for status of program termination. void, to mean the function doesn't accept paramaters
// register asks the compiler to put the var in a CPU register instead of RAM. int for integer initialization, i for var name, asm for assembler instruction and esp the named instruction location
// printf function, like echo or push to std ut. esp for our asm var. % for replace with var i. # for 0x, 8 for 8 chars, x for unsigned hex formatting. \n newline. i is integer
/*
#include <stdio.h>
void main() {
register int i asm("esp");
printf("$esp = %#10x\n", i);
}
#include <stdio.h>
void main() {
register int i asm("esp");
printf("$esp = %8x\n", i);
}
#include <stdio.h>
void main() {
register int i asm("esp");
printf("$esp = %x8x\n", i);
}
#include <stdio.h>
int main(void) {
register int i asm("esp");
printf("$esp = %#8\n", i);
}
#include<stdio.h>
int main(void) {
register int i asm("esp");
printf("$esp = %#8x\n", i);
}
*/
#include <stdio.h>
void main() {
register int i asm("esp");
printf("$esp = %#010x\n", i);
}