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

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

Ответ нейросети
18 июня 2026 00:02

It looks like a time-based blind SQL injection payload aimed at PostgreSQL. Here’s the high-level idea and why it exists, plus how to defend against it for an exam.

What the string represents

  • 555-1 OR 92=(SELECT 92 FROM PG_SLEEP(15))--
    • This is injecting into a SQL statement in place of user input.
    • The OR clause tries to alter the logic of the query.
    • PG_SLEEP(15) (PostgreSQL) makes the database wait for 15 seconds. The idea is that a noticeable delay indicates the input was unsafely embedded into SQL and executed.
    • The comment marker -- ends the remainder of the SQL statement, effectively bypassing trailing parts that might reveal errors or further checks.
  • If the application is vulnerable, the database will either delay the response (confirming vulnerability) or reveal timing-based behavior that an attacker can use to infer data.

Key concepts demonstrated

  • Time-based blind SQL injection: using a sleep function to infer information based on response time rather than error messages.
  • SQL logic manipulation: injecting OR conditions to alter the WHERE clause (or other logical parts) of a query.
  • The role of comments in injection: -- hides the rest of the original query to avoid syntax errors.

Why this is a concern in exams

  • It tests understanding of injection vectors, how time-based attackers operate, and what safeguards look like.
  • It ties together knowledge of the specific DB (PostgreSQL) and its functions (pg_sleep) with secure coding practices.

Defenses (how to prevent this)

  • Use parameterized queries / prepared statements
    • Do not concatenate user input into SQL strings.
    • Example (conceptually):
      • PostgreSQL: cursor.execute("SELECT * FROM customers WHERE phone = %s", (user_input,))
  • Input validation and whitening
    • If a field should be numeric, cast/validate to a numeric type (and reject non-numeric input).
    • Apply strict length and format checks for fields like phone numbers.
  • Least privilege
    • Run the application database user with minimal privileges (avoid permissions that aren’t needed).
  • Use ORMs or proper escaping
    • Tools that automatically parameterize inputs reduce risk.
  • Error handling and logging
    • Do not leak database errors to users; log them securely on the server side.
  • Monitoring and WAF
    • Detect abnormal delays or patterns that resemble time-based injections.
  • Safe testing practice
    • Test defenses in a controlled, legal environment (e.g., your own lab, DVWA-like setups, or classroom environments) and with explicit authorization.

If you’d like, I can:

  • Turn this into a short exam-style Q&A (question and model answer).
  • Provide a safe, concrete example of a secure vs. insecure query in a specific language (e.g., Python with psycopg2) to illustrate the defense.