Python 3

Prompt

We have created a python script for you to break into as training. See if you can figure out a password that will authenticate with the program.

PYTHON3.pyc0.6KB

Walk-Through

This challenge involves analyzing vulnerabilities in a compiled Python program. The uncompyle program can be used to convert the compiled program back into Python code. The result of running uncompyle can be seen below:

import sys

def main():
    if len(sys.argv) != 2:
        print 'Invalid args'
        return
    password = sys.argv[1]
    builder = 0
    for c in password:
        builder += ord(c)

    builder = builder << 2
    builder = ~builder
    builder = builder ^ 12648430
    builder = ~builder
    if builder == 12645638 and ord(password[0]) == 78 and len(password) == 11:
        print 'correct'
    else:
        print 'incorrect'


if __name__ == '__main__':
    main()

An analysis of the code reveals that the sum of the ASCII codes for the characters in the password will have a specific value after several transformations. Question 1 can be solved by hand by reversing the transformations. Below is a solution created with the aid of some JavaScript code.

image

Questions

What is an input to this program that will result in a correct validation?

©️ 2024 Cyber Skyline. All Rights Reserved. Unauthorized reproduction or distribution of this copyrighted work is illegal.