Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.79 KB | None | 0 0
  1. #Include "windows.bi"
  2.  
  3. Dim Shared NtSystemDebugControl As Function(As Integer, As Any Ptr, As Dword, As Any Ptr, As Dword, As Dword Ptr) As Long
  4.  
  5. Type CALL_GATE Field = 1
  6.         addrlo As Word
  7.         Seg As Word
  8.         arg:5 As Byte
  9.         u:3 As Byte
  10.         typ:5 As Byte
  11.         dpl:2 As Byte
  12.         pres:1 As Byte
  13.         addrhi As Word
  14. End Type
  15.  
  16. Type gdtrStruct Field = 1
  17.         limit As Word
  18.         base As Dword
  19. End Type
  20.  
  21. Type VIRTUAL1 Field = 1
  22.         A As Any Ptr
  23.         B As Any Ptr
  24.         C As Dword
  25. End Type
  26.  
  27. #Define Virtual(_a_, _b_, _c_, _d_) Scope: Var v = Type<VIRTUAL1>((_a_), (_b_), (_c_)): NtSystemDebugControl((_d_), @v, SizeOf(v), 0, 0, 0): End Scope
  28.  
  29.  
  30. Sub Ring0(cs As Dword, text As ZString Ptr)
  31.         *text = !"A1MER.dll"    
  32.         Asm mov eax, cr0      
  33.         Asm
  34.                 leave
  35.                 .byte 0xCA ' retf 4
  36.                .word 4
  37.        End Asm
  38. End Sub
  39.  
  40. Dim As Word farcall(3) = {0, 0, gate Shl 3}
  41.        Dim As ZString Ptr param = CAllocate(100)
  42.        Dim As Long result
  43.        
  44.  //lägg till så den läser wire
  45.        Asm
  46.                push [param]
  47.                call fword Ptr [farcall]
  48.                mov [result], eax
  49.        End Asm
  50.        
  51.      
  52.        Dim As LongInt c = 0
  53.        Virtual(gdtr.base + gate * 8, @c, 8, 9)
  54.        
  55.        Print !"\n" & *param & !"\nCR0 = " & Hex(result, 8)
  56.        Sleep
  57.        
  58.        DeAllocate(param)
  59.        
  60.        Return 0
  61. End Function
  62.  
  63. Function Main() As Integer
  64.        NtSystemDebugControl = GetProcAddress(LoadLibrary("ntdll"), "NtSystemDebugControl")
  65.        
  66.        Dim As TOKEN_PRIVILEGES pv, po
  67.        pv.PrivilegeCount = 1
  68.        pv.Privileges(0).Attributes = SE_PRIVILEGE_ENABLED
  69.        Dim As HANDLE t
  70.        Dim As Dword no
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement