已有administrator权限,如何用vb获取system权限?

解决方案 »

  1.   

    Option ExplicitPrivate Const SE_DEBUG_NAME = "SeDebugPrivilege"
    Private Type LUID
       UsedPart As Long
       IgnoredForNowHigh32BitPart As Long
    End TypePrivate Type LUID_AND_ATTRIBUTES
       TheLuid As LUID
       Attributes As Long
    End TypePrivate Type TOKEN_PRIVILEGES
       PrivilegeCount As Long
       TheLuid As LUID
       Attributes As Long
    End TypePrivate Declare Function GetLastError Lib "kernel32" () As Long
    Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
    Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
    Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long
    Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
    Private Declare Sub SetLastError Lib "kernel32" (ByVal dwErrCode As Long)
    Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As LongPublic Sub AdjustToken()      '********************************************************************
          '* This procedure sets the proper privileges to allow a log off or a
          '* shut down to occur under Windows NT.
          '********************************************************************         Const TOKEN_ADJUST_PRIVILEGES = &H20
             Const TOKEN_QUERY = &H8
             Const SE_PRIVILEGE_ENABLED = &H2         Dim hdlProcessHandle As Long
             Dim hdlTokenHandle As Long
             Dim tmpLuid As LUID
             Dim tkp As TOKEN_PRIVILEGES
             Dim tkpNewButIgnored As TOKEN_PRIVILEGES
             Dim lBufferNeeded As Long         'Set the error code of the last thread to zero using the
             'SetLast Error function. Do this so that the GetLastError
             'function does not return a value other than zero for no
             'apparent reason.
             SetLastError 0         'Use the GetCurrentProcess function to set the hdlProcessHandle
             'variable.
             hdlProcessHandle = GetCurrentProcess()         If GetLastError <> 0 Then
                MsgBox "GetCurrentProcess error==" & GetLastError
             End If         OpenProcessToken hdlProcessHandle, _
                (TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY), hdlTokenHandle         If GetLastError <> 0 Then
                MsgBox "OpenProcessToken error==" & GetLastError
             End If         'Get the LUID for shutdown privilege
             LookupPrivilegeValue "", SE_DEBUG_NAME, tmpLuid         If GetLastError <> 0 Then
                MsgBox "LookupPrivilegeValue error==" & GetLastError
             End If         tkp.PrivilegeCount = 1    ' One privilege to set
             tkp.TheLuid = tmpLuid
             tkp.Attributes = SE_PRIVILEGE_ENABLED         'Enable the shutdown privilege in the access token of this process
             AdjustTokenPrivileges hdlTokenHandle, _
                                   False, _
                                   tkp, _
                                   Len(tkpNewButIgnored), _
                                   tkpNewButIgnored, _
                                   lBufferNeeded
                     If GetLastError <> 0 Then
                MsgBox "AdjustTokenPrivileges error==" & GetLastError
             End If      End Sub
      

  2.   

    上面是获得DUBUG权限的吧?何为SYSTEM权限呀?按我的理解是在任务管理器中用户为“SYSTEM”,如果是的话,那把程序做成服务吧
      

  3.   

    写成服务,以local system用户启动
      

  4.   

    http://support.microsoft.com/default.aspx?scid=kb%3Bzh-cn%3B295004
      

  5.   

    http://cache.baidu.com/c?word=openwindowstation&url=http%3A//www%2Exfocus%2Enet/articles/200504/795%2Ehtml&b=0&a=7&user=baidu
      

  6.   

    1. "利用ZwCreateToken()自己创建一个SYSTEM令牌(Token)" 
    2. HOOK掉创建进程的函数ZwCreateProcess(Ex),用winlogon ID 创建
    3. 远线程插入,插入线程到系统进程,创建一新进程还可以:
    4. 将程序做成服务,带参数运行新进程
      

  7.   

    http://www.hbhacker.net/read.php?tid=8726
      

  8.   

    你们好!“电厂生产管理系统”本人刚刚完成,需要的朋友可以与我联系,我用QQ直接发给你,打包后有30M,源码只有2.5M,呵。。我的QQ:450939943
      

  9.   

    是vb啊,不是用c.用C的话有很多方法.
    而且我要进程本身就是以system 权限运行的,而不是从有system权限的进程创建的子进程.难啊!