Bitwise: 55

Here comes the coding , the code is available in two languages Java and Python ( which is a hacker language πŸ™‚  )

I feel comfortable coding in python as it is very easy πŸ˜› and here is the question

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?

Available in Python or Java

Here are my links in case the above one doesn’t work ( after some time)

Python:https://drive.google.com/file/d/0BxDZABox5hT2SWl5THlnei13OWc/edit?usp=sharing

Java:https://drive.google.com/file/d/0BxDZABox5hT2WDBEWjVvSlFCZUk/edit?usp=sharing

Here is the code for better view

#!/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
# '|' 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"

I hope that everyone has a basic idea about the left shift and the right shift in C language , the same applies here.

I was a bit lazy to do the calculation so I have written a small script to get the answers , first to write the script we need to understand the code a bit so that it makes easy for us and saves a lot of time. If you look at the code that verifies the password. we can clearly say that it’s length is 10 as the code verifies whether the length of the password is 10 if not it doesn’t execute.

Here is my script in python:https://drive.google.com/file/d/0BxDZABox5hT2eFdZN3k1NGFaZFk/edit?usp=sharing

This is very easy I checked for the ascii values which matches the to the password then it save it in the array (in python list ) and then add it and print here is the code


verify_arr = [193,35,9,33,1,9,3,33,9,225]
password =[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):
        password[i]=chr(k)
        break

key=''
for a in password:
    key+=a
print key

If you interpret (run) the code and the magic happens and you get the code

as ub3rs3cr3t

Password:’ub3rs3cr3t’

Here you go coding saved our day . I need not do all the left shift and the bit wise stuff πŸ™‚

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s