Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
79 lines (79 loc) · 1.64 KB

File metadata and controls

79 lines (79 loc) · 1.64 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <windows.h>
size_t GetSize(char * szFilePath)
{
size_t size;
FILE* f = fopen(szFilePath, "rb");
fseek(f, 0, SEEK_END);
size = ftell(f);
rewind(f);
fclose(f);
return size;
}
unsigned char* ReadBinaryFile(char *szFilePath, size_t *size)
{
unsigned char *p = NULL;
FILE* f = NULL;
size_t res = 0;
*size = GetSize(szFilePath);
if (*size == 0) return NULL;
f = fopen(szFilePath, "rb");
if (f == NULL)
{
printf("Binary file does not exists!\n");
return 0;
}
p = new unsigned char[*size];
rewind(f);
res = fread(p, sizeof(unsigned char), *size, f);
fclose(f);
if (res == 0)
{
delete[] p;
return NULL;
}
return p;
}
int main(int argc, char* argv[])
{
char *szFilePath="c:\\test\\shellcode.bin";
char *szFilePath2="c:\\test\\shellcode2.bin";
unsigned char *BinData = NULL;
size_t size = 0;
BinData = ReadBinaryFile(szFilePath, &size);
for(int i=0;i<size;i++)
{
BinData[i]=BinData[i]^0x44;
}
FILE* f = NULL;
f = fopen(szFilePath2, "wb");
if (f == NULL)
{
printf("Create error\n");
return 0;
}
char decode[]="\x83\xC0\x14\x33\xC9\x8A\x1C\x08\x80\xF3\x44\x88\x1C\x08\x41\x80\xFB\x91\x75\xF1";
char end[]="\xD5";
fwrite(decode,20,1,f);
fwrite(BinData,size,1,f);
fwrite(end,1,1,f);
fclose(f);
f = fopen(szFilePath2, "rb");
if (f == NULL)
{
printf("Create error\n");
return 0;
}
unsigned char *BinData2 = NULL;
size_t size2 = 0;
BinData2 = ReadBinaryFile(szFilePath2, &size2);
printf("\"");
for (int j=0;j<size2;j++)
{
printf("\\x%02x",BinData2[j]);
if((j+1)%16==0)
printf("\"\n\"");
}
printf("\"");
fclose(f);
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.