![]() |
|
Toppo CTF Challenge Walkthrough - Beginner - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Hacks, Exploits, and Various Discussions (https://hackforums.net/forumdisplay.php?fid=45) +--- Forum: Whitehat • Blue Team • Defensive Security (https://hackforums.net/forumdisplay.php?fid=448) +---- Forum: Pentesting and Forensics (https://hackforums.net/forumdisplay.php?fid=231) +---- Thread: Toppo CTF Challenge Walkthrough - Beginner (/showthread.php?tid=5866313) |
Toppo CTF Challenge Walkthrough - Beginner - Xphile - Jul 25, 2018 Toppo CTF Challenge
Difficulty: Beginner/Easy
Author: h4d3sw0rm
Hello all, It's been a while since I've posted on HF, so I felt like giving out a walkthrough to a simple and quick CTF challenge that was recently uploaded to VulnHub. This CTF doesn't require any advanced exploitation by any means, and simply requires common-sense and minimal tools. That being said, I feel anyone wishing to get into CTF challenges or pentesting would appreciate some of the tools and techniques used to obtain root on this box. Steps to root: 1. Initial scanning & recon. 2. Exploiting predictable & lazy admins. 3. Gaining root thanks to more laziness. Initial scanning & recon When starting any CTF challenge out there, your first priority is to understand where and what you're working with. I generally use three tools during my initial scanning phase, before I begin to dig into specific services and determine the best approach, these three are: 1. Nmap - An absolute essential for getting a good picture of what the target box is using to send and receive information, a full Nmap scan is invaluable to any CTF challenger. 2. Nikto - Nikto is a quick way of locating interesting and potentially useful files on a webserver. Many CTF challenges will have a webserver running and is typically your best bet at attacking the box itself (for example, uploading a shell or exploiting a flaw in the website's design). 3. DirBuster - This tool will scan for directories provided by a wordlist (DirBuster comes with some good lists) in order to provide an in-depth look of how the website is mapped out. This tool sometimes finds misplaced directories or files that will help you exponentially with your efforts to exploit the target system. Nmap: Code $ nmap -A -p- -T5 192.168.56.101The command I used can be broken down into its separate arguments, for those who aren't experienced with Nmap: -A: Enable OS detection, version detection, script scanning, and traceroute -p-: Scans all ports on the system -T5: Sets the timing template for the scan to its maximum of 5 (higher is faster) From this scan report I would quickly determine that:
Nikto: Code $ perl nikto.pl -host http://192.168.56.101/From here I can immediately spot that an admin directory (/admin/) is present and public, sometimes the most obvious route is the way to go, at least in this instance. The other directories appear to either be potentially useful (such as /img/ or /mail/) whereas others are simply useless bits of documentation (/manual/) The DirBuster report was filled with effectively the same relevant info and a lot of useless manual pages, so I won't post the report here. Exploiting predictable & lazy admins After browsing to the /admin/ directory, I was greeted with a single file named 'notes.txt'. Of course, this is a beginner challenge and will generally require a small amount of effort (this far) on the attacker's part. Quote:Note to myself : So this admin is lazy, he's left a personal document on a public directory for all to see. He even gives out his current password, just like that. So now there's a password in the bank for later, but a username and point of entry is still needed, as there is no evident login form on the website. Obviously the only visible entry point is through the SSH service. This is where some may trip up with trying to overcomplicate things, as I've done a lot in the past. Looking back over the mainly numerical password, the word - or name - "ted" stands out. Worth a try as a username, surely? Code $ ssh [email protected]And of course it works... So now I've got a presence on the machine, time to figure out whereabouts I am and what's around me. Code ted@Toppo:~$ whoamiSadly Ted isn't root, which is what I need to complete this challenge. Gaining root thanks to more laziness I'm not great with post-exploitation if I'm completely honest and privilege escalation has never been my primary skill. However, I know to always look for programs that allow me to write and execute system commands on the box. Many lazy admins will restrict their user's permissions, but not their application's - this leaves gaping holes in a system where any old user can run commands as a root user. For example, with this box I quickly checked for Python: Code ted@Toppo:~$ python --versionSweet, so let's see where Python stands amongst other users and programs... For this I began to execute system commands using a module called "os" (documentation on the module can be found here). You can play around with it and see what info you can get the system to spew out, but I went straight for the goal of this CTF..: Code ted@Toppo:/$ pythonAnd there we are, root permissions while running commands through Python. This can be proven by changing directory to /root and listing its contents: Code >>> os.system("cd /root && ls -alt")Bingo, flag.txt is what I'm looking for, so to open it up... Code >>> os.system("cat /root/flag.txt")Short, sweet and simple. It was perfect for me at 5 in the morning and no sleep. 😏 Hopefully you enjoyed reading and have perhaps learned a few basic tools & tricks, feel free to ask any further questions if I've missed something out (I still haven't slept, so excuse any errors). Thanks for reading, - Ð3M0GORG0N RE: Toppo CTF Challenge Walkthrough - Beginner - Refr3sh - Jul 27, 2018 Well written guide and fun to read! Might give it a try soon :D RE: Toppo CTF Challenge Walkthrough - Beginner - Last_viking - Jul 27, 2018 Very helpful walk-through I'll try this soon RE: Toppo CTF Challenge Walkthrough - Beginner - whoredoor - Aug 2, 2018 This is awesome, thanks a lot! RE: Toppo CTF Challenge Walkthrough - Beginner - CyberStrike - Aug 4, 2018 Well done, and well written always good to see people practicing and in a safe environment. |