Новая Школа - онлайн-школа подготовки к ЕГЭ
Задача Задача №3619980
А
Аноним
17 июня 2026 22:53 · публичный вопрос
А
Аноним

555-1) OR 496=(SELECT 496 FROM PG_SLEEP(15))--

Нейросеть17 июня 2026 22:53

This looks like a time-based SQL injection payload intended for PostgreSQL.

What the payload does (high level)

  • The injected fragment: OR 496=(SELECT 496 FROM PG_SLEEP(15))--
    • PG_SLEEP(15) makes PostgreSQL pause for 15 seconds.
    • SELECT 496 FROM PG_SLEEP(15) returns a row with the value 496, but only after the 15-second delay.
    • The comparison 496 = (SELECT 496 FROM PG_SLEEP(15)) becomes true after the sleep.
    • The trailing -- comments out the rest of the original query.
  • In a vulnerable query, this can cause the overall condition to become true (or the query to behave differently), and the attacker can detect success by the delay (a time-based blind injection).

Key points to remember

  • It’s a time-based blind SQL injection technique using pg_sleep to infer truth values.
  • The “555-1)” part is likely just the injected value in a field (e.g., a phone number) that’s being concatenated into SQL.
  • The “--” ends the rest of the SQL line, preventing syntax errors from the injected payload.

Defensive measures (essential for exams and real apps)

  • Use parameterized queries / prepared statements everywhere:
    • Example (pseudo-language):
      • Python with psycopg2: cursor.execute("SELECT ... WHERE phone = %s", (user_input,))
      • Java: PreparedStatement with placeholders (?)
  • Validate and sanitize inputs:
    • Enforce expected types, lengths, and character sets.
    • Use allow-lilters: e.g., allow only digits for phone numbers if appropriate.
  • Principle of least privilege:
    • Database user used by the application should have only the minimal privileges needed (no unnecessary table access, no superuser).
  • Disable detailed error messages from the app/database that leak structure.
  • Use ORM parameter binding when possible to avoid concatenation.
  • Consider WAFs or runtime protections to detect anomalous patterns, but don’t rely on them alone.
  • Regular code reviews and security testing:
    • Static analysis, dynamic testing, and, if permitted, safe, authorized penetration testing.

Exam-oriented takeaway

  • This payload demonstrates a classic time-based blind SQL injection technique in PostgreSQL using pg_sleep.
  • The fix is strict parameterization and input validation; never concatenate user input into SQL.
  • On exams, be able to identify:
    • The purpose of pg_sleep in the injection
    • How the boolean condition is manipulated
    • Why the rest of the line is commented out
    • The corresponding defensive coding practices.
555-1) OR 496=(SELECT 496 FROM PG_SLEEP(15))--
This looks like a time-based SQL injection payload intended for PostgreSQL. What the payload does (high level) - The injected fragment: OR 496=(SELECT 496 FROM PG_SLEEP(15))-- - PG_SLEEP(15) makes PostgreSQL pause for 15 seconds. - SELECT 496 FROM PG_SLEEP(15) returns a row with the value 496, but only after the 15-second delay. - The comparison 496 = (SELECT 496 FROM PG_SLEEP(15)) becomes true after the sleep. - The trailing -- comments out the rest of the original query. - In a vulnerable query, this can cause the overall condition to become true (or the query to behave differently), and the attacker can detect success by the delay (a time-based blind injection). Key points to remember - It’s a time-based blind SQL injection technique using pg_sleep to infer truth values. - The “555-1)” part is likely just the injected value in a field (e.g., a phone number) that’s being concatenated into SQL. - The “--” ends the rest of the SQL line, preventing syntax errors from the injected payload. Defensive measures (essential for exams and real apps) - Use parameterized queries / prepared statements everywhere: - Example (pseudo-language): - Python with psycopg2: cursor.execute("SELECT ... WHERE phone = %s", (user_input,)) - Java: PreparedStatement with placeholders (?) - Validate and sanitize inputs: - Enforce expected types, lengths, and character sets. - Use allow-lilters: e.g., allow only digits for phone numbers if appropriate. - Principle of least privilege: - Database user used by the application should have only the minimal privileges needed (no unnecessary table access, no superuser). - Disable detailed error messages from the app/database that leak structure. - Use ORM parameter binding when possible to avoid concatenation. - Consider WAFs or runtime protections to detect anomalous patterns, but don’t rely on them alone. - Regular code reviews and security testing: - Static analysis, dynamic testing, and, if permitted, safe, authorized penetration testing. Exam-oriented takeaway - This payload demonstrates a classic time-based blind SQL injection technique in PostgreSQL using pg_sleep. - The fix is strict parameterization and input validation; never concatenate user input into SQL. - On exams, be able to identify: - The purpose of pg_sleep in the injection - How the boolean condition is manipulated - Why the rest of the line is commented out - The corresponding defensive coding practices.