Join our Newsletter — 33% off our NHI Course
Home› Guides› sqlmap for Beginners: How Testers Find SQL Injection…
Guide Web & API Security

sqlmap for Beginners: How Testers Find SQL Injection Automatically

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 2 December 2026 12 min read
On this page

sqlmap is a free testing tool that automatically checks websites for a database flaw called SQL injection.

This guide is for website owners, new IT staff and anyone who has spotted "sqlmap" in a log. It explains what the tool is, what it means if you see it, and how to close the flaw it looks for. It does not explain how to use it.

In short

  • sqlmap is an open-source tool that automates finding SQL injection, a flaw that lets typed text change a database command.
  • Security testers use it with written permission. Using it on a site without permission can be a crime, such as under the UK Computer Misuse Act.
  • Seeing "sqlmap" in your web logs means someone ran it against your site, so check whether it was an approved test.
  • The fix is in your code: send database commands and user input separately, and give the database account only the access it needs.

What you will learn

  • Explain what sqlmap is and why testers use it.
  • Spot signs of sqlmap in a web server log.
  • Check whether a scan was approved and what to do if not.
  • Ask your developer the right questions about SQL injection.
Database trick (SQL injection)
a flaw where text typed into a website changes the command sent to its database.
Approved attack test (penetration test)
a check where a hired tester tries to break in, with written permission, to find flaws first.
Visit record (web log)
a file where the web server notes each request it receives.

What is sqlmap?

Think of a building inspector with a machine that tries every door handle and window latch in a block of flats. It works fast and notes which ones give way.

sqlmap does this for one kind of website flaw. Its makers call it an open-source testing tool that automates finding and exploiting SQL injection flaws [1][2]. Open source means anyone can read and reuse its code.

SQL injection happens when text a visitor types is mixed into a database command, so the text can change what the command does. Our SQL Injection for Beginners guide explains the flaw itself.

sqlmap supports over 40 kinds of database, from long-standing ones such as MySQL and PostgreSQL to cloud data stores [1]. It is free under the GPLv2 licence, with a paid licence also offered [1].

Where the comparison stops working: an inspector works for the owner. sqlmap does not check who runs it. A hired tester and a criminal can use the same tool.

Why does it matter?

A tool like this makes testing quick for defenders. It also means a site with this flaw can be found quickly by anyone who runs it.

If you run a website or online shop

What could happen: someone runs a tool like sqlmap against your site, finds the flaw and copies customer data.

Check this: ask your developer or web agency how your site sends search and form input to its database.

Next: SQL Injection for Beginners

If you are new to IT or security work

What could happen: you see "sqlmap" in a log and are not sure whether it is a test or an attack.

Check this: find out who keeps the list of approved tests and their dates.

Next: SIEM for Beginners

If you buy security testing

What could happen: a tester runs automated tools on systems you did not agree to, and nobody warns the team watching the logs.

Check this: put the systems, dates and tools in writing before any test starts.

Next: Buying a Penetration Test for Beginners

What does it look like?

For a defender, sqlmap usually shows up in the web server's log. Here is a made-up extract.

Example only. All values are made up.

203.0.113.10 [02/Dec/2026:21:04:11] "GET /shop/item?id=0000 HTTP/1.1" 200
   agent: "sqlmap/1.x.x.x#dev (https://sqlmap.org)"                       (1)
203.0.113.10 [02/Dec/2026:21:04:11] "GET /shop/item?id=0000[odd symbols and database words] HTTP/1.1" 500   (2)
203.0.113.10 [02/Dec/2026:21:04:12] "GET /shop/item?id=0000[odd symbols and database words] HTTP/1.1" 200   (3)
... several hundred similar lines in a few minutes ...                     (4)
  1. The user agent, a label the visiting program sends about itself. sqlmap's default label names the tool [3].
  2. In a real file, this line would show strange characters and database words in the web address, and a server error.
  3. The same page asked for again with small changes each time.
  4. Many requests from one address in a short time, far more than a person would send.

Why this is risky: the pattern means someone is testing your site for SQL injection. If the flaw is there, the same tool can be used to read data.

The safer way: confirm whether a test was approved. If not, treat it as a possible attack, keep the logs and ask your developer to check the pages it targeted.

A missing sqlmap label does not mean you are safe. Its documentation shows the label can be changed or set at random [3], so look for the pattern as well as the name.

How does it work?

Here is what happens at a high level, seen from the defender's side.

  1. A page that takes input is chosen. This might be a search box, a login form or a web address with a number in it.
  2. The tool sends many changed requests. Each one alters the input a little, which is why logs fill up quickly.
  3. It watches how the site answers. Errors, delays or different pages can hint that input is reaching the database command.
  4. It reports what it found. A tester writes this up so the owner can fix it. An attacker could use the same result to take data.
  5. The owner fixes the code. The fix is to keep commands and input apart, not to block the tool's name.
Diagram titled You see sqlmap in your logs: what next? Four boxes in a row joined by arrows. Box 1, Spot it: sqlmap in the user agent, or hundreds of odd requests to one page. Box 2, Was it approved? Check the list of agreed tests, dates and addresses. Box 3, If not approved: keep the logs and tell whoever handles incidents. Box 4, shown in green, Fix the cause: separate commands from input and limit the database account. A note underneath says blocking the tool's name alone is not a fix, because the name can be changed.
Figure 1. What to do when sqlmap shows up in your logs.

The main fix is called a parameterised query. The code sends the command and the visitor's input to the database separately, so input cannot change the command. A widely used web security guide, the OWASP cheat sheet, calls this the preferred pattern [4].

OWASP also says to check input against a short list of allowed values where a command part cannot be separated. It advises giving each database account only the access it needs [4]. It strongly discourages relying on escaping input by hand, because that is easy to get wrong [4].

A worked example

Nils Rinaldi runs a small online shop that sells bike parts. A freelance developer built the site three years ago.

One Monday, Nils's hosting company emails a weekly report. It shows a spike of several thousand requests on Saturday night to one product page. Nils opens the log and sees "sqlmap" in the user agent on many lines.

Nils has not booked any security test. He does not delete anything. He saves a copy of the log and writes down the date, time and the web address that sent the requests.

He calls his developer. She checks the product page code and finds that the product number from the web address is pasted straight into a database command. That is the kind of flaw sqlmap looks for.

She rewrites the page to use a parameterised query and checks the other pages that take input. She also changes the database account so the shop can read products and write orders, but cannot change other tables.

Because the flaw was real, Nils cannot be sure no data was read. He asks his hosting company for the database logs for that night. He also asks the developer whether customer details sit in the same database. He gets advice on whether he must report it, since the rules depend on what data was reached.

Next year, Nils books a proper test with a written scope. He tells his hosting company the dates first, so the team watching the logs knows what to expect.

Myths and mistakes

What people thinkWhat is true
Blocking the word "sqlmap" protects my site.The tool's label can be changed. Fix the code so input cannot change database commands.
sqlmap is a hacking tool, so having it is illegal.It is a testing tool. What matters is permission. Running it on systems you do not have permission to test can be an offence.
A firewall in front of the site is enough.A web application firewall can help, but the lasting fix is in the code.
No sqlmap in my logs means no SQL injection attempts.Other tools and people try the same thing. Look for the pattern, not just the name.
Escaping quote marks by hand is a fine fix.OWASP strongly discourages relying on it. Use parameterised queries.

What can I do this week?

  • Ask your developer whether every page sends input to the database using parameterised queries.
  • Find out where your web logs are kept and how long they are kept for.
  • Search the last month of logs for "sqlmap" and for bursts of requests to one page.
  • Write down who can approve a security test, and keep a list of approved tests.
  • Check that your website's database account has only the access it needs.

Checklist

  • Every database command that uses visitor input is parameterised.
  • The site's database account cannot change or delete tables it does not need.
  • Web logs are kept long enough to look back at a suspicious night.
  • Someone watches for bursts of odd requests, not only the word "sqlmap".
  • Every security test has written permission, a scope and dates.
  • The team watching logs is told before a test starts.
  • You know who to call if a scan was not approved.

Common questions

Is sqlmap legal?

The tool is free to download. Using it is a different matter. Running it against a system without permission can be an offence. Status (checked 2 Dec 2026): the Computer Misuse Act 1990 is in force in the UK; section 1 covers unauthorised access. One example is the UK Computer Misuse Act, which covers unauthorised access to computer material [5]. Testers get written permission first. This is general information, not legal advice.

I found sqlmap in my logs. Was I hacked?

Not necessarily. It shows someone tested your site for SQL injection. If your code keeps commands and input separate, the tool likely found nothing. If a flaw existed, data may have been read, so keep the logs and ask your developer and hosting company to check.

Should I block sqlmap?

You can, but do not rely on it. The tool's label can be changed or set at random, so a block on the name is easy to get round. Treat any block as an extra layer, and fix the code so typed input cannot change database commands.

Do security teams use sqlmap?

Yes. Its makers describe it as a penetration testing tool, and testers use tools like it during approved tests. It helps them check many pages quickly. The result is a report that tells the site owner what to fix.

Does sqlmap only work on one kind of database?

No. Its makers say it supports over 40 kinds of database, including MySQL, Oracle, PostgreSQL and SQL Server, plus some cloud data stores. That is why the fix in your code matters whichever database you use.

Where next?

Ready for the detail? Read the practitioner guide: SQL Injection Prevention Guide. It goes further into safe query patterns, database hardening and how to detect injection attempts in web, firewall and database logs.

Also useful:

Related NHI Mgmt Group resources: NoSQL Injection Prevention Guide, SQL Injection vs Prompt Injection and SIEM for Beginners.

Key terms

SQL injection
A flaw where text typed into a site changes the command sent to its database.
Parameterised query
A way of sending a database command and the user's input separately, so input cannot change the command.
Penetration testing
An approved test in which a tester tries to break in, to find flaws before attackers do.
User agent
A label a program sends with each web request to say what it is; it can be changed.
Access log
A record of requests made to a system, such as each page a web server was asked for.
Least privilege
Giving each account only the access it needs for its job.
Web application firewall
A filter in front of a website that checks incoming requests and can block some harmful ones.

Sources and further reading

  1. sqlmap project, "sqlmap: automatic SQL injection and database takeover tool". https://sqlmap.org/ (accessed 2 Dec 2026).
  2. sqlmap project, "sqlmap" README, GitHub. https://github.com/sqlmapproject/sqlmap (accessed 2 Dec 2026).
  3. sqlmap project, "Usage" wiki, GitHub. https://github.com/sqlmapproject/sqlmap/wiki/Usage (accessed 2 Dec 2026).
  4. OWASP Cheat Sheet Series, "SQL Injection Prevention Cheat Sheet". https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html (accessed 2 Dec 2026).
  5. UK Government, "Computer Misuse Act 1990, section 1: Unauthorised access to computer material", legislation.gov.uk. https://www.legislation.gov.uk/ukpga/1990/18/section/1 (accessed 2 Dec 2026).

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.