CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/external/source/shellcode/osx/template/template_aarch64_darwin.c
Views: 11784
1
#include <fcntl.h>
2
#include <unistd.h>
3
#include <stdlib.h>
4
#include <string.h>
5
#include <sys/mman.h>
6
7
char payload[8000] = "PAYLOAD:";
8
int main() {
9
void *ptr = mmap(0, sizeof(payload), PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
10
if (ptr == MAP_FAILED) {
11
return 0;
12
}
13
memcpy(ptr, payload, sizeof(payload));
14
mprotect(ptr, sizeof(payload), PROT_READ | PROT_EXEC);
15
int (*sc)() = ptr;
16
sc();
17
return 0;
18
}
19
20