<?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 Anuj rawal on Medium]]></title>
        <description><![CDATA[Stories by Anuj rawal on Medium]]></description>
        <link>https://medium.com/@anujrawal?source=rss-74d2a114f1a1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kPSOpfLx6HKewndFLy7SMg.jpeg</url>
            <title>Stories by Anuj rawal on Medium</title>
            <link>https://medium.com/@anujrawal?source=rss-74d2a114f1a1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:54:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anujrawal/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[Changing “false” to “true”: How I Discovered an Email Verification Bypass Through Mass Assignment]]></title>
            <link>https://medium.com/@anujrawal/changing-false-to-true-how-i-discovered-an-email-verification-bypass-through-mass-assignment-12233efb1f00?source=rss-74d2a114f1a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/12233efb1f00</guid>
            <category><![CDATA[pentest-web]]></category>
            <category><![CDATA[hackerone]]></category>
            <category><![CDATA[mass-assignment]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Anuj rawal]]></dc:creator>
            <pubDate>Sun, 22 Nov 2026 18:34:14 GMT</pubDate>
            <atom:updated>2026-11-22T18:34:14.111Z</atom:updated>
            <content:encoded><![CDATA[<p>When you sign up on most shopping websites, they ask you to click a link in your email before you can edit your profile or track orders. It’s a basic security check to prove the email actually belongs to you.</p><p>Recently, while testing a bug bounty target (let’s call it <strong>redacted.com</strong>), I found a simple Mass Assignment bug that let me skip this check completely — without ever opening my inbox.</p><p>Here is how I found it.</p><h3>Step 1: Getting Stuck on the Verification Screen</h3><blockquote>I started by creating a brand-new account on redacted.com using a temporary email address.</blockquote><p>As soon as I signed up, the site redirected me to an activation page saying:</p><blockquote>“To access your account, please verify your email by clicking on the link sent to tes***@example.com.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8S_M4PVZC4tJ0y4qJlaAjQ.jpeg" /></figure><p>At this point, my account was locked down. If I tried to change my name or check order history, the site blocked me until I clicked that email link.</p><h3>Step 2: Checking the Traffic in Burp Suite</h3><p>I had Burp Suite running in the background while clicking around the profile page. I looked through my HTTP history and spotted a GET request fetching my account details:</p><pre>GET /mobify/proxy/api/customer/.../customers/{customerId}?siteId=redacted HTTP/1.1<br>Host: redacted.com</pre><p>In the JSON response, one line immediately stood out:</p><pre>{<br>  &quot;customerId&quot;: &quot;12345&quot;,<br>  &quot;email&quot;: &quot;testuser@example.com&quot;,<br>  &quot;c_isCustomerVerified&quot;: &quot;false&quot;<br>}</pre><h3>Step 3: Changing “false” to “true”</h3><p>Whenever an API sends a status flag like isVerified or isAdmin back to the browser, I always like to test if the server lets me overwrite it.</p><p>I sent the request to Burp Repeater, changed the method from GET to PATCH, and sent this JSON body:</p><pre>PATCH /mobify/proxy/api/customer/shopper-customers/v1/organizations/redacted_org/customers/{customerId}?siteId=redacted<br>Host: redacted.com<br>Content-Type: application/json</pre><pre>{<br>  &quot;c_isCustomerVerified&quot;: &quot;true&quot;<br>}</pre><p>The server replied with <strong>200 OK</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/0*kjXlgbFVNON3jKrB" /></figure><p>To confirm that the change was actually saved on the server, I sent another GET request to the customer profile endpoint.</p><p>The response now showed:</p><pre>{<br>  &quot;c_isCustomerVerified&quot;: &quot;true&quot;<br>}</pre><p>I went back to my browser and hit refresh. The “please verify your email” screen was gone. I could now edit my profile details and access order tracking — even though I never clicked the link in my email.</p><h3>What Was the Actual Vulnerability?</h3><p>This was a Mass Assignment vulnerability. The API allowed me to modify the c_isCustomerVerified field directly through a PATCH request. This field should only be controlled by the backend through the email verification process, not by the user.</p><h3>Why Does This Matter?</h3><p>Even though this bug doesn’t leak other users’ data, it breaks an important trust boundary:</p><ul><li>Email ownership verification can be bypassed.</li><li>Verification-gated functionality becomes accessible.</li><li>An attacker can modify their own account’s verification status.</li></ul><h3>How to Fix It</h3><p>The fix is straightforward: the backend should never trust the user to set their own verification status.</p><ul><li>Use an <strong>allowlist</strong> on the profile update endpoint so users can only update safe fields like their first and last name.</li><li>Keep c_isCustomerVerified locked on the server side, and only flip it to true when the user clicks the actual verification link sent to their email.</li></ul><h3>Quick Tip</h3><p>Always pay close attention to the JSON responses when loading your user profile. Developers often send internal flags to the frontend to decide what to show on the screen, and sometimes they forget to block users from sending those exact same flags back in a PATCH or PUT request.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12233efb1f00" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built a Subdomain Enumeration Tool From Scratch in Python — Here’s How It Works]]></title>
            <link>https://medium.com/@anujrawal/i-built-a-subdomain-enumeration-tool-from-scratch-in-python-heres-how-it-works-fb94902a6bde?source=rss-74d2a114f1a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb94902a6bde</guid>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[kali-linux]]></category>
            <category><![CDATA[subhunter]]></category>
            <category><![CDATA[reconnaissance]]></category>
            <dc:creator><![CDATA[Anuj rawal]]></dc:creator>
            <pubDate>Sun, 07 Jun 2026 06:11:17 GMT</pubDate>
            <atom:updated>2026-06-07T06:20:28.757Z</atom:updated>
            <content:encoded><![CDATA[<p>A deep dive into passive DNS recon, API integration, and Python threading — and why building tools teaches you more than just using them.</p><h4>Why I Built This</h4><p>Tools like Subfinder and Amass are industry standards in reconnaissance. But I wanted to understand what actually happens under the hood — not just run a command and get results. So I built <strong>SubHunter</strong>, a passive DNS subdomain enumeration tool in Python that combines multiple free sources, validates results with HTTP probing, and tags each finding with its source.</p><p><a href="https://github.com/Anujrawal1/subhunter">github.com/Anujrawal1/subhunter</a></p><h4>What Is Subdomain Enumeration?</h4><p>Every large website has subdomains — separate services running under the same domain. For example:</p><pre>api.example.com        → backend API<br>admin.example.com      → admin panel<br>staging.example.com    → test environment<br>mail.example.com       → email server</pre><p>During a security assessment, finding these subdomains is <strong>called</strong> <strong>reconnaissance</strong>. A forgotten staging server or exposed admin panel can be a critical vulnerability — this is why subdomain enumeration is the first step in any professional pentest or bug bounty workflow.</p><h4>Features</h4><ul><li><em>12 passive DNS sources queried simultaneously</em></li><li><em>DNS validation — removes subdomains that don’t resolve</em></li><li><em>Multi-protocol probing — HTTP HEAD + TCP on ports 80, 443, 8080</em></li><li><em>Source tagging — every result shows which source found it</em></li><li><em>Manual save with </em><em>-o flag — no auto-generated clutter files</em></li><li><em>Config file for API keys — no hardcoded secrets ever in code</em></li><li><em>Custom wordlist support for DNS brute-force</em></li><li><em>Multiple flags to control scan speed and depth</em></li></ul><h4>All Commands and Flags</h4><blockquote><strong>Basic scan — all 12 sources + brute-force + probing</strong></blockquote><pre>python subdomain_hunter.py example.com</pre><blockquote><strong>Save results to your own file</strong></blockquote><pre>python subdomain_hunter.py example.com -o results.txt</pre><blockquote><strong>Passive sources only — skip brute-force</strong></blockquote><pre>python subdomain_hunter.py example.com --only-passive</pre><blockquote><strong>Skip HTTP probing for faster scan</strong></blockquote><pre>python subdomain_hunter.py example.com --no-probe</pre><blockquote><strong>Skip DNS validation — more results including inactive</strong></blockquote><pre>python subdomain_hunter.py example.com --no-validate</pre><blockquote><strong>Use a custom wordlist</strong></blockquote><pre>python subdomain_hunter.py example.com -w /path/to/wordlist.txt</pre><blockquote><strong>Combine multiple flags</strong></blockquote><pre>python subdomain_hunter.py example.com --only-passive --no-probe -o output.txt</pre><blockquote><strong>Real Output Example</strong></blockquote><pre>======================================================================<br>  LIVE SUBDOMAINS — example.com<br>======================================================================<br>  SUBDOMAIN                              PORT    STATUS    SOURCES<br>  --------------------------------------------------------------------<br>  api.example.com                        :443    200       [VirusTotal, crt.sh]<br>  auth.example.com                       :443    301       [SecurityTrails]<br>  dev.example.com                        :8080   200       [BruteForce]<br>  mail.example.com                       :80     TCP-open  [AlienVault, crt.sh]</pre><pre>  Total live: 4</pre><pre>[i] Tip: add -o results.txt to save output</pre><h4>Key Technical Decisions</h4><p><strong>1. Parallel Execution</strong></p><p>Querying 12 APIs one by one would take 2–3 minutes. Using Python’s concurrent.futures.ThreadPoolExecutor runs all sources at the same time — total time drops to under 10 seconds.</p><pre>with concurrent.futures.ThreadPoolExecutor(max_workers=6) as ex:<br>    futures = [<br>        ex.submit(source_crtsh,          domain),<br>        ex.submit(source_virustotal,     domain),<br>        ex.submit(source_securitytrails, domain),<br>        ex.submit(source_alienvault,     domain),<br>    ]</pre><p><strong>2. Source Tagging</strong></p><p>Every subdomain is stored as a dictionary mapping the name to the set of sources that found it. A result found by 3 different sources is far more reliable than one found only by brute-force.</p><pre>{<br>  &quot;api.example.com&quot;:     {&quot;VirusTotal&quot;, &quot;crt.sh&quot;, &quot;SecurityTrails&quot;},<br>  &quot;dev.example.com&quot;:     {&quot;BruteForce&quot;},<br>  &quot;staging.example.com&quot;: {&quot;AlienVault&quot;}<br>}</pre><p><strong>3. Multi-Protocol Probing</strong></p><p>DNS resolution alone is not enough. A subdomain can resolve in DNS but be completely unreachable on HTTP. The tool sends a lightweight HEAD request to HTTPS 443, HTTP 80, and port 8080. If HTTP fails it falls back to a raw TCP connection check.</p><p><strong>4. No Auto-Save</strong></p><p>Most tools auto-save with a timestamped filename on every run, cluttering your directory. SubHunter only saves when you use -o filename.txt — you stay in control.</p><p><strong>5. Config File for API Keys</strong></p><p>API keys never touch the source code. Users copy config.yaml.example to config.yaml, paste their own free keys, and .gitignore ensures that file is never accidentally pushed to GitHub.</p><pre>virustotal: &quot;your_key_here&quot;<br>securitytrails: &quot;your_key_here&quot;<br>alienvault: &quot;your_key_here&quot;</pre><h4>Installation</h4><pre>git clone https://github.com/Anujrawal1/subhunter<br></pre><pre>cd subhunter</pre><pre>pip install -r requirements.txt</pre><pre>cp config.yaml.example config.yaml</pre><pre>nano config.yaml</pre><pre>python subdomain_hunter.py example.com</pre><h4>What I Learned</h4><p>Building this tool taught me more about DNS, passive reconnaissance, HTTP internals, Python threading, and API design than months of just reading about security. Every decision — from parallel execution to source tagging to the config file pattern — came from a real problem I had to solve.</p><p><strong>If you want to truly understand how security tools work — build one yourself.</strong></p><p>Star the repo if you find it useful and feel free to open issues or contribute new sources.</p><p><a href="https://github.com/Anujrawal1/subhunter">⭐ github.com/Anujrawal1/subhunter</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb94902a6bde" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[️ What Is an API? And How I Built a Weather App with It Using PHP + WeatherAPI]]></title>
            <link>https://medium.com/@anujrawal/%EF%B8%8F-what-is-an-api-and-how-i-built-a-weather-app-with-it-using-php-weatherapi-1cf5212037d6?source=rss-74d2a114f1a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cf5212037d6</guid>
            <dc:creator><![CDATA[Anuj rawal]]></dc:creator>
            <pubDate>Tue, 15 Jul 2025 14:37:46 GMT</pubDate>
            <atom:updated>2025-07-15T14:37:46.001Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>“APIs aren’t just for big tech companies — they’re like magical doors anyone can open to build real things on the internet.”</em></blockquote><h3>✨ Introduction</h3><p>Ever used a weather app and wondered:<br> <strong>“Where does it even get that live temperature from?”</strong><br> Well, surprise: it doesn’t come from inside your phone! 😄 It comes from something called an <strong>API</strong> — and in this article, I’ll explain what that means, how I learned it the fun way, and how I built my own weather app in under an hour using <strong>HTML + PHP + WeatherAPI</strong>.</p><p>Also — while we often hear API explained using the famous <em>kitchen and waiter</em> example (where an API is like a waiter delivering your order to the kitchen and back), I want to go a bit deeper too — not just analogy, but real definitions.</p><h3>📘 What is an API? (Technical Definition)</h3><p><strong>API</strong> stands for <strong>Application Programming Interface</strong>. It is a <strong>set of rules</strong> that allows one software application to interact with another.</p><p>More precisely:</p><blockquote><em>An API is a defined interface that allows software programs to communicate and exchange data using a set of predefined functions, endpoints, and data formats (like JSON or XML).</em></blockquote><p>APIs can:</p><p>Retrieve data (like weather info)</p><p>Send data (like a form submission)</p><p>Trigger actions (like logging in)</p><h3>In simple words</h3><p>An <strong>API (Application Programming Interface)</strong> is a middleman that allows two systems to talk. You send a request like:</p><blockquote><strong><em>Imagine you walk into a restaurant.</em></strong></blockquote><p>You’re hungry, but you <strong>don’t go into the kitchen</strong> to cook your own food.<br> Instead, you <strong>look at the menu</strong>, pick a dish, and place an order <strong>through the waiter</strong>.</p><p><strong>You</strong> = <strong>Client (Browser)</strong></p><p><strong>Waiter</strong> = <strong>API (Middle Layer)</strong></p><p><strong>Menu</strong> = <strong>API Documentation</strong> (List of available requests)</p><p><strong>Kitchen</strong> = <strong>Server (Backend)</strong></p><p><strong>Dish</strong> = <strong>Response (Data you requested)</strong></p><h3>🔁 How it works, step-by-step:</h3><ol><li><strong>You (the client)</strong> tell the waiter what you want (e.g., “1 Masala Dosa”).</li><li>The <strong>waiter (API)</strong> takes your request and delivers it to the <strong>kitchen (server)</strong>.</li><li>The <strong>kitchen processes</strong> the order (runs code, queries databases).</li><li>The <strong>waiter picks up the dish</strong> (data) and brings it back to <strong>you</strong>.</li><li>The <strong>waiter (API)</strong> takes your request and delivers it to the <strong>kitchen (server)</strong>.</li><li>You get your <strong>delicious Masala Dosa (JSON/XML response)</strong> — without ever stepping into the kitchen.</li></ol><p>⚠️ What if the dish doesn’t exist?</p><p>If you order something not on the menu, the waiter will say:</p><blockquote><em>“Sorry, item not found” — that’s like a </em><strong><em>404 error</em></strong><em> or </em><strong><em>API error response</em></strong><em>.</em></blockquote><h3>⚖️ API vs Web Service — Are They the Same?</h3><p>Technically:</p><p>All <strong>Web Services</strong> are <strong>APIs</strong>.</p><p>Not all <strong>APIs</strong> are <strong>Web Services</strong>.</p><h3>🔍 Definitions:</h3><ul><li><strong>API:</strong> A software interface that allows interaction between two systems. It doesn’t require network communication.</li></ul><p><strong>Web Service:</strong> A type of API that uses <strong>HTTP</strong> over a network to exchange data.</p><h3>🆚 Key Differences:</h3><p>Feature API Web Service Network Required? ❌ Not always ✅ Yes Data Formats JSON, XML Mostly XML Protocols HTTP, HTTPS, others Only HTTP Flexibility High Lower</p><h3>📊 Types of APIs</h3><h3>1. Public APIs</h3><ul><li>Open to developers globally.</li><li>Example: GitHub API, WeatherAPI.</li><li>May have rate limits or free tiers.</li></ul><h3>2. Partner APIs</h3><ul><li>Shared between businesses (B2B).</li><li>Require agreements and access keys.</li></ul><h3>3. Private APIs</h3><ul><li>Used within an organization.</li><li>Example: HR system connecting to payroll service.</li></ul><h3>4. Composite APIs</h3><ul><li>Combine multiple APIs into one call.</li><li>Example: GraphQL.</li></ul><h3>🔁 API Protocols: How They Communicate</h3><h3>🔧 REST (Representational State Transfer)</h3><ul><li>Stateless</li><li>Uses HTTP methods: GET, POST, PUT, DELETE</li><li>Supports JSON &amp; XML</li><li>Used by: Twitter, GitHub, WeatherAPI</li></ul><h4>✅ JSON Example (Weather Response):</h4><pre>{<br>  &quot;location&quot;: {<br>    &quot;name&quot;: &quot;London&quot;,<br>    &quot;country&quot;: &quot;UK&quot;<br>  },<br>  &quot;current&quot;: {<br>    &quot;temp_c&quot;: 17,<br>    &quot;condition&quot;: {<br>      &quot;text&quot;: &quot;Partly cloudy&quot;<br>    }<br>  }<br>}</pre><h3>🧼 SOAP (Simple Object Access Protocol)</h3><ul><li>XML only</li><li>Highly structured</li><li>Requires WSDL files (Web Services Description Language)</li><li>Still used in banking and enterprise systems</li></ul><h4>🧾 XML Example:</h4><pre>&lt;current&gt;<br>  &lt;temperature_c&gt;17&lt;/temperature_c&gt;<br>  &lt;condition&gt;Partly cloudy&lt;/condition&gt;<br>&lt;/current&gt;</pre><h3>⚡ Other Protocols:</h3><ul><li><strong>RPC:</strong> Remote Procedure Call. Executes a function on another machine.</li><li><strong>gRPC:</strong> Uses Protocol Buffers. Faster, more efficient.</li><li><strong>GraphQL:</strong> Requests only specific data. Saves bandwidth.</li></ul><h3>🌐 My First API Project: A Weather App with PHP</h3><p>I used <a href="https://weatherapi.com/">WeatherAPI.com</a> to build a real-time weather app where users can:</p><ul><li>Type any city</li><li>Get live temperature, condition, and humidity</li></ul><h3>🛠️ Tools Used:</h3><ul><li>HTML for form</li><li>PHP for backend</li><li>WeatherAPI (free key)</li></ul><h3>🗝️ Get Your Free API Key:</h3><ol><li>Go to <a href="https://weatherapi.com/">weatherapi.com</a></li><li>Sign up</li><li>Copy your API key</li></ol><p>Example URL:</p><pre>http://api.weatherapi.com/v1/current.json?key=YOUR_API_KEY&amp;q=London</pre><h3>📄 Code Example</h3><h3>1. index.html</h3><pre>&lt;form action=&quot;weather.php&quot; method=&quot;GET&quot;&gt;<br>  &lt;input type=&quot;text&quot; name=&quot;city&quot; required&gt;<br>  &lt;button type=&quot;submit&quot;&gt;Get Weather&lt;/button&gt;<br>&lt;/form&gt;</pre><p>✅ <strong>What it does:</strong></p><p>Displays a form for the user to enter a <strong>city name</strong>.On clicking <strong>“Get Weather”</strong>, the form sends the city to weather.php using the <strong>GET</strong> method.The value is passed in the URL like this: weather.php?city=London.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*N3VJgVZXiPPRJn_OEcadnw.png" /></figure><h3>2. weather.php</h3><pre>&lt;?php<br>if (isset($_GET[&#39;city&#39;])) {<br>    $city = urlencode($_GET[&#39;city&#39;]);<br>    $apiKey = &quot;YOUR_API_KEY&quot;;<br>    $url = &quot;http://api.weatherapi.com/v1/current.json?key=$apiKey&amp;q=$city&quot;;<br>    $response = @file_get_contents($url);<br>    if ($response === FALSE) {<br>        echo &quot;Error fetching data.&quot;;<br>    } else {<br>        $data = json_decode($response, true);<br>        if (isset($data[&#39;error&#39;])) {<br>            echo &quot;API Error: &quot; . $data[&#39;error&#39;][&#39;message&#39;];<br>        } else {<br>            echo &quot;&lt;h2&gt;Weather in {$data[&#39;location&#39;][&#39;name&#39;]}, {$data[&#39;location&#39;][&#39;country&#39;]}&lt;/h2&gt;&quot;;<br>            echo &quot;&lt;p&gt;🌡️ Temp: {$data[&#39;current&#39;][&#39;temp_c&#39;]} °C&lt;/p&gt;&quot;;<br>            echo &quot;&lt;p&gt;☁️ Condition: {$data[&#39;current&#39;][&#39;condition&#39;][&#39;text&#39;]}&lt;/p&gt;&quot;;<br>            echo &quot;&lt;p&gt;💧 Humidity: {$data[&#39;current&#39;][&#39;humidity&#39;]}%&lt;/p&gt;&quot;;<br>        }<br>    }<br>}<br>?&gt;<br>   </pre><p>🔹 <strong>This PHP script takes a city name from the user, sends a request to WeatherAPI, and gets live weather data.</strong><br> 🔹 It checks for errors (like wrong city or API failure) and handles them gracefully.<br>🔹 If successful, it shows the city’s temperature, weather condition, and humidity in a clean format.<br> 🔹 It’s a simple example of how to use an API in PHP to build a real-time project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*ISd_yH8tPYjnb10-N9aHUg.png" /></figure><p>Thanks for reading. Follow me for more dev-friendly, no-jargon, beginner-level tech content!</p><p>for more query connect me with</p><p>Linkedin-<a href="https://www.linkedin.com/in/anuj-r-70b364310/">Anuj Rawal</a></p><p>tweeter(x)-<a href="https://x.com/anujrawal_">Anuj Rawal</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cf5212037d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enabling Remote Root Access in MySQL on Debian and CentOS]]></title>
            <link>https://medium.com/@anujrawal/enabling-remote-root-access-in-mysql-on-debian-and-centos-dc4ff661cbe3?source=rss-74d2a114f1a1------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc4ff661cbe3</guid>
            <dc:creator><![CDATA[Anuj rawal]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 05:55:32 GMT</pubDate>
            <atom:updated>2025-06-13T15:38:07.935Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide will walk you through the process of configuring your MySQL server to allow remote root logins, and then how to connect to it from a client system. This is a common task for developers and system administrators, especially when setting up a remote development environment or managing a database server.</p><h3>Setting Up Your MySQL Server for Remote Access</h3><p>Here’s how to prepare your MySQL server to accept connections from other machines.</p><h4>Step 1: Configure MySQL to Listen on All IPs</h4><p>By default, MySQL often only listens for connections from localhost. To allow remote connections, you&#39;ll need to change this setting in the MySQL configuration file.</p><p>Open the configuration file using vim or your preferred text editor:</p><pre>sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf</pre><p>Inside this file, locate the line that specifies the bind-address:</p><pre>bind-address = 127.0.0.1</pre><p>Change it to 0.0.0.0 to instruct MySQL to listen on all available network interfaces:</p><pre>bind-address = 0.0.0.0</pre><p>Save and exit the file. This crucial change enables MySQL to accept connections from any IP address.</p><h4>Step 2: Restart the MySQL Service</h4><p>After modifying the configuration, you must restart the MySQL service for the changes to take effect:</p><pre>sudo systemctl restart mysqld</pre><p>This command ensures that MySQL reloads its configuration and begins listening on the newly specified address.</p><h4>Step 3: Log In to MySQL as Root</h4><p>Now, you’ll need to access the MySQL shell as the root user to adjust user permissions.</p><pre>sudo mysql -u root -p</pre><p>You’ll be prompted for the root password. Enter it to gain access to the MySQL prompt.</p><h4>Step 4: Check Current Host Access for the Root User</h4><p>It’s good practice to verify the current permissions for the root user before making any changes.</p><p>First, let’s look at the available databases:</p><pre>SHOW DATABASES;</pre><p>Then, switch to the mysql database, which stores user privileges:</p><pre>USE mysql;</pre><p>Finally, check the host entry for the root user to see which IPs it&#39;s currently allowed to connect from:</p><pre>SELECT host FROM user WHERE user = &#39;root&#39;;</pre><p>Typically, you’ll see localhost, meaning root can only log in from the same machine.</p><h4>Step 5: Update Root Access to Allow Remote IPs</h4><p>Now, let’s modify the root user’s permissions to allow remote access. You have two main options:</p><p><strong>Option A: Allow all IPs (for testing purposes only — not recommended for production)</strong></p><p>This option allows the root user to connect from any IP address. Use this only for temporary testing environments, as it poses a significant security risk in production.</p><pre>UPDATE user SET host=&#39;%&#39; WHERE user=&#39;root&#39; AND host=&#39;localhost&#39;;</pre><p><strong>Option B: Allow only a specific client IP (recommended for production)</strong></p><p>For better security, it’s highly recommended to restrict access to a specific IP address that you know will be connecting to your MySQL server. Replace “client ip” with your client machine&#39;s actual IP address.</p><pre>UPDATE user SET host=&#39;client ip&#39; WHERE user=&#39;root&#39; AND host=&#39;localhost&#39;;</pre><p>After executing your chosen UPDATE command, you must apply the privilege changes and verify them:</p><pre>FLUSH PRIVILEGES;</pre><pre>SELECT host FROM user WHERE user = &#39;root&#39;;</pre><pre>EXIT;</pre><p>Purpose: Grant and save permission changes to allow remote login.</p><p>This step ensures that your server’s firewall permits incoming connections on the MySQL port.</p><h4>Step 6: Allow MySQL Port Through Firewall</h4><pre>sudo ufw allow 3306</pre><pre>sudo ufw reload </pre><h4>Step 7: Final Restart of MySQL</h4><p>Perform one last restart of the MySQL service to make sure all configurations and permissions are fully active.</p><pre>sudo systemctl restart mysqld</pre><h3>Connecting from Your Client System (Censtos/Debian)</h3><p>Once your MySQL server is configured, you can connect to it remotely from your client machine.</p><h4>Step 1: Install the MySQL Client</h4><p>First, update your package list:</p><pre>sudo apt update<br>sudo yum update</pre><p>Then, install the MySQL client utility:</p><pre>sudo apt install mysql-client -y<br>sudo yum install mysql-client -y<br></pre><p>This installs the necessary tools to connect to a remote MySQL server.</p><h4>Step 2: Connect to the Remote MySQL Server</h4><p>Finally, use the mysql command along with the server&#39;s IP address, the root username, and the -p flag to prompt for the password:</p><pre>mysql -h &lt;server-ip&gt; -u root -p</pre><p><strong>Remember to replace </strong><strong>&lt;server-ip&gt; with the actual IP address of your MySQL server.</strong> You&#39;ll be asked for the root password, and upon successful entry, you&#39;ll be connected to your remote MySQL server.</p><p>note if use kali as client use this cmd</p><pre> mysql -h &lt;server ip &gt;-u root -p --ssl=0</pre><h3>Conclusion</h3><p>You’ve successfully configured your MySQL server to accept remote root logins and connected to it from a client machine! Remember that allowing root access from % (all IPs) is a security risk and should only be used for testing. For production environments, always restrict access to specific, known IP addresses.</p><p>Remote access to your database is a powerful feature, enabling flexible development and management workflows.</p><p><strong>Ask any query -</strong></p><p>linkedin=<a href="https://www.linkedin.com/in/anuj-r-70b364310/">Anuj-Rawal</a></p><p>x=<a href="https://x.com/anujrawal_">Anuj-rawal</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc4ff661cbe3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>