next week
Structured Query Language
Fingerprinting
Version()
sqlite_version()
@@Version
Finding the schema
information_schema.[tables|columns]
sqlite_[master|schema]
SHOW TABLES; DESCRIBE <table_name>
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 |=======|=======|
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
covered in the extended lecture
HAAS
, we can’t access KB
, but HAAS
could, and we can send requests through HAAS
HAAS
, which aren’t expecting itten minute presentation on something cool security related from the last week? for bonus marks??
anybody want to present the solutions for blog / files?