Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double Hyphen/Dash in SQL-Injection. What are they used for?

I'm currently learning how SQL-Injections work. On many teaching-websites there are examples shown, such as

SELECT fieldlist
FROM table
WHERE field = 'x' AND email IS NULL; --';

In the field 'field' the content thats going to be checked comes from a textfield or something similar from a website. The user-input in this case is x' AND email IS NULL; -- What is the use of -- ??

I saw a few similar examples but no explanation. Am I missing something fundamental?

like image 617
Officer Bacon Avatar asked Jul 08 '15 09:07

Officer Bacon


People also ask

What is the purpose of a double dash in a SQL injection attack?

The double dash indicates that the rest of the string is interpreted as a comment. With that, the actual SQL query is just: SELECT * FROM Users WHERE username = 'admin' . This would effectively log in the attacker as the administrator user.

What does 2 hyphens mean?

Definition of double hyphen : a punctuation mark ⸗ used in place of a hyphen at the end of a line to indicate that the word so divided is normally hyphenated.

What is dash dash in SQL?

The double hyphen places a single-line comment in a SQL*Plus script. The double hyphen works the same way as REMARK, except that it may be used in SQL statements and PL/SQL blocks. When used in a SQL statement or PL/SQL block, the double hyphen may be used to add trailing comments to a line.

What is SQL UNION attack?

Union-based SQL injection involves the use of the UNION operator that combines the results of multiple SELECT statements to fetch data from multiple tables as a single result set. The malicious UNION operator query can be sent to the database via website URL or user input field.


1 Answers

Ohh nevermind. The -- is used to out-comment the rest of the query...

like image 178
Officer Bacon Avatar answered Oct 26 '22 22:10

Officer Bacon