<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hjalte Abelskov</title>
    <description>The latest articles on DEV Community by Hjalte Abelskov (@habitminds).</description>
    <link>https://dev.to/habitminds</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F824759%2Fbdead5c3-04dd-4c6d-92da-ae2911c8c2b1.png</url>
      <title>DEV Community: Hjalte Abelskov</title>
      <link>https://dev.to/habitminds</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/habitminds"/>
    <language>en</language>
    <item>
      <title>A Beginner's Guide to Penetration Testing (Part 2)</title>
      <dc:creator>Hjalte Abelskov</dc:creator>
      <pubDate>Wed, 04 May 2022 11:23:20 +0000</pubDate>
      <link>https://dev.to/itminds/a-beginners-guide-to-penetration-testing-part-2-45h8</link>
      <guid>https://dev.to/itminds/a-beginners-guide-to-penetration-testing-part-2-45h8</guid>
      <description>&lt;p&gt;Hey everyone! I’m back at it with another blogpost about information-security or, more specifically, penetration testing.&lt;/p&gt;

&lt;p&gt;This blogpost constitutes the second part in my series on penetration testing. If you are not familiar with penetration testing in general, I highly recommend checking out my first post above where I go over penetration testing methodology and show you some tools that can be useful when enumerating a target.&lt;/p&gt;

&lt;p&gt;To finish off this mini series on penetration testing, my blogpost today will go over a target from HackTheBox. To be more precise, we'll be looking at one of their retired boxes named &lt;strong&gt;Blocky&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hu81GEk3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v64v4yxrck6iravvzqoz.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hu81GEk3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v64v4yxrck6iravvzqoz.PNG" alt="Image description" width="302" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For those of you who are new to HackTheBox, think of it as a big hacking playground with lots of targets varying in difficulty. For every target out there, you need to first &lt;strong&gt;gain a foothold&lt;/strong&gt; and then &lt;strong&gt;escalate your privileges&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Two .txt files exist on the target, and your goal is to submit the contents of both. The first .txt file is named user.txt, and submitting that will prove to HackTheBox that you’ve achieved &lt;strong&gt;foothold&lt;/strong&gt;. The second .txt file is named root.txt (even on Windows), and submitting that will prove to HackTheBox that you’ve achieved &lt;strong&gt;escalated privileges&lt;/strong&gt;, a.k.a root privileges (Administrator for Windows).&lt;/p&gt;

&lt;p&gt;The foothold flag is usually the hardest to obtain, or at least the one that requires the most steps, since it requires combing through lots of information about the services running on the server. I have intentionally not included some of the dead ends I ran into while doing this box.&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 1: Foothold
&lt;/h1&gt;

&lt;p&gt;We are given the following IP-address: &lt;strong&gt;10.10.10.37&lt;/strong&gt;&lt;br&gt;
First thing I did was to run an &lt;strong&gt;nmap scan&lt;/strong&gt; to see which services are running on the target. I specified -sV for versions and -p- for all ports. -oN tells nmap to output in “nmap format” to the specified file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X4qqLCmu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ec60kfaz9ap9r3hflu3r.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X4qqLCmu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ec60kfaz9ap9r3hflu3r.PNG" alt="Image description" width="880" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we see ftp, ssh, http and a minecraft server.&lt;br&gt;
Let’s go ahead and visit the website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8tgX4EEQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0b7wjnqy2bcdehytlwpq.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8tgX4EEQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0b7wjnqy2bcdehytlwpq.PNG" alt="Image description" width="880" height="573"&gt;&lt;/a&gt;&lt;br&gt;
It looks like a blog of some sort. Some might recognize that it resembles the standard Twenty Seventeen Wordpress theme. To find out more, I started a subdirectory-scan with &lt;strong&gt;Gobuster&lt;/strong&gt; while continuing to explore the site manually. Here, I specified -u for url and -w for wordlist.&lt;/p&gt;

&lt;p&gt;Looking at the source code, network traffic, etc. did not yield anything particularly useful, but eventually my Gobuster scan finished and showed me the following information:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ncRfIYI3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z99tx7jtua3cmg3nh0ii.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ncRfIYI3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z99tx7jtua3cmg3nh0ii.PNG" alt="Image description" width="880" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Aha! Here, we see a bunch of sites with 403 (Forbidden) and some 301s (Redirects/Hits).&lt;br&gt;
Also, we see /phpmyadmin and /plugins as well as some wordpress sites.&lt;br&gt;
We can navigate to phpmyadmin and try some default credentials, such as root:root, admin:admin, root:admin etc.&lt;br&gt;
We don’t get a hit, and since we don’t know any users, we are unable to progress much further in this direction right now.&lt;/p&gt;

&lt;p&gt;However, there is a great tool for Wordpress sites called wpscan. It automatically looks through posts, authors, themes, assets etc. to spot anything vulnerable or out of the ordinary.&lt;/p&gt;

&lt;p&gt;By running a command such as &lt;code&gt;wpscan --url http://10.10.10.37/ --enumerate u&lt;/code&gt;, we find a user named notch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KBMr7MRX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r6dinr9pp3k89dfv0xi.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KBMr7MRX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r6dinr9pp3k89dfv0xi.PNG" alt="Image description" width="734" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Meanwhile, if we visit /plugins we see two .jar files.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RmEC3gbB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aw30f2xdfzprni5hg80c.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RmEC3gbB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aw30f2xdfzprni5hg80c.PNG" alt="Image description" width="757" height="501"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I downloaded the first one, BlockyCore.jar, and unzipped it to find a BlockyCore.class file. Using a Java decompiler, I was able to read the contents.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7_bKOXJM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pgkhc23myefu1r4oamhw.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7_bKOXJM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pgkhc23myefu1r4oamhw.PNG" alt="Image description" width="702" height="535"&gt;&lt;/a&gt;&lt;br&gt;
Looks like we found some credentials!&lt;br&gt;
We now have two users: root and notch.&lt;br&gt;
Going back to the website, we can visit the /phpmyadmin endpoint and try logging in. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g6Gaqaah--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yc4bubaj31gwmx3g2yz8.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g6Gaqaah--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yc4bubaj31gwmx3g2yz8.PNG" alt="Image description" width="714" height="620"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It worked! We now have access to phpMyAdmin and can view the underlying database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eUGURBm1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tswy5rph18jlmrx90iz4.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eUGURBm1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tswy5rph18jlmrx90iz4.PNG" alt="Image description" width="847" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Usually, when gaining access to admin panels, you want to look for ways to upload files, read credentials, update permissions and such. Since phpmyadmin is using SQL, we can query the database and such. We can try uploading a webshell, which would allow us to execute commands on the server. The following command takes an input and writes it to /phpmyadmin/cmd.php (assuming the folder exists under /var/www/).&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT "&amp;lt;?php if($_GET['cmd']) {system($_GET['cmd']);} ?&amp;gt;"&lt;br&gt;
 INTO OUTFILE '/var/www/phpMyAdmin/cmd.php&lt;/code&gt;&lt;br&gt;
We are denied access though. But it was worth a shot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tOik3MUu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9p1xmup6ervt01ujx67i.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tOik3MUu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9p1xmup6ervt01ujx67i.PNG" alt="Image description" width="642" height="57"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  So far so good…
&lt;/h2&gt;

&lt;p&gt;Okay, so where are we with all the gathered information? Well, we have obtained two usernames and a password from diving into port 80. We were able to log into phpmyadmin but unable to run any SQL queries from there.&lt;/p&gt;

&lt;p&gt;However, a common scenario when dealing with lazy developers is the reuse of passwords. Don’t do this, people. Get a password manager and generate a new unique password every time, please.&lt;br&gt;
Anyhow, once we get credentials, it is usually a good idea to look for other services where we could try those credentials as well.&lt;/p&gt;

&lt;p&gt;Let’s remind ourselves what the other services were:&lt;br&gt;
Our &lt;strong&gt;nmap scan&lt;/strong&gt; showed us that the services running were ftp, ssh, http and minecraft.&lt;/p&gt;

&lt;p&gt;We try using the notch username with the password from before on the ftp server and manage to successfully log in.&lt;br&gt;
Here, we see the user.txt file. We can use the “get” command to download files over ftp.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FbJ_DgJ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9y6khvosf2x6o698hm9.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FbJ_DgJ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9y6khvosf2x6o698hm9.PNG" alt="Image description" width="623" height="307"&gt;&lt;/a&gt;&lt;br&gt;
And we are rewarded with our first flag! &lt;strong&gt;Foothold achieved!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gVm_4oox--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lmdxacfw6mjd6aurnakx.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gVm_4oox--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lmdxacfw6mjd6aurnakx.PNG" alt="Image description" width="656" height="203"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 2: Privilege Escalation
&lt;/h1&gt;

&lt;p&gt;With the SAME notch credentials used for FTP, I was also able to SSH into the box.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sXEjHzjp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5jl2ywxokifb5ahby2vk.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sXEjHzjp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5jl2ywxokifb5ahby2vk.PNG" alt="Image description" width="611" height="270"&gt;&lt;/a&gt;&lt;br&gt;
One of the first things to enumerate, when looking to escalate privileges on a system, is which rights you have as a user. Are you able to run some commands with elevated privileges?&lt;br&gt;
An easy way to see this on Linux is to run &lt;code&gt;sudo -l&lt;/code&gt; which will list all your sudo rights.&lt;br&gt;
Here, we see that we may run (ALL: ALL) ALL. This means we can run any command as the superuser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Jm6Ux3g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31uv5osxzc2ujg6prphe.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Jm6Ux3g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31uv5osxzc2ujg6prphe.PNG" alt="Image description" width="714" height="183"&gt;&lt;/a&gt;&lt;br&gt;
This makes for a &lt;strong&gt;&lt;u&gt;very&lt;/u&gt;&lt;/strong&gt; easy win with &lt;code&gt;sudo su root&lt;/code&gt;. Enter the credentials for notch and bam! We’re root.&lt;br&gt;
We can see the root.txt file, readable by our user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YsN-uM-s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7cvaxxh9urfu0h4dpwq.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YsN-uM-s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u7cvaxxh9urfu0h4dpwq.PNG" alt="Image description" width="513" height="215"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that is both of the proofs we need to submit to gain full points on the box!&lt;/p&gt;

&lt;p&gt;Were you able to follow along and understand everything that happened there?&lt;br&gt;
Let’s quickly recap the steps we took:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We scanned the site with &lt;strong&gt;nmap&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;On port 80, we found a website and performed a subdirectory-listing scan with &lt;strong&gt;Gobuster&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;We saw Wordpress files and used &lt;strong&gt;wpscan&lt;/strong&gt; to find a user named notch&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;/plugins&lt;/strong&gt; folder, we found a .jar file with some credentials&lt;/li&gt;
&lt;li&gt;We tried reusing the credentials on the other services (&lt;strong&gt;foothold&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;We were able to &lt;strong&gt;SSH&lt;/strong&gt; into the box&lt;/li&gt;
&lt;li&gt;With &lt;strong&gt;sudo -l&lt;/strong&gt; we listed our privileges and saw that we could run any command as root&lt;/li&gt;
&lt;li&gt;We switched to root user with the &lt;code&gt;sudo su root&lt;/code&gt; command which gave us root flag&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Alright, that wraps up my second post and this series on penetration testing!&lt;br&gt;
This post was a bit longer and a bit more technical than the first post, but translating theoretical knowledge into practical usage is often what helps you truly understand something new. &lt;br&gt;
I hope you learned something from this mini series on penetration testing - or at least enjoyed the reading :-) Feel free to post your questions below! &lt;/p&gt;

</description>
      <category>beginners</category>
      <category>penetrationtesting</category>
      <category>hacking</category>
      <category>hackthebox</category>
    </item>
    <item>
      <title>A Beginner's Guide to Penetration Testing (Part 1)</title>
      <dc:creator>Hjalte Abelskov</dc:creator>
      <pubDate>Thu, 21 Apr 2022 11:52:13 +0000</pubDate>
      <link>https://dev.to/itminds/a-beginners-guide-to-penetration-testing-part-1-4ki0</link>
      <guid>https://dev.to/itminds/a-beginners-guide-to-penetration-testing-part-1-4ki0</guid>
      <description>&lt;h2&gt;
  
  
  Disclaimer:
&lt;/h2&gt;

&lt;p&gt;Before we start, I feel the need to write a short disclaimer: remember that these are real hacking tools that should never be used without a formal agreement in place between the parties involved. These posts are meant to be a teaser with the goal of giving you, the reader, a sense of what penetration testing is and what to be aware of when building your applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a pentest?
&lt;/h2&gt;

&lt;p&gt;A pentest is essentially a simulated cyberattack on a computer system with the purpose of evaluating the security of the system. A pentest can be whitebox, meaning that the attacker has access to background and system information, or blackbox, meaning that the attacker has little or no information about the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we pentest?
&lt;/h2&gt;

&lt;p&gt;The UK National Cyber Security Center describes pentesting as &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A method for gaining assurance in the security of an IT system by attempting to breach some or all of that system’s security, using the same tools and techniques as an adversary might&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let me start by going over some quick glossary to ensure that we are all on the same page:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Target&lt;/strong&gt;: A target is typically a single IP address, but could also be a range of IP addresses.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Port&lt;/strong&gt;: A communication endpoint for the computer, numbered between 0-65535. Ports can be either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OPEN (If you send a SYN, you get back a SYN/ACK)&lt;/li&gt;
&lt;li&gt;UNFILTERED (The special ACK scan, used for mapping firewall rule sets, can sometimes return RST. This means that the port is accessible, but we can’t determine if it is open or closed).&lt;/li&gt;
&lt;li&gt;FILTERED (Target is behind some sort of firewall and packets get dropped / no response)&lt;/li&gt;
&lt;li&gt;CLOSED (When you send a SYN, it responds back with a RST).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;&lt;strong&gt;CVE&lt;/strong&gt;: Short for “Common Vulnerabilities and Exposures”. This is a method of indexing and referencing publicly known software vulnerabilities. There are roughly between 15,000 - 20,000 new CVEs reported each year.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7veomwcoh1bb9rwz4qk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn7veomwcoh1bb9rwz4qk.png" alt="ports below 1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Phases of a pentest
&lt;/h2&gt;

&lt;p&gt;You should know that there are 5 phases to professional pentesting, namely&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Planning&lt;/li&gt;
&lt;li&gt;Scanning&lt;/li&gt;
&lt;li&gt;Gaining Access&lt;/li&gt;
&lt;li&gt;Persistent Access&lt;/li&gt;
&lt;li&gt;Reporting&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this post, however, I want to focus mainly on phase 2 and 3 since that's where the exciting stuff happens.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Scanning
&lt;/h1&gt;

&lt;p&gt;When we scan a target, we are looking for information about which operating system and software might be running on the computer. Scanning for open ports tells us how the target can be interacted with, which often lets us infer a lot of information about the target. This is typically done with a tool called nmap.&lt;/p&gt;

&lt;p&gt;A scan could look like the following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6ft8mzcp3ywyhoyopin.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6ft8mzcp3ywyhoyopin.png" alt="Example nmap scan"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we see two open ports, namely port 22 (ssh) and port 80 (http). This indicates that the target is probably hosting one or more websites and has SSH access enabled for remote configuration. We can see it is running OpenSSH 7.4 and the website is Apache httpd 2.4.25. From this information alone, we may start looking for well-known vulnerabilities, also known as CVEs. Mitre has a CVE database (&lt;a href="https://cve.mitre.org/" rel="noopener noreferrer"&gt;https://cve.mitre.org/&lt;/a&gt;) we can look in. A website such as &lt;a href="https://www.exploit-db.com/" rel="noopener noreferrer"&gt;https://www.exploit-db.com/&lt;/a&gt; even goes as far as to provide working code exploits for a lot of known CVEs.&lt;/p&gt;

&lt;p&gt;On a different scan we might find a Domain Controller in an Active Directory which would be indicated by ports 53 (dns), 88 (kerberos), 135 (msrpc), 139 (netbios-ssn), 389 (ldap), 445 (file replication service), 464 (kerberos password change), 3268 and 3269 (ldap) being open.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Remember:&lt;/strong&gt; &lt;em&gt;Scanning the target and enumerating the attack vectors that come to mind is an iterative process and should be done continuously throughout the pentest.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;After our initial port scan, we might do more scans depending on what we find. In order to be as effective as possible, and to gather as much information as possible, pentesters are often running multiple scans simultaneously on a target. There are hundreds of tools out there for every service imaginable. Some of the tools worth mentioning are wpscan (&lt;a href="https://wpscan.com/wordpress-security-scanner" rel="noopener noreferrer"&gt;https://wpscan.com/wordpress-security-scanner&lt;/a&gt;) for Wordpress sites or sqlmap (&lt;a href="https://sqlmap.org/" rel="noopener noreferrer"&gt;https://sqlmap.org/&lt;/a&gt;) for automatic SQL injection. For a more extensive list of tools check out &lt;a href="https://0xcybery.github.io/ehtk/" rel="noopener noreferrer"&gt;https://0xcybery.github.io/ehtk/&lt;/a&gt; or &lt;a href="https://github.com/enaqx/awesome-pentest" rel="noopener noreferrer"&gt;https://github.com/enaqx/awesome-pentest&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  3. Gaining access
&lt;/h1&gt;

&lt;p&gt;This step will vary a lot based on the results of the second phase, but let’s assume a very common case: we see a website on port 80/443.&lt;br&gt;
First, we want to identify which technologies are being used. For this, there are several tools, but we can also poke at it manually.&lt;/p&gt;

&lt;p&gt;We could try to..&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Read the source code&lt;/li&gt;
&lt;li&gt;See if we get a hit on a well-known endpoint such as /wp-content/ for Wordpress, /user/login/ for Drupal, or /manager/html for Tomcat.&lt;/li&gt;
&lt;li&gt;Inspect the server responses and look for technologies used. This will sometimes also yield version numbers which makes it easy to look for existing exploits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we’re lazy we can use tools such as Nikto, WhatWeb, BuiltWith or Wappalyzer that will analyze which technologies are being used by the website for us.&lt;/p&gt;

&lt;p&gt;We can also use tools such as Gobuster to scan websites for subpages.&lt;br&gt;
Gobuster has a ton of features, but we will be using the url parameter and provide it with a wordlist of words to search for. Operating systems such as Kali Linux or ParrotOS come pre-installed with wordlists, but there are plenty of useful wordlists on Github we can use - check out &lt;a href="https://github.com/danielmiessler/SecLists" rel="noopener noreferrer"&gt;https://github.com/danielmiessler/SecLists&lt;/a&gt;. An example of this could be: &lt;br&gt;
&lt;code&gt;Gobuster -u https://site-we-want-to-scan/ -w /path/to/wordlist -t threads -o gobuster_scan_from_website_root&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;An output could look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fastc00dftkievtscn94v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fastc00dftkievtscn94v.png" alt="Initial gobuster scan example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If our wordlist is well-chosen, we now have a good overview of the site, and we can continue our attack based on what we find. As mentioned earlier, enumeration is a continuous process.&lt;/p&gt;

&lt;p&gt;With this new information, we could try a gobuster scan on &lt;a href="https://site-we-want-to-scan/images" rel="noopener noreferrer"&gt;https://site-we-want-to-scan/images&lt;/a&gt;, &lt;a href="https://site-we-want-to-scan/uploads" rel="noopener noreferrer"&gt;https://site-we-want-to-scan/uploads&lt;/a&gt; or &lt;a href="https://site-we-want-to-scan/assets" rel="noopener noreferrer"&gt;https://site-we-want-to-scan/assets&lt;/a&gt; to gain more information about which artifacts exist on the site.&lt;/p&gt;

&lt;p&gt;Well, this wraps up my first post on penetration testing!&lt;br&gt;
Thank you for reading! &lt;br&gt;
In the next post, I will get more hands-on as I walk you through how I hacked a target from the famous website HackTheBox.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>penetrationtesting</category>
      <category>hacking</category>
    </item>
  </channel>
</rss>
