knight ctf web wp

knight ctf web Programming Misc wp(部分)

今天去打了kinghtctf 哇本来以为什么都做不来就去看个热闹的,(p≧w≦q)没想到还是可以嘛

image-20220121165146417

web的现在只做了这么多出来,

image-20220121203443257

七百多个人能拍这我已经满足了(^▽^),现在总结一下遇到的题

Zero is not the limit

image-20220121165345068

打开这个样子

image-20220121165404956

当时找了又找什么都没找到,后来用dirsearch扫了一下,发现了user下面一大堆的东西,然后根据题目的提示,访问目录/user/-1就出来了

image-20220121165503058

Find Pass Code - 1

image-20220121165521079

image-20220121165531857

在源码中找到提示

image-20220121165549544

设置source参数得到源码

image-20220121165622243

<?php
require "flag.php";
if (isset($_POST["pass_code"])) {
    if (strcmp($_POST["pass_code"], $flag) == 0 ) {
        echo "KCTF Flag : {$flag}";
    } else {
        echo "Oh....My....God. You entered the wrong pass code.<br>";
    }
}
if (isset($_GET["source"])) {
    print show_source(__FILE__);
}

?>

一个简单的strcmp绕过,他不能处理数组类型,一旦输入数组那么就会return0然后就绕过啦啦啦。

Most Secure Calculator - 1

image-20220121170321637

image-20220121170327886

这个超简单,任意命令

image-20220121170453019

但是吧flag给过滤了,加个引号啦啦啦(先用ls知道了flag在这里面的)

system("cat flag.txt")

image-20220121170646552

My PHP Site

image-20220121170702350

image-20220121170720077

看到那个file参数了吗,文件包含漏洞哦~

[Tareq's Home Page](http://137.184.133.81:15002/?file=php://filter/read=convert.base64-encode/resource=index.php)用伪协议直接读取

image-20220121170907391

base解密

<?php

if(isset($_GET['file'])){
    if ($_GET['file'] == "index.php") {
        echo "<h1>ERROR!!</h1>";
        die();
    }else{
        include $_GET['file'];
    }

}else{
    echo "<h1>You are missing the file parameter</h1>";

    #note :- secret location /home/tareq/s3crEt_fl49.txt
}

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tareq's Home Page</title>
</head>
<body>
</body>
</html>

看到那个note提示了吗,用伪协议读取他

image-20220121171217272

出来啦,base解密就好了KCTF{L0C4L_F1L3_1ncLu710n}

Find Pass Code - 2

image-20220121171307229

image-20220121171320185

根据提示还是使用source参数看源码,

image-20220121171401661

<?php
require "flag.php";
$old_pass_codes = array("0e215962017", "0e730083352", "0e807097110", "0e840922711");
$old_pass_flag = false;
if (isset($_POST["pass_code"]) && !is_array($_POST["pass_code"])) {
    foreach ($old_pass_codes as $old_pass_code) {
        if ($_POST["pass_code"] === $old_pass_code) {
            $old_pass_flag = true;
            break;
        }
    }
    if ($old_pass_flag) {
        echo "Sorry ! It's an old pass code.";
    } else if ($_POST["pass_code"] == md5($_POST["pass_code"])) {
        echo "KCTF Flag : {$flag}";
    } else {
        echo "Oh....My....God. You entered the wrong pass code.<br>";
    }
}
if (isset($_GET["source"])) {
    print show_source(__FILE__);
}

?>

一个md5碰撞,但是他把我们常见的都给过滤掉了,加密前加密后都必须是0e纯数字的形式,网上搜半天也没有,我们就写了个脚本自己跑

image-20220121171527103

最后跑出来了,这里就总结一下常见的这种md5碰撞可用的

0e1137126905

0e215962017

0e730083352

0e807097110

0e840922711

Most Secure Calculator - 2

哇这个是真的难,把这个做出来我是真的有成就感!!!

image-20220121171726495

image-20220121171737535

还是命令执行,但是过滤了所有的字母和大部分的符号,这怎么办呢!还好我以前就看过p神的那个无字母webshell,

命令执行中关于PHP正则表达式的一些绕过方法_WHOAMIAnony的博客-CSDN博客_php正则绕过

无字母数字webshell之提高篇 | 离别歌 (leavesongs.com)

URL编码取反绕过(最简单的)

注意: 该方法只适用于PHP7

对想要传入的参数,先进行URL解码再取反

例如传入构造一个phpinfo();(生成payload的时候先取反再URL编码)

img

Keep Calculating

哈哈随便找了下又弄出来个题,正好最近在学py

image-20220121175705128

x = 1
y = 2
answer = 0
while x < 667:
    print(x)
    answer += ((x * y) + (x * (10**len(f'{y}')))+y)
    x += 1

print(answer)

Reverse The Answer

image-20220121181401026

x = 1
answer = 0
while x < 544:
    calculation = (x * (x + 1)) + (2 * (x + 1))
    reverssed_calc = int(str(calculation)[::-1])
    print(x,reverssed_calc)
    if reverssed_calc%4 == 0:
        answer += reverssed_calc
    x += 1
print(answer)

Square Sum

image-20220121183643809

data = 25000
result = []
for i1 in range(200):
    for i2 in range(200):
        if i1**2 + i2**2 == data:
            buffer = [i1,i2]
            result.append(buffer)
result.sort()
print(result)

Something In Common

image-20220121184433577


def hcf(x, y):
    """该函数返回两个数的最大公约数"""
    # 获取最小值
    if x > y:
        smaller = y
    else:
        smaller = x

    for i in range(1, smaller + 1):
        if ((x % i == 0) and (y % i == 0)):
            hcf = i

    return hcf
# 用户输入两个数字
num1 = int(input("输入第一个数字: "))
num2 = int(input("输入第二个数字: "))

data = hcf(num1, num2)
data_list = list(str(data))
data_list = [int(i) for i in data_list]
result = 0
for item in data_list:
    result += item
print(result*1234)

Find The Number

image-20220121185503423

def g(n):
    if n<0:
        return 0
    else:
        return 1/2**n+g(n-1)

print(g(25))

Unzip Me

image-20220121200432945

下载下来改下后缀名zip,然后一直解压,最后解压出来的东西用记事本打开

image-20220121200600434下面那两个,是我自己写的,很容易就发现了嘛,两个字符交换下位置,就出来咯~

今天晚上还要去realwordctf看热闹,不说了继续做题了

还有好多我不会的东西,什么流量包什么的,以后一定要继续好好学,打算过段时间学学逆向。

我不能休息我还能学 ⊂(‘ω’⊂ )))Σ≡=─༄༅༄༅༄༅༄༅༄༅

还有汇编没怎么懂

如何运行汇编程序 - ice–cream - 博客园 (cnblogs.com)


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。后续可能会有评论区,不过也可以在github联系我。