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

5557idcN7HJ' OR 577=(SELECT 577 FROM PG_SLEEP(15))--

Ответ нейросети
18 июня 2026 10:45

I can’t help with crafting or optimizing exploit payloads or breaking into systems. But I can help you understand SQL injection at a defensive, exam-prep level and show how to prevent it.

What the input resembles

  • It looks like a time-based SQL injection attempt. The idea is to alter a SQL query so the database executes something like a sleep function (e.g., pg_sleep in PostgreSQL) or otherwise changes the query’s logic, which can reveal vulnerabilities by causing delays or different responses.
  • In practice, time-based injections rely on the database’s response time to infer information about the underlying data or query structure.

Defensive measures you should know for exams

  • Use parameterized queries (prepared statements) everywhere.
    • Example (Python psycopg2):
      • cur.execute("SELECT * FROM users WHERE username = %s AND password = %s", (username, password))
    • Example (Java JDBC):
      • PreparedStatement ps = conn.prepareStatement("SELECT * FROM users WHERE username = ? AND password = ?");
  • Validate and constrain input server-side.
    • Enforce types (e.g., numeric fields must be numbers).
    • Limit input length.
    • Use allow-lilters or white-lists for acceptable values.
  • Least privilege for the database user.
    • Application code should connect with a user that has only the necessary privileges (e.g., read/write on specific tables, nothing like CREATE/DROP).
  • Avoid dynamic SQL and concatenation of user input into queries.
  • Use ORM or query builders that abstract SQL and encourage parameterization.
  • Error handling and logging.
    • Do not reveal detailed DB errors to clients; log them server-side instead.
  • Deploy defensive infrastructure.
    • Web Application Firewall (WAF) with rules that detect common injection patterns.
    • Regular dependency and patch management for the database and drivers.
  • Secure testing in a controlled environment.
    • If you’re studying for an exam, practice in a lab that you’re authorized to use. Do not test against systems you don’t own or have permission to test.

Safe practice exam-style prompts (defense-focused)

  • Question: What is SQL injection, and why is parameterized querying effective against it?
    • Answer: SQL injection occurs when an attacker can influence the structure of a SQL query by injecting input. Parameterized queries separate code from data, sending the query with placeholders and the data separately, so the DB treats user input strictly as data, not executable code.
  • Question: Name three types of SQL injection attacks.
    • Answer: Classic or tautology-based, Union-based, and time-based blind SQL injection (also error-based as a fourth).
  • Question: How does a time-based blind SQL injection work, at a high level?
    • Answer: The attacker causes the database to delay a response (e.g., via a sleep function) if a condition is true, and then observes the response time to infer information about the data.
  • Question: List three defensive practices to prevent SQL injection in a web app.
    • Answer: Use parameterized queries, validate input on server side, and enforce least-privilege database accounts.

If you’d like, I can tailor a short, exam-focused set of practice questions (with answers) or provide sample secure code snippets in your language of choice (Python, Java, PHP, Node.js) to illustrate proper defense against SQL injection.