看流星社区

 找回密码
 注册账号
查看: 3172|回复: 3

终极方法:debugport清零过NP

[复制链接]

该用户从未签到

发表于 2013-4-26 09:06:10 | 显示全部楼层 |阅读模式

  1. 绕过inline HOOK对于很多人而言应该不难实现。而主要影响很多人的是debugport清零等东西。
  2. 让我们改造WRK实现自己的方便调试的内核吧。下次有时间讲intel的vt下的IDT Redirect
  3. debugport清零免疫与防nprotect断链的改造 文件base\ntos\inc\ps.h中修改EPROCESS结构~
  4. // Process structure.
  5. //
  6. // If you remove a field from this structure, please also
  7. // remove the reference to it from within the kernel debugger
  8. // (nt\private\sdktools\ntsd\ntkext.c)
  9. //
  10. typedef struct _EPROCESS {
  11.     KPROCESS Pcb;
  12.     //
  13.     // Lock used to protect:
  14.     // The list of threads in the process.
  15.     // Process token.
  16.     // Win32 process field.
  17.     // Process and thread affinity setting.
  18.     //
  19.     EX_PUSH_LOCK ProcessLock;
  20.     LARGE_INTEGER CreateTime;
  21.     LARGE_INTEGER ExitTime;
  22.     //
  23.     // Structure to allow lock free cross process access to the process
  24.     // handle table, process section and address space. Acquire rundown
  25.     // protection with this if you do cross process handle table, process
  26.     // section or address space references.
  27.     //
  28.     EX_RUNDOWN_REF RundownProtect;
  29.     HANDLE UniqueProcessId;
  30.     //
  31.     // Global list of all processes in the system. Processes are removed
  32.     // from this list in the object deletion routine. References to
  33.     // processes in this list must be done with ObReferenceObjectSafe
  34.     // because of this.
  35.     //
  36.     LIST_ENTRY FakeActiveProcessLinks;
  37.     //
  38.     // Quota Fields.
  39.     //
  40.     SIZE_T QuotaUsage[PsQuotaTypes];
  41.     SIZE_T QuotaPeak[PsQuotaTypes];
  42.     SIZE_T CommitCharge;
  43.     //
  44.     // VmCounters.
  45.     //
  46.     SIZE_T PeakVirtualSize;
  47.     SIZE_T VirtualSize;
  48.     LIST_ENTRY SessionProcessLinks;
  49.     PVOID FakeDebugPort;
  50.     PVOID ExceptionPort;
  51.     PHANDLE_TABLE ObjectTable;
  52.     //
  53.     // Security.
  54.     //
  55.     EX_FAST_REF Token;
  56.     PFN_NUMBER WorkingSetPage;
  57.     KGUARDED_MUTEX AddressCreationLock;
  58.     KSPIN_LOCK HyperSpaceLock;
  59.     struct _ETHREAD *ForkInProgress;
  60.     ULONG_PTR HardwareTrigger;
  61.     PMM_AVL_TABLE PhysicalVadRoot;
  62.     PVOID CloneRoot;
  63.     PFN_NUMBER NumberOfPrivatePages;
  64.     PFN_NUMBER NumberOfLockedPages;
  65.     PVOID Win32Process;
  66.     struct _EJOB *Job;
  67.     PVOID SectionObject;
  68.     PVOID SectionBaseAddress;
  69.     PEPROCESS_QUOTA_BLOCK QuotaBlock;
  70.     PPAGEFAULT_HISTORY WorkingSetWatch;
  71.     HANDLE Win32WindowStation;
  72.     HANDLE InheritedFromUniqueProcessId;
  73.     PVOID LdtInformation;
  74.     PVOID VadFreeHint;
  75.     PVOID VdmObjects;
  76.     PVOID DeviceMap;
  77.     PVOID Spare0[3];
  78.     union {
  79.         HARDWARE_PTE PageDirectoryPte;
  80.         ULONGLONG Filler;
  81.     };
  82.     PVOID Session;
  83.     UCHAR ImageFileName[ 16 ];
  84.     LIST_ENTRY JobLinks;
  85.     PVOID LockedPagesList;
  86.     LIST_ENTRY ThreadListHead;
  87.     //
  88.     // Used by rdr/security for authentication.
  89.     //
  90.     PVOID SecurityPort;
  91. #ifdef _WIN64
  92.     PWOW64_PROCESS Wow64Process;
  93. #else
  94.     PVOID PaeTop;
  95. #endif
  96.     ULONG ActiveThreads;
  97.     ACCESS_MASK GrantedAccess;
  98.     ULONG DefaultHardErrorProcessing;
  99.     NTSTATUS LastThreadExitStatus;
  100.     //
  101.     // Peb
  102.     //
  103.     PPEB Peb;
  104.     //
  105.     // Pointer to the prefetches trace block.
  106.     //
  107.     EX_FAST_REF PrefetchTrace;
  108.     LARGE_INTEGER ReadOperationCount;
  109.     LARGE_INTEGER WriteOperationCount;
  110.     LARGE_INTEGER OtherOperationCount;
  111.     LARGE_INTEGER ReadTransferCount;
  112.     LARGE_INTEGER WriteTransferCount;
  113.     LARGE_INTEGER OtherTransferCount;
  114.     SIZE_T CommitChargeLimit;
  115.     SIZE_T CommitChargePeak;
  116.     PVOID AweInfo;
  117.     //
  118.     // This is used for SeAuditProcessCreation.
  119.     // It contains the full path to the image file.
  120.     //
  121.     SE_AUDIT_PROCESS_CREATION_INFO SeAuditProcessCreationInfo;
  122.     MMSUPPORT Vm;
  123. #if !defined(_WIN64)
  124.     LIST_ENTRY MmProcessLinks;
  125. #else
  126.     ULONG Spares[2];
  127. #endif
  128.     ULONG ModifiedPageCount;
  129.     #define PS_JOB_STATUS_NOT_REALLY_ACTIVE      0x00000001UL
  130.     #define PS_JOB_STATUS_ACCOUNTING_FOLDED      0x00000002UL
  131.     #define PS_JOB_STATUS_NEW_PROCESS_REPORTED   0x00000004UL
  132.     #define PS_JOB_STATUS_EXIT_PROCESS_REPORTED 0x00000008UL
  133.     #define PS_JOB_STATUS_REPORT_COMMIT_CHANGES 0x00000010UL
  134.     #define PS_JOB_STATUS_LAST_REPORT_MEMORY     0x00000020UL
  135.     #define PS_JOB_STATUS_REPORT_PHYSICAL_PAGE_CHANGES 0x00000040UL
  136.     ULONG JobStatus;

  137.     //
  138.     // Process flags. Use interlocked operations with PS_SET_BITS, etc
  139.     // to modify these.
  140.     //
  141.     #define PS_PROCESS_FLAGS_CREATE_REPORTED        0x00000001UL // Create process debug call has occurred
  142.     #define PS_PROCESS_FLAGS_NO_DEBUG_INHERIT       0x00000002UL // Don't inherit debug port
  143.     #define PS_PROCESS_FLAGS_PROCESS_EXITING        0x00000004UL // PspExitProcess entered
  144.     #define PS_PROCESS_FLAGS_PROCESS_DELETE         0x00000008UL // Delete process has been issued
  145.     #define PS_PROCESS_FLAGS_WOW64_SPLIT_PAGES      0x00000010UL // Wow64 split pages
  146.     #define PS_PROCESS_FLAGS_VM_DELETED             0x00000020UL // VM is deleted
  147.     #define PS_PROCESS_FLAGS_OUTSWAP_ENABLED        0x00000040UL // Outswap enabled
  148.     #define PS_PROCESS_FLAGS_OUTSWAPPED             0x00000080UL // Outswapped
  149.     #define PS_PROCESS_FLAGS_FORK_FAILED            0x00000100UL // Fork status
  150.     #define PS_PROCESS_FLAGS_WOW64_4GB_VA_SPACE     0x00000200UL // Wow64 process with 4gb virtual address space
  151.     #define PS_PROCESS_FLAGS_ADDRESS_SPACE1         0x00000400UL // Addr space state1
  152.     #define PS_PROCESS_FLAGS_ADDRESS_SPACE2         0x00000800UL // Addr space state2
  153.     #define PS_PROCESS_FLAGS_SET_TIMER_RESOLUTION   0x00001000UL // SetTimerResolution has been called
  154.     #define PS_PROCESS_FLAGS_BREAK_ON_TERMINATION   0x00002000UL // Break on process termination
  155.     #define PS_PROCESS_FLAGS_CREATING_SESSION       0x00004000UL // Process is creating a session
  156.     #define PS_PROCESS_FLAGS_USING_WRITE_WATCH      0x00008000UL // Process is using the write watch APIs
  157.     #define PS_PROCESS_FLAGS_IN_SESSION             0x00010000UL // Process is in a session
  158.     #define PS_PROCESS_FLAGS_OVERRIDE_ADDRESS_SPACE 0x00020000UL // Process must use native address space (Win64 only)
  159.     #define PS_PROCESS_FLAGS_HAS_ADDRESS_SPACE      0x00040000UL // This process has an address space
  160.     #define PS_PROCESS_FLAGS_LAUNCH_PREFETCHED      0x00080000UL // Process launch was prefetched
  161.     #define PS_PROCESS_INJECT_INPAGE_ERRORS         0x00100000UL // Process should be given inpage errors - hardcoded in trap.asm too
  162.     #define PS_PROCESS_FLAGS_VM_TOP_DOWN            0x00200000UL // Process memory allocations default to top-down
  163.     #define PS_PROCESS_FLAGS_IMAGE_NOTIFY_DONE      0x00400000UL // We have sent a message for this image
  164.     #define PS_PROCESS_FLAGS_PDE_UPDATE_NEEDED      0x00800000UL // The system PDEs need updating for this process (NT32 only)
  165.     #define PS_PROCESS_FLAGS_VDM_ALLOWED            0x01000000UL // Process allowed to invoke NTVDM support
  166.     #define PS_PROCESS_FLAGS_SMAP_ALLOWED           0x02000000UL // Process allowed to invoke SMAP support
  167.     #define PS_PROCESS_FLAGS_CREATE_FAILED          0x04000000UL // Process create failed
  168.     #define PS_PROCESS_FLAGS_DEFAULT_IO_PRIORITY    0x38000000UL // The default I/O priority for created threads. (3 bits)
  169.     #define PS_PROCESS_FLAGS_PRIORITY_SHIFT         27
  170.    
  171.     #define PS_PROCESS_FLAGS_EXECUTE_SPARE1         0x40000000UL //
  172.     #define PS_PROCESS_FLAGS_EXECUTE_SPARE2         0x80000000UL //

  173.     union {
  174.         ULONG Flags;
  175.         //
  176.         // Fields can only be set by the PS_SET_BITS and other interlocked
  177.         // macros. Reading fields is best done via the bit definitions so
  178.         // references are easy to locate.
  179.         //
  180.         struct {
  181.             ULONG CreateReported            : 1;
  182.             ULONG NoDebugInherit            : 1;
  183.             ULONG ProcessExiting            : 1;
  184.             ULONG ProcessDelete             : 1;
  185.             ULONG Wow64SplitPages           : 1;
  186.             ULONG VmDeleted                 : 1;
  187.             ULONG OutswapEnabled            : 1;
  188.             ULONG Outswapped                : 1;
  189.             ULONG ForkFailed                : 1;
  190.             ULONG Wow64VaSpace4Gb           : 1;
  191.             ULONG AddressSpaceInitialized   : 2;
  192.             ULONG SetTimerResolution        : 1;
  193.             ULONG BreakOnTermination        : 1;
  194.             ULONG SessionCreationUnderway   : 1;
  195.             ULONG WriteWatch                : 1;
  196.             ULONG ProcessInSession          : 1;
  197.             ULONG OverrideAddressSpace      : 1;
  198.             ULONG HasAddressSpace           : 1;
  199.             ULONG LaunchPrefetched          : 1;
  200.             ULONG InjectInpageErrors        : 1;
  201.             ULONG VmTopDown                 : 1;
  202.             ULONG ImageNotifyDone           : 1;
  203.             ULONG PdeUpdateNeeded           : 1;    // NT32 only
  204.             ULONG VdmAllowed                : 1;
  205.             ULONG SmapAllowed               : 1;
  206.             ULONG CreateFailed              : 1;
  207.             ULONG DefaultIoPriority         : 3;
  208.             ULONG Spare1                    : 1;
  209.             ULONG Spare2                    : 1;
  210.         };
  211.     };
  212.     NTSTATUS ExitStatus;
  213.     USHORT NextPageColor;
  214.     union {
  215.         struct {
  216.             UCHAR SubSystemMinorVersion;
  217.             UCHAR SubSystemMajorVersion;
  218.         };
  219.         USHORT SubSystemVersion;
  220.     };
  221.     UCHAR PriorityClass;
  222.     MM_AVL_TABLE VadRoot;
  223.     ULONG Cookie;

  224. PVOID DebugPort;
  225. LIST_ENTRY ActiveProcessLinks;
  226. } EPROCESS, *PEPROCESS;
复制代码

该用户从未签到

发表于 2013-4-26 16:38:26 | 显示全部楼层
哈哈哈呵呵

该用户从未签到

发表于 2013-4-27 07:24:38 | 显示全部楼层
高手,看不懂啊~~~~

该用户从未签到

发表于 2013-4-27 08:32:50 | 显示全部楼层
非常强大,收藏了
点击按钮快速添加回复内容: 支持 高兴 激动 给力 加油 苦寻 生气 回帖 路过 感恩
您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

小黑屋|手机版|Archiver|看流星社区 |网站地图

GMT+8, 2024-4-20 22:47

Powered by Kanliuxing X3.4

© 2010-2019 kanliuxing.com

快速回复 返回顶部 返回列表