diff options
author | Matt Graeber <mattgraeber@gmail.com> | 2013-04-06 07:04:16 -0400 |
---|---|---|
committer | Matt Graeber <mattgraeber@gmail.com> | 2013-04-06 07:04:16 -0400 |
commit | 2224f4dca9d856f37a02a9fe4c1941d27c4e564f (patch) | |
tree | 058c9943e5b8d277600b04095ffcb644d8cddf19 /CodeExecution/DemoReflectiveDLL/DemoDLL/DemoDLL.cpp | |
parent | 014a7bb421477a18add25164d71e977574832c14 (diff) | |
download | PowerSploit-2224f4dca9d856f37a02a9fe4c1941d27c4e564f.tar.gz PowerSploit-2224f4dca9d856f37a02a9fe4c1941d27c4e564f.zip |
Adding reflective DLL loading capability
Adding Invoke-ReflectiveDllInjection. PowerSploit now has reflective DLL
loading capabilities!!! Thanks to Joe Bialek @JosephBialek for writing
this awesome code!
Diffstat (limited to 'CodeExecution/DemoReflectiveDLL/DemoDLL/DemoDLL.cpp')
-rw-r--r-- | CodeExecution/DemoReflectiveDLL/DemoDLL/DemoDLL.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/CodeExecution/DemoReflectiveDLL/DemoDLL/DemoDLL.cpp b/CodeExecution/DemoReflectiveDLL/DemoDLL/DemoDLL.cpp new file mode 100644 index 0000000..61380d3 --- /dev/null +++ b/CodeExecution/DemoReflectiveDLL/DemoDLL/DemoDLL.cpp @@ -0,0 +1,60 @@ +// DemoDLL.cpp : Defines the exported functions for the DLL application. +// + +#include "stdafx.h" +#include "DemoDLL.h" + +using namespace std; + + +extern "C" __declspec( dllexport ) char* StringFunc() +{ + ostream *outputStream = NULL; + + //If you want to output to cout, simply set outputStream to &cout. This allows you to write a program that can switch between outputting to string or to cout. + //outputStream = &cout; + + ostringstream *stringStream = new ostringstream(); + outputStream = stringStream; + + (*outputStream) << "String DLL function is working" << endl << endl; + + string output = (*stringStream).str(); + const char* outputStr = output.c_str(); + + char* out = new char[output.size()+1]; + strcpy(out, outputStr); + out[output.size()] = '\0'; + + + return out; +} + +extern "C" __declspec( dllexport ) void VoidFunc() +{ + printf("Void DLL function is working, using printf to display. You will only see this if you run locally.\n\n"); + return; +} + +extern "C" __declspec( dllexport ) wchar_t* WStringFunc() +{ + wostream *outputStream = NULL; + + //If you want to output to wcout, simply set outputStream to &cout. This allows you to write a program that can switch between outputting to wstring or to wcout. + outputStream = &wcout; + + wostringstream *stringStream = new wostringstream(); + outputStream = stringStream; + + (*outputStream) << L"WString DLL function is working" << endl << endl; + + wstring output = (*stringStream).str(); + const wchar_t* outputStr = output.c_str(); + + wchar_t* out = new wchar_t[output.size()+1]; + wcscpy(out, outputStr); + out[output.size()] = '\0'; + + + return out; +}
\ No newline at end of file |