dllenvhijacking.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #include <windows.h>
  2. typedef struct _FILE_BASIC_INFORMATION {
  3. LARGE_INTEGER CreationTime; // absolute system, number of 100-nanosecond intervals
  4. LARGE_INTEGER LastAccessTime; // since the start of the year 1601 in the Gregorian calendar.
  5. LARGE_INTEGER LastWriteTime;
  6. LARGE_INTEGER ChangeTime;
  7. ULONG FileAttributes; // metadata about the file, ex.: archive, compressed, directory, hidden, etc.
  8. } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
  9. typedef enum _FILE_INFORMATION_CLASS {
  10. FileDirectoryInformation = 1,
  11. FileFullDirectoryInformation, // 2
  12. FileBothDirectoryInformation, // 3
  13. FileBasicInformation, // 4
  14. FileStandardInformation, // 5
  15. FileInternalInformation, // 6
  16. FileEaInformation, // 7
  17. FileAccessInformation, // 8
  18. FileNameInformation, // 9
  19. FileRenameInformation, // 10
  20. FileLinkInformation, // 11
  21. FileNamesInformation, // 12
  22. FileDispositionInformation, // 13
  23. FilePositionInformation, // 14
  24. FileFullEaInformation, // 15
  25. FileModeInformation, // 16
  26. FileAlignmentInformation, // 17
  27. FileAllInformation, // 18
  28. FileAllocationInformation, // 19
  29. FileEndOfFileInformation, // 20
  30. FileAlternateNameInformation, // 21
  31. FileStreamInformation, // 22
  32. FilePipeInformation, // 23
  33. FilePipeLocalInformation, // 24
  34. FilePipeRemoteInformation, // 25
  35. FileMailslotQueryInformation, // 26
  36. FileMailslotSetInformation, // 27
  37. FileCompressionInformation, // 28
  38. FileObjectIdInformation, // 29
  39. FileCompletionInformation, // 30
  40. FileMoveClusterInformation, // 31
  41. FileQuotaInformation, // 32
  42. FileReparsePointInformation, // 33
  43. FileNetworkOpenInformation, // 34
  44. FileAttributeTagInformation, // 35
  45. FileTrackingInformation, // 36
  46. FileIdBothDirectoryInformation, // 37
  47. FileIdFullDirectoryInformation, // 38
  48. FileValidDataLengthInformation, // 39
  49. FileShortNameInformation, // 40
  50. FileIoCompletionNotificationInformation, // 41
  51. FileIoStatusBlockRangeInformation, // 42
  52. FileIoPriorityHintInformation, // 43
  53. FileSfioReserveInformation, // 44
  54. FileSfioVolumeInformation, // 45
  55. FileHardLinkInformation, // 46
  56. FileProcessIdsUsingFileInformation, // 47
  57. FileNormalizedNameInformation, // 48
  58. FileNetworkPhysicalNameInformation, // 49
  59. FileIdGlobalTxDirectoryInformation, // 50
  60. FileIsRemoteDeviceInformation, // 51
  61. FileUnusedInformation, // 52
  62. FileNumaNodeInformation, // 53
  63. FileStandardLinkInformation, // 54
  64. FileRemoteProtocolInformation, // 55
  65. FileRenameInformationBypassAccessCheck, // 56
  66. FileLinkInformationBypassAccessCheck, // 57
  67. FileVolumeNameInformation, // 58
  68. FileIdInformation, // 59
  69. FileIdExtdDirectoryInformation, // 60
  70. FileReplaceCompletionInformation, // 61
  71. FileHardLinkFullIdInformation, // 62
  72. FileIdExtdBothDirectoryInformation, // 63
  73. FileDispositionInformationEx, // 64
  74. FileRenameInformationEx, // 65
  75. FileRenameInformationExBypassAccessCheck, // 66
  76. FileDesiredStorageClassInformation, // 67
  77. FileStatInformation, // 68
  78. FileMemoryPartitionInformation, // 69
  79. FileStatLxInformation, // 70
  80. FileCaseSensitiveInformation, // 71
  81. FileLinkInformationEx, // 72
  82. FileLinkInformationExBypassAccessCheck, // 73
  83. FileStorageReserveIdInformation, // 74
  84. FileCaseSensitiveInformationForceAccessCheck, // 75
  85. FileKnownFolderInformation, // 76
  86. FileMaximumInformation
  87. } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
  88. typedef struct _IO_STATUS_BLOCK {
  89. union {
  90. NTSTATUS Status;
  91. PVOID Pointer;
  92. };
  93. ULONG_PTR Information;
  94. } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
  95. typedef NTSTATUS (NTAPI *NtQueryInformationFile_t)(
  96. HANDLE FileHandle,
  97. PIO_STATUS_BLOCK IoStatusBlock,
  98. PVOID FileInformation,
  99. ULONG Length,
  100. FILE_INFORMATION_CLASS FileInformationClass
  101. );
  102. typedef NTSTATUS (NTAPI *NtSetInformationFile_t)(
  103. HANDLE FileHandle,
  104. PIO_STATUS_BLOCK IoStatusBlock,
  105. PVOID FileInformation,
  106. ULONG Length,
  107. FILE_INFORMATION_CLASS FileInformationClass
  108. );
  109. //CreateHiddenDir
  110. DECLSPEC_IMPORT BOOL WINAPI KERNEL32$CreateDirectoryW(LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes);
  111. DECLSPEC_IMPORT DWORD WINAPI KERNEL32$GetFileAttributesW(LPCWSTR lpFileName);
  112. DECLSPEC_IMPORT BOOL WINAPI KERNEL32$SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes);
  113. DECLSPEC_IMPORT DWORD WINAPI KERNEL32$GetLastError(void);
  114. WINBASEAPI int __cdecl MSVCRT$printf(const char * _Format,...);
  115. WINBASEAPI int __cdecl MSVCRT$getchar(void);
  116. //CreateHiddenFile
  117. DECLSPEC_IMPORT HANDLE WINAPI KERNEL32$CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
  118. DECLSPEC_IMPORT BOOL WINAPI KERNEL32$CloseHandle (HANDLE hObject);
  119. //MoveDLL
  120. DECLSPEC_IMPORT BOOL WINAPI KERNEL32$MoveFileW(LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName);
  121. //RunProc
  122. DECLSPEC_IMPORT BOOL WINAPI KERNEL32$SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue);
  123. DECLSPEC_IMPORT BOOL WINAPI KERNEL32$CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
  124. DECLSPEC_IMPORT BOOL WINAPI KERNEL32$InitializeProcThreadAttributeList(LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, DWORD dwAttributeCount, DWORD dwFlags, PSIZE_T lpSize);
  125. DECLSPEC_IMPORT LPVOID WINAPI KERNEL32$HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes);
  126. DECLSPEC_IMPORT HANDLE WINAPI KERNEL32$GetProcessHeap();
  127. DECLSPEC_IMPORT HANDLE WINAPI KERNEL32$OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId);
  128. DECLSPEC_IMPORT BOOL WINAPI KERNEL32$UpdateProcThreadAttribute(LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList, DWORD dwFlags, DWORD_PTR Attribute, PVOID lpValue, SIZE_T cbSize, PVOID lpPreviousValue, PSIZE_T lpReturnSize);
  129. DECLSPEC_IMPORT void WINAPI KERNEL32$DeleteProcThreadAttributeList(LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList);
  130. //main
  131. WINBASEAPI wchar_t * __cdecl MSVCRT$wcscpy(wchar_t *destination, const wchar_t *source);
  132. WINBASEAPI wchar_t * __cdecl MSVCRT$wcscat(wchar_t *destination, const wchar_t *source);
  133. WINBASEAPI char * __cdecl MSVCRT$strcpy(char *destination, const char *source);
  134. WINBASEAPI char * __cdecl MSVCRT$strcat(char *destination, const char *source);
  135. WINBASEAPI size_t __cdecl MSVCRT$wcslen(const wchar_t *string);