Files
metasploit-gs/How-to-decode-Base64-with-Metasploit-Framework-Compiler.md
T

27 lines
907 B
Markdown

# Description
## How to decode Base64 with Metasploit::Framework::Compiler
The Metasploit C compiler has built-in support for Base64 encoding and decoding, which is implemented as `base64.h`.
# Code Example
```c
#include <Windows.h>
#include <String.h>
#include <base64.h>
// "Hello World" encoded by Rex::Text.encode_base64()
#define BASE64STR "aGVsbG8gd29ybGQ="
int main() {
int base64StrLen = strlen(BASE64STR);
LPVOID lpBuf = VirtualAlloc(NULL, sizeof(int) * base64StrLen, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
memset(lpBuf, '\0', base64StrLen);
base64decode(lpBuf, BASE64STR, base64StrLen);
MessageBox(NULL, (char*) lpBuf, "Base64 Test", MB_OK);
return 0;
}
```
To compile, use [How to use Metasploit::Framework::Compiler::Windows to compile C code](https://github.com/rapid7/metasploit-framework/wiki/How-to-use-Metasploit%3A%3AFramework%3A%3ACompiler%3A%3AWindows-to-compile-C-code)