our tutorial is scheduled to do the lecture notes for the wednesday lecture of week 4
you get to attend meetings with Richard?
try to focus on analysis, rather than just noting down what you read
do just this stuff
* rounded up
if it has something targeting others, you need their express permission
share what you’re planning on doing for your Something Awesome!
some stuff I forgot to mention last week
ones i’ve done, in order of goodness
others I haven’t done
this slide is intentionally blank
structured query language
Queries >
SELECT <column> FROM <table>;
INSERT INTO table VALUES (a, b);
UPDATE table SET ... = ...
DELETE FROM table ...
-- a comment (also #)
SELECT * FROM table WHERE …
col = ...
col > ...
col < ...
col <> ... #
not equals (!=)col LIKE ... #
regexp_
(.)
and %
(.*)
are wildcardsSELECT user, pass FROM users UNION SELECT title, author FROM blogs
user pass id title author THE UNION
|=======|=======| |===|=======|=======| |=======|=======|
| admin | admin | | 1 | blog1 | melon | | admin | admin |
| melon | water | | 2 | blog2 | admin | | melon | water |
|=======|=======| | 3 | blog3 | admin | | blog1 | melon |
|===|=======|=======| | blog2 | admin |
| blog3 | admin |
users blogs |=======|=======|
fingerprinting
Version()
sqlite_version()
@@Version
finding the schema
information_schema.[tables|columns]
sqlite_[master|schema]
SHOW TABLES; DESCRIBE <table_name>
tldr: blindly trusting user input is bad
what if we injected control characters which changed how the database interprets the query? e.g. inject our own UNIONS/WHERES/etc
how could it tell the difference?
SELECT * FROM users WHERE user = '{input}' AND password = '{...}'
If our input was: ' OR 1=1 --
-- vvvvvvvvvvvvvvvvvvvv
SELECT * FROM users WHERE user = '' OR 1=1 --'and password = '...'
-- ^^^^^^^^^^^^^^^^^^^^
-- user = '' is always false, but 1=1 is always true
-- so this will return every user from the database
syntax needs to be correct, or you’ll throw an error
you have SQLi in items
, but want users
UNION
a basic login form
'username or password incorrect'
)note: these have historically still been vulnerable, don’t solely rely on them