Programming mission 11

Reverse Ascii Shift

Published on October 2, 2015

Reverse Ascii Shift

The task is to decode a generated ascii string. Furthermore, the time limit is only 5 seconds !

generated string

An example of the generated string

My approach

The time limit of 5 seconds (!) force us to solve this mission completely by scripting. We thus use the selenium webdriver package for python to: 1. Open a browser, 2. Login, 3. Grab the generated string, 4. Solve it and 5. Submit the answer.

1. Open a browser

# URL to the 11th prog mission
url_data = ''

# Open in firefox
driver = webdriver.Firefox()

2. Log in

# Login
log_pass_list = [('your_username','your_password')]

# Load the page

# Username
inputElement = driver.find_element_by_name('username')

# Password
inputElement = driver.find_element_by_name('password')

# Enter

3. Grab the generated string (from the source code)

# Search for the generated string
search_word = 'Generated String'
start_loc = source.find(search_word)+len(search_word)+2

# Search for the shift statement
search_word = 'Shift'
start_loc = source.find(search_word)+len(search_word)+2
num_shift = int(source[start_loc:start_loc+100].split('<br>')[0])

# Final array to decode
gen_str = clean-num_shift

4. Solve it

# Decoding
asci_str = []
for i in xrange(len(gen_str)):

After cleaning the answer to submit we finally arrive at the last step

5. Submit the answer

# Submit solution
inputElement = driver.find_element_by_name('solution')

# Enter

And that's it! All done in less than 5 seconds! 

The full code for this mission can be found at Github.