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

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

Нейросеть18 июня 2026 11:13

This looks like a time-based blind SQL injection payload intended for PostgreSQL. It tries to cause the database to sleep for 15 seconds (via pg_sleep(15)) if a certain condition evaluates to true, which lets an attacker infer boolean information based on response time.

Notes on syntax and behavior:

  • pg_sleep(15) is a PostgreSQL function that pauses the current query for 15 seconds.
  • The exact fragment you posted (555-1) OR 16=(SELECT 16 FROM PG_SLEEP(15))--) is an injection attempt to force a delay when the injected condition is true. Depending on the surrounding SQL, the syntax may or may not be valid in PostgreSQL, because pg_sleep returns void and a boolean comparison like 16 = (SELECT 16 FROM pg_sleep(15)) isn’t always valid. The practical idea, though, is to trick the query into executing pg_sleep when a condition holds.

What this is used for (in learning/exam contexts):

  • To test whether an application is vulnerable to SQL injection.
  • To perform time-based inference: by measuring response delay, an attacker can deduce whether a condition is true or false.

Defensive takeaways (how to protect against this kind of attack):

  • Use parameterized queries (prepared statements) for all user-supplied input. Do not concatenate or interpolate user input into SQL.
  • Apply the principle of least privilege: the database user used by the application should have only the minimum rights needed.
  • Enable proper input validation and escaping as a defense-in-depth measure (not a substitute for parameterization).
  • Avoid enabling multiple-statement execution where possible (some drivers support this; disable if not needed).
  • Use an ORM or query builder that automatically uses parameterized queries.
  • Implement robust error handling and logging to detect unusual query patterns.
  • Run regular security scans and code reviews focused on SQL injection risks.
  • In Postgres-specific hardening, consider monitoring for and mitigating abuse of functions like pg_sleep in user-facing queries, and ensure your app’s inputs cannot cause unintended side effects.

exam-ready example (vulnerable vs fixed, language-agnostic):

  • Vulnerable pattern (pseudocode): query = "SELECT * FROM users WHERE username = '" + userInput + "' AND password = '" + passwordInput + "'" // If userInput is crafted, the attacker may inject payloads like the one you posted.

  • Fixed pattern (safe): query = "SELECT * FROM users WHERE username = ? AND password = ?" // Use parameter binding to pass userInput and passwordInput, so they are treated as data, not code.

If you’re studying for an exam, you can practice by:

  • Writing a tiny vulnerable snippet in a controlled lab (e.g., a deliberately insecure test app) and then fixing it with parameterized queries.
  • Simulating time-based testing in a safe environment to understand how delays reveal information, without exploiting real systems.

If you want, tell me your language/stack (e.g., Python + psycopg2, Java + JDBC, Node.js + pg), and I’ll tailor a concrete vulnerable snippet and its secure fix.

555-1) OR 16=(SELECT 16 FROM PG_SLEEP(15))--
This looks like a time-based blind SQL injection payload intended for PostgreSQL. It tries to cause the database to sleep for 15 seconds (via pg_sleep(15)) if a certain condition evaluates to true, which lets an attacker infer boolean information based on response time. Notes on syntax and behavior: - pg_sleep(15) is a PostgreSQL function that pauses the current query for 15 seconds. - The exact fragment you posted (555-1) OR 16=(SELECT 16 FROM PG_SLEEP(15))--) is an injection attempt to force a delay when the injected condition is true. Depending on the surrounding SQL, the syntax may or may not be valid in PostgreSQL, because pg_sleep returns void and a boolean comparison like 16 = (SELECT 16 FROM pg_sleep(15)) isn’t always valid. The practical idea, though, is to trick the query into executing pg_sleep when a condition holds. What this is used for (in learning/exam contexts): - To test whether an application is vulnerable to SQL injection. - To perform time-based inference: by measuring response delay, an attacker can deduce whether a condition is true or false. Defensive takeaways (how to protect against this kind of attack): - Use parameterized queries (prepared statements) for all user-supplied input. Do not concatenate or interpolate user input into SQL. - Apply the principle of least privilege: the database user used by the application should have only the minimum rights needed. - Enable proper input validation and escaping as a defense-in-depth measure (not a substitute for parameterization). - Avoid enabling multiple-statement execution where possible (some drivers support this; disable if not needed). - Use an ORM or query builder that automatically uses parameterized queries. - Implement robust error handling and logging to detect unusual query patterns. - Run regular security scans and code reviews focused on SQL injection risks. - In Postgres-specific hardening, consider monitoring for and mitigating abuse of functions like pg_sleep in user-facing queries, and ensure your app’s inputs cannot cause unintended side effects. exam-ready example (vulnerable vs fixed, language-agnostic): - Vulnerable pattern (pseudocode): query = "SELECT * FROM users WHERE username = '" + userInput + "' AND password = '" + passwordInput + "'" // If userInput is crafted, the attacker may inject payloads like the one you posted. - Fixed pattern (safe): query = "SELECT * FROM users WHERE username = ? AND password = ?" // Use parameter binding to pass userInput and passwordInput, so they are treated as data, not code. If you’re studying for an exam, you can practice by: - Writing a tiny vulnerable snippet in a controlled lab (e.g., a deliberately insecure test app) and then fixing it with parameterized queries. - Simulating time-based testing in a safe environment to understand how delays reveal information, without exploiting real systems. If you want, tell me your language/stack (e.g., Python + psycopg2, Java + JDBC, Node.js + pg), and I’ll tailor a concrete vulnerable snippet and its secure fix.