INNER CODE UNIT · C++
valb
stivenhacker/GhostStrike · GhostStrike.cpp:38
int valb = -6;
for (size_t i = 0; i < bufLen; ++i) {
val = (val << 8) + buf[i];
valb += 8;
while (valb >= 0) {
ret.push_back(base64_chars[(val >> valb) & 0x3F]);
valb -= 6;
}
}
if (valb > -6) ret.push_back(base64_chars[((val << 8) >> (valb + 8)) & 0x3F]);
while (ret.size() % 4) ret.push_back('=');
return ret;
}
// Decodes a Base64 string back into binary data.
// This is necessary to decode the shellcode before executing it.
std::vector<unsigned char> base64_decode(const std::string& encoded_string) {
std::vector<unsigned char> ret;