Welcome to Emoji Stack, the brand new stack based emoji language! Instead of other stack based turing machines that use difficult to read and challenging characters like + - and [], Emoji Stack uses our proprietary patent pending emoji system.
The details of our implentation is below:
👉: Move the stack pointer one cell to the right 👈: Move the stack pointer one cell to the lef 👍: Increment the current cell by one, bounded by 255 👎: Decrement the current cell by one, bounded by 0 💬: Print the ASCII value of the current cell 🔁##: Repeat the previous instruction 0x## times The Emoji Stack is 256 cells long, with each cell supporting a value between 0 - 255.
for i in range(len(str)): if str[i].isnumeric(): continue elif str[i]=="🔁": arr.pop() arr.append(str[i-1]+str[i]+str[i+1]+str[i+2]) else: arr.append(str[i])
cell=[0 for i in range(256)] ptr=0
for i in range(len(arr)): if arr[i]=="👉": ptr+=1 if arr[i]=="👈": ptr-=1 if arr[i]=="👍": cell[ptr]+=1 if len(arr[i])==4: for j in range(int(arr[i][2]+arr[i][3],16)+1): if arr[i][0] == "👉": ptr += 1 if arr[i][0] == "👈": ptr -= 1 if arr[i][0] == "👍": cell[ptr] += 1 if arr[i]=="💬": print(chr(cell[ptr]),end="")
CACI{TUR!NG_!5_R011!NG_!N_H!5_GR@V3}
Making Baking Pancakes
难度:Easy,对我的难度:Beginner
好tm简单的题,不懂为什么这么少解
nc连接,发现challenge内容为:
1 2 3 4 5 6 7 8 9
Welcome to the pancake shop! Pancakes have layers, we need you to get through them all to get our secret pancake mix formula. This server will require you to complete 1000 challenge-responses. A response can be created by doing the following: 1. Base64 decoding the challenge once (will output (encoded|n)) 2. Decoding the challenge n more times. 3. Send (decoded|current challenge iteration) Example response for challenge 485/1000: e9208047e544312e6eac685e4e1f7e20|485 Good luck!
from base64 import b64decode as de import warnings from tqdm import tqdm warnings.defaultaction = "ignore" from pwn import * c = remote('chal.pctf.competitivecyber.club', 9001) c.recvuntil('Good luck!') for j in tqdm(range(1002)): #这里是因为有两个\n所以跑两个空循环,不是很会用pwntools别骂了 k = j-2 a = c.recvline().decode() if a == '\n': continue a = a.split(': ')[1] a1 = de(a).decode() basestring, times = a1.split('|') for i in range(int(times)): basestring = de(basestring) c.sendline(basestring+b'|'+str(k).encode()) c.interactive()
输出
1 2 3
(999/1000) >> Wow you did it, you've earned our formula! DO NOT SHARE: pctf{store_bought_pancake_batter_fa82370}
def binary_to_ascii(binary_string): # Remove the 'b' prefix and convert the binary string to decimal decimal_value = int(binary_string, 2) # Convert decimal to ASCII character return chr(decimal_value)
binary_values = [ "01010000", # P "01000011", # C "01010100", # T "01000110", # F "01111011", # { "01010010", # R "01010100", # T "01001100", # L "01011111", # _ "01101001", # i "00100100", # $ "01011111", # _ "01000100", # D "01000000", # @ "01000100", # D "01011111", # _ "00110000", # 0 "01000110", # F "01011111", # _ "01001000", # H "01000000", # @ "01110010", # r "01100100", # d "01110111", # w "01000000", # @ "01110010", # r "00110011", # 3 "01111101" # } ]
ascii_characters = [binary_to_ascii(bv) for bv in binary_values]
def filter_check(command): user_input = command parsed = command.split() #Must begin with echo if not "echo" in parsed: return False else: if ">" in parsed: #print("HEY! No moving things around.") req.sendall(b"HEY! No moving things around.\n\n") return False else: parsed = command.replace("$", " ").replace("(", " ").replace(")", " ").replace("|"," ").replace("&", " ").replace(";"," ").replace("<"," ").replace(">"," ").replace("`"," ").split() #print(parsed) for i in range(len(parsed)): if parsed[i] in blacklist: return False return True
def backend(req): req.sendall(b'This is shell made to use only the echo command.\n') while True: #print("\nThis is shell made to use only the echo command.") req.sendall(b'Please input command: ') user_input = req.recv(4096).strip(b'\n').decode() print(user_input) #Check input if user_input: if filter_check(user_input): output = os.popen(user_input).read() req.sendall((output + '\n').encode()) else: #print("Those commands don't work.") req.sendall(b"HEY! I said only echo works.\n\n") else: #print("Why no command?") req.sendall(b"Where\'s the command.\n\n")
class incoming(socketserver.BaseRequestHandler): def handle(self): signal.alarm(1500) req = self.request backend(req)
class ReusableTCPServer(socketserver.ForkingMixIn, socketserver.TCPServer): pass
// Sub module instances top$pulser$shot$counter counter ( .d(counter$d), .q(counter$q), .clock(counter$clock) ); top$pulser$shot$state state ( .d(state$d), .q(state$q), .clock(state$clock) );
// Update code always @(*) begin counter$clock = clock; state$clock = clock; counter$d = counter$q; state$d = state$q; if (state$q) begin counter$d = counter$q + 32'h1; end fired = 1'b0; if (state$q && (counter$q == duration)) begin state$d = 1'b0; fired = 1'b1; end active = state$q; if (trigger) begin state$d = 1'b1; counter$d = 32'h0; end end
// Update code always @(*) begin counter$clock = clock; counter$d = counter$q; if (enable) begin counter$d = counter$q + 32'h1; end strobe = enable & (counter$q == threshold); if (strobe) begin counter$d = 32'h1; end end
file = open("program.txt","r") rom = file.read() file.close() interpreter = Interpreter(rom)
interpreter.run()
cv2.imwrite("flag.png",interpreter.stack)
出:
好恐怖啊(bushi)
PCTF{3MOJ!==G00D!}
写在后面
这次虽然名次不是很理想,但依然是我印象里最好的一次CTF体验。主要是队友之间真正地开始有了合作,让我有了一种队伍的归属感。说句心里话,CTF作为小众爱好(大学学网安的不算),能找到如此志同道合的队友跟我一起做我喜欢做的事情,我是何其幸运啊。作为高中生,我只能CTF for fun,大部分国内的大赛我都不配参加。我能找到一群人陪我打国外的CTF,跟我交流技术,让我在孤独了几年的兴趣爱好上第一次有了同伴,即使菜我也很开心了(我菜,我队友全tql)。我发自内心地感谢我的队友们,谢谢你们给了我如此的幸福。