Based on github.com/UnitasBrooks/rails_sql_injection
¶ ↑
READMEThis is a simple Ruby on Rails app to practice SQL injection. Raw SQL Search inserts user input directly into a query and is highly susceptible to injection attacks. Sanitized Search is much better, it replaces single quotes with double quotes. I have read that this method can be broken but I was unable to replicate any of the methods I found. Prepared statement search uses a two step prepared statement built into the PG gem and is by far the safest.
The site is currently being hosted on Heroku at: enigmatic-retreat-3573.herokuapp.com/users
Example injections to try: 1) x’; insert into users values (6,‘sidney’,1,1);– This will create a new user from the search bar
2) bobby’ and ssn=444;– This will return all users whose name is bobby and whose SSN is 444
3) x’; select * from users;– Returns everything in the users db
In order to run this locally you need PSQL, Ruby 1.9.3, Rails 4.0 and a database.yml file in your config/ folder. That database.yml was ommitted for security reasons. Send me a message or e-mail if you need help generating one.
Set up steps
1) Clone the project
2) Run bundle install
3) Add you database.yml file
a) No need for a test or production b) Name your development database psql_injection_development c) Add host: localhost under development
4) Run rake db:migrate
5) Run rails s to start the server
6) Point your browser to localhost:3000