Posts Basic Pentesting
Post
Cancel

Basic Pentesting

Description

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

RoomBasic Pentesting
OSLinux
DifficultyEasy
Creatorashu

Let’s start with port scanning which can be done with nmap,

1
nmap -sV -sC 10.10.168.119 -oN nmap.txt

image

We got some open ports 22 (ssh), 80 (http), 139,445 (samba) which seems fine for us in this machine.

Let’s start with enumerating website by visiting http://10.10.168.119,

image

The site is under maintenance. Let’s check it’s source code,

image

There’s a comment left, says, we can visit dev note section. Might be worth checking it.

But first let’s brute force directories using dirseach,

1
python3 /home/kali/tools/dirsearch/dirsearch.py -u http://10.10.168.119 -e txt,php -i 200,301 -o dirsearch.py

image

we got /development directory. Let’s navigate to it.

Visiting http://10.10.168.119/development,

image

we got 2 text files but only j.txt seems valuable to us,

image

Seems like we can brute force the password of J user.

Now, that we’ve enumerated website, let’s enumerate shares using smbclient,

1
smbclient -L //10.10.168.119

image

we got Anonymous share open. Let’s try to access it.

1
smbclient \\\\10.10.168.119\\Anonymous

image

Establishing content with ls and we got staff.txt file.

Let’s download this file on our system using get command,

1
get staff.txt

image

Now, that we’ve downloaded the file on our system, let’s view file’s content,

1
cat staff.txt

image

By reading this, we got that user is Jay and we’ve to brute force their password and we can achieve this using hydra tool.

1
hydra -l jan -P /usr/share/wordlists/rockyou.txt ssh://10.10.168.119:22/ -t 4

image

we got password!! Let’s authenticate ourselves.

1
ssh jan@10.10.168.119

image

We got in!

After enumerating it a bit, I found another user in home directory, kay. Let’s navigate into kay’s directory and establish contents using ls -la,

image

we got many directory and a pass.bak file.

Let’s try to read pass.bak file,

1
cat pass.bak

image

we got Permission denied! We can’t read this file because owner of this file is kay user and we (as a jan user) don’t have privileges of kay user.

Let’s establish content of .ssh directory,

1
ls -la .ssh

image

we got id_rsa private/public key pair and an authorized_keys file

Time for Lateral Privilege Escalation because there is another user kay from which we can gain root. Let’s find our way to get to kay user.

Let’s copy id_rsa file content on our local machine and we can crack this key using JohnTheRipper.

1
/usr/share/john/ssh2john.py id_rsa > john.hash

image

we get a john-crackable file that we can crack,

1
john --wordlist=/usr/share/wordlists/rockyou.txt john.hash

image

we got the password! Let’s try to ssh as kay user with id_rsa file,

1
ssh -i id_rsa kay@10.10.168.119

image

Let’s establish directory content using ls,

image

we can see pass.bak file and since we’re kay user, we can read the pass.bak file and after reading it, we got a long password.

Here comes Privilege Escalation.

Let’s try to use this password to become superuser,

1
sudo su

image

YAY! we’re root now!!

There’s a flag in /root directory,

image

Read the flag,

image

We have completed this machine.

This post is licensed under CC BY 4.0 by the author.