Created
November 5, 2022 08:19
-
-
Save PotatoPwn/f54e1def46945087ece9a2a2469e7862 to your computer and use it in GitHub Desktop.
For a CTF challenge where i needed to unzip the current files based on the contents inside
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/pyithon | |
| import zipfile | |
| import os | |
| original_file = "5900.zip" | |
| while True: | |
| original_file = zipfile.ZipFile(original_file, 'r') #sets variable as an interactive object | |
| password = original_file.namelist() #list content in zip file | |
| pw = (password[0].removesuffix('.zip')) #removes array and removes .zip from zip content | |
| pw = (pw.encode()) # encodes out as int | |
| print(pw) | |
| original_file.setpassword(pw) #set password for zip needs it as an integer | |
| original_file.extractall() #extracts zip | |
| pw = (pw.decode()) # re-encodes into bytes | |
| original_file = pw + '.zip' # changes original_file variable into new variable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment