Featured Content Slider

Home » » picoctf 2013 - Bitwise: 55

picoctf 2013 - Bitwise: 55

Vo Uu | 21:09 | 0 nhận xét
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?

SRC:
#!/usr/bin/env python

user_submitted = "ub3rs3cr3t"

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"
user_submitted = raw_input("Enter Password: ")

 Có đoạn chỉ dẫn nè:

  # '<<' is left bit shift ==> dịch trái bit
  # '>>' is right bit shift ==> dịch phải bit
  # '|' is bit-wise or ==> toán tử or
  # '^' is bit-wise xor ==> toán tử xor
  # '&' is bit-wise and ==> toán tử and

Mình sẽ dùng 1 bảng kí tự được bitwise trước để đối chiếu với mảng
verify_arr = [193, 35, 9, 33, 1, 9, 3, 33, 9, 225]
Bảng này mình mới chỉ dùng các kí tự số và các kí tự in thường "0123456789abcdefghijklmnopqrstuvwxyz"

#!/usr/bin/env python
user_submitted = "0123456789abcdefghijklmnopqrstuvwxyz"
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 )
print user_arr
print "  "

 Rồi đối chiếu với mảng kia là xong!!
Share this article :

0 nhận xét:

Đăng nhận xét

Recent Post

Test Footer 1

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. The UG - All Rights Reserved
Template Modify by Creating Website
Proudly powered by Blogger