Tag: security

Questions Related to security

Which attack(s) are possible in the below code: protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { String name = req.getParameter("name"); ... out.println("hello " + name.trim()); }

  1. Reflected Cross Site Scripting

  2. Improper Error Handling

  3. Directory Listing

  4. Phishing

  5. Option 1 AND Option 2 AND Option 4

  6. Option 1 AND Option 2


Correct Option: E

AI Explanation

To determine which attack(s) are possible in the given code, let's go through each option:

Option A: Reflected Cross Site Scripting (XSS) - This attack involves injecting malicious scripts into a website, which are then executed by the victim's browser. In the given code, the "name" parameter is directly concatenated with the string "hello" and written to the output. This can potentially allow an attacker to inject malicious scripts into the "name" parameter and execute them in the victim's browser. Therefore, this code is vulnerable to Reflected Cross Site Scripting.

Option B: Improper Error Handling - This attack involves mishandling errors or exceptions in a way that exposes sensitive information or provides valuable clues to an attacker. The given code does not directly handle errors or exceptions, so this code is not vulnerable to Improper Error Handling.

Option C: Directory Listing - This attack involves exposing the contents of directories on a web server, which can lead to the disclosure of sensitive information. The given code does not involve directory listing, so this code is not vulnerable to Directory Listing.

Option D: Phishing - This attack involves tricking users into providing sensitive information by impersonating a trusted entity. The given code does not involve any phishing techniques, so this code is not vulnerable to Phishing.

Based on the above analysis, the correct answer is E. Option 1 (Reflected Cross Site Scripting) AND Option 2 (Improper Error Handling) AND Option 4 (Phishing) are possible attacks in the given code.

Which attack(s) are possible in the below code:

  1. Content Spoofing

  2. HTTP Response Splitting

  3. Directory Listing

  4. Option 1 AND Option 2

  5. Option 2 AND Option 3


Correct Option: D

Identify the weakness in the below JSP file: 1 ... 2 3 4 8 9 11 12 13 14 function doBack() 15 { 16 history.go(-1); 17 } 18 function doDelete() 19 { 20 document.forms[0].action="/DeleteUsersAction"; 21 document.forms[0].submit(); 22 } 23 24 ...

  1. SQL Injection

  2. Cross Site Scripting

  3. Broken Access Control

  4. Improper Resource Initialization


Correct Option: C

Identify the weakness in the below JSP file: 1 2 ... 3 Dear User, 4 5 If you liked our services, then you would like to refer it to your friends. 6 7 Click on the below link: 8 9 ";> "Refer a Friend"! 10 ... 11

  1. Information Disclosure

  2. Cross Site Scripting

  3. Usage of Risky Encryption

  4. All of the above


Correct Option: C

Identify the Vulnerable Line # in the below code: 1 ... 2 public static Connection getConnection() 3 { 4 Connection con = null; 5 try 6 { 7 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 8 con = DriverManager.getConnection("jdbc:odbc:Lookup","admin","admin"); 9 10 }catch (ClassNotFoundException e) 11 { 12 if(con!=null) 13 close(con); 14 log.debug(“Error Occurred:” + e); 15 16 } catch(SQLException ex) 17 { 18 19 if(con!=null) 20 close(con); 21 log.debug(“Error Occurred:” + ex); 22 } 23 return con; 24 } 25 ...

  1. Line # 4

  2. Line # 13 & 20

  3. Line # 7 & 8

  4. None of the above


Correct Option: C

AI Explanation

To identify the vulnerable line in the given code, we need to understand what vulnerability we are looking for.

In this case, the code is establishing a database connection using JDBC. The vulnerability we are looking for is an SQL injection vulnerability, where an attacker can manipulate the SQL query being executed.

Looking at the code, we can see that the SQL query is being constructed in line #8 using a hardcoded username and password. This can be a potential vulnerability if the username and password are not properly validated or sanitized.

Therefore, the vulnerable lines in the code are Line #7 and Line #8.

The correct answer is C) Line #7 and Line #8.