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

-1" OR 5*5=25 --

Нейросеть18 июня 2026 10:45

That string is a classic SQL injection payload.

What it does:

  • The quote closes a string literal in a vulnerable query.
  • The OR 55=25 adds a condition that is always true (55 equals 25).
  • The trailing -- starts a SQL comment, so the rest of the query is ignored.

Example vulnerable query: SELECT * FROM users WHERE username = "-1" OR 5*5=25 --;

Effect:

  • The WHERE clause becomes true for all rows, so the query returns all users (if the injection works).

How to defend (exam-style takeaway):

  • Use parameterized queries/prepared statements instead of string concatenation.
    • Example (pseudo):
      • In Python with psycopg2: cur.execute("SELECT * FROM users WHERE username = %s", (username,))
      • In Java with JDBC: PreparedStatement ps = conn.prepareStatement("SELECT * FROM users WHERE username = ?");
  • Validate and sanitize inputs; apply allow-listing where possible.
  • Use least-privilege database accounts and avoid dynamic SQL.
  • Consider ORM layers that automatically parameterize queries.
  • Enable proper error handling to avoid leaking database details.

If you want, I can give you a few practice questions or show how to fix a vulnerable snippet in a specific language. Do you want that?

-1" OR 5*5=25 --
That string is a classic SQL injection payload. What it does: - The quote closes a string literal in a vulnerable query. - The OR 5*5=25 adds a condition that is always true (5*5 equals 25). - The trailing -- starts a SQL comment, so the rest of the query is ignored. Example vulnerable query: SELECT * FROM users WHERE username = "-1" OR 5*5=25 --; Effect: - The WHERE clause becomes true for all rows, so the query returns all users (if the injection works). How to defend (exam-style takeaway): - Use parameterized queries/prepared statements instead of string concatenation. - Example (pseudo): - In Python with psycopg2: cur.execute("SELECT * FROM users WHERE username = %s", (username,)) - In Java with JDBC: PreparedStatement ps = conn.prepareStatement("SELECT * FROM users WHERE username = ?"); - Validate and sanitize inputs; apply allow-listing where possible. - Use least-privilege database accounts and avoid dynamic SQL. - Consider ORM layers that automatically parameterize queries. - Enable proper error handling to avoid leaking database details. If you want, I can give you a few practice questions or show how to fix a vulnerable snippet in a specific language. Do you want that?