「Hacker101 CTF Encrypted Pastebin write-up」的评论 https://blog.werner.wiki/hacker101-ctf-encrypted-pastebin-write-up/ Try harder Thu, 02 Apr 2020 13:59:26 +0000 hourly 1 https://wordpress.org/?v=6.8.3 评论者:Werner https://blog.werner.wiki/hacker101-ctf-encrypted-pastebin-write-up/#comment-1071 Thu, 02 Apr 2020 13:59:26 +0000 https://blog.werner.wiki/?p=1032#comment-1071 回复给 jtorr3s

“`
plains = bytes([(16-index) ^ iv[index]]) + plains
index -= 1
“`
Here are two lines of code. You seem to write them on the same line.

]]>
评论者:jtorr3s https://blog.werner.wiki/hacker101-ctf-encrypted-pastebin-write-up/#comment-1069 Tue, 31 Mar 2020 13:45:27 +0000 https://blog.werner.wiki/?p=1032#comment-1069 Hello, very good manual. Thx

In script in python i have a error can help please?

import base64
import requests
def decode(data): return base64.b64decode(data.replace(‘~’, ‘=’).replace(‘!’, ‘/’).replace(‘-‘, ‘+’))
def encode(data): return base64.b64encode(data).decode(‘utf-8’).replace(‘=’, ‘~’).replace(‘/’, ‘!’).replace(‘+’, ‘-‘)
def bxor(b1, b2): # use xor for bytes result = b”” for b1, b2 in zip(b1, b2):
result += bytes([b1 ^ b2])
return result
def test(url, data): r = requests.get(url+’?post={}’.format(data))
if ‘PaddingException’ in r.text:
return False
else:
return True
def generate_iv_list(tail):
iv = b’\x00′ * (16 – len(tail) -1)
return [iv+bytes([change])+tail for change in range(0x00, 0xff+1)]
def padding_oracle(real_iv, url, data):
index = 15
plains = bytes()
tail = bytes()
while index >= 0:
for iv in generate_iv_list(tail):
if test(url, encode(iv+data)):
plains = bytes([(16-index) ^ iv[index]]) + plains index -= 1 ///// ERROR HERE plains = bytes([(16-index) ^ iv[index]]) + plains index -= 1
^
SyntaxError: invalid syntax ////////

tail = bytes([plain ^ (16-index) for plain in plains])
break return bxor(real_iv, plains)
if __name__ == ‘__main__’:
post = ‘LPTALJ-WW1!q1nfGhY54lVwmLGQexY7uNSfsUowFr2ercuG5JXhsPhd8qCRF8VhNdeZCxxwCcvztwOURu!Nu!oTs3O7PKqDolpVZAxybuxaIPInRPlTm1mos!7oCcyHvPxS5L!gthTFpbJfrE0Btn3v9-gVly!yyMceC-FQlgsta53SGNVNHBVnwE0fWiLw8Yh2kKNk5Uu9KOWSItZ3ZBQ~~’ url = ‘http://35.190.155.168/82356bdd25/’
i = 1 plains = bytes()
data = decode(post) length = len(data) while True:
if i*16 < length:
iv = data[(i-1)*16: i*16] plains += padding_oracle(iv, url, data[i*16:
(i+1)*16])
else:
break i += 1
print(plains)

]]>