30 lines
894 B
C
30 lines
894 B
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include "string.h"
|
|
|
|
int main() {
|
|
char* pass = "";
|
|
|
|
size_t pid = getpid();
|
|
printf("\n%d\n", pid);
|
|
while (1) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
Create a simple program which stores only a message in the heap.
|
|
Keep the program running and access the maps file at
|
|
/proc/{pid}/maps. Print the content of the file to stdout. Locate
|
|
the start and end addresses of the heap.
|
|
You can access the virtual memory of the process whose id is pid
|
|
at /proc/{pid}/mem. Try to access the file using less command.
|
|
Access the heap of the program using
|
|
Navigate the heap memory file till finding the message. Locate the
|
|
page number where the message is stored and its address.
|
|
Access the file /proc/{pid}/smaps and specify what the total size
|
|
of pages of the heap. What is the file /proc/{pid}/map files?
|
|
Use the command pmap to check the memory mappings of the
|
|
process.
|
|
*/ |