<?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 Luke Wegryn on Medium]]></title>
        <description><![CDATA[Stories by Luke Wegryn on Medium]]></description>
        <link>https://medium.com/@luke_83192?source=rss-9cd8725f748d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*MNVALSclg2YOUnWENNuXQg.jpeg</url>
            <title>Stories by Luke Wegryn on Medium</title>
            <link>https://medium.com/@luke_83192?source=rss-9cd8725f748d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 16:58:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@luke_83192/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[DIY Web App Pentesting Guide]]></title>
            <link>https://medium.com/@luke_83192/diy-web-app-pentesting-guide-be54b303c6eb?source=rss-9cd8725f748d------2</link>
            <guid isPermaLink="false">https://medium.com/p/be54b303c6eb</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[web-pen-testing]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[diy]]></category>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[Luke Wegryn]]></dc:creator>
            <pubDate>Tue, 16 Apr 2019 14:01:52 GMT</pubDate>
            <atom:updated>2019-05-02T18:35:19.129Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_v4rCwzw9QDFGHoIbqzNJw.jpeg" /></figure><p>If you are curious about the state of your web application’s security, but you aren’t ready to have a full scale penetration test done; don’t fear. I am going to walk you through steps you can take to test your project’s security and gauge its resilience to attack. Attackers often scan thousands of websites looking for low hanging fruit. If you can ensure that your website is resilient to these wide net attacks, you will have a much lower chance of being hacked, and attackers will move on to juicier targets.</p><p>Whether you are a senior software developer at a Fortune 500 company or creating your first WordPress site, you know you need to secure yourself from attackers. You’ve heard in the news that Equifax and Yahoo! suffered attacks, and you wonder if you will be subject to the same fate sometime in the future.</p><p>Googling can provide you with a plethora of information. Hopefully you find some good pointers such as ensuring that your site uses HTTPS, adding a Web Application Firewall, installing security plugins, ensuring all of your software is up to date, hashing your passwords, etc. These are all important recommendations, and the more you can educate yourself early on, the less likely you’ll be to introduce vulnerabilities into your code. Security is a continually evolving process, and it’s best to build security into your development lifecycle.</p><p>Even if you do everything in your power to build security into your product, it’s likely there will still be security vulnerabilities that are impossible to identify until you put on the hat of an attacker and put your site through the wringer. In this article, I am going to walk you through some different ways you can perform your own mini penetration test.</p><p>I say “mini” because ultimately a full penetration test performed by trained security experts is paramount. But you may not have the resources to fund a penetration test, or you may feel you need a better understanding of security testing before you hire a professional.</p><p>No matter your reasons, there is very little downside in conducting your own mini penetration test. This exercise will help you build better security for your applications by introducing you to the way attackers think. So buckle up, and enjoy the ride!</p><h3>Part 1: Setting up your Testing Environment</h3><p>Before we jump into our penetration test, we are going to need to set up a practice environment. We will start by installing Kali Linux which is frequently used by penetration testers. This will be our “attacker machine” (remember you are the “attacker”). To be clear, the attacker machine will be where we launch our attacks from and the target machine/network will be the recipient of our attacks. Ultimately, once you are ready to test your own web application, you can use the same Kali Linux instance we set up in this guide to attack your site which will then be the “target machine/network”. Make sense?</p><p>If you have your own web application that you would like to test, I would recommend working through the examples in this guide first, and then once you feel comfortable, try these attacks against your own site. Please keep in mind that using what you learn here to attack sites you don’t own or are not given express permission to attack can be very illegal. Please exercise good judgement when deciding if you have the proper permission to attack a target.</p><h4>Setup your Kali Linux Instance</h4><p>Kali Linux provides many tools necessary for penetration testing all in one convenient place. I will be installing this on macOS and will show all of the these commands in macOS format.</p><p>If you are using Windows or Linux, you can watch the following YouTube videos which will walk you through installing Kali Linux.</p><ul><li>Windows: <a href="https://www.youtube.com/watch?v=YfxELlv7FpI">https://www.youtube.com/watch?v=YfxELlv7FpI</a></li><li>Linux: <a href="https://www.youtube.com/watch?v=dDbvA0AdQAA">https://www.youtube.com/watch?v=dDbvA0AdQAA</a></li></ul><p>Once we have Kali up and running, we will all be using the same Linux environment and everything will be more straightforward. We will set Kali up on macOS using this guide: <a href="https://www.kali.org/news/announcing-kali-for-vagrant/">https://www.kali.org/news/announcing-kali-for-vagrant/</a>.</p><p><em>Note: If you are using Windows or Linux, and are having trouble installing Kali using Vagrant, there are other ways to install Kali: </em><a href="https://docs.kali.org/category/installation"><em>https://docs.kali.org/category/installation</em></a><em>. As long as you get Kali running one way or another you will be able to follow the rest of this guide. If you get stuck, Googling “install kali linux on windows” or watching the youtube videos above should do the trick.</em></p><p>As this guide is geared toward developers, you are likely already familiar with the terminal. If not, then you may need to do some research on your own first and understand basic commands like cd and ls. There is a code academy course you can work through if you don’t know how to use the terminal: <a href="https://www.codecademy.com/courses/learn-the-command-line/lessons/navigation/exercises/your-first-command">https://www.codecademy.com/courses/learn-the-command-line/lessons/navigation/exercises/your-first-command</a>.</p><p><strong>If you are using macOS, then follow the rest of the instructions in this section. If not, please refer to those YouTube videos above and get Kali Linux installed in a virtual machine on your computer. Once you have Kali installed, move to part 2 of this guide.</strong></p><p>For macOS, we will need to install a package management tool called brew. This can easily be installed by opening the Terminal and pasting and running the following script:</p><pre>/usr/bin/ruby -e &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&quot;</pre><p>Now that you have brew installed, we need to install Vagrant (<a href="https://www.vagrantup.com/intro/getting-started/install.html">https://www.vagrantup.com/intro/getting-started/install.html</a>):</p><pre>brew update<br>brew cask install virtualbox<br>brew cask install vagrant</pre><p>Now that we have Vagrant installed, we can easily install Kali Linux:</p><pre>mkdir ~/kali-linux/; cd ~/kali-linux/<br>vagrant init offensive-security/kali-linux<br>vagrant up</pre><p>This may take some time to complete because Vagrant is pulling down a full copy of Kali Linux. Feel free to make some coffee and come back in a few. That’s what I’m going to do!</p><p>You’ll eventually see Kali Linux boot up and come to a screen like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aumJS8fdjU7lUlByTppEKg.png" /><figcaption>Kali Linux: Login Screen</figcaption></figure><p>The default credentials to login are username: root and password toor. Simply login with those credentials, and BOOM, Kali Linux is installed.</p><p>Before we move on to doing things in Kali Linux, let me give you a couple tips. When you are done using Kali Linux for the day, go back to your original terminal in macOS and type</p><pre>cd ~/kali-linux/<br>vagrant halt</pre><p>This will shut down Kali. When you want to start using it again, do the opposite</p><pre>cd ~/kali-linux/<br>vagrant up</pre><p>Magic!</p><p>Now that we have Kali Linux successfully installed and running, we are ready to move on to the next step.</p><h3><strong>Part 2: Basic Web Application Penetration Testing</strong></h3><p><em>Note: From here on out, I will be dropping tips about using the methods you learn in this guide to find vulnerabilities in your own application. I will italicize them to make them stand out.</em></p><p>Disclaimer: Before running any of the tools that we are going to cover in the following sections you must be the owner of the target you are testing or have written permission from the target owner. If not, you are doing something illegal.</p><p>For this guide we will use a website that is legal for us to test against because it was intentionally set up to be hacked. Thank you to Troy Hunt for setting this up. The website is: <a href="http://hack-yourself-first.com/">http://hack-yourself-first.com/</a>.</p><p>Now that you have everything setup and ready to go, we are going to walk through the basic penetration testing cycle. Here is a great diagram provided by RedCanari (<a href="https://blog.redcanari.com/2015/10/26/top-5-questions-to-ask-your-next-penetration-tester/">https://blog.redcanari.com/2015/10/26/top-5-questions-to-ask-your-next-penetration-tester/</a>). Not all penetration testers agree on how many steps there are, and sometimes the line between steps are blurred, but here is the general idea.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*zjvHhJib86c3zTF2AFqbnA.png" /><figcaption>Penetration Testing Cycle from RedCanari</figcaption></figure><p>As shown in the image, there are four main steps to a penetration test.</p><ol><li>Reconnaissance —This can be considered the “passive scanning” portion of the test. A lot can be learned about a website or corporation without needing to attack the site directly. The information enumerated in this step will help in later stages, and can be crucial to successfully finding important vulnerabilities.</li><li>Scanning —This can be considered the “active scanning” portion of the test. This stage is normally a combination of running tools and manually inspecting results to determine where vulnerabilities may exist. Most of this stage relies on a tester’s knowledge of how certain applications and systems work. Often in this stage, a tester will determine that it is likely a vulnerability exists.</li><li>Exploitation — This stage is where we exploit the vulnerabilities we believe we’ve identified. Exploiting a vulnerability may be as simple as running a known exploit or as complicated as writing custom exploits using assembly code.</li><li>Post-Exploitation — When we successfully exploit a vulnerability, we do two things: a) Ensure that a vulnerability we’ve identified is really a risk, b) gain deeper access into the application/system/network which opens up new possibilities for attack (pivoting). This is the reason there is an arrow pointing from Post Exploitation back to Recon. Usually once we gain a new level of access we have to start the cycle over again.</li></ol><p>Now that you have a basic idea of the 4 steps of penetration testing, we are going to run through some examples of each that you will ultimately be able to use against your own environment to test your security. There are so many tools out there that there is no way to cover even a small portion of them in this guide, but this will be a great starting point and give you the confidence to move beyond this guide and discover additional ways to test your application.</p><p>Keep in mind that no matter how good you get at using the tools we cover, the tools will often miss a lot of vulnerabilities. Tools are a great asset, but they must be used effectively and in combination with a brain that is experienced at identifying and exploiting vulnerabilities.</p><p>That’s why it’s crucial that you eventually hire a professional penetration tester who will have a greater grasp of the tools we are going to use. They will be able to use the information they gather in a more purposeful way, and will perform lots of manual testing required to identify certain vulnerabilities. If you are looking for a reliable and experienced penetration testing service please reach out to us at <a href="https://pensivesecurity.io./">https://pensivesecurity.io.</a></p><p>Without further ado, let’s get down to business!</p><h4><strong>Part 2a: Reconnaissance</strong></h4><p>In this stage we are going to do some passive information gathering about a target company and website without actually attacking the site. There are many ways to approach this, but we will go over just 2 as examples. Namely, Google Dorking and ReconNG.</p><p><strong>Google Dorking</strong></p><p>Google Dorking simply means making queries on Google that reveal information about websites.</p><p>For example, many people connect security cameras to the Internet and leave them completely unauthenticated. This is often because camera systems are insecure by default. For example, if you Google the following</p><pre>inurl:/view.shtml</pre><p>and click one of the links, you will find a plethora of insecure security cameras that you can creepily watch. If you want to look at even more things like this, simply try out some of the dorks on <a href="https://www.exploit-db.com/google-hacking-database">https://www.exploit-db.com/google-hacking-database</a>.</p><p>Google Dorking is more than just for fun though. Dorking can give you tons of information about a target such as email addresses, passwords, usernames, and other sensitive data without you even needing to go to the website.</p><p>For example, if our target was <a href="http://hack-yourself-first.com/">http://hack-yourself-first.com/</a><a href="https://hackthissite.org,/">,</a> we could start making specific Google searches that may reveal information about the target company. Here is a list of some examples to try. Try to see if you can understand what these searches are doing:</p><pre>site:hack-yourself-first.com filetype:pdf</pre><pre>password filetype:pdf site:hack-yourself-first.com</pre><pre>?action= site:hack-yourself-first.com</pre><p>If you want a list of more dorks to try, look at: <a href="https://gbhackers.com/latest-google-dorks-list/">https://gbhackers.com/latest-google-dorks-list/</a>.</p><p><em>Note: By running through these examples against your own application url, you can determine if you are revealing any sensitive information about yourself or your users (think email addresses, passwords, internal documents, etc). If dorking against your own site turns up this information, you will need to update your site to remove that sensitive data or put that information behind authentication.</em></p><p><strong>Recon-Ng</strong></p><p>Another way to find out a lot of interesting information about a target is to use a tool called Recon-Ng in your Kali Linux instance. It comes preinstalled, but you an see the source code here if you want: <a href="https://bitbucket.org/LaNMaSteR53/recon-ng">https://bitbucket.org/LaNMaSteR53/recon-ng</a>.</p><p>Go ahead an open up your Kali Linux instance, and open up a new terminal.</p><p>Type the following into your terminal:</p><pre>recon-ng</pre><p>This will open up the recon-ng application. It should look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gIk3coihdXu41_FgwOeW9g.png" /><figcaption>Kali Linux: Recon-Ng</figcaption></figure><p>Now we need to set our target. This time we are going to use hackthissite.org as our example since it will give us more interesting results than hack-yourself-first.com.</p><pre>workspaces add hackthissite<br>add domains hackthissite.org</pre><p>Now we can attempt to find some of the subdomains associated with this site using Bing.</p><pre>use recon/domains-hosts/bing_domain_web<br>run</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dFRgXxTDt7QyuR9-DsYZgA.png" /><figcaption>Kali Linux: Recon-Ng Subdomains Bing</figcaption></figure><p>Wow! 14 subdomains. We originally thought our target was only hackthissite.org, but now we know that the attack surface is much bigger. Let’s try to identify even more subdomains.</p><pre>use recon/domains-hosts/google_site_web<br>run</pre><p>Doing that found us another 2 subdomains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-hbGTGAOjaNutyqp0-7DXw.png" /><figcaption>Kali Linux: Recon-Ng Subdomains Google</figcaption></figure><p>The last method we will attempt to find subdomains with is brute force (this may take a few minutes):</p><pre>use recon/domains-hosts/brute_hosts<br>run</pre><p>Awesome! We found 31 more:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z0GG-oOlGdqbpI9Wkw_l_A.png" /><figcaption>Kali Linux: Recon-Ng Subdomains Brute Force</figcaption></figure><p>Now that we’ve run those 3 scans, let’s print out all of the domains we’ve found so far.</p><pre>show domains</pre><p>Some of the domains in the list might be repeats, but you can see how large this attack surface is. One domain that really sticks out to me is “admin.hackthissite.org”. That is something I would look at in detail to see if I could gain access to a privileged account.</p><p><em>Note: You can run these commands against your own website too. If you have subdomains that shouldn’t exist, you can make your attack surface a lot smaller by removing subdomains you’re not using.</em></p><p>Let’s take this a step further and see if we can use Recon-Ng to find even more information about hackthissite.org. We can use Recon-Ng to take the list of hosts we identified and find other valuable information such as email addresses, additional IPs, interesting files, and more. Try out the following commands in Recon-NG and see what you find.</p><pre>use recon/domains-hosts/netcraft<br>run</pre><pre>use recon/hosts-hosts/resolve<br>run</pre><pre>use recon/hosts-hosts/reverse_resolve<br>run</pre><pre>use discovery/info_disclosure/interesting_files<br>run</pre><pre>use recon/domains-contacts/whois_pocs<br>run</pre><pre>use recon/domains-contacts/pgp_search<br>run</pre><pre>use recon/contacts-credentials/hibp_paste<br>run</pre><p>There are tons of commands in addition to these that you can do. These are just scratching the surface. For more information type “help” in the Recon-Ng terminal prompt, or go to the usage guide here: <a href="https://bitbucket.org/LaNMaSteR53/recon-ng/wiki/Usage%20Guide">https://bitbucket.org/LaNMaSteR53/recon-ng/wiki/Usage%20Guide</a>.</p><p>Once you are satisfied that you have run all of the commands you desire, you can generate a report.</p><pre>use reporting/html<br>set CREATOR YOUR_NAME<br>set CUSTOMER YOUR_CLIENT<br>run</pre><pre>firefox /root/.recon-ng/workspaces/hackthissite/results.html</pre><p>As I mentioned before, there is so much more we could do in terms of Reconnaissance. If you don’t believe me, just look at the number of tools under “Information Gathering” on the Kali tools website: <a href="https://tools.kali.org/tools-listing">https://tools.kali.org/tools-listing</a>. These tools are all installed by default on Kali Linux. Feel free to give any of them a whirl!</p><p>In the next section we will begin active scanning our targets.</p><h4><strong>Part 2b: Scanning and Exploiting</strong></h4><p>We will now run a few different tools that perform active scanning. These tools will send lots of traffic to the target to help us identify potential vulnerabilities that we can look at in detail. As with the last section, there simply isn’t enough room in this guide to go through all the different tools that can be used. However, we will focus on tools that do a lot for you automatically.</p><p>For this section of the guide, this is our target: <a href="http://hack-yourself-first.com./">http://hack-yourself-first.com.</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ui9juqwS5S__tXPqhhrK4g.png" /><figcaption>Hack Yourself First</figcaption></figure><p>This is the site that we will be testing. As you can see there is a “Register” and “Login” button along with a bunch of car content. This website is intentionally left vulnerable so that people like us can practice our pentesting skills.</p><p>Now let’s start using some tools!</p><p><strong>Whatweb</strong></p><p>One easy tool right off the bat is Whatweb. This tools gives us lots of information about how the target site is setup.</p><p>Simply open up a terminal in Kali Linux, and run the following:</p><pre>whatweb hack-yourself-first.com</pre><p>You will see the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4pv5Jgj5kqO9UrJ6A4bJzQ.png" /><figcaption>Output from Whatweb</figcaption></figure><p>As you can see, there is a lot of information about what technologies are used and the version number associated. If any of these have known exploits, then they could be vulnerable to attack.</p><p><em>Note: When you run this against your own site, Google each of the names and version numbers along with the word “exploit” and see if any known exploits exist. For example, in the above case we would Google: “Microsoft IIS 10.0 exploits”.</em></p><p>Now we are going to move on to a more powerful tool called Nmap.</p><p><strong>Nmap</strong></p><p>We will start by scanning our target with Nmap (explained below): hack-yourself-first.com/.</p><p>First, let’s see what options Nmap has:</p><pre>nmap --help</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zMxSXPtZ-PvZ1M79bG3pcg.png" /><figcaption>Nmap: — help</figcaption></figure><p>Woah! That’s a lot of options. Especially if you’ve never used Nmap before, that list will seem extremely overwhelming.</p><p>We are going to do a couple simple scans in this example. If you want more information about the countless things Nmap can do, feel free to read here: <a href="https://nmap.org/book/man.html">https://nmap.org/book/man.html</a>.</p><p>Let’s start with a ping scan.</p><pre>nmap -sP hack-yourself-first.com</pre><p>Quickly, we get the following results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rPMTu0033WQXbtrYfFPnEQ.png" /><figcaption>NMAP Ping Results</figcaption></figure><p>This ran a quick Nmap ping scan to determine if the target we are attacking is actually running. As you can see by the “1 IP address (1 host up)” we have found a target that is in fact running. We have also found that the IP address is: 104.42.152.64.</p><p>Now we are going to do a much more in depth scan to see which ports are open. This will give us an idea of our attack surface, and let us know if anything else is running besides just the website that you see when you navigate to <a href="http://hack-yourself-first.com./">http://hack-yourself-first.com.</a></p><p>Run the following</p><pre>nmap -A hack-yourself-first.com</pre><p>While the scan is running, I’ll give a brief explanation of what’s happening. Nmap is an incredible tool that uses a variety of methods to determine which ports are open on a machine and what services are running on them. It also does a plethora of other things like run additional testing scripts, determines which operating system and version the target is running on, and much more. Nmap is the Swiss army knife of the network pentesting world. We are keeping things simple and using the -A option, which does a pretty comprehensive scan of the target without getting into the nitty gritty details of what’s going on. Once the scan is complete you should see something like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hVO8dLGIGxCnag6Z0nVENw.png" /><figcaption>NMAP Scan of Hack Yourself First</figcaption></figure><p>Right away we’ve discovered some very interesting information about our target! For instance, it appears two ports are open: 443 and 80. Generally port 443 runs the HTTPS version of the website, and port 80 runs the HTTP version. In addition, the scan shows us that the web server is running Microsoft IIS httpd 10.0 and it has 2 especially interesting directories /secret/admin and /api/admin/users.</p><p>It’s always a good idea to google the versions of the services you find to see if there are any known exploits. After googling “microsoft iis 10 exploits” I see: <a href="https://vuldb.com/?id.98097">https://vuldb.com/?id.98097</a>. So it appears there is at least one known vulnerability.</p><p><em>Note: If this was your web application, you would want to double check to make sure that your IIS server was fully up to date and fully patched.</em></p><p>For now, we will move on to the other interesting directories Nmap found. Let’s start with /secret/admin. To see what’s there we simply go to: <a href="http://hack-yourself-first.com/secret/admin">http://hack-yourself-first.com/secret/admin</a> in a web browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZTEYSU9T2Oahi3MKvZk6cg.png" /><figcaption>Access Denied: /secret/admin</figcaption></figure><p>Darn. It looks like this endpoint is behind access controls. Let’s move on to the other directory Nmap found: /api/admin/users. Again, we can view this simply by navigating to <a href="http://hack-yourself-first.com/api/admin/users">http://hack-yourself-first.com/api/admin/users</a> in our web browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uVle2ff83Y3NfcZfi2ACWQ.png" /><figcaption>Found Credentials</figcaption></figure><p>Woah! Jackpot! We’ve found a list of usernames and passwords. Even worse, the passwords are in plain text! They should be encrypted. Also, there is a field called “IsAdmin” in this data. For many of them the value is “null”, but if we look through we find that there are actually a couple where we see “IsAdmin”:true. These are the credentials we will extract and attempt to log in with. These credentials may be different by the time you read this guide, so you will need to search (Ctrl+F) the webpage for “true” and find credentials that match your search.</p><pre>{&quot;UserId&quot;:28,&quot;Email&quot;:&quot;LKP11209@yahoo.com&quot;,&quot;FirstName&quot;:&quot;Michael&quot;,&quot;LastName&quot;:&quot;Lebowski&quot;,&quot;IsAdmin&quot;:true,&quot;Password&quot;:&quot;LKP11209&quot;},<br>{&quot;UserId&quot;:30,&quot;Email&quot;:&quot;lolboaeoihnaf@qwrfnq.com&quot;,&quot;FirstName&quot;:&quot;John&quot;,&quot;LastName&quot;:&quot;Smith&quot;,&quot;IsAdmin&quot;:true,&quot;Password&quot;:&quot;poopoo&quot;},<br>{&quot;UserId&quot;:64,&quot;Email&quot;:&quot;asd@s.com&quot;,&quot;FirstName&quot;:&quot;asdsad&quot;,&quot;LastName&quot;:&quot;sadasd&quot;,&quot;IsAdmin&quot;:true,&quot;Password&quot;:&quot;asd&quot;},</pre><p><em>Note: If you find something like this on your website, you would need to fix this ASAP. This would be really bad on a real site.</em></p><p>We can now attempt to login to the website using a pair of our admin credentials. We will use the first set we found:</p><pre>Username: LKP11209@yahoo.com<br>Password: LKP11209</pre><p>We go to the login screen (<a href="http://hack-yourself-first.com/Account/Login">http://hack-yourself-first.com/Account/Login</a>) and enter our credentials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9oT6VsCt0xT8ynK7qGO1vg.png" /><figcaption>Login with Admin Credentials</figcaption></figure><p>When we click Login we see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vP7oF_Cg_1fofpydTsZzjQ.png" /><figcaption>Admin Dashboard</figcaption></figure><p>Wow! We found valid Admin login credentials. This means we now have access to an Admin account. As you can see this is a very bad vulnerability.</p><p>At this point we would want to record the details of what we have found and take screenshots so that we don’t forget about what we’ve found here. During a normal penetration test, we would use our increased level of access to see what capabilities we have as admin. Now that you’re logged in as an admin try to see what is at the /secret/admin endpoint again.</p><p><em>Note: Nmap will undoubtedly return different results for your own website. Look through each line of the output, and try to determine if it provides information that might be useful to an attacker. When in doubt, Google it! Then once you identify an issue with your site, Google the issue for tips on how to fix it.</em></p><p>For this guide, we are going to continue by exploring other scanning tools so that you learn different ways to test your site if NMAP doesn’t discover anything interesting.</p><p>Specifically, let’s now take a look at Nikto.</p><p><strong>Nikto</strong></p><p>Nikto is an easy to use web application scanner. It uses a variety of testing methods to find vulnerabilities in a web app.</p><p>To get started with Nikto, let’s go to our Kali Linux terminal and type the following:</p><pre>nikto --help</pre><p>This will output the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atoecS8x9UWRSkJdon8ABA.png" /></figure><p>As you can see there are lots of different options we can use. We are going to keep things simple, and just run the basic scan.</p><p>Run:</p><pre>nikto -h hack-yourself-first.com</pre><p>This is running the scan against port 80. We can also run the scan against the other open port we found, 443. However, since 443 uses SSL, we need to add the ssl flag to the command.</p><pre>nikto -h hack-yourself-first.com -ssl</pre><p><em>Note: The command you use against your website will depend on whether or not you are using HTTPS. In general, there is almost no reason to use HTTP. If your site has a login mechanism, or transmits any sensitive data you should be using HTTPS. Even if you don’t do anything sensitive on your website, using HTTPS gives your users confidence that your site is secure even if it isn’t explicitly necessary.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eLOg3RoWlXIMpssFcLvYNA.png" /><figcaption>Nikto Scan Output</figcaption></figure><p>Take a look through the results. There is quite a lot of output here.</p><ol><li>There are a few recommendations for adding or changing certain HTTP headers.</li><li>We see the /secret/admin and /api/admin/users endpoints again. We have already explored those.</li><li>We see that there is a /robots.txt file containing 4 entires (likely the same endpoints we’ve already identified)</li><li>There is a /backup.zip file. This is very interesting.</li><li>There is a /help/ directory which could be very interesting.</li></ol><p><em>Note: When you run this against your web application, you should go through each line of this output one at a time to see what you need to fix it. Google is your best friend when it comes to this. You can simply Google the issue, and you will find answers.</em></p><p>Let’s start by looking at robots.txt at <a href="http://hack-yourself-first.com/robots.txt">http://hack-yourself-first.com/robots.txt</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*60u2ptrSsCnOyzcHfj0Y7A.png" /><figcaption>Robots.txt</figcaption></figure><p>Great, so these are the same files from before. If we try to look through the images and scriptsdirectories, we get access denied.</p><p>Let’s move on to the /backup.zip file located at <a href="http://hack-yourself-first.com/backup.zip">http://hack-yourself-first.com/backup.zip</a>. We are able to download it, and it has the following content:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YW6q3MC2SPrQcKpEsAaeiQ.png" /><figcaption>backup.zip</figcaption></figure><p>As the file states, many websites store a backup file here which would give an attacker access to the website’s code and possibly other sensitive files.</p><p><em>Note: If you have a file like this on your system, or any other file that you don’t want people to see, you will need to move it outside your website directory so that it’s not accessible to any web user.</em></p><p>If we continue on to explore the /help/ directory found by Nikto (<a href="http://hack-yourself-first.com/help/">http://hack-yourself-first.com/help/</a>), we see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0CykyQkVcRjAjP7hu7s3uw.png" /><figcaption>Help Page</figcaption></figure><p>This is great! This provides us with some information on how we can interact with the website’s API. Looking at those parameters in <a href="http://hack-yourself-first.com/Help/Api/GET-api-supercar-leaderboard_limitResults">GET api/supercar/leaderboard?limitResults={limitResults}</a> and <a href="http://hack-yourself-first.com/Help/Api/GET-api-supercar-id">GET api/supercar/{id}</a>, these could potentially be vulnerable to XSS or an SQL injection.</p><p>Let’s check to see if these endpoints (or any others on the site) are vulnerable to an SQL injection.</p><p><strong>SQL Injection and SQL Map</strong></p><p>SQL Injection is a common vulnerability found on websites that use an SQL database. SQL makes it easy to string together complicated search queries to locate and process data in the database. SQL does a lot of things very well, however it has some security downsides. Because SQL combines the data plane (query parameters) and the control plane (commands) into a single string, it can give attackers a way to inject commands into SQL statements and do things the website admin didn’t intend such as bypassing a login or returning all of the passwords in the database instead of the intended data. I would recommend reading this easy to understand article by W3 Schools on SQL injection so that you have a better idea of what it means (<a href="https://www.w3schools.com/sql/sql_injection.asp">https://www.w3schools.com/sql/sql_injection.asp</a>).</p><p><em>Note: Before I go any further, I should point out that if you don’t use an SQL database (such as Postgres, MySQL, or Microsoft SQL Server) then you don’t need to worry about SQL injection. However, many websites use SQL, so it’s good to be aware of it anyway.</em></p><p>Back to our <a href="http://hack-yourself-first.com/help/">http://hack-yourself-first.com/</a> example. As we saw, there are a couple of website endpoints that allow us to inject our own parameters. For example, <a href="http://hack-yourself-first.com/Help/Api/GET-api-supercar-leaderboard_limitResults">GET api/supercar/leaderboard?limitResults={limitResults}</a>. At this point, we have no reason to believe SQL injection is possible, except that anytime we (as attackers) have inputs we control, our ears should prick up. If we are able to inject some SQL into either of those parameters, we could potentially gain access to a lot of sensitive data.</p><p>Before we try to do any SQL injection, let’s go through the website and make a list of URLs that let a user control the input to a parameter. You can do this by simply clicking around the site, and looking at the URL in the address bar. If it has a query string (?something=something ) then that means we may have a place to try an SQL injection.</p><p>Here are some URLs with query strings that I found (see if you can find the same ones by clicking around yourself):</p><pre><a href="http://hack-yourself-first.com/Supercar/Leaderboard?orderBy=PowerKw&amp;asc=false">http://hack-yourself-first.com/Supercar/Leaderboard?orderBy=PowerKw&amp;asc=false</a></pre><pre><a href="http://hack-yourself-first.com/Make/2?orderby=supercarid">http://hack-yourself-first.com/Make/2?orderby=supercarid</a></pre><pre><a href="http://hack-yourself-first.com/Search?searchTerm=adsf">http://hack-yourself-first.com/Search?searchTerm=adsf</a></pre><pre><a href="http://hack-yourself-first.com/CarsByCylinders?Cylinders=V10">http://hack-yourself-first.com/CarsByCylinders?Cylinders=V10</a></pre><p>We will use a tool called Sqlmap (<a href="http://sqlmap.org/">http://sqlmap.org/</a>) to try to identify SQL injections, but first let’s just just see what happens when we start putting weird data into an endpoint.</p><p>For example, let’s take this URL: <a href="http://hack-yourself-first.com/Make/2?orderby=supercarid">http://hack-yourself-first.com/Make/2?orderby=supercarid</a>. You can see this URL has the parameter orderby with the value supercarid. What if we put in a bogus parameter such as -1? Here is the URL:</p><p><a href="http://hack-yourself-first.com/Make/2?orderby=-1">http://hack-yourself-first.com/Make/2?orderby=-1</a></p><p>Go to that URL in your browser and you will see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZikuqCeRxFfD_Z6R3u058Q.png" /><figcaption>SQL Error</figcaption></figure><p>Wow! Look at that. We receive an error. If you look closely at “Exception Details”, you can see that it says:</p><pre>System.Data.SqlClient.SqlException: The ORDER BY position number -1 is out of range of the number of items in the select list.</pre><p>Great! That indicates that the website does in fact use an SQL database, and therefore could potentially be vulnerable to SQL injection.</p><p>Now it’s time to use Sqlmap. This tool is really amazing, and like many other tools we have used thus far, it has a ton of options. We are going to do things the easy way.</p><p>We are going to tell Sqlmap to look for an SQL injection in that URL (<a href="http://hack-yourself-first.com/Make/2?orderby=supercarid">http://hack-yourself-first.com/Make/2?orderby=supercarid</a>), and if there is an injection we are going to try to steal all of the data out of the database.</p><p>Open a terminal in Kali and enter the following:</p><pre>sqlmap --dump-all -u <a href="http://hack-yourself-first.com/Make/2?orderby=supercarid">http://hack-yourself-first.com/Make/2?orderby=supercarid</a></pre><p>While it’s running, Sqlmap will ask you 3 questions and wait for you to answer. Simply hit “Enter” on your keyboard each time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_RKHUeK36SmJxVzZR-b3iw.png" /><figcaption>Hit Enter after First Two Questions</figcaption></figure><p>Wohoo! Sqlmap has told us that it looks like the orderbyparameter is vulnerable.</p><p>This means that we are now able to retrieve the data out of the database. Simply hit “Enter” again on your keyboard to continue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LYri8MbRDSz4eCkyr07uUg.png" /><figcaption>Hit Enter again after Third Question</figcaption></figure><p>Sqlmap will now need to run for about 15 minutes or so to successfully extract all of the data.</p><p>Once it’s finished, we can poke around at all the data it found. We can open the folder where the data files were exfiltrated. Type the following in the terminal:</p><pre>xdg-open /root/.sqlmap/output/hack-yourself-first.com/dump/hackyourselffirst_db/</pre><p>A window should open and you should see files like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HcLncfsaS7xkp7jlQbPkYg.png" /><figcaption>Files Dumped by Sqlmap</figcaption></figure><p>Let’s take a look at UserProfile.csv (double click it).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZAVl70hs5iNh_idDkRrYXQ.png" /><figcaption>UserProfile.csv</figcaption></figure><p>As you can see, Sqlmap was able to successfully steal the user information, including clear text passwords! This is similar to the data we saw earlier (with the <a href="http://hack-yourself-first.com/api/admin/users">http://hack-yourself-first.com/api/admin/users</a> endpoint), but we were able to get this data using a completely different vulnerability.</p><p>Feel free to explore the other files in that folder, it may be interesting as well.</p><p>There is quite a bit more that can be done with this SQL injection than just reading data from the database. We can actually write data to the database as well! Sometimes with an SQL injection, you can even achieve remote code execution, and gain access to the remote server’s underlying operating system. We won’t go over how to do that in this guide but you can try yourself if you are interested (thorough example here: <a href="https://www.acunetix.com/blog/articles/exploiting-sql-injection-example/">https://www.acunetix.com/blog/articles/exploiting-sql-injection-example/</a>)</p><p><em>Note: Don’t worry, there are ways to prevent SQL injection via parameterizing queries, and a quick Google search will give you tons of information on how to fix any issues you have.</em></p><p><em>Another Note: When you try this on your own site, the first URL may not be susceptible to SQL injection, so try out as many URLs with injectable parameters as you can.</em></p><p><strong>Dirb</strong></p><p>Dirb is another easy to use tool in Kali Linux that helps us enumerate a website and find hidden files and directories.</p><p>It’s extremely easy to use, simply run the following in a Kali terminal:</p><pre>dirb <a href="http://hack-yourself-first.com/help/">http://hack-yourself-first.com</a></pre><p>This tool will take a while to run, but it will locate some additional files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-VQNqbEHfjTg1Aw2fZK8vQ.png" /></figure><p>In this case, none of the additional files it found are particularly interesting, however this tool often finds very interesting files and directories.</p><p><em>Note: As with earlier tools we ran, when you run this tool against your site, navigate to the different directories and files it detects and see if any sensitive information is exposed or any additional access is granted.</em></p><p><strong>Uniscan</strong></p><p><a href="https://tools.kali.org/web-applications/uniscan">Uniscan</a> is another easy to use tool that will do a bunch of tests against your website for the issues we have talked about so far (like SQL injection) and many others, such as Cross Site Scripting, Remote and Local File Inclusion, Path Traversal, and more.</p><p>You can run it in your terminal like so:</p><pre>uniscan -u <a href="http://hack-yourself-first.com/">http://hack-yourself-first.com</a> -qweds</pre><p><em>Note: As before, look through the output and see if anything stands out. Google any issues to learn more.</em></p><h4>Part 2c: Post-Exploitation</h4><p>At this point we have gone through quite a few tools, and we have exploited a few vulnerabilities. We should take a step back and see what we have gained access to:</p><ol><li>We can see all usernames and passwords using the <a href="http://hack-yourself-first.com/api/admin/users">http://hack-yourself-first.com/api/admin/users</a> endpoint. We used this to log into an admin account.</li><li>We know the version numbers of most of the services involved in running the web application.</li><li>We have noticed that the site doesn’t use HTTPS by default.</li><li>We could see a (simulated) backup file often containing the entire code of the website.</li><li>We can perform SQL injections and steal data out of the database. We may also be able to write and execute code on the server as well.</li></ol><p>On top of those 5 items, we have also gleaned a lot of other information about the hack-yourself-first website.</p><p>If we were working on a real penetration test, we would run a status check to evaluate our situation. Do we have access to anything now that we need to explore deeper? What common attacks (such as the <a href="https://www.owasp.org/images/7/72/OWASP_Top_10-2017_%28en%29.pdf.pdf">OWASP Top 10</a>) have we not attempted yet? Have we discovered any new information that may hint at a vulnerability that needs to be explored?</p><p>Alas, those are questions for another day.</p><p>Take a moment to pat yourself on the back. Great job! You found some serious security vulnerabilities on hack-yourself-first.com, and hopefully you were able to try the same techniques against your own site as well. You likely have a better idea of your own website’s security, and a better idea of how a penetration tester might evaluate your web application.</p><h3>Part 3: Conclusion</h3><p>Hopefully you enjoyed putting on the hat of an attacker and using some of the tools that a pentester might use during a test of your web application. Despite us finding serious issues with hack-yourself.com, there are still many potential vulnerabilities on that site that we couldn’t cover in this guide because they aren’t easily identified by running “point and shoot” tools.</p><p>For instance, we haven’t looked for other common web application attacks like arbitrary file uploads, path traversals, CSRF, XSS, access control issues, broken authentication, XML injection, and many other attacks.</p><p>I should stress again that what we covered in this guide doesn’t constitute a real penetration test. The tools we covered look for known vulnerabilities, and give you a general idea of your security, but they miss a lot. For instance, the site we were testing against (hack-yourself-first.com) has around 50 security vulnerabilities, and the tools we used found around 5.</p><p>If you wish you could <strong>hire a professional to do this type of security work for you</strong>, please check us (Pensive Security) out at <a href="https://pensivesecurity.io,/">https://pensivesecurity.io</a> and contact us via the contact form at the bottom of the page. We’d be happy to meet with you and determine if we are a good fit for your needs.</p><p>On the other hand, if this guide has left you wanting more, we have barely scratched the surface of web application penetration testing. In fact, we haven’t even talked about one of the best tools and testing environments yet! If you put in the time and the effort, you can greatly improve your security prowess with free online resources.</p><h4><strong>Epilogue: Burp Suite and Google Gruyere</strong></h4><p>It would be wrong to write a guide about web application penetration testing and not mention Burp Suite. Burp Suite is, at its core, a web proxy but with tons of useful features integrated it. Out of all of the tools that we have looked at so far, Burp Suite is probably the best for web application pentesting. The reason we didn’t go over it in depth is because it requires more technical knowledge to setup and use then the other tools we went over.</p><p>The tools that we have used thus far are mostly “point and shoot”, meaning you just put in the URL of the victim site, and the tool does the rest.</p><p>Burp Suite isn’t quite like that, and requires more setup (<a href="https://support.portswigger.net/customer/portal/articles/1783066-configuring-firefox-to-work-with-burp">https://support.portswigger.net/customer/portal/articles/1783066-configuring-firefox-to-work-with-burp</a>). However, if you are interested in learning how to use it, I highly suggest you use it in conjunction with Google Gruyere (<a href="https://google-gruyere.appspot.com/">https://google-gruyere.appspot.com/</a>)</p><p>Google Gruyere is another intentionally vulnerable website, and it’s a great place to learn how to use Burp along with other tools not covered in this guide. Google Gruyere has guides on how to exploit every single vulnerability on the site here (<a href="https://google-gruyere.appspot.com/part1">https://google-gruyere.appspot.com/part1</a>).</p><p><em>Note: Once you hone your skills using Burp Suite against Google Gruyere you can perform the same types of attacks against your own web app to find vulnerabilities we didn’t cover like XSS, CSRF, and more.</em></p><p>Happy Hunting!</p><p>PS: If you want to play around with other Kali tools we didn’t cover in this guide, head over to <a href="https://tools.kali.org/">https://tools.kali.org/</a>.</p><p><em>Credits: Thank you to </em><a href="https://www.linkedin.com/in/brianna-wegryn/"><em>Brianna Wegryn</em></a><em> and </em><a href="https://www.linkedin.com/in/jason-kraft-696331a5/"><em>Jason Kraft</em></a><em> for reviewing and improving this article.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be54b303c6eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>