CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/docs/metasploit-framework.wiki/How-to-decode-Base64-with-Metasploit-Framework-Compiler.md
Views: 1904

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

#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|How to use Metasploit Framework Compiler Windows to compile C code]]