312-50v12 Exam QuestionsBrowse all questions from this exam

312-50v12 Exam - Question 38


Suppose that you test an application for the SQL injection vulnerability. You know that the backend database is based on Microsoft SQL Server. In the login/password form, you enter the following credentials:

Exam 312-50v12 Question 38

Based on the above credentials, which of the following SQL commands are you expecting to be executed by the server, if there is indeed an SQL injection vulnerability?

Show Answer
Correct Answer: D

In a SQL injection attack, the intention is to manipulate the query in such a way that it bypasses the normal authentication checks. The provided input aims to inject `attack' or 1=1 --` into the `UserName` field. This results in the query interpreting `1=1` which is always true, and the `--` commenting out the rest of the query. Therefore, the correct SQL command that would be executed by the server is `select * from Users where UserName = 'attack' or 1=1 --' and UserPassword = '123456'`. This effectively bypasses the password check. The correct answer is option D.

Discussion

19 comments
Sign in to comment
StoaOption: D
Aug 13, 2023

Well I confirm that it is the D, with the following The query is select * from Users where UserName = 'varName' and UserPassword = 'varPassword'. So if we change by the credentials that say would be the following result: select * from Users where UserName = 'attack' or 1=1 --' and UserPassword = '123456' An important consideration is that it is not asking for any correction of the command or if the command itself is correct, it is asking to be executed on the server.

MKesenheimerOption: A
Aug 28, 2023

Answer A. Look at the single quote.

eli117Option: B
Apr 4, 2023

B. select * from Users where UserName = ‘attack’ or 1=1 -- and UserPassword = ‘123456’ In an SQL injection attack, the attacker manipulates the input of an application in a way that results in the execution of unintended SQL commands. In this case, the attacker entered the username "attack' or 1=1 -" and the password "123456". The hyphen at the end of the username is used to comment out the rest of the SQL query that the application may append to the query.

sshksankOption: D
May 22, 2024

CEH BOOK V12 P.2205

jeremy13Option: D
Apr 10, 2023

D. select * from Users where UserName = ‘attack’ or 1=1 --’ and UserPassword = ‘123456’ CEH BOOK V12 : P2204 SELECT Count(*) FROM Users WHERE UserName='Blah' or 1=1 --' AND Password='Springfield' SQL Query Executed : SELECT Count(*) FROM Users WHERE UserName='Blah' or 1=1 Code after -- are now comments : --' AND Password='Springfield'

ShuvroD
Apr 12, 2023

I have my CEHv12 exam tomorrow. Can anyone please give me temporary contributor access ?

zhack405
Jun 30, 2023

CEH BOOK V12 : P2204 SELECT Count(*) FROM Users WHERE UserName='Blah' or 1=1 --' AND Password='Springfield' ' ' --' ' '

Rijoe
Jul 9, 2023

A is the correct answer look closely, the username = attack' so the actual query will have 'attack' '....the additional hyphen is for the username then 2 hyphen for the query.

Vincent_Lu
Jun 12, 2023

D. select * from Users where UserName = ‘attack’ or 1=1 --’ and UserPassword = ‘123456’

Nst6310
Jul 21, 2023

B. select * from Users where UserName = 'attack' or 1=1 -- and UserPassword = '123456' Option D is incorrect because the SQL injection payload is placed after the closing single quote for 'UserPassword', which would likely result in a syntax error. Option A is incorrect because the payload is missing the closing single quote after 'attack', which would likely result in a syntax error.

IPconfigOption: D
Oct 31, 2023

Understanding an SQL Injection Query Attacker Launching SQL Injection SELECT Count(*) FROM Users WHERE UserName='Blah' or 1=1 --' AND Password='Springfield' SELECT Count(*) FROM Users WHERE UserName='Blah' or 1=1 --' AND Password='Springfield' CEH V12 Page 2204

insaniuntOption: D
Dec 10, 2023

D. select * from Users where UserName = ‘attack’ or 1=1 --’ and UserPassword = ‘123456’ pay attention: --’

[Removed]Option: D
Dec 16, 2023

D. select * from Users where UserName = ‘attack’ or 1=1 --’ and UserPassword = ‘123456’. The point of the question is not whether the select statement will provide anything useful, but to show that you understand how the strings/parameters are passed from the login/password form to the SQL query. This was a question for me when I took the exam on 13 Dec 2023.

Mann098Option: D
Dec 29, 2024

select * from Users where UserName = 'attack' or 1=1 --' and UserPassword = '123456'

victorfsOption: D
May 14, 2023

The correct option is D. select * from Users where UserName = ‘attack’ or 1=1 --’ and UserPassword = ‘123456’

predator67Option: D
Jun 1, 2023

The correct option is D.

581777aOption: D
Aug 4, 2023

D. select * from Users where UserName = ‘attack’ or 1=1 --’ and UserPassword = ‘123456’

kinok9438
Aug 8, 2023

D is the Correct

mattlai
Aug 14, 2023

https://owasp.org/www-community/attacks/SQL_Injection_Bypassing_WAF

barey
Feb 12, 2024

GPT 4.0 what you think in that way ? : Apologies for the confusion. In line with the credentials provided and typical SQL injection techniques, the correct SQL command that would be executed by the server, if there is indeed an SQL injection vulnerability, would indeed be: A. select * from Users where UserName = 'attack' or '1'='1' -- and UserPassword = '123456' In this scenario, the injection point is within the UserName parameter, and the rest of the SQL statement is commented out using the double dashes (--). This would cause the where condition to always be true, potentially allowing an attacker to bypass authentication mechanisms.

Miracleam
Oct 16, 2024

The answer is D. Please refer to CEH V12 Module 15