<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Adeen Ali on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Adeen Ali on Medium]]></description>
        <link>https://medium.com/@madeenali2003?source=rss-15d328f31bbd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vDhDpJJR8kxZA0Gxx1VGvg.jpeg</url>
            <title>Stories by Muhammad Adeen Ali on Medium</title>
            <link>https://medium.com/@madeenali2003?source=rss-15d328f31bbd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 18:16:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@madeenali2003/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Getting Started with Metasploit: A Beginner’s Guide to Ethical Penetration Testing]]></title>
            <link>https://medium.com/@madeenali2003/getting-started-with-metasploit-a-beginners-guide-to-ethical-penetration-testing-46ff2fa32062?source=rss-15d328f31bbd------2</link>
            <guid isPermaLink="false">https://medium.com/p/46ff2fa32062</guid>
            <dc:creator><![CDATA[Muhammad Adeen Ali]]></dc:creator>
            <pubDate>Fri, 12 Jul 2024 06:32:26 GMT</pubDate>
            <atom:updated>2024-07-12T06:32:26.228Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*waFDh88WH0YeIK3xMP6TjA.png" /></figure><p>Metasploit is a powerful tool that we can use to successfully exploiting vulnerable machines. This will enable you to be a more empowered ethical hacker.</p><p>The scenario of this guided project is that you are a penetration tester hired to test the security posture of Aeronautical Corporation called AeroTech. The main goal of the assessment is to identify vulnerabilities that could be exploited by malicious hackers and rectify those weaknesses.</p><h4>Learning Objectives:</h4><ul><li>Perform a Port Scan Analysis to enable effective vulnerability reporting.</li><li>Utilize an exploit using Metasploit to gain access to a vulnerable system.</li><li>Drafting of a basic penetration testing report with results that will enable a company to fix its vulnerabilities.</li></ul><h4>Prerequisites and Related Resources:</h4><ul><li><strong>Download VMWare (or VirtualBox): </strong>Download for Windows and Linux click <a href="https://www.vmware.com/products/workstation-player/workstation-player-evaluation.html">here</a>.</li><li><strong>Upload the Kali Linux Virtual Machine to VMWare:</strong> To download the Kali Linux Virtual Machine click <a href="https://www.kali.org/get-kali/#kali-virtual-machines">here</a>.</li><li><strong>Upload the Metasploitable2 Machine to VMWare:</strong> To download the Metasploitable2 click <a href="https://sourceforge.net/projects/metasploitable/">here</a> and for a walkthrough for downloading and installing click <a href="https://www.youtube.com/watch?v=LnRgCop4jkk">here</a>.</li><li><strong>Connect the boxes in VMWare so they can ping each other: </strong>To access the written guide click <a href="https://www.ubackup.com/enterprise-backup/how-to-connect-one-virtual-machine-to-another.html">here</a>.</li></ul><h3>Reconnaisance Stage:</h3><p>It’s a stage where we’ll learn more about the system and explore the system in depth.</p><h4>1) Nmap Scan:</h4><p>Aerotech has given us a machine to pen-test it. We’ll use the <a href="https://nmap.org/"><strong>Nmap</strong></a> tool to search for open ports. This activity will be conducted on a virtual machine as it is a safe environment for penetration testing.</p><ul><li>Kali Linux operating system (attacking machine)</li><li>A metasploitable2 machine (victim machine)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*Jj3peNWPpEo0ppFgbD9iCQ.png" /><figcaption>Now I know the IP of the victim machine (usually it’s given) by typing the command, “ip a”</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u69alESWEHyr7bXF3v-pEQ.png" /><figcaption>Let’s boot and ping both machines in parallel.</figcaption></figure><blockquote><strong>fun fact:</strong></blockquote><blockquote>The reason they are pinged successfully is because they are connected through the same VMware.</blockquote><p>Now we’ll run an Nmap scan to explore open ports on the victim machine. The more ports are open on the victim machine; the more attack surface we have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*z1BMK1Be9OP3jyuz6E5zpQ.png" /><figcaption>Here is the list of open ports in the victim machine.</figcaption></figure><p>For a more in-depth and comprehensive scan, we’ll use this command:</p><blockquote><strong>nmap sC -sV</strong> victim machine’s IP address</blockquote><p>We’ll add <strong>–Sc</strong>(which stands for scripts), and <strong>-Sv</strong>(which stands for version) to give us the version number of the ports we’re scanning because the ports with outdated services often host vulnerabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*Er66MhAwAfnNJiMszFwFMg.png" /><figcaption>Here’s the more detailed scan with respective version numbers.</figcaption></figure><h4>2) Google Dorking:</h4><p>Google Dorking is an effective way to enhance our search capabilities and by adding extensions, it produces more effective and accurate results. Moreover, websites such as <em>‘exploit.db’</em> and <em>‘rapid7’</em> are powerful tools and vulnerability databases for vulnerability research.</p><p>Since I know the version number of the FTP service now I’ll check if it’s vulnerable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*4ZG4z8WlrlIkkWPhCu443w.png" /><figcaption>After adding the extension, I got filtered results only of the rapid7 site.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*fnk6aiUmq816M2LjIc4jSQ.png" /><figcaption>This vulnerability’s description, creation date, and author name are available.</figcaption></figure><h3>Penetration Testing Process with Metasploit:</h3><h4>1) Introduction to Metasploit:</h4><p>To run Metasploit, we’ll use this command:</p><blockquote>msfconsile</blockquote><p>Here <em>MSF</em> stands for <em>Metasploit framework</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*GHxsTK8dC6gWpwFCKH4_1A.png" /><figcaption>CLI of Metasploit.</figcaption></figure><p>I’ll briefly describe the modules listed here.</p><ul><li><strong>Exploit:</strong> We’ll primarily focus on this module. It is used to hack into machines.</li><li><strong>Auxiliary:</strong> Contains scanner to scan machines.</li><li><strong>Post:</strong> Post-Exploitation modules, once you break into a machine, will help you dive deeper in.</li><li><strong>Evasion</strong>: Techniques that allow us to evade tools like Windows Defender and antiviruses once we are in the machine.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*5Xfgy0koWavXi6HNYpQEbg.png" /><figcaption>You can learn more about the Metasploit commands in detail by accessing the help manual.</figcaption></figure><h4>2) Load and Configure Your First Metasploit Module:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*e-w3xOM2niqIjV7FkeUgxQ.png" /></figure><p>Let’s check if any module is available for this FTP version, so I’ll enter the version number with the <em>search</em> keyword.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*1ILZdn0pNl0F8DWAu0Ie3w.png" /><figcaption>Sadly only one module is available to us for this particular version :(</figcaption></figure><p>Let’s configure this module…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*n_MtpkfO_nM5e3zy_0jaRA.png" /><figcaption>After searching for the desired payload, load it into our session using the <strong>use</strong> command.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*W84-NmFknWpzcYxjB6522w.png" /><figcaption>An extensive list of <strong>options </strong>we need to configure to execute an attack.</figcaption></figure><blockquote><em>We can use the </em><strong><em>set </em></strong><em>command to change these options.</em></blockquote><ul><li>RHOSTS= Victim Machine.</li><li>RPORT= The port we are attacking with this module.</li></ul><p>We’ll focus on the required option only. Since RPORT is already set to 21(FTP). Let’s add the victim’s IP to RHOSTS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*ZMO2COI5hJ5sg458ccIxEQ.png" /><figcaption>The victim’s IP is also added to RHOSTS</figcaption></figure><p>Now the exploit is ready let’s execute it using the “exploit” command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*wkoXVnNYu3j60NHRP58QXA.png" /><figcaption>Voila! We’ve successfully exploited this machine.</figcaption></figure><h4>3) Establishing Persistence:</h4><p>So now we’re in the system, we’ll add a <strong>backdoor</strong> account so that we can access Aerotech’s systems more easily in the future, we won’t have to use Metasploit, configure, and search module each time.</p><p>Usually after exploiting a system, hackers will typically create a way back into the victim’s machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*TtlTYnp57vJ_nh3F_xRndA.png" /><figcaption>We’ve successfully created a new user named <strong>“backdoor”</strong> :)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/263/1*2o_213g8egxh9Cq2_-PYYg.png" /><figcaption>No worries! It’s giving weird prompts since we’re in a shell that’s not ours.</figcaption></figure><p>SSH(Secure Shell) is a Typical way of connecting one Linux machine to another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*4cJ4HwOm8EYE1b4dQ0TOhA.png" /><figcaption>I’ve successfully logged into the backdoor account <strong>“backdoor”</strong> from my terminal.</figcaption></figure><h3>Reporting Our Findings:</h3><p>In this hypothetical scenario, we’ll add our findings to a simple penetration testing report template and provide this to the client, Aerotech.</p><p>We’ll use a simplified version of the penetration testing report. It’s an open-source template, provided by <strong><em>Magda Chelly</em></strong> from <strong><em>responsible cyber</em></strong><em>. </em>You can access the template by clicking <a href="https://g.co/kgs/iUHpp5x">here</a>.</p><p>Whether simple or complex every penetration testing report will have a ‘<strong><em>purpose</em></strong><em>’</em>, ‘<strong><em>executive summary</em></strong><em>’</em>, ‘<strong><em>details</em></strong><em>’</em>, and ‘<strong><em>results</em></strong><em>/</em><strong><em>findings</em></strong><em>.’</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*biDMn9WKWuHS8Nn-kBXhCg.png" /><figcaption>Template of our penetration testing report with basic info.</figcaption></figure><ul><li><strong>Purpose:</strong> The purpose is to identify the vulnerabilities of Aerotech’s in-scope devices.</li><li><strong>Executive Summary:</strong> We dive deeper but keep it at a high-level non-technical perspective. We also briefly talk about the findings here as well.</li><li><strong>Scope:</strong> The time of this testing and the victim machine’s IP address that was in scope are mentioned here.</li><li><strong>Results:</strong> Actual findings from scans etc.</li></ul><p>Let’s add the results in our report from the port scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*eHO3bd-peMcEg-dnMKaSRQ.png" /></figure><p>Let’s update the <strong>findings</strong> section. To find the severity of this vulnerability, we’ve to do a little research.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*ErilEBBMlnloC-Plnk_Irw.png" /><figcaption>CVSS stands for common vulnerability scoring system.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*HgJEhR5jUA9pf4e-2vD2jQ.png" /><figcaption>Official NIST Gov. classification for this vulnerability.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*LFZV9TPWmLpDn6zGxxUcBw.png" /><figcaption>Here you can see the severity score. It’s a critical severe vulnerability.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*8xl12dpqx23Emfp8qjZWEA.png" /><figcaption>Updated findings…</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*Z06NH6Dl_A7AjILTGjhq7w.png" /><figcaption>The final version of our report.</figcaption></figure><p>It’s a simplified version of a penetration testing report for a basic overview.</p><p>Well, that’s a wrap! Through this hands-on project, we’ve learned about using Metasploit to exploit vulnerable machines, port scanning, and drafting a basic penetration testing report. As we conclude this project, remember that cybersecurity is a continuous adventure, and penetration testing is integral to this space. Stay curious and keep learning!</p><p>For additional resources, check out the following:</p><p><strong>Blogs:</strong></p><blockquote><a href="https://systemweakness.com/metasploit-exploitation-tryhackme-walkthrough-6b9724700624"><em>https://blog.logrocket.com/implementing-cryptography-python/</em></a></blockquote><blockquote><a href="https://www.varonis.com/blog/what-is-metasploit"><em>https://lockpin010.medium.com/classical-cryptography-with-python-part-1-9c3fe28d1f1c</em></a></blockquote><p><strong>Books:</strong></p><blockquote><strong><em>.</em>Metasploit: The Penetration Tester’s Guide<em>:</em></strong><em> </em><a href="https://www.amazon.com/Metasploit-Penetration-Testers-David-Kennedy/dp/159327288X">https://www.amazon.com/Metasploit-Penetration-Testers-David-Kennedy/dp/159327288X</a></blockquote><p><strong>Courses/Reference:</strong></p><blockquote><strong><em>. </em>Metasploit Unleashed — Free Online Ethical Hacking Course:</strong><em> </em><a href="https://www.offsec.com/metasploit-unleashed/">https://www.offsec.com/metasploit-unleashed/</a></blockquote><blockquote><strong><em>. </em>Metasploit for Beginners: Ethical Penetration Testing:</strong><em> </em><a href="https://www.coursera.org/projects/metasploit-for-beginners-ethical-penetration-testing">https://www.coursera.org/projects/metasploit-for-beginners-ethical-penetration-testing</a></blockquote><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46ff2fa32062" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking Cryptography: A Hands-On Guide to Encrypting and Decrypting Files Using Python]]></title>
            <link>https://medium.com/@madeenali2003/unlocking-cryptography-a-hands-on-guide-to-encrypting-and-decrypting-files-using-python-611766e73f7a?source=rss-15d328f31bbd------2</link>
            <guid isPermaLink="false">https://medium.com/p/611766e73f7a</guid>
            <dc:creator><![CDATA[Muhammad Adeen Ali]]></dc:creator>
            <pubDate>Tue, 05 Dec 2023 16:14:53 GMT</pubDate>
            <atom:updated>2023-12-05T16:14:53.759Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*jaWiGAYvk02VkOKmCKQoLg.jpeg" /><figcaption>Source: Google</figcaption></figure><p>Cryptography is the art of ensuring our digital messages and data stay private and safe. It’s like the lock and key of the internet. It uses special codes to encrypt information so only authorized people can decrypt it.</p><p>This project-based blog focuses on using Python to encrypt and decrypt files using public and private key pairs, providing a practical and accessible way to understand encryption/decryption concepts.</p><p><strong>What’s the difference between Public Key and Private Key?</strong></p><p>The public key is like a lock for encrypting data, while the Private key is the unique key to unlock and decrypt the data.</p><p><strong>Why Python?</strong></p><p>Python’s simplicity and powerful libraries make it a top choice for encryption tasks. For instance, libraries like<em> ‘cryptography’</em> (used in this project) and <em>‘pycryptodome’</em> offer pre-built encryption algorithms, enhancing efficiency and ensuring security.</p><h4>Prerequisites and Related Resources:</h4><p>Before we start, let’s ensure you’re all set to embark on this encryption journey. Here’s what you’ll need:</p><ul><li><strong>Basic Understanding of Python Programming:</strong> If you’re new to Python, consider brushing up on fundamental concepts like variables, functions, and loops. You can find free resources online to get started by clicking <a href="https://www.youtube.com/watch?v=eWRfhZUzrAc">here</a>.</li><li><strong>Python Installation:</strong> Make sure you have Python installed on your computer. To watch the complete tutorial click <a href="https://www.youtube.com/watch?v=yivyNCtVVDk">here</a>.</li><li><strong>Visual Studio Code (IDE):</strong> The complete installation guide for VS Code can be accessed <a href="https://www.youtube.com/watch?v=MlIzFUI1QGA">here</a>.</li></ul><h4>Common Cryptography Packages in Python:</h4><ol><li><strong><em>import cryptography</em></strong>: This import statement is used to import a package.</li><li><strong><em>from cryptography.hazmat.primitives import serialization: </em></strong>Importing just the <em>‘serialization’</em> object allows us to handle loading and reading the public key from a file into memory. This is essential in the encrypt program where we need to work with cryptographic keys.</li><li><strong><em>from cryptography.hazmat.primitives import hashes</em></strong>: Hashing generates a message digest for data integrity verification. It creates a binary representation of the original data, enabling recipients to validate data authenticity without inspecting the file.</li><li><strong><em>from cryptography.hazmat.primitives.asymmetric import padding: </em></strong>Padding adds characters before encryption. Our project’s padding links to data length, enhancing security against decoding.</li></ol><h4>Fun fact:</h4><blockquote><strong>‘Hazmat,’</strong> abbreviated as <strong>hazardous materials</strong>, is a powerful module of the cryptography library that provides a low-level interface for cryptographic primitives in Python.</blockquote><blockquote>It allows us to directly work with cryptographic algorithms and protocols, offering classes and functions related to cryptographic primitives such as asymmetric and symmetric encryption, digital signatures, key derivation, etc.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*s9jXsOhoSZWGe-DhonFeWw.png" /><figcaption>A graphical overview of secure communication for a better understanding.</figcaption></figure><p>Let’s get started!</p><h4>Generate and Save a Private Key:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*KzQdYixhQJlLEKWsGAkSxA.png" /><figcaption>Let’s install the cryptography package by entering the command highlighted, on our VS Code’s terminal.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*eTUxS6yrK652xYTS9IahJg.png" /><figcaption>Let’s create a private key instance with the recommended public exponent size and key size according to the RSA package documentation.</figcaption></figure><ul><li><strong>Public exponent size: </strong>This exponent is used to decode the original value.</li><li><strong>Key size: </strong>The number of bits used in the key itself.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*26_C12y9Qx7-ifVC_FtCeA.png" /><figcaption>A private key <strong>object’s address </strong>is generated as shown in the terminal (It’s <strong>unserialized</strong> as of now)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*9jUKruwemcsajUzdXyXa3A.png" /><figcaption>Serialization of the private key object.</figcaption></figure><p><strong>Why Serialization?</strong></p><p>It creates a byte representation of objects that can be saved in files in a human-readable form.</p><p>We have used <strong>PEM (Privacy Enhanced Mail)</strong> that will make the private key’s object in a more human-readable form through ASCII values.</p><p>Now, let’s save the generated private key priv_pem to a file. We&#39;ll use this key later to decrypt files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*mX_fyeyBe6HbJXZWbP4Cew.png" /><figcaption>We’re writing our <strong>serialized</strong> private key object in binary mode to a file.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*n6wV0YC6xT8JE2qGtifPIg.png" /><figcaption>The private key file has been generated!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*eLZCKIAwGlHmkFjxsiWU7A.png" /><figcaption>Here’s our private key in ASCII format. Much bigger than the public key :)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*nE9Sw7be3T3haNiMmSehvw.png" /><figcaption>We’ll export the file location as an environment variable. The variable “PEMK” will hold the path to our key file.</figcaption></figure><p><strong>Why Export?</strong></p><p>It’s redundant to enter the address every single time; therefore, after exporting, we’ll just use the variable PEMK, and the interpreter will automatically fetch the whole path of the file.</p><h4>Generate and Save a Public Key:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*53_MyVEPj_mOUIN-FZ04XQ.png" /><figcaption>The previous code only requires changing “private” to “public” to obtain the public key.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*hTzsrCdGiqUX92BXGO23DQ.png" /><figcaption>Upon code execution, a file-format bytecode of the public key is generated and saved, as illustrated in the provided image.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*FTQJhhnMCwW77rHOBIIHzQ.png" /><figcaption>Voila! Here’s the generated public key in the file.</figcaption></figure><h4>Encrypt the Original File using the Public Key:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*qpu7fARsGvAJrgEFU0fQlA.png" /><figcaption>The code is explained below.</figcaption></figure><p>We’ve stored the public key in a file named “pub.pem.” After reading the file using<strong> “pub.pem”</strong> and<strong> “rb”</strong> (read in binary), we load the <strong>PEM</strong> public key using the serialization object with “public_key_file.read.” This deserializes the key, giving us the public key object in memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*B2nW2y34Nm4Ag8z5FgNvcg.png" /><figcaption>Please refer to the code comments for a clearer understanding.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*prXkMz8schx5Id1vLtvCug.png" /><figcaption>Setting the path of <strong>pub.pem</strong> file to<strong> PUB_PEMK</strong> environment variable.</figcaption></figure><pre>$env:PUB_PEMK = &quot;C:\Your_File_Path\pub.pem&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*xqCVg7GXHX78_VAljcr5Vw.png" /><figcaption>After entering the<strong> “encrypt.py” </strong>file path. It displays the path of <strong>PEMK</strong> and the <strong>Original</strong> file name.</figcaption></figure><pre>python -u &quot;c:\file_path_of_encrypt.py\encrypt.py&quot; data.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*yB7C2joF3XohoMNK_rx8oQ.png" /><figcaption>An <strong>encrypted</strong> file of my <strong>original</strong> file has been created!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*F2J_pb2KgOt2O1a6zRZIeQ.png" /></figure><h4>Decrypt the Encrypted File using the Private Key:</h4><p>Each function will be the same as encryption, with just some minor changes discussed below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*fhzpUxus9b7l9fqaJVvb7w.png" /><figcaption>decryption code…</figcaption></figure><p><strong>Changes:</strong></p><ul><li><strong>‘public_key’ </strong>will be changed to <strong>‘private_key.’</strong></li><li><strong>‘original_file’</strong> will be replaced by <strong>‘encrypt_file.’</strong></li><li>Setting the path of the ‘<strong>priv.pem’</strong> file to the ‘<strong>PEMK’</strong> environment variable.</li><li>Entering the<strong> ‘decrypt.py’ </strong>file path.</li></ul><pre>$env:PEMK = &quot;C:\Users\HP\Desktop\NCYS\priv.pem&quot;<br>python -u &quot;c:\Users\HP\Desktop\NCYS\decrypt.py&quot; data.txt.encrypted</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*bK9Tc41Xr_Ov83eN5OZwoQ.png" /><figcaption>The file name of the newly generated <strong>decrypted</strong> file.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*w3AH1DVC8nOFPLZB1dUWmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*WqxP2uY7BQ0Dzoe6LdXVmA.png" /><figcaption>Voila! The<strong> encrypted</strong> file has been <strong>decrypted </strong>successfully!</figcaption></figure><p>As you can see, the <strong>decrypted</strong> text is perfectly identical to the <strong>original</strong> text.</p><p>Well, that’s a wrap! Through this hands-on project, we’ve learned about generating public and private keys and decrypting and encrypting files in Python. As we conclude this journey, remember that cybersecurity is a continuous adventure, and cryptography is an integral part of this space. Stay curious, keep learning, and strive for a safer digital world!</p><p>To access the source code click <a href="https://github.com/adeenali600/Cryptography">here</a> and for additional resources, check out the following:</p><p><strong>Blogs:</strong></p><blockquote><strong><em>.</em></strong><a href="https://blog.logrocket.com/implementing-cryptography-python/">https://blog.logrocket.com/implementing-cryptography-python/</a></blockquote><blockquote><em>.</em><a href="https://professorghost.medium.com/using-python-for-cryptography-an-introduction-8299cb60a830"><em> </em></a><a href="https://lockpin010.medium.com/classical-cryptography-with-python-part-1-9c3fe28d1f1c">https://lockpin010.medium.com/classical-cryptography-with-python-part-1-9c3fe28d1f1c</a></blockquote><p><strong>Books:</strong></p><blockquote><strong><em>.</em>The Codebreakers:</strong> <a href="https://www.amazon.com/Codebreakers-Comprehensive-History-Communication-Internet/dp/0684831309">https://www.amazon.com/Codebreakers-Comprehensive-History-Communication-Internet/dp/0684831309</a></blockquote><blockquote><strong><em>. </em>Handbook of Applied Cryptography:</strong><em> </em><a href="https://www.amazon.com/Handbook-Cryptography-Discrete-Mathematics-Applications/dp/0849385237"><em>https://bookauthority.org/books/best-wireshark-books</em></a></blockquote><p><strong>Courses:</strong></p><blockquote><strong><em>. Encryption with Python: Encrypt data with key pairs:</em></strong><em> </em><a href="https://www.coursera.org/projects/encryption-with-python-encrypt-data-with-key-pairs"><em>https://www.coursera.org/projects/wireshark-for-network-security</em></a></blockquote><blockquote><strong><em>.</em>Decryption with Python:</strong><em> </em><a href="https://www.coursera.org/projects/decryption-with-python">https://www.coursera.org/projects/decryption-with-python</a></blockquote><p>You can follow me on social networks.</p><blockquote>Linkedin: <a href="https://www.linkedin.com/in/m-adeen-ali-02150b245/">https://www.linkedin.com/in/m-adeen-ali-02150b245/</a></blockquote><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=611766e73f7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Silent Whispers of the Network: Decrypting Communication Mysteries with Wireshark]]></title>
            <link>https://medium.com/@madeenali2003/silent-whispers-of-the-network-decrypting-communication-mysteries-with-wireshark-e64340c2966b?source=rss-15d328f31bbd------2</link>
            <guid isPermaLink="false">https://medium.com/p/e64340c2966b</guid>
            <dc:creator><![CDATA[Muhammad Adeen Ali]]></dc:creator>
            <pubDate>Sat, 12 Aug 2023 12:35:09 GMT</pubDate>
            <atom:updated>2023-08-12T12:35:09.651Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*mMMUXeLUT7RWL8GB.png" /><figcaption>Source: Google</figcaption></figure><p>Ever wondered how the internet works behind the scenes? Meet Wireshark, a tool that shows you the secrets of digital communication. Unlike command-line tools like ‘tcpdump,’ Wireshark provides a user-friendly interface that simplifies the decoding of data. In this blog, we’ll take a beginner-friendly journey through Wireshark and learn how to uncover fascinating details about the data that travels around us.</p><p>But there’s more! We’ll also dive into an engaging guided project where we’ll capture packets, decrypt credentials, and apply conditional filters to target specific data packets. This skill is essential for eliminating unnecessary data capture, resulting in a more organized and focused analysis.</p><p>So, if you’re ready to reduce clutter and unlock hidden insights within network communication, let’s get started!</p><p><strong>Common Network Protocols and Ports:</strong></p><ol><li>HTTP(Hyper Text Transfer Protocol): Uses Port 80 for transferring data over the web.</li><li>HTTP(Hyper Text Transfer Protocol Secure): The secure version of HTTP, uses Port 443 with encryption to ensure secure data transmission.</li><li>DNS(Domain Name System): Uses Port 53 for translating domain names into IP addresses.</li><li>Telnet: A protocol for terminal emulation, uses Port 23.</li><li>SSH(Secure Shell): Uses Port 22 for secure remote access and data communication.</li></ol><blockquote>Remember that except SSH and HTTPS all protocols mentioned are unencrypted. If you want to know more about protocols and their working click <a href="https://www.comptia.org/content/guides/what-is-a-network-protocol">here</a>.</blockquote><p><strong>Project Goals:</strong></p><ul><li>Using Wireshark and most of its basic functionalities: capturing some network traffic flowing through your machine now.</li><li>Generating and capturing RADIUS Traffic, analyzing it, and viewing it in Wireshark. Knowing what the RADIUS Architecture consists of and decrypting the encrypted password with the shared secret using Wireshark.</li><li>Connecting to an HTTP Server and initiating a Basic HTTP Authentication and capturing its Traffic on Wireshark, analyzing the captured packets, and seeing the username and password being sent.</li><li>Knowing how Telnet works, starting a Telnet Session with a remote Device using Powershell, capturing its traffic in Wireshark, and analyzing it from the Security perspective.</li><li>Opening an SSH Session with the same Device as in Task 5, capturing the traffic, and comparing it with the Telnet Packet Capture. Capturing traffic based on the host involved and how to see all the host, packet, and protocol statistics as well as conversations that have happened in a certain Capture.</li></ul><p>Let’s Begin!</p><h4><strong>Capture DNS Packet Using Filter:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*LBOEHgU7uop64HhMFKsJnw.png" /><figcaption>DNS traffic captured on ethernet.</figcaption></figure><h4><strong>Generate and Capture RADIUS Traffic:</strong></h4><p>Just to give you some context, Radius helps control and track who can access a network service from a central location.</p><p><strong>Why is it called Server?</strong></p><p>This is because RADIUS is the client/server protocol that runs in the application layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*CIJQKBspOLBV1sXFxWa6vg.png" /><figcaption>GUI of the RADIUS Server</figcaption></figure><p>Now we will test the authentication site and analyze the unencrypted data it contains.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*44OAxuYLYtbaKr1pnYwGGA.png" /><figcaption>Client of RADIUS architecture</figcaption></figure><p>We’ll send several access requests using the IP address we noticed in the interface. We’ll also choose port ‘1812’ to create some data traffic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*m32-iFDVAJQs_8-xqlkO5A.png" /><figcaption>Voila! As you can see Wireshark is capturing the traffic on port1812, which was generated by our request.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*oqIxSn5LidPlXBVcMXjw_A.png" /><figcaption>No encryption :(</figcaption></figure><p>Unfortunately, the radius system doesn’t protect information, so you can see if access requests were denied or allowed. Yet, this can be made safer by using TLS encryption.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*oqIxSn5LidPlXBVcMXjw_A.png" /><figcaption>Let’s dig more in the packet! As you can see username is visible. The only thing we can’t see over here is the password.</figcaption></figure><p>Remember that field called Secret Key?<br>Also known as Shared secret, RADIUS uses this value<br>and the MD5 hashing algorithm to hide the passwords<br>between the server and the client, which is itself a week<br>protection of the user&#39;s credentials.</p><p>Since we are analyzing the packets from the security aspect,<br>let me show you how we can use Wireshark to decrypt<br>these passwords.</p><p>Click on edit, then preferences, protocols, search<br>for RADIUS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*SHtP7u3J_ZoNrFu5lQ0XdQ.png" /><figcaption>Over here it’s asking for the shared secret.</figcaption></figure><p>I used a secret code to secure the traffic between NTRadPing and the server. I switched it to ‘secret’ and confirmed. This secret code needs to be shared and agreed upon by the server and the client for it to work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*EKFrM6s__Bj6u-oJd6pbow.png" /><figcaption>Voila! Now you<br>can see the password in clear text as ‘password’</figcaption></figure><h4><strong>Analyze an HTTP Basic Authentication:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*nomsNfm1Syu8kap6zh3_WQ.png" /><figcaption>Setting Capture Filter for HTTP Traffic on Port ‘80&#39;</figcaption></figure><p>Let’s start an HTTP basic authentication. It’s a simple way for a server to ask a client (you) for login details (username and password) when accessing a public server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*Vul_N5ncZHhn3evtcxjRrQ.png" /><figcaption>I’ve entered the credentials and accessed the given HTTP website.</figcaption></figure><p>Open the initial packet, expand the hypertext transfer protocol, then the authorization section. Look for the term “basic.” Next to it, you’ll find the password encoded in base64. However, this encoding doesn’t encrypt the username and password sent to the server. Wireshark successfully decoded it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*LAQ8ZJbPzJXFrgjdbYSHbg.png" /><figcaption>As expected, you can see the credentials, such as the username and password</figcaption></figure><h4><strong>Initiate, Capture, and Analyze Telnet Sessions:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*S4SCShtmNqqlOsP8ixL8Lg.png" /><figcaption>Setting Capture Filter for Telnet Traffic on Port ‘23’</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*bAbUl--rAmiTdtOewSLfcA.png" /><figcaption>Enter this command on PowerShell to generate some Telnet traffic.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*iRYYlr3LoPajMvelpcPlcA.png" /><figcaption>Wireshark captures the Telnet traffic</figcaption></figure><p>Right-click here on the initial telnet packet, then select “Follow TCP Stream.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*qgoTUcB0G2GtuX98_AX27g.png" /><figcaption>As you can see, everything visible in our telnet session is unencrypted and insecure.</figcaption></figure><h4><strong>Capturing and Analyzing SSH Sessions:</strong></h4><p>Let’s capture all traffic between us and the remote server. Instead of specifying just the port (22) for SSH, we’ll mention the host we’re connecting to: tty.sdf.org</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*duvp6sBKrMebfiycVEKzWQ.png" /><figcaption>Connecting to the same host as Telnet.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*q0fh5hgl79Z1M10c9V26Rw.png" /><figcaption>Let’s generate SSH traffic using the command ‘ssh adeen@tty.sdf.org.&#39;</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*SlHSCFCDRUt8n7hRNHOYQg.png" /><figcaption>SSH session’s output same as Telnet.</figcaption></figure><p><strong>What’s the difference then?</strong></p><p>Now, check out statistics and then conversations. Since both SSH and Telnet use TCP, click on TCP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*wLRkFKPTyHj6Uq4wY_DxqA.png" /><figcaption>You can observe the port numbers, IP addresses, and so on.</figcaption></figure><blockquote>Click ‘Telnet,’ then ‘Follow Stream’ to see session details.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*Le-a4phcKSMZoHTo8jMtBg.png" /><figcaption>As you can see Telnet session’s activity is completely unencrypted</figcaption></figure><blockquote>Click ‘SSH,’ then ‘Follow Stream’ to see session details.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*TiwOi2y9IJcd0sekUmfUCg.png" /><figcaption>The output of the SSH session is entirely encrypted.</figcaption></figure><p>The difference is clear!</p><h4>Generate, Capture, Analyze then Decrypt HTTPS Traffic:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*j2AIZXtFVRDpgn8a2Pv2Tw.png" /><figcaption>Let’s begin capture on Port ‘443&#39;</figcaption></figure><p>Let’s pick a data packet. When we open TLS (extra security), it’s HTTP over TLS — a secure connection. Data is hidden like a secret code. Without the right key, it’s unreadable. That’s why it’s super secure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*oVRzyo6RD7PehFkHCtmSPQ.png" /><figcaption>Data is encrypted🛡️</figcaption></figure><p><strong>Let’s decrypt SSL traffic!</strong></p><p>We’ll use an easy method called the “pre-master Secret Key.” Here’s how it works:</p><ul><li>The browser (client) generates a pre-master secret key.</li><li>The key is stored in an SSL key log file.</li><li>The server (webpage) uses the key to create a master secret key for encryption.</li><li>Having the pre-master key in the file lets us share it with Wireshark for decoding.</li></ul><p>Imagine it as a hidden code between your browser and the server. Wireshark uses it to unlock encrypted data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*bxAF0YszJm5Lo9TRW5pjYQ.png" /><figcaption>First, go to environment variables and create a new user variable. Enter the variable name as ‘SSL’ and choose a suitable log file name and location, like ‘ssl-keys.log’ in my case</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*4WVbWVx2Uh6-BhMAAKBE9g.png" /><figcaption>Open Wireshark, and head to the home page. Click edit, then preferences. Expand protocols, search ‘TLS,’ and enter the saved name of your SSL log file.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*ayRRhtrKnC3VGeArtBQnPw.png" /><figcaption>Re-capturing HTTPS traffic.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*Fg7sbh0VIzqqqjLbJd05jA.png" /><figcaption>Accessing a basic HTTPS website to generate traffic</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*1ImQqwosZM0IGKyioIn7Ug.png" /><figcaption>After stopping the capture, let’s intercept conversations.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*eZrL20G-x6h76wLTg8FxLw.png" /><figcaption>Several conversations…</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*4fh7BPs1qvJTAfGZqhMCzw.png" /><figcaption>Let’s ping the server to confirm the client’s IP. Type the hostname into the command prompt.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*FfpEoOWevaelTe37oyba8A.png" /><figcaption>That’s our IP! Now, click on ‘Follow Stream’ to intercept conversations.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*zsLtJK-PTaxq6v8Ha2H_gg.png" /><figcaption>Voila! The entire conversation is now encrypted.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*zjKQlCSbuOQq731uiZSBoA.png" /><figcaption>Even, you can see headers, source code, requests, protocols, and more.</figcaption></figure><p>Well, that’s a wrap! Through this hands-on project, we’ve learned about packet capturing, credential decryption, and targeted data analysis using Wireshark. As we conclude this journey, remember that cybersecurity is a continuous adventure. Stay curious, keep learning, and stay curious for a safer digital world!</p><p>For additional resources, check out the following:</p><p><strong>Blogs:</strong></p><blockquote><strong><em>.</em></strong><a href="https://medium.com/@valerie7995/wireshark-traffic-analysis-tryhackme-ea19a9891946">https://medium.com/@valerie7995/wireshark-traffic-analysis-tryhackme-ea19a9891946</a></blockquote><blockquote>. <a href="https://www.varonis.com/blog/how-to-use-wireshark">https://www.varonis.com/blog/how-to-use-wireshark</a></blockquote><p><strong>Books:</strong></p><blockquote><strong>.</strong>Wireshark Certified Network Analyst Certification — WCNA Exam Guide:<a href="https://www.amazon.com/dp/1838551670?tag=uuid10-20">https://www.amazon.com/dp/1838551670?tag=uuid10-20</a></blockquote><blockquote><strong>. </strong>Mastering Wireshark: <a href="https://bookauthority.org/books/best-wireshark-books">https://bookauthority.org/books/best-wireshark-books</a></blockquote><p><strong>Courses:</strong></p><blockquote><strong>.</strong> Wireshark for Basic Network Security Analysis: <a href="https://www.coursera.org/projects/wireshark-for-network-security">https://www.coursera.org/projects/wireshark-for-network-security</a></blockquote><blockquote><strong>.</strong>Wireshark: Packet Analysis and Ethical Hacking: <a href="https://www.udemy.com/course/wireshark-packet-analysis-and-ethical-hacking-core-skills/">https://www.udemy.com/course/wireshark-packet-analysis-and-ethical-hacking-core-skills/</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e64340c2966b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking Network Traffic Analysis: An In-Depth Exploration of TCPDump]]></title>
            <link>https://medium.com/@madeenali2003/unlocking-network-traffic-analysis-an-in-depth-exploration-of-tcpdump-1abd4aeaa477?source=rss-15d328f31bbd------2</link>
            <guid isPermaLink="false">https://medium.com/p/1abd4aeaa477</guid>
            <dc:creator><![CDATA[Muhammad Adeen Ali]]></dc:creator>
            <pubDate>Sat, 05 Aug 2023 13:37:06 GMT</pubDate>
            <atom:updated>2023-08-05T13:37:06.471Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="tcpdump logo" src="https://cdn-images-1.medium.com/max/225/1*tU1G7tgyHNMGWBOEImeucw.jpeg" /></figure><p>In this blog post, we will explore the world of network traffic analysis using TCPDump, a robust command-line packet analyzer. Our focus will be on capturing and examining packets related to website activities to gain valuable insights into network behavior.</p><p>With a step-by-step breakdown of a comprehensive shell script, we’ll uncover how to effectively utilize TCPDump’s capabilities. As an engaging and educational activity, we’ll simulate SSH session activity on a secure sandbox terminal and analyze SSH traffic using TCPDump.</p><p>Let’s embark on this exciting quest with TCPDump to improve our skills in monitoring and securing network communications!</p><p><strong>Common Keywords:</strong></p><ol><li>sudo: Use this command to run tcpdump with administrative privileges for capturing network traffic, as it requires elevated access.</li><li>tcpdump: tcpdump is a tool for capturing and analyzing network packets.</li><li>port 22: Use this filter to capture network traffic specifically related to the SSH protocol, which operates on port 22.</li><li>-i any: Use the -i any flag to capture network traffic on all available network interfaces, enabling the capture of SSH traffic on all active interfaces.</li><li>-#XX: Replace # with the desired number to specify the maximum number of packets tcpdump should capture. For instance, using -c 100 would capture 100 packets.</li><li>tttt: Use the -t flag to instruct tcpdump to print the timestamp of each captured packet in a human-readable format.</li><li>-w sshcapture.pcap: Use the -w option to tell tcpdump to write the captured packets to a file named sshcapture.pcap. The .pcap extension signifies that it will be saved in the standard packet capture file format.</li><li>-C 3: Use the -C 3 flag to specify the maximum size (in megabytes) of each capture file. When the current file reaches 3MB in size, tcpdump will create a new file to continue capturing network data.</li><li>-G 600: Use the -G 600 option to set the time interval (in seconds) for creating a new capture file. In this example, tcpdump will create a new file every 600 seconds (or 10 minutes) to capture subsequent packets.</li></ol><h3>Capturing Website Traffic:</h3><h4><strong>Examples:</strong></h4><blockquote><strong><em>1) sudo tcpdump port -#XXtttt host skyroute66.com -c 10</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*pqWMvtknnoEWWloyJaOUiw.png" /><figcaption>We’ve granted execute permission and written a bash script to capture incoming and outgoing network traffic solely for this host. The capture limit is set to 10 using the `-c 10` command.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*5rriurueo1VEEnUsVY6jtQ.png" /><figcaption>The website accessed through the host captured 10 packets, classified as ASCII and hexadecimal values.</figcaption></figure><blockquote><strong><em>2) </em>sudo tcpdump -#XXtttt ‘tcp[((tcp[12:1] &amp; 0xf0) &gt;&gt; 2):4] = 0x47455420’</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*5-PWgt8hg3HgQfFWaH9cEg.png" /><figcaption>Clicking the link allows tcpdump to capture GET network traffic from the API on the specific website.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*3sHN6Y26fqFAFb_gk-6ZWA.png" /><figcaption>The script captures GET network traffic when the API is accessed on a specific website. It filters TCP headers to look for packets of 12 bytes ‘[12:1]’ and checks the starting 4 bits ‘:4’ for ‘0x47455420’, which represents GET with a space in ASCII values.</figcaption></figure><h3>Analyzing SSH Traffic:</h3><blockquote>sudo tcpdump port 22 -i any -#XXtttt -w proof.pcap -G 600 -C 2</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*nJTItUUvH3aH20QUgyetfg.png" /><figcaption>The script captures only SSH (port 22) traffic, logging it to a file named “proof.pcap.” It sets a time limit of 10 minutes and restricts the file size to 2MB.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*huJrcPPZGnMu7bM_1hidSw.png" /><figcaption>With a single command ‘ssh localhost,’ mysterious SSH traffic floods the terminal. It’s not easy to read, but our script captures and logs 10 intriguing packets, pushing the limits to 2MB. Let’s dive into the enigmatic world of SSH traffic analysis and reveal its hidden treasures!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*nWYcx2iHIOVtLlgVQwy3KA.png" /><figcaption>As shown, the script has captured some SSH traffic. We’ll import the previously created .pcap file into tcpdump for analysis.</figcaption></figure><h4>Analysis:</h4><ul><li>Simulated Attack Scenario:</li><li>Intentionally set the sender and receiver IP addresses to be the same.</li><li>The receiver port is identified as 22 (SSH).</li><li>Sender port highlighted (e.g., 37326) for insight into network communication patterns under attack scenarios.</li></ul><p>During the TCPDump terminal analysis, we simulate an attack scenario, intentionally setting the sender and receiver IP addresses to be the same (highlighted in blue). The receiver port is identified as 22 (SSH), while the sender port is highlighted in red and assigned as 37326. This simulation offers valuable insights into network communication patterns under attack scenarios, aiding in understanding potential vulnerabilities and appropriate defensive measures.</p><p>To analyze the traffic in a more precise and simplified manner, you can use the Wireshark tool, as shown in the picture below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*i3xWERrfn3-Ls8hWR2QPsg.png" /><figcaption>Voila! With Wireshark’s user-friendly GUI interface, you can easily analyze the network traffic for better insights and troubleshooting.</figcaption></figure><p>In this blog, we learned to analyze network traffic using TCPDump. Specifically, we focused on capturing SSH packets across interfaces using a shell script. This enables us to monitor network activities and enhance security. Keep learning and stay curious for a safer digital world!</p><p>As promised, here are some additional resources:</p><p>Jalin Mayberry’s blog:</p><p><strong><em>. </em></strong><a href="https://medium.com/@mayberryjalin/mastering-network-traffic-analysis-a-closer-look-at-tcpdump-eedcd9e8ea74">https://medium.com/@mayberryjalin/mastering-network-traffic-analysis-a-closer-look-at-tcpdump-eedcd9e8ea74</a></p><p>Books:</p><p><strong>. </strong>Tcpdump: An Open Source Tool for Analyzing Packetsv: <a href="https://www.informit.com/articles/article.aspx?p=170902">https://www.google.com/search?q=books+related+to+tcpdump&amp;oq=books+related+to+tcpdump&amp;aqs=chrome..69i57j33i160l2.11126j0j7&amp;sourceid=chrome&amp;ie=UTF-8</a></p><p><strong>. </strong>Packet Analysis of Unmodified Bluetooth Communication Devices: <a href="https://www.amazon.com/dp/1249833663?tag=uuid10-20">https://www.amazon.com/dp/1249833663?tag=uuid10-20</a></p><p>Courses:</p><p><strong>.</strong> Analyze Network Traffic with TCPDump: <a href="https://www.coursera.org/projects/analyze-network-traffic-with-tcpdump">https://www.coursera.org/projects/analyze-network-traffic-with-tcpdump</a></p><p><strong>. </strong>A Beginners Guide to tcpdump: <a href="https://www.giac.org/paper/gsec/3489/beginners-guide-tcpdump/105700">https://www.giac.org/paper/gsec/3489/beginners-guide-tcpdump/105700</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1abd4aeaa477" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>