forked from HeroCTF/HeroCTF_v3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSOURCE_ARMada.cpp
More file actions
60 lines (50 loc) · 2.12 KB
/
SOURCE_ARMada.cpp
File metadata and controls
60 lines (50 loc) · 2.12 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
59
60
#include <string>
#include <vector>
#include <iostream>
#include <cstring>
#define TCHAR char
#define DWORD long
#define BYTE unsigned char
std::basic_string<TCHAR> yolo(std::vector<BYTE> inputBuffer);
static TCHAR encodeLookup[] = "\x01\x16\x35\x05\x2a\x21\x08\x28\x69\x2c\x09\x11\x33\x03\x10\x31\x13\x70\x75\x2d\x2f\x1a\x72\x0b\x2e\x27\x3b\x7b\x73\x37\x24\x06\x20\x12\x3a\x14\x1b\x76\x23\x30\x77\x17\x25\x0f\x0c\x36\x6d\x0e\x71\x00\x34\x38\x29\x04\x2b\x0a\x18\x15\x74\x26\x0d\x32\x7a\x07";
std::basic_string<TCHAR> yolo(std::vector<BYTE> inputBuffer){
std::basic_string<TCHAR> encodedString;
encodedString.reserve(((inputBuffer.size()/3) + (inputBuffer.size() % 3 > 0)) * 4);
DWORD temp;
std::vector<BYTE>::iterator cursor = inputBuffer.begin();
for(size_t idx = 0; idx < inputBuffer.size()/3; idx++){
temp = (*cursor++) << 16;
temp += (*cursor++) << 8;
temp += (*cursor++);
encodedString.append(1,encodeLookup[(temp & 0x00FC0000) >> 18] ^ 0x42);
encodedString.append(1,encodeLookup[(temp & 0x0003F000) >> 12] ^ 0x42);
encodedString.append(1,encodeLookup[(temp & 0x00000FC0) >> 6 ] ^ 0x42);
encodedString.append(1,encodeLookup[(temp & 0x0000003F) ] ^ 0x42);
}
switch(inputBuffer.size() % 3){
case 1:
temp = (*cursor++) << 16;
encodedString.append(1,encodeLookup[(temp & 0x00FC0000) >> 18] ^ 0x42);
encodedString.append(1,encodeLookup[(temp & 0x0003F000) >> 12] ^ 0x42);
encodedString.append(2,0x7f ^ 0x42);
break;
case 2:
temp = (*cursor++) << 16;
temp += (*cursor++) << 8;
encodedString.append(1,encodeLookup[(temp & 0x00FC0000) >> 18] ^ 0x42);
encodedString.append(1,encodeLookup[(temp & 0x0003F000) >> 12] ^ 0x42);
encodedString.append(1,encodeLookup[(temp & 0x00000FC0) >> 6 ] ^ 0x42);
encodedString.append(1,0x7e ^ 0x43);
break;
}
return encodedString;
}
int main(){
char* cstring = new char[64];
std::cout << "Entrez un input : ";
std::cin.getline(cstring, 65, '\n');
std::vector<BYTE> superVect = std::vector<BYTE>((BYTE*)cstring, (BYTE*)cstring + strlen(cstring));
std::basic_string<TCHAR> encoded = yolo(superVect);
std::cout << "Encoded : " << encoded << std::endl;
return 0;
}