-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencrypt.cpp
More file actions
59 lines (50 loc) · 1.04 KB
/
encrypt.cpp
File metadata and controls
59 lines (50 loc) · 1.04 KB
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
//encrypt shellcode prior to storing in stub
//store in shellcodeEncrypted.txt
//copy into runPE.cpp
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
//Real PE shellcode dump here - fix length also
const int length = 2;
unsigned char rawData[length] = {
0x00, 0xff
};
void crypt(unsigned char rawData[], int length)
{
char key = 0x42;
for (int i = 0; i < length; i++)
{
rawData[i] = (char)(rawData[i] ^ key);
}
}
struct HexCharStruct
{
unsigned char c;
HexCharStruct(unsigned char _c) : c(_c) { }
};
inline std::ostream& operator<<(std::ostream& o, const HexCharStruct& hs)
{
return (o << std::hex << (int)hs.c);
}
inline HexCharStruct hex(unsigned char _c)
{
return HexCharStruct(_c);
}
int main()
{
ofstream output;
output.open("shellcodeEncrypted.txt");
crypt(rawData, length);
output << "unsigned char rawData[" << to_string(length) << "]" \
<< " = { ";
for (int i = 0; i < length; i++)
{
output << "0x" << hex(rawData[i]) << ",";
if (i % 20 == 0)
{
output << endl;
}
}
output << "};";
}