<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ P S Mohammed Ali - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ P S Mohammed Ali - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 18 May 2026 10:46:50 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/psmohammedali/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ Why Security Audits Are Important ]]>
                </title>
                <description>
                    <![CDATA[ In this digital world, companies rely on the latest technology to run their businesses, and the risk of cyber attacks is high. Every product, whether it’s software or an application, should go through some sort of security testing process. These chec... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/why-security-audits-are-important/</link>
                <guid isPermaLink="false">67db2704d898a5f4273111cf</guid>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ #cybersecurity ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ P S Mohammed Ali ]]>
                </dc:creator>
                <pubDate>Wed, 19 Mar 2025 20:20:20 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1742397497226/ec06b7c2-1a2a-4eb1-bbaa-4c1d40e4e60e.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this digital world, companies rely on the latest technology to run their businesses, and the risk of cyber attacks is high.</p>
<p>Every product, whether it’s software or an application, should go through some sort of security testing process. These checks reveal whether the product is safe or vulnerable to threats.</p>
<p>Penetration testing is a common way to test process or products, but it’s typically more specifically designed with a particular product in mind. On the other hand, a full security audit has a broader scope and covers more ground than penetration testing alone.</p>
<p>In this article, you’ll learn what’s involved in a standard security audit and how these processes can help keep your software secure. By the end, you’ll have a better idea of how security audits can help improve an organisation’s overall security posture.</p>
<h2 id="heading-what-is-a-security-audit">What is a Security Audit?</h2>
<p>A security audit is an overall review of an organization’s security controls, policies, standards, and procedures based on a set of predefined expectations.</p>
<p>These predefined expectations are derived from industry standards such as PCI DSS (Payment Card Industry Data Security Standard), which is a mandatory framework for organizations dealing with credit card transactions. Similarly, HIPAA (Health Insurance Portability and Accountability Act) focuses on the privacy and protection of your health information, making it essential for companies who are handling health-related data.</p>
<p>Apart from these standards, polices, and frameworks, security audits also examine infrastructure components and check application backups or recovery mechanisms to make sure data is protected if accidental or malicious data loss occurs.</p>
<p>The outcome of the audit can help inform the company of its current security posture, and also provides details about possible vulnerabilities and compliance threats.</p>
<p>Usually, security audits are conducted by a group of security experts. They plan the audit well in advance to ensure that it interrupts the company’s day-to-day business as little as possible.</p>
<p>There are two types of security audits:</p>
<ol>
<li><p>Internal Audit</p>
</li>
<li><p>External Audit</p>
</li>
</ol>
<p>In this article, we will discuss internal audits. The main difference between the two processes is that internal audits are conducted by people belonging to the organization, while external audits are conducted by a security team outside the organisation.</p>
<h2 id="heading-elements-of-an-internal-audit-process-flow">Elements of an Internal Audit (Process Flow)</h2>
<p>A well-structured security audit provides transparency and ensures that there’s a systematic approach to evaluating the effectiveness of in-place security policies and procedures.</p>
<p>The internal audit process typically follows these five steps:</p>
<ol>
<li><p>Establishing goals and objectives</p>
</li>
<li><p>Conducting a risk assessment</p>
</li>
<li><p>Completing a control assessment</p>
</li>
<li><p>Assessing compliance</p>
</li>
<li><p>Communicating to stakeholders</p>
</li>
</ol>
<p>To understand the elements of an internal audit in more detail, let's break down the process by working through a case study. This will show you how a company or team can plan an internal audit using a systematic approach.</p>
<h2 id="heading-security-audit-case-study">Security Audit Case Study</h2>
<p>In order to understand this process more clearly, let’s consider an e-Commerce website called “walkGen.com” as an example.</p>
<p><strong>Case Study:</strong> There is a eCommerce website named <strong>walkGen.com</strong> which primarily sells footwear through their website. Customers can order by logging in using their username and password and can pay using a credit/debit card or UPI. To create a better user experience, the website asks for the user’s name, age, gender, and location for personalized information and design.</p>
<p>With this information in mind, let’s conduct a security audit for the website.</p>
<h3 id="heading-step-1-establish-goals-and-objectives">Step 1: Establish Goals and Objectives</h3>
<p>This first step involves identifying all the critical assets and services required for the website to run. You’ll also need to define a set of industry standard expectations.</p>
<p>For our walkGen.com website, the critical assets we need to consider include customer data, transaction details, and infrastructure details like hosting server, database, and so on.</p>
<p>Keeping these initial data points in mind, here are some possible goals and objectives:</p>
<ol>
<li><p><strong>Strength access controls</strong>: We want to make sure there are strict authentication and authorization policies in place for any users who sign in.</p>
</li>
<li><p><strong>Maintain proper frameworks</strong>: Since customers can pay using a credit card, we’ll want to ensure that the site adheres to standards like PCI DSS for payment security.</p>
</li>
<li><p><strong>Secure Infrastructure</strong>: Assets like hosting servers and databases need to be safeguard from cyber threats and theft.</p>
</li>
</ol>
<p>Now, the key expectations are that we’ll maintain compliance with security standards such as GDPR (General Data Protection Regulation) for protecting customer data as well as PCI DSS (Payment Card Industry Data Security Standard) for monetary transactions. We’ll also need to perform regular maintenance and patch updates for servers and databases.</p>
<h3 id="heading-step-2-conduct-a-risk-assessment">Step 2: Conduct a Risk Assessment</h3>
<p>Risk assessment helps us identify and prioritize threats that may possibly affect walkGen’s critical assets. It helps categorize the risks based on their severity and likelihood.</p>
<p>Identifying and categorizing risks will be the ultimate goal in this step, as it will help walkGen implement effective security measures for critical risks compared to low/information risks.</p>
<p>From the assets and services we identified in the previous step, the possible risks could be:</p>
<ol>
<li><p><strong>Customer data leakage</strong>: Exposure of customer data such as names, email ID, customer delivery addresses, payment details, and so on.</p>
</li>
<li><p><strong>Man-in-the-Middle attacks</strong>: Intercepting website traffic between the logged in users and the website, leading to stolen login credentials, stored payment card details, and so on.</p>
</li>
<li><p><strong>Non-compliance with PCI DSS:</strong> Failing to meet the standards required for handling credit card transaction securely.</p>
</li>
<li><p><strong>Unauthorized transactions or stolen payment details:</strong> payment transaction happening on compromised accounts by cybercriminals.</p>
</li>
<li><p><strong>Server vulnerabilities:</strong> Weaknesses/loopholes in the hosted web server configuration, third-party software, or cloud network infrastructure.</p>
</li>
<li><p><strong>Database exploits:</strong> Exploiting vulnerabilities present in the database through penetration testing like SQL Injection, and so on.</p>
</li>
<li><p><strong>Missing patch updates</strong>: Ignoring/Failing to apply security patches for the OS or walkGen’s applications.</p>
</li>
</ol>
<blockquote>
<p><strong>Note:</strong> If you look closely, some of these risks seem to overlap with others, and some may seem to be defined in the same way. This is called the “<strong>chain link of risk</strong>”. But deep down they are different from each other.</p>
</blockquote>
<p>Once we’ve identified these risks, the next step is to prioritize them (Critical, Medium, or Low) based on various factors such as severity, likelihood of occurring, potential damage that may happen if the threat occurs, and so on.</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Risk Level</td><td>Assigned Risks</td></tr>
</thead>
<tbody>
<tr>
<td>Critical Risk</td><td>1. Customer data leakage  </td></tr>
</tbody>
</table>
</div><p>3. Man-in-the-Middle attacks<br>4. Non-Compliance with PCI DSS<br>5. Unauthorized transactions or stolen payment details<br>7. Database Exploits |
| Medium Risk | 6. Server vulnerabilities |
| Low Risk | 7. Missing patch updates |</p>
<h3 id="heading-step-3-complete-a-controls-assessment">Step 3: Complete a Controls Assessment</h3>
<p>This phase ensures that security checkpoints/controls are implemented for the risks we’ve identified while maintaining compliance standards. If any security controls are missing, the audit documents them and provides optimized preventative measures to safeguard the WalkGen website.</p>
<p>In this particular scenario, some control assessments could be:</p>
<ul>
<li><p>Implementing Multi-Factor Authentication (MFA) or 2 Factor Authentication (2FA) using a one time password (OTP) request to a registered mobile number to prevent accidental exposure of customer data.</p>
</li>
<li><p>Protecting data using encryption standards such as AES (Advanced Encryption Standard)-256 and TLS (Transport Layer Security) 1.3 for secure data transmission, thus helping eliminate possible man-in-the-middle attacks.</p>
</li>
<li><p>Also, <a target="_blank" href="https://www.freecodecamp.org/news/how-to-create-a-python-siem-system-using-ai-and-llms/">implementing SIEM</a> (Security Information and Event Management) Tools for event logging to prevent Man-in-the-Middle attacks.</p>
</li>
<li><p>Account compromise often happens through brute-force attacks when the attacker makes multiple login attempts while trying to guess a user’s password. On the walkGen website, a security plugin has been implemented to block multiple login attempts.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1742237464615/aba6bb18-48dd-40d1-8d27-681711077ef9.png" alt="Security plugin" class="image--center mx-auto" width="1278" height="548" loading="lazy"></p>
</li>
<li><p>As stated in the "chain link of risk," the risks of non-compliance with PCI DSS and unauthorized transactions or stolen payment details fall into the same category. We can mitigate these risks by enabling proper authorization during payment transactions and, more importantly, disabling the "Remember my card" option by default, which significantly reduces the risk.</p>
</li>
<li><p>Server vulnerabilities and missing patch updates also fall into the same category of human-based risks. These risks are mitigated by providing periodic updates and reminders to the respective person in charge for walkGen servers. There is a high likelihood that hosting clouds such as Azure, AWS, or Google Cloud Platform (GCP) may have server vulnerabilities, which we can avoid by keeping them updated to their latest versions.</p>
</li>
</ul>
<p>This phase helps us understand the actual security posture in protecting the website from real time attacks.</p>
<h3 id="heading-step-4-assess-compliance">Step 4: Assess Compliance</h3>
<p>Usually, this phase is merely a continuation of the previous phase. But in an audit, equal weight is given to both risk and compliance. This means that we’ll need to conduct a separate compliance review for all the measures taken to mitigate the risks.</p>
<p>Industry regulations and security standards such as GDPR, PCI DSS, Cybersecurity Best Practices, and ISO 27001 (Information Security Management System) are applicable to WalkGen. Assessing whether these standards are maintained and followed is important – otherwise the website may face threats or heavy fines for non-compliance.</p>
<p>These frameworks are general and foundational frameworks that must be adhered to by almost all companies, regardless of their working model. But there are certain frameworks that are more specific to companies like WalkGen.</p>
<p>One specific framework for walkGen would be ISO 22301 (Business Continuity Management System - BCMS), which helps to ensures that walkGen can continue its operations during cyber attacks (if this happens). It also ensures that the company creates disaster recovery and risk mitigation plans to prepare for the worst case scenario.</p>
<blockquote>
<p><strong>Note:</strong> If a security control is effective in mitigating the risk but is still not compliant with regulations, it’s considered a red flag in security.</p>
</blockquote>
<p>At this stage, 95% of the audit is complete. The team members conducting the audit should have a clear understanding of the risks managed, the security working model, the frameworks implemented, and the security protocols that WalkGen adheres to.</p>
<h3 id="heading-step-5-communicate-to-stakeholders">Step 5: Communicate to Stakeholders</h3>
<p>This phase concludes the audit process for walkGen and provides the audit results to the relevant security teams and board members, such as founders and the CEO. This report helps them understand the findings and determine the next steps for the website, including how much funding should be allocated for the necessary security measures.</p>
<p>The report for security teams will contain a lot of technical nuances, such as the scope of the website, how vulnerabilities are identified (with code snippets), and a detailed walkthrough of each vulnerability. In contrast, the report for non-technical people, including potentially founders and CEOs, will provide high-level information about the audit and security gaps.</p>
<p>Typically, WalkGen's audit report provides insights such as:</p>
<ul>
<li><p>A summary of identified risks and managed threats</p>
</li>
<li><p>Implemented security frameworks</p>
</li>
<li><p>Compliance status: Statements such as "WalkGen meets industry standards like GDPR and ISO 22301."</p>
</li>
<li><p>Recommendations and further steps, includes suggested security enhancements, security budget requirements, and respective action plans for WalkGen.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Companies should conduct security audits regularly. Each time, they should compare the current results with the previous audit’s results to check the analytics and security status of the organisation.</p>
<p>I hope this article gave you a better idea about what’s involved in a security audit and why they’re necessary for companies to complete on a regular basis. It’s important for companie to stay resilient against cyber threats, reduce potential and legal risks, and maintain customer trust in this evolving digital world.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is Penetration Testing in Cybersecurity? A Beginner's Guide ]]>
                </title>
                <description>
                    <![CDATA[ In today's digital world, almost every activity we engage in is intertwined with technology. From making payments via UPI and booking movie or travel tickets online to selling products through e-commerce platforms, technology has become an integral p... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/beginners-guide-to-penetration-testing-cybersecurity/</link>
                <guid isPermaLink="false">67a62fc9c3ae66ee9e7a4b3e</guid>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ hacking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ penetration testing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ security testing  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ P S Mohammed Ali ]]>
                </dc:creator>
                <pubDate>Fri, 07 Feb 2025 16:07:37 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1738941455446/843335c0-35a3-4173-bd4c-7baf0e630e8e.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In today's digital world, almost every activity we engage in is intertwined with technology. From making payments via UPI and booking movie or travel tickets online to selling products through e-commerce platforms, technology has become an integral part of our daily routine.</p>
<p>To make sure that these activities are safe and secure, dev teams need to have a robust security testing framework in place. This helps identify vulnerabilities, prevent cyber threats, and maintain the integrity of digital transactions.</p>
<p>In this article, you will learn all about penetration testing – what it is, why each phase of the process is important, and the tools pentesters use to do their jobs.</p>
<h2 id="heading-what-is-penetration-testing">What is Penetration Testing?</h2>
<p>Penetration Testing is a practice used by security professionals to help companies and teams secure their data. A company gives the security pro permission to try to find vulnerabilities in their system. The security pro then reports any potential weak spots they find to the company so they can fix them. This helps these companies prevent potential attacks before hackers can get access to their data.</p>
<p>If a company fails to conduct pentesting, it can lead to serious consequences like policy violations, hefty compliance regulation fines, loss of customer trust, and a decline in the organization's reputation and overall business value.</p>
<p>There are four phases of penetration testing:</p>
<ol>
<li><p>Reconnaissance</p>
</li>
<li><p>Scanning</p>
</li>
<li><p>Exploitation</p>
</li>
<li><p>Report Submission</p>
</li>
</ol>
<p>Let’s go through each one so you can learn what’s involved in the entire process.</p>
<h2 id="heading-reconnaissance-the-art-of-information-gathering">Reconnaissance: The Art of Information Gathering</h2>
<p>Reconnaissance involves gathering information about the target system or network. A pentester’s goal here is to collect as much data as possible about the target, helping them understand the target’s architecture, identify potential vulnerabilities, and develop an effective attack strategy.</p>
<p>In reconnaissance, testing can be conducted in various ways, such as browsing social media for information about the target, using information-gathering tools like theHarvester to crawl websites related to the target domain, and more.</p>
<p>At this stage, all available data—whether technical or non-technical—is gathered without filtering for relevance. The goal is to collect as much information as possible, as even seemingly insignificant details can later prove useful in an attack.</p>
<p>Reconnaissance is crucial for a successful penetration test. So it can be a time-consuming process, often taking anywhere from a few hours to several weeks, depending on the complexity of the target.</p>
<h3 id="heading-types-of-reconnaissance"><strong>Types of Reconnaissance</strong></h3>
<p>We can categorize reconnaissance into two main types based on the level of interaction with the target system:</p>
<p>First, we have passive reconnaissance. This involves gathering information from publicly available sources <strong>without directly interacting</strong> with the target system. Since no direct contact is made, it is stealthy and less likely to alert the target.</p>
<p>At this point, a question may arise: If penetration testing is conducted with prior approval from the target domain, why should we conduct passive reconnaissance to minimize direct interaction when we have the freedom to perform active reconnaissance?</p>
<p>Well, a penetration tester must think from an unethical hacker's perspective. Attackers often rely heavily on passive reconnaissance techniques to gather critical information without alerting the target, making it a crucial phase in ethical hacking as well.</p>
<p>This is why penetration testing should include passive reconnaissance. It helps identify potential information leaks, such as a target company's public announcements or employees posting coding-related doubts on platforms like Substack, which could lead to unauthorized system access.</p>
<p>Active Reconnaissance, on the other hand, involves <strong>direct interaction</strong> with the target system to extract specific information. Common methods include port scanning, banner grabbing, and network sniffing.</p>
<p>This approach provides more accurate and detailed information, but it comes with a higher risk—the tester’s IP address or digital footprint may be logged by the target system.</p>
<p>For the reconnaissance phase, there are numerous tools available on the internet. But a few are considered highly efficient and popular among penetration testers. Some of these include Medusa and theHarvester.</p>
<p>As an example here, we’ll use theHarvester to gather information on a target domain (Zudio.com) and analyze the different types of data retrieved by the tool.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1738871546984/dc7e71a4-e76d-42df-b895-4b2f626fe902.png" alt="dc7e71a4-e76d-42df-b895-4b2f626fe902" class="image--center mx-auto" width="592" height="335" loading="lazy"></p>
<p>You can see that the tool crawled the Brave search engine and discovered a couple of IP addresses along with additional subdomains of the target domain (Zudio.com). These findings should be properly documented and included in the target’s reconnaissance report.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1738871767740/e0af88ca-35ec-435c-9196-2a0f173cb6fd.png" alt="Findings from gathering info using theHarvester" class="image--center mx-auto" width="433" height="462" loading="lazy"></p>
<h2 id="heading-scanning-the-art-of-detecting-loopholes">Scanning: The Art of Detecting Loopholes</h2>
<p>The information a pentester gathers during the reconnaissance phase serves as a crucial input for the scanning phase. This data helps them gain deeper insights into the target system, allowing them to pinpoint areas and filter data that require further analysis.</p>
<p>With a wide range of scanning tools available, pentesters utilize various techniques to:</p>
<ul>
<li><p>Identify open ports, as they can serve as potential entry points.</p>
</li>
<li><p>Monitor network activity to detect vulnerabilities and security gaps.</p>
</li>
</ul>
<h3 id="heading-phases-of-scanning"><strong>Phases of Scanning</strong></h3>
<p>Scanning typically involves two key steps:</p>
<p>First, we have <strong>port scanning</strong>, which identifies open and closed ports on the target system. This helps determine which services are running and are potentially exploitable.</p>
<p>System Ports serve as entry points for a computer system to perform various tasks. Ensuring that all unnecessary ports are closed is crucial for security. Leaving optional ports open can create potential entry points for hackers.</p>
<p>You can use tools like <strong>Nmap, Netcat, Masscan</strong> for this purpose.</p>
<p>For better understanding, let's scan a sample target domain (192.168.13.136) using Nmap and check which service ports are open.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1738868226793/82cc30ab-7383-4b81-95ab-95e6a1b9bf07.png" alt="Nmap scan Result for sample target domain showing open ports" class="image--center mx-auto" width="641" height="510" loading="lazy"></p>
<p>Next, we have <strong>vulnerability scanning</strong>, which detects weaknesses in software, configurations, and services. It helps pentesters assess the security risks associated with identified ports and services.</p>
<p>Let’s use the same nmap tool to detect the vulnerabilities from the identified open ports. In the scanning results, you can see that port 21 is open and this port is specifically used for File Transfer Protocol.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1738871075994/70823cf4-97ce-4cb7-b76b-0a8db3acb1bb.png" alt="Results of nmap vulnerability scan" class="image--center mx-auto" width="819" height="333" loading="lazy"></p>
<p>Here, we run Nmap on the target address (192.168.13.136) to scan FTP port 21 using the ftp-brute script. This allows us to check whether the FTP service is accessible using default usernames and passwords.</p>
<p>During the scan, we were able to extract additional useful information, including details about the FTP server version (vsftpd 2.3.4). This information can be valuable for identifying potential vulnerabilities in this version.</p>
<p>Finally, the tool successfully identified a vulnerability in the server by discovering valid usernames and passwords from the dictionary list included in the tool.</p>
<p>In general, reconnaissance and scanning are often overlooked by security analysts, assuming they are not important. But these phases provide a valuable dataset and a deeper understanding of the target domain. They help in filtering and directing the exploitation process, allowing penetration testers to focus on specific vulnerabilities instead of blindly attempting various exploits.</p>
<p>Skipping these phases leads to inefficiency, wasting time, resources, and effort. So for successful exploitation, it is essential to conduct thorough information gathering and scanning before proceeding further.</p>
<h2 id="heading-exploitation-the-art-of-attack-simulation">Exploitation: The Art of Attack Simulation</h2>
<p>The outcome of the scanning phase gives pentesters a clear understanding of potential entry points, commonly referred to as “open doors”, through identified ports and services. These insights help testers determine which vulnerabilities can be exploited to simulate a real-world cyberattack.</p>
<p>Once vulnerabilities are identified, testers deploy various attack techniques to assess their impact. The goal is to demonstrate how a malicious hacker could gain unauthorized access and compromise the target system. Some common attack methods include:</p>
<ul>
<li><p><strong>SQL Injection</strong> – Exploiting database vulnerabilities.</p>
</li>
<li><p><strong>Cross-Site Scripting (XSS)</strong> – Injecting malicious scripts into web applications.</p>
</li>
<li><p><strong>Buffer Overflow</strong> – Overwriting memory to execute malicious code.</p>
</li>
<li><p><strong>Brute Force Attacks</strong> – Cracking weak passwords for system access.</p>
</li>
</ul>
<p>For a clearer understanding, let's explore how database vulnerabilities are exploited using SQL Injection attacks.</p>
<p>Let's say there is a username and password field in a login form. Typically, when a user enters their credentials, the system fetches these input values, constructs a SQL query, and sends it to the server for authentication.</p>
<p>SQL Injection works by manipulating this query to bypass authentication. At a basic level, an attacker can input specially crafted values to alter the query logic. For example, consider the following SQL query:</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> PRODUCTS <span class="hljs-keyword">WHERE</span> USERNAME = <span class="hljs-string">" OR 1=1 -- "</span> <span class="hljs-keyword">AND</span> <span class="hljs-keyword">PASSWORD</span> = <span class="hljs-string">"1234"</span>
</code></pre>
<p>Let’s break down this exploit to see what’s going on:</p>
<ul>
<li><p>The OR 1=1 condition always evaluates to true, meaning the query retrieves all records from the database.</p>
</li>
<li><p>The <code>--</code> sequence is a comment operator in SQL, which ignores the rest of the query (including password verification).</p>
</li>
</ul>
<p>As a result, the attacker gains access without valid credentials, effectively bypassing authentication.</p>
<h2 id="heading-report-submission-the-art-of-validation">Report Submission: The Art of Validation</h2>
<p>The final phase of penetration testing involves reporting the vulnerabilities identified during the security test cycle. These reports are crucial for guiding the remediation process, ensuring that the company addresses any weaknesses before they can be exploited.</p>
<p>Penetration testing reports typically include detailed information about the attacks conducted, the respective results, and an assessment of the risks involved. Importantly, the language used in these reports is non-technical, as the findings are often shared with different teams across the organization, including:</p>
<ul>
<li><p>Management</p>
</li>
<li><p>Higher authorities</p>
</li>
<li><p>Non-technical teams (like HR, legal, and so on)</p>
</li>
</ul>
<p>These reports must be easily understandable and confidential, as they may contain sensitive information about the organization’s vulnerabilities.</p>
<p>The report should include the following key parameters:</p>
<ul>
<li><p>Number of employees involved</p>
</li>
<li><p>Start date and end date of the assessment</p>
</li>
<li><p>List of target domains</p>
</li>
<li><p>List of open ports (if any)</p>
</li>
<li><p>List of identified vulnerabilities, categorized by risk level (Critical, High, Medium, Low, Informational)</p>
</li>
<li><p>Preventive measures to mitigate risks</p>
</li>
<li><p>List of tools used during the assessment</p>
</li>
</ul>
<p>While the structure and content of these reports may vary from organization to organization, the above parameters are mandatory for a comprehensive security assessment.</p>
<p>The goal is to ensure that stakeholders at all levels of the organization can take appropriate action, whether it's patching a vulnerability, revising a policy, or updating a security strategy.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>The penetration testing lifecycle is continuous and it’s something your team must perform periodically. You can’t just do it once, address those concerns, and forget about it.</p>
<p>As new vulnerabilities emerge with the release of updated versions of software, applications, and systems, penetration testing remains essential in identifying and addressing these new risks.</p>
<p>A proactive approach to security through continuous penetration testing is crucial for maintaining a safe and secure digital environment for organizations and their users.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is Socket Programming in Python? ]]>
                </title>
                <description>
                    <![CDATA[ In this article, you will learn how to code a socket program in Python. But before that, let's understand what a socket is and where you might use it. We can define a socket as a quick connection which allows the transmission of data between two proc... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/socket-programming-in-python/</link>
                <guid isPermaLink="false">66d460c9b3016bf139028d8b</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ P S Mohammed Ali ]]>
                </dc:creator>
                <pubDate>Thu, 25 May 2023 14:25:40 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/05/ab_networks_network_8uds-1030x438-1.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this article, you will learn how to code a socket program in Python. But before that, let's understand what a socket is and where you might use it.</p>
<p>We can define a socket as a quick connection which allows the transmission of data between two processes on the same machine or different machines over a network. It is commonly used in client-server interaction, as sockets allow applications to communicate using the built-in mechanisms of the hardware and operating system.</p>
<p>Many of the today’s most used software – including web browsers, file sharing software, and social media instant messaging applications like WhatsApp and others – fundamentally depend on the concept of sockets.</p>
<p>Usually, a socket program is comprised of two main programs called the client and server. Here, the <strong>client acts as the requester</strong>, where it requests some data. The <strong>server acts as the listener</strong> and provides the client the requested data as the response.</p>
<p>In Python, creating a client and server program is a simple task, as Python has many inbuilt modules to help with this.</p>
<h2 id="heading-how-to-code-the-server">How to Code the Server</h2>
<p>First, let's code our server program. To keep it simple, let's assume that the server listens to the host on a particular port. Whatever data it receives, it just prints and send some random ASCII letters as a response.</p>
<pre><code class="lang-python"><span class="hljs-comment"># server.py</span>
<span class="hljs-comment"># Importing neccessary inbuilt modules</span>
<span class="hljs-keyword">import</span> socket
<span class="hljs-keyword">import</span> random
<span class="hljs-keyword">import</span> string

<span class="hljs-comment"># Creating a socket instance</span>
server_object = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)

<span class="hljs-comment"># Connecting to the localhost</span>
ip_address = <span class="hljs-string">'127.0.0.1'</span>
port = <span class="hljs-number">5555</span>
server_object.bind((ip_address, port))
server_object.listen()

<span class="hljs-comment">#Once the client connects to the particular port, the server starts to accept the request.</span>
connection_object, _ = server_object.accept()


<span class="hljs-keyword">if</span> connection_object:
    <span class="hljs-comment"># Connected to client successfully</span>
    print(<span class="hljs-string">"SERVER CONNECTED TO CLIENT"</span>)

    <span class="hljs-comment"># sending initial message to the client</span>
    connection_object.send(<span class="hljs-string">b"type the message"</span>)

    <span class="hljs-comment"># receiving message from the client</span>
    data_receive = connection_object.recv(<span class="hljs-number">1024</span>)

    <span class="hljs-keyword">while</span> data_receive != <span class="hljs-string">b'stop'</span>:
        print(<span class="hljs-string">"{}: {}"</span>.format(<span class="hljs-string">"CLIENT MESSAGE: "</span>, data_receive.decode(<span class="hljs-string">'utf-8'</span>)))
        server_input = random.choice(string.ascii_letters)
        connection_object.send(server_input.encode(<span class="hljs-string">'utf-8'</span>))
        data_receive = connection_object.recv(<span class="hljs-number">1024</span>)
</code></pre>
<p>In the above code, we created a socket instance for the server. You can see that <code>family=socket.AF_INET</code> defines the address family that this socket can accept – only IPv4 addresses. And <code>type=socket.SOCK_STREAM</code> defines that the socket accepts only TCP (Transmission Control Protocol) connections.</p>
<p>For the server socket instance to listen and accept requests, it needs an IP address and a port. So, we have <code>ip_address = '127.0.0.1'</code> and <code>port = 5555</code>. Here, we have localhost as our IP address as the server and client reside in the same machine.</p>
<p>In the next step, the server instance <code>server_object</code> establishes (binds) an address so that clients can use it to find the server. The <code>bind((ip_address,port))</code> method assigns a local IP address and a port number to this <code>server_object</code> instance explicitly as the server programs listens on the published port <code>port</code>. A port and local IP address neds to be assigned.</p>
<p>It then starts to actively listens on that particular port. When the client connects to that port from the client side, the server instance accepts the client's request for a connection. It then creates a new <code>connection_object</code> and returns to the server instance.</p>
<p>This <code>connection_object</code> contains all the necessary information about the client and server. Now, we use this <code>connection_object</code> to send a message from the server to client. So we print a <code>SERVER CONNECTED TO CLIENT</code> message if the <code>connection_object</code> is created successfully.</p>
<p>Once the <code>connection_object</code> is created, then the instance sends an initial message <code>type the message</code> in bytes to the client and receives the request from the client.</p>
<p>In the <code>while</code> loop, the connection instance <code>connection_object</code> prints the client message. Then as a response it sends random ASCII letters and waits for the client request. This <code>while</code> loop will execute in the server program until the client sends the request message <code>stop</code>.</p>
<h2 id="heading-how-to-code-the-client">How to Code the Client</h2>
<p>Up to this point, we have seen the server side code. Now, lets code the client side which is pretty simple.</p>
<pre><code class="lang-python"><span class="hljs-comment"># client.py</span>

<span class="hljs-comment">#importing socket module</span>
<span class="hljs-keyword">import</span> socket

<span class="hljs-comment"># creating socket instance</span>
client_object = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)

<span class="hljs-comment"># target ip address and port</span>
ip_address = <span class="hljs-string">'127.0.0.1'</span>
port = <span class="hljs-number">5555</span>

<span class="hljs-comment"># instance requesting for connection to the specified address and port</span>
client_object.connect((ip_address,port))

<span class="hljs-comment"># receiving response from server</span>
data_receive = client_object.recv(<span class="hljs-number">1024</span>)

<span class="hljs-comment"># if response is not null</span>
<span class="hljs-keyword">if</span> data_receive:
    <span class="hljs-comment"># Connection is successful</span>
    print(<span class="hljs-string">"CLIENT CONNECTED TO SERVER"</span>)
    print(data_receive.decode(<span class="hljs-string">'utf-8'</span>))


    <span class="hljs-keyword">while</span> data_receive:
        <span class="hljs-comment"># user input</span>
        client_input = input().encode(<span class="hljs-string">'utf-8'</span>)

        <span class="hljs-comment"># sending request to the server</span>
        client_object.send(client_input)

        <span class="hljs-comment"># receiving response from the server</span>
        data_receive = client_object.recv(<span class="hljs-number">1024</span>)
        <span class="hljs-keyword">if</span> data_receive:
            print(<span class="hljs-string">"{}: {}"</span>.format(<span class="hljs-string">"SERVER"</span>,data_receive.decode(<span class="hljs-string">'utf-8'</span>)))
</code></pre>
<p>In the client side code, we have created a similar socket instance <code>client_object</code>, the target <code>ip_address</code>, and <code>port</code>, just like we created in the server side program.</p>
<p>The next step is to use the <code>client_object</code> instance and connect to the respective target address and port using the <code>connect()</code> method.</p>
<p>Once the connection is successful and the <code>connection_object</code> is created on the server side, then the server sends the response <code>type the message</code> which gets stored in the <code>data_receive</code> in the client side.</p>
<p>Since the server has sent the message, we use this message to confirm that the connection is successful. So, we print <code>CLIENT CONNECTED TO SERVER</code> and then print the message sent by the server <code>type the message</code>.</p>
<p>In the <code>while</code> loop, we first give the input in a string using the <code>input()</code> inbuilt function. Then we convert it to bytes using the <code>encode('utf-8')</code> method and store it in <code>client_input</code> (as the data can be sent only in bytes). We then send the <code>client_input</code> to the server using <code>client_object.send(client_input)</code>.</p>
<p>We receive the response data from the server after sending the request to the server. The server will accept and give a response to the client until the user types <code>stop</code> as a request to the server.</p>
<p><strong>Note:</strong> We have to first execute the server program and then the client program because when client wants to connect to the target, there should be a server listening, up and running.</p>
<p>Here's the execution of of <code>server.py</code> and then <code>client.py</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/ff.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Left-Side: Server Program, Right-Side: Client Program</em></p>
<p>As you can see, once the execution started, the server displayed <code>SERVER CONNECTED TO CLIENT</code> so the user can tell it's working, and sent the initial message to the client.</p>
<p>On the client side, when the client received the message, it displayed <code>CLIENT CONNECTED TO SERVER</code> and also printed <code>type the message</code> received from the client.</p>
<p>Since the client is waiting for the input from the user, once the user entered the input, it sends it to the server and the server prints the client message. It then sent the random ASCII letter as the response to the client.</p>
<p>The flow looped until the client sent the <code>stop</code> message as the request to the server. Once the server received the <code>stop</code> request, it terminated from the socket session.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this tutorial, We understood socket is one of the most fundamental technologies of computer networking and learnt how to set up a socket program in Python using the socket module in client-side and server-side programs.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Handle Errors in Python – the try, except, else, and finally Keywords Explained ]]>
                </title>
                <description>
                    <![CDATA[ “It’s hard enough to find an error in your code when you’re looking for it; it’s even harder when you’ve assumed your code is error-free.”― Steve McConnell Errors are inevitable in a programmer's life. In fact, while writing programs, errors can be ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-handle-errors-in-python/</link>
                <guid isPermaLink="false">66d460c5b6b7f664236cbe45</guid>
                
                    <category>
                        <![CDATA[ error handling ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ P S Mohammed Ali ]]>
                </dc:creator>
                <pubDate>Tue, 01 Nov 2022 14:53:34 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/10/11.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <blockquote>
<p>“It’s hard enough to find an error in your code when you’re looking for it; it’s even harder when you’ve assumed your code is error-free.”<br>― Steve McConnell</p>
</blockquote>
<p>Errors are inevitable in a programmer's life. In fact, while writing programs, errors can be really helpful in identifying the logic bugs and syntax errors in your code.</p>
<p>But, if you can anticipate an error in a particular set of code lines before execution, then you can handle those errors and make the code error free.</p>
<h2 id="heading-why-error-handling-is-important">Why Error Handling is Important</h2>
<p>Handling or taking care of errors that you're aware of helps the code flow and execute smoothly without any interruptions. If errors occur in any lines of code, the error handling takes care of them and then the code resumes execution.</p>
<p>Let's take an example and understand why we need error handling:</p>
<pre><code class="lang-python">a = <span class="hljs-number">12</span>
b = <span class="hljs-number">6</span>
result = a/b
print(result)
print(<span class="hljs-string">"I have reached the end of the line"</span>)
</code></pre>
<p>From the above code, what do you expect ?. Well, the <code>result</code> variable prints <code>2.0</code> and on the next line, the console prints <code>I have reached the end of the line</code>. That's what we are excepting.</p>
<p>Let's change value of <code>b</code> from <code>b = 6</code> to <code>b = 0</code> and run.</p>
<pre><code class="lang-python"><span class="hljs-number">1.</span> a = <span class="hljs-number">12</span>
<span class="hljs-number">2.</span> b = <span class="hljs-number">0</span>
<span class="hljs-number">3.</span> result = a/b
<span class="hljs-number">4.</span> print(result)
<span class="hljs-number">5.</span> print(<span class="hljs-string">"I have reached the end of the line"</span>)
</code></pre>
<p>When this code gets executed, we will get an error as below:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/2.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Error message displayed when b is set to 0</em></p>
<p>The code didn't print the <code>result</code> value and it also didn't print <code>I have reached the end of the line</code></p>
<p>The above error messages displays <code>division by zero</code>, which means that if we try to divide any number by <code>0</code>, we will get this error.</p>
<p>The problem is in line <code>3</code>. Even though the code didn't print the <code>result</code> value, it should have printed <code>I have reached the end of the line</code>. But, it didn't – why ?</p>
<p>Well, because the Python interpreter stopped at line 3 when the <code>a</code> got divided by <code>0</code>. At this point, it raised an error in the console and exited the code.</p>
<p>One of the naive solutions to solve this problem can be hard coding the values. If the values of <code>a</code> and <code>b</code> are hard-coded, then running the code will solve this error to some extent.</p>
<p>But the other major problem that may arise is when a user wants to give values of <code>a</code> and <code>b</code> at the time of execution.</p>
<pre><code class="lang-python">a = int(input())
b = int(input())
result = a/b
print(result)
print(<span class="hljs-string">"I have reached the end of the line"</span>)
</code></pre>
<p>At this time, there's a high probability that the user will give <code>0</code> as the input to <code>b</code>. In order to handle this kind of expected error, we will use certain methods of error handling in order to avoid interrupting the execution flow (even though the user might give any invalid input like <code>0</code> as input to <code>b</code>).</p>
<h2 id="heading-how-to-use-the-try-and-except-keywords-in-python">How to Use the Try and Except Keywords in Python</h2>
<p>Any lines of code that are more prone to errors are kept in <code>try</code> block. If any error occurs, then the <code>except</code> block will take care of those errors.</p>
<p>The code structure looks something like this:</p>
<pre><code class="lang-python"><span class="hljs-keyword">try</span>:
   code that may/may <span class="hljs-keyword">not</span> produce errors
<span class="hljs-keyword">except</span>:
   when error arises, then this block of code exceutes.
   Otherwise, this block of code doesn<span class="hljs-string">'t exceute</span>
</code></pre>
<p>Let's come back to the standard example that we have been discussing. We will handle the <code>division by zero</code> problem using <code>try/except</code> blocks.</p>
<p>Let's insert the lines of code that have a high probability of producing an error. In our case, lines <code>1-4</code> of our code have high potential to produce an error. So, we put these four lines in the <code>try</code> block:</p>
<pre><code class="lang-python"><span class="hljs-keyword">try</span>:
  a = int(input())
  b = int(input())
  result = a/b
  print(result)
<span class="hljs-keyword">except</span>:
  print(<span class="hljs-string">"We caught an error"</span>)

print(<span class="hljs-string">"I have reached the end of the line"</span>)
</code></pre>
<p>Now, when we give <code>b</code> a value of <code>0</code>, an error occurs. So, the <code>except</code> block executes and the interpreter prints <code>We caught an error</code> and comes out of the except block and resumes printing <code>I have reached the end of the line</code>.</p>
<p>On the other hand, when we give <code>b</code> a non-zero value, then we print the <code>result</code> value. The code comes out of the try block and resumes printing <code>I have reached the end of the line</code>.</p>
<p>In both cases, we are able to execute until the last line of code without any interruptions.</p>
<p>Apart from try and except, it's quite important to understand the <code>else</code> and <code>finally</code> keywords that come along with <code>try</code> and <code>except</code>.</p>
<p>The <code>else</code> block of code comes after the <code>try</code> and <code>except</code> blocks and executes when no error is raised from the <code>try</code> code block. Similarly, the <code>finally</code> code block comes after the <code>else</code> block and executes whether errors occur or not – this block will execute for sure.</p>
<p>Now that you understand how the <code>try</code>, <code>except</code>, <code>else</code>, and <code>finally</code> code blocks work, the order of flow will be:</p>
<pre><code class="lang-python"><span class="hljs-keyword">try</span>:
   code that may/may <span class="hljs-keyword">not</span> produce errors

<span class="hljs-keyword">except</span>:
   when error arises, then this block of code exceutes

<span class="hljs-keyword">else</span>:
   when error doesn<span class="hljs-string">'t arise, then this block of code exceutes

finally:
   This block will exceute whether error occurs or not.</span>
</code></pre>
<p>On applying the same structure to the number division problem, we get this:</p>
<pre><code class="lang-python"><span class="hljs-keyword">try</span>:
  a = int(input())
  b = int(input())
  result = a/b
  print(result)

<span class="hljs-keyword">except</span>:
   print(<span class="hljs-string">"We caught an error"</span>)

<span class="hljs-keyword">else</span>:
   print(<span class="hljs-string">"Hurray, we don't have any errors"</span>)

<span class="hljs-keyword">finally</span>:
   print(<span class="hljs-string">"I have reached the end of the line"</span>)
</code></pre>
<p>When <code>b</code> is assigned <code>0</code>, then we get an error. So, the except block executes and prints <code>We caught an Error</code> and finally the code block executes and prints <code>I have reached the end of the line</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/11/55.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Code execution flow when error occurs</em></p>
<p>On the other hand, if <code>b</code> gets <code>6</code> for example (or any non-zero value), then we divide the <code>a</code> value by <code>6</code> and store it in the <code>result</code> variable. The code then prints the <code>result</code> value.</p>
<p>Then, the <code>else</code> block executes and prints <code>Hurray, we don't have any errors</code> and finally the code block executes and prints <code>I have reached the end of the line</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/11/56.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Code execution flow when no error raises</em></p>
<h2 id="heading-summary">Summary</h2>
<p>Now I hope you understand how you can implement error handling in Python in order to catch potential errors with <code>try/except</code> blocks.</p>
<p>You've also learned how to use the <code>else</code> and <code>finally</code> code blocks that are associated with these error handling methods.</p>
<p>Happy Programming...</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Sort a List Recursively in Python ]]>
                </title>
                <description>
                    <![CDATA[ When you want to sort a list or array in Python, there are many sorting algorithms you can use. Some use looping concepts like Insertion Sort, Bubble Sort, and Selection Sort. On the other hand, you can also sort the same list or array using Merge So... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-sort-recursively-in-python/</link>
                <guid isPermaLink="false">66d460c7f855545810e934cf</guid>
                
                    <category>
                        <![CDATA[ algorithms ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Recursion ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ P S Mohammed Ali ]]>
                </dc:creator>
                <pubDate>Fri, 23 Sep 2022 14:35:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/09/max-harlynking-_QcLpud-gD0-unsplash-1.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>When you want to sort a list or array in Python, there are many sorting algorithms you can use.</p>
<p>Some use looping concepts like Insertion Sort, Bubble Sort, and Selection Sort. On the other hand, you can also sort the same list or array using Merge Sort with the help of recursion.</p>
<p>In this article, you will learn how the Merge Sort algorithm works. You will also learn how recursion plays an important role in Merge Sort.</p>
<h2 id="heading-how-recursion-works">How Recursion Works</h2>
<p>As a prerequisite, we will first understand how recursion works, as it's the backbone of the merge sort algorithm.</p>
<p>First, you should know that a recursive function is one that calls itself until it reaches its desired outcome.</p>
<p>Now, unless you set some condition to stop this process, it'll go on forever – or until your JS code throws an error. This is known as a base case, and it will stop the function from calling itself when its condition is met.</p>
<p>Now that you know the basics of recursion, let's get into the weeds a bit and understand how it works under the hood:</p>
<p>In general, recursion works based on a concept called Principal Mathematical Induction (PMI). In simple words, PMI is a technique which is used to prove certain statements from a basic set of proven statements.</p>
<p>Usually, there are three steps in this process.</p>
<p>Let's prove that the formula of n natural number is <code>P(n)= n*(n+1)/2</code> using PMI:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/123.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>To prove that P(n) is true</em></p>
<p>Step 1: The first step is also known as the <strong>base case</strong>. During this step, you specify the proven statements. Universally, we know that the sum of the first 1 natural number is <code>1</code>. Let's consider it the left-hand side of the equation (LHS).</p>
<p>When we apply <code>n = 1</code> in the the formula, we get <code>p(1) = 1*(1+1)/2 =&gt; 1</code> as the right-hand side (RHS).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/1234.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Applying 1 in formula</em></p>
<p>This means that LHS = RHS. This step confirms it's a valid base case.</p>
<p>Step 2: This step is known as the <strong>Induction Hypothesis</strong>. In this step, we simply assume that this formula is true for some integer <code>k</code> where <code>1 &lt; k &lt; n</code>. So, we substitute k in the formula and we get <code>p(k) = k*(k+1)/2</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/12345.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Induction Hypothesis step for some Integer value k</em></p>
<p>Step 3: This step is known as <strong>the Induction Step</strong>. At this point, we have to prove that this will work for the integer <code>k+1</code>.</p>
<p>When we substitute <code>k + 1</code> in the formula and consider it as the LHS, then we get the following:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/125.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>LHS Statement for P(k+1)</em></p>
<p>For the RHS, we know that the sum of the natural number <code>k+1</code> integer is equal to the sum of the natural number of <code>k</code> integer and <code>k+1</code>th integer. We can write it like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/21.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Sum of k+1 integers is equal to (k+1)th integer and sum of k Integers</em></p>
<p>The above equation can be rewritten like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/22.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>sum of k natural integers is rewritten as p(k) from step-2</em></p>
<p>At this point, we know the value of p(k) from step-2 (Induction Hypothesis). When we substitute the value of p(k), we get this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/23.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Substitute p(k) from step-2</em></p>
<p>We can take the common denominator and simplify the equation, and we get:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/37.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Simplifying the equation</em></p>
<p>On comparing the LHS and RHS, we get the same result and we have proved that this formula works for <code>k+1</code> integers.</p>
<p>Also, when we substitute <code>n</code> in the place of <code>k+1</code>, we get the end result as:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/45.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Substituting k+1 with n</em></p>
<p>We have proven that formula for n natural number is n*(n+1)/2.</p>
<p>When we observe all the steps in PMI, we did a simple assumption at step-2 and and therefore, we proved the statement at step-3.</p>
<p>This is how recursion works: we initialize a base case for a problem at the start of the function and we assume that this function works for small values of the same problem. Then as the final step, we prove that this works for the existing problem.</p>
<h2 id="heading-how-the-merge-sort-algorithm-works">How the Merge Sort Algorithm Works</h2>
<p>The Merge Sort algorithm works by breaking down an unsorted list into two halves. You then call the merge sort on each of these two parts.</p>
<p>Since, we know recursion works based on Principal Mathematical Induction (PMI), we assume that the smaller lists gets sorted on calling merge sort on these 2 smaller lists.</p>
<blockquote>
<p><strong>Note:</strong> Before calling recursion in smaller lists, it's more important to define a base case for the function as it acts as a stopping point for the recursive call.</p>
</blockquote>
<p>Here, the base case for the merge sort will be if the length of the list is 1. In that case (if the length is 1, it means there's only one item in the list), the list is already sorted so we have to just return the list as it is.</p>
<p>For more clarity, let's take an example and implement merge sort over the unsorted list.</p>
<pre><code class="lang-python">my_list = [<span class="hljs-number">3</span>,<span class="hljs-number">8</span>,<span class="hljs-number">2</span>,<span class="hljs-number">7</span>,<span class="hljs-number">1</span>,<span class="hljs-number">4</span>,<span class="hljs-number">5</span>]
</code></pre>
<p>In the code above, you can see that the variable <code>my_list</code> contains a list which is unsorted.</p>
<p>Now, since the length of my_list is not 1, we can't assume that it is sorted. So, we call merge sort on first half <code>list1 = [3,8,2]</code> and also call merge sort on second half <code>list2 = [7,1,4,5]</code>.</p>
<p>We assume that <code>list1</code> and <code>list2</code> are sorted as per the induction step. Now, the list looks like <code>list1 = [2,3,8]</code> and <code>list2 = [1,4,5,7]</code>. Now, all we have to do is just merge those two sorted lists into one using the two pointer technique.</p>
<p>In order to combine and sort the two smaller sorted lists, we take 2 pointers, pointing at the start of each list.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/56.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Pointers at start index of list and empty list to append the new list while comparing</em></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/333.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Intermediate step in comparing pointer value process</em></p>
<p>We are comparing the value at each place the pointer points, and whichever is smaller we append that value next in the final list. Then we move the pointer place to the next index.</p>
<p>After looping through this process, when we reach the first final index (in one of the two loops we're joining) we stop the loop. Then we append all the values in the other list (if any remain) to the final list.</p>
<p>Using this technique, we can merge and sort the two small pre-sorted lists.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/09/Blank-diagram--1-.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Working Flow of Merge Sort</em></p>
<p>When we're using recursion, we assume that it works when we call the same function for a smaller problem. This assumption comes from the induction hypothesis step in PMI.</p>
<p>So when we declare the base case for the problem, we similarly assume that the function will return the correct answer for smaller problems. All we have to do is prove that this works for larger problems, too.</p>
<p>In this algorithm, we declared that the base case is that for a list length of 1, the list is sorted. In the induction hypothesis step, we assumed that algorithm would work for half of the list. In the third step, we just merged the sorted list and proved that this will work on a larger list.</p>
<h2 id="heading-python-code-for-the-merge-sort-algorithm">Python Code for the Merge Sort Algorithm</h2>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">merge_sort</span>(<span class="hljs-params">my_list</span>):</span>

    <span class="hljs-comment"># Base Case</span>
    <span class="hljs-keyword">if</span> len(my_list) &lt;= <span class="hljs-number">1</span>:
        <span class="hljs-keyword">return</span> my_list

    list_1 = my_list[<span class="hljs-number">0</span>:len(my_list) // <span class="hljs-number">2</span>]
    list_2 = my_list[len(my_list) // <span class="hljs-number">2</span>:]

       <span class="hljs-comment"># Induction Step</span>
    ans_1 = merge_sort(list_1)
    ans_2 = merge_sort(list_2)

    <span class="hljs-comment"># Sorting and merging two sorted list</span>
    sort_list = sort_two_list(ans_1, ans_2)
    <span class="hljs-keyword">return</span> sort_list



<span class="hljs-comment"># Separate Function to sort and merge 2 sorted lists</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">sort_two_list</span>(<span class="hljs-params">list_1, list_2</span>):</span>
    final_list = []
    i = <span class="hljs-number">0</span>
    j = <span class="hljs-number">0</span>
    <span class="hljs-keyword">while</span> i &lt; len(list_1) <span class="hljs-keyword">and</span> j &lt; len(list_2):
        <span class="hljs-keyword">if</span> list_1[i] &lt;= list_2[j]:
            final_list.append(list_1[i])
            i += <span class="hljs-number">1</span>
            <span class="hljs-keyword">continue</span>
        final_list.append(list_2[j])
        j += <span class="hljs-number">1</span>

    <span class="hljs-keyword">while</span> i &lt; len(list_1):
        final_list.append(list_1[i])
        i = i + <span class="hljs-number">1</span>

    <span class="hljs-keyword">while</span> j &lt; len(list_2):
        final_list.append(list_2[j])
        j = j + <span class="hljs-number">1</span>

    <span class="hljs-keyword">return</span> final_list


my_list = [<span class="hljs-number">3</span>, <span class="hljs-number">8</span>, <span class="hljs-number">2</span>, <span class="hljs-number">7</span>, <span class="hljs-number">1</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>]
ans = merge_sort(my_list)
print(ans)
<span class="hljs-comment"># prints [1, 2, 3, 4, 5, 7, 8]</span>
</code></pre>
<p>As you see in the above code, I have implemented two separate functions for sorting and merging the two sorted lists. This leads to better readability and easier code reviews.</p>
<p>The main drawback in merge sort is it uses more space. This is because, at every recursive call, a new list gets created and recursion is called on that new list. So space complexity for the worst case scenario is <code>O(n)</code> and time complexity is <code>O(n log n)</code>.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Merge Sort is pretty quick in sorting a list recursively from a time complexity perspective. This is useful for counting inversions in lists and it's widely used for external sorting applications than other sorting algorithms.</p>
<p>Happy programming...</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
