【实验吧】逆向之bitwise

You see the doors to the loading bay of the hangar, but they are locked. However, you are able to extract the password verification program from the control panel... Can you find the password to gain access to the loading bay?
解题链接:  http://ctf5.shiyanbar.com/reverse/bitwise/bitwise.rar  

题中给出了py代码:

#!/usr/bin/env python

user_submitted = raw_input("Enter Password: ")

if len(user_submitted) != 10:
  print "Wrong"
  exit()


verify_arr = [193, 35, 9, 33, 1, 9, 3, 33, 9, 225]
user_arr = []
for char in user_submitted:
  # '<<' is left bit shift
  # '>>' is right bit shift
  # '|' is bit-wise or
  # '^' is bit-wise xor
  # '&' is bit-wise and
  user_arr.append( (((ord(char) << 5) | (ord(char) >> 3)) ^ 111) & 255 )

if (user_arr == verify_arr):
  print "Success"
else:
  print "Wrong"

于是 根据题的意思写出了自己的解题脚本:

#!/usr/bin/env python3
verify_arr = [193, 35, 9, 33, 1, 9, 3, 33, 9, 225]
key=[0,0,0,0,0,0,0,0,0,0]
for i in range(10):
    for k in range(128):
        if verify_arr[i]==(((k<< 5) | (k >> 3)) ^ 111) & 255 :
            key[i]=chr(k)
        
flag= ''
for i in key:
    flag+=i
print flag

最终得到:
ub3rs3cr3t
技不如人就要多努力,假期已过,一切已是物是人非

你可能感兴趣的:(【实验吧】逆向之bitwise)