From 4258de1573f6a9cf1a045c488e13a964a3bf87a6 Mon Sep 17 00:00:00 2001 From: sangge <2251250136@qq.com> Date: Thu, 2 Nov 2023 09:11:18 +0800 Subject: [PATCH] feat: finish CS --- misc/Claude_Shannon/crack.py | 5 ++--- misc/Claude_Shannon/crack.sage | 6 +++--- misc/Claude_Shannon/dockerfile | 7 +++++++ misc/Claude_Shannon/main_local.py | 1 - misc/Claude_Shannon/main_remote.py | 12 ++++++------ 5 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 misc/Claude_Shannon/dockerfile diff --git a/misc/Claude_Shannon/crack.py b/misc/Claude_Shannon/crack.py index 819ead6..07e65e2 100644 --- a/misc/Claude_Shannon/crack.py +++ b/misc/Claude_Shannon/crack.py @@ -26,7 +26,7 @@ for i in range(0,1000,100): for i in range(300): try: - r = remote("localhost", 10011) + r = remote('172.20.14.117', "61553") # r = process(['python3', 'main.py']) for i in range(15): r.sendlineafter(b":", b"1") @@ -35,8 +35,7 @@ for i in range(300): r.sendlineafter(b"chests:", b"0 0 1 0 0 1 0") r.recvline() flag = r.recvline() - if b"flag" in flag: - end_time = time.time() + if b"0xFA" in flag: print(flag) break else: diff --git a/misc/Claude_Shannon/crack.sage b/misc/Claude_Shannon/crack.sage index ba7ecb9..1fc29b0 100644 --- a/misc/Claude_Shannon/crack.sage +++ b/misc/Claude_Shannon/crack.sage @@ -164,10 +164,10 @@ for i in range(15): from pwn import * # 设置日志级别为 debug,以便在执行过程中输出详细日志信息 -#context.log_level = 'debug' +context.log_level = 'debug' -r = process(['python3', 'main_local.py']) -#r = remote("localhost", "10011") +#r = process(['python3', 'main_local.py']) +r = remote('172.20.14.117', "61553") for i in range(1): msg = '' diff --git a/misc/Claude_Shannon/dockerfile b/misc/Claude_Shannon/dockerfile new file mode 100644 index 0000000..cfd07eb --- /dev/null +++ b/misc/Claude_Shannon/dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11 + +COPY main_remote.py /app/ + +WORKDIR /app + +CMD [ "python", "main_remote.py" ] \ No newline at end of file diff --git a/misc/Claude_Shannon/main_local.py b/misc/Claude_Shannon/main_local.py index c752623..72c581a 100644 --- a/misc/Claude_Shannon/main_local.py +++ b/misc/Claude_Shannon/main_local.py @@ -1,6 +1,5 @@ from random import choice as c from random import randint, shuffle -from Crypto.Util.number import * # type: ignore flag = b"flag{this_is_a_test_flag}" diff --git a/misc/Claude_Shannon/main_remote.py b/misc/Claude_Shannon/main_remote.py index eac4217..33db53a 100644 --- a/misc/Claude_Shannon/main_remote.py +++ b/misc/Claude_Shannon/main_remote.py @@ -2,10 +2,12 @@ from random import choice as c from random import randint, shuffle import socketserver import signal -import string -import random import os +# 白名单列表,包含允许在问题中使用的关键词和符号 +white_list = ['==', '(', ')', 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', '0', '1', 'and', 'or', 'not'] + + class Task(socketserver.BaseRequestHandler): def _recvall(self): BUFF_SIZE = 2048 @@ -74,7 +76,7 @@ class Task(socketserver.BaseRequestHandler): # 游戏开始 self.send(b"The Unbreakable Shannon has returned, with some suspicious chests and a far more complicated strategy -- he MAY LIE ONCE OR TWICE! Can you still get all the treasure without losing your head?") - for i in range(1): + for _ in range(1): if not self.do_round(): # 执行游戏回合 self.send(b"A chest suddenly comes alive and BITE YOUR HEAD OFF.\n") return @@ -91,9 +93,7 @@ class ForkedServer(socketserver.ForkingMixIn, socketserver.TCPServer): if __name__ == "__main__": flag = bytes(os.getenv("FLAG"),"utf-8") # type: ignore - # 白名单列表,包含允许在问题中使用的关键词和符号 - white_list = ['==', '(', ')', 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', '0', '1', 'and', 'or', 'not'] - HOST, PORT = '0.0.0.0', 10011 + HOST, PORT = '0.0.0.0', 10001 server = ForkedServer((HOST, PORT), Task) server.allow_reuse_address = True print(HOST, PORT)