Skip to content

Instantly share code, notes, and snippets.

@leonardocordeiro
Created January 29, 2016 21:43
Show Gist options
  • Save leonardocordeiro/c7b33edf711d0ae6969c to your computer and use it in GitHub Desktop.
Save leonardocordeiro/c7b33edf711d0ae6969c to your computer and use it in GitHub Desktop.
String nome = "Leonardo";
String senha = "' or 1=1 #";
Connection cnn = DriverManager.getConnection("jdbc:mysql://localhost/sql_injection", "root", "");
PreparedStatement statement = cnn.prepareStatement("select * from Usuario where nome = '" + nome + "' and senha='" + senha + "';");
ResultSet resultSet = statement.executeQuery();
while(resultSet.next())
System.out.println(resultSet.getString("nome"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment