Skip to content

Commit 6f19e30

Browse files
David MaloneyDavid Maloney
authored andcommitted
Merge branch 'staging/hd-wfs' into feature/hd-wfsdelay
2 parents b0858e9 + 927785c commit 6f19e30

File tree

292 files changed

+101975
-79267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

292 files changed

+101975
-79267
lines changed

Gemfile.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ PATH
77
bcrypt
88
jsobfu (~> 0.2.0)
99
json
10+
metasm (~> 1.0.2)
1011
metasploit-concern (= 1.0.0)
1112
metasploit-model (= 1.0.0)
12-
metasploit-payloads (= 1.0.12)
13+
metasploit-payloads (= 1.0.13)
1314
msgpack
1415
nokogiri
1516
packetfu (= 1.1.11)
@@ -107,6 +108,7 @@ GEM
107108
json (1.8.3)
108109
mail (2.6.3)
109110
mime-types (>= 1.16, < 3)
111+
metasm (1.0.2)
110112
metasploit-concern (1.0.0)
111113
activerecord (>= 4.0.9, < 4.1.0)
112114
activesupport (>= 4.0.9, < 4.1.0)
@@ -123,7 +125,7 @@ GEM
123125
activemodel (>= 4.0.9, < 4.1.0)
124126
activesupport (>= 4.0.9, < 4.1.0)
125127
railties (>= 4.0.9, < 4.1.0)
126-
metasploit-payloads (1.0.12)
128+
metasploit-payloads (1.0.13)
127129
metasploit_data_models (1.2.5)
128130
activerecord (>= 4.0.9, < 4.1.0)
129131
activesupport (>= 4.0.9, < 4.1.0)
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Release/
2+
Debug/
3+
x64/
4+
dll/Release/
5+
dll/Debug/
6+
dll/reflective_dll.vcproj.*.user
7+
dll/reflective_dll.vcxproj.user
8+
inject/Release/
9+
inject/Debug/
10+
inject/inject.vcproj.*.user
11+
inject/inject.vcxproj.user
12+
*.ncb
13+
*.suo
14+
*.sdf
15+
*.opensdf
16+
*.suo
17+
bin/
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2011, Stephen Fewer of Harmony Security (www.harmonysecurity.com)
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted
5+
provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice, this list of
8+
conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice, this list of
11+
conditions and the following disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
14+
* Neither the name of Harmony Security nor the names of its contributors may be used to
15+
endorse or promote products derived from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
POSSIBILITY OF SUCH DAMAGE.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
About
2+
=====
3+
4+
Reflective DLL injection is a library injection technique in which the concept of reflective programming is employed to perform the loading of a library from memory into a host process. As such the library is responsible for loading itself by implementing a minimal Portable Executable (PE) file loader. It can then govern, with minimal interaction with the host system and process, how it will load and interact with the host.
5+
6+
Injection works from Windows NT4 up to and including Windows 8, running on x86, x64 and ARM where applicable.
7+
8+
Overview
9+
========
10+
11+
The process of remotely injecting a library into a process is two fold. Firstly, the library you wish to inject must be written into the address space of the target process (Herein referred to as the host process). Secondly the library must be loaded into that host process in such a way that the library's run time expectations are met, such as resolving its imports or relocating it to a suitable location in memory.
12+
13+
Assuming we have code execution in the host process and the library we wish to inject has been written into an arbitrary location of memory in the host process, Reflective DLL Injection works as follows.
14+
15+
* Execution is passed, either via CreateRemoteThread() or a tiny bootstrap shellcode, to the library's ReflectiveLoader function which is an exported function found in the library's export table.
16+
* As the library's image will currently exists in an arbitrary location in memory the ReflectiveLoader will first calculate its own image's current location in memory so as to be able to parse its own headers for use later on.
17+
* The ReflectiveLoader will then parse the host processes kernel32.dll export table in order to calculate the addresses of three functions required by the loader, namely LoadLibraryA, GetProcAddress and VirtualAlloc.
18+
* The ReflectiveLoader will now allocate a continuous region of memory into which it will proceed to load its own image. The location is not important as the loader will correctly relocate the image later on.
19+
* The library's headers and sections are loaded into their new locations in memory.
20+
* The ReflectiveLoader will then process the newly loaded copy of its image's import table, loading any additional library's and resolving their respective imported function addresses.
21+
* The ReflectiveLoader will then process the newly loaded copy of its image's relocation table.
22+
* The ReflectiveLoader will then call its newly loaded image's entry point function, DllMain with DLL_PROCESS_ATTACH. The library has now been successfully loaded into memory.
23+
* Finally the ReflectiveLoader will return execution to the initial bootstrap shellcode which called it, or if it was called via CreateRemoteThread, the thread will terminate.
24+
25+
Build
26+
=====
27+
28+
Open the 'rdi.sln' file in Visual Studio C++ and build the solution in Release mode to make inject.exe and reflective_dll.dll
29+
30+
Usage
31+
=====
32+
33+
To test use the inject.exe to inject reflective_dll.dll into a host process via a process id, e.g.:
34+
35+
> inject.exe 1234
36+
37+
License
38+
=======
39+
40+
Licensed under a 3 clause BSD license, please see LICENSE.txt for details.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//===============================================================================================//
2+
// Copyright (c) 2013, Stephen Fewer of Harmony Security (www.harmonysecurity.com)
3+
// All rights reserved.
4+
//
5+
// Redistribution and use in source and binary forms, with or without modification, are permitted
6+
// provided that the following conditions are met:
7+
//
8+
// * Redistributions of source code must retain the above copyright notice, this list of
9+
// conditions and the following disclaimer.
10+
//
11+
// * Redistributions in binary form must reproduce the above copyright notice, this list of
12+
// conditions and the following disclaimer in the documentation and/or other materials provided
13+
// with the distribution.
14+
//
15+
// * Neither the name of Harmony Security nor the names of its contributors may be used to
16+
// endorse or promote products derived from this software without specific prior written permission.
17+
//
18+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19+
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20+
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22+
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25+
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
// POSSIBILITY OF SUCH DAMAGE.
27+
//===============================================================================================//
28+
#ifndef _REFLECTIVEDLLINJECTION_REFLECTIVEDLLINJECTION_H
29+
#define _REFLECTIVEDLLINJECTION_REFLECTIVEDLLINJECTION_H
30+
//===============================================================================================//
31+
#define WIN32_LEAN_AND_MEAN
32+
#include <windows.h>
33+
34+
// we declare some common stuff in here...
35+
36+
#define DLL_METASPLOIT_ATTACH 4
37+
#define DLL_METASPLOIT_DETACH 5
38+
#define DLL_QUERY_HMODULE 6
39+
40+
#define DEREF( name )*(UINT_PTR *)(name)
41+
#define DEREF_64( name )*(DWORD64 *)(name)
42+
#define DEREF_32( name )*(DWORD *)(name)
43+
#define DEREF_16( name )*(WORD *)(name)
44+
#define DEREF_8( name )*(BYTE *)(name)
45+
46+
typedef ULONG_PTR (WINAPI * REFLECTIVELOADER)( VOID );
47+
typedef BOOL (WINAPI * DLLMAIN)( HINSTANCE, DWORD, LPVOID );
48+
49+
#define DLLEXPORT __declspec( dllexport )
50+
51+
//===============================================================================================//
52+
#endif
53+
//===============================================================================================//

0 commit comments

Comments
 (0)