Description:
I thought I found a perfect match but she ended up being my regEx girlfriend.
翻译:我以为我找到了一个完美的匹配,但她最终成为了我的正则表达式女朋友????
It wasn’t so hard, I asked google for the best way to generate matched string to a given pattern and wrote the following script. The only headache was when my generator used newlines (“\n”) so I removed them.
翻译:这并不难,我向谷歌询问了生成给定模式匹配字符串的最佳方法,并编写了以下脚本。唯一令人头疼的是当我的生成器使用换行符 (“n”) 时,所以我删除了它们。
from pwn import *
import rstr
import exrex
from time import sleep
import re
# conect to server
r = remote('misc.chal.csaw.io', 8001)
# Print the question string
print r.recvline()
# Counter
i=1
while True:
# Recieve the regex pattern
reg = r.recvline()[:-1]
print "%d -------\n"%i
print reg
print "-------\n"
ans=rstr.xeger(reg).replace('\n','') # Remove newlines!
# ans=exrex.getone(reg).replace('\n','') # Another possible option
r.sendline(ans)
i+=1
sleep(0.2)
And after 1000 tests we got the flag: flag{^regularly_express_yourself$}