This repository has been archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
misc/jailbreak #9
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8661e11
basic script
Jack-Crowley 386c1c8
finish
Jack-Crowley 4a08ff1
fixes
Jack-Crowley a64e08f
fixes
Jack-Crowley 5c41ecc
deploy stuff
mud-ali 0c3fa86
make easier
Jack-Crowley 1cb1f6c
combine into one file and allow nonstring values
mud-ali File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: JailBreak | ||
categories: | ||
- misc | ||
value: 75 | ||
flag: camp{PYth0n_M4steR_M2!f45} | ||
description: |- | ||
After a recent prison escape due to hidden messages in letters, the facility has tightened security. Can you find a way around these new measures? | ||
hints: | ||
- How can you access variables in python? | ||
files: | ||
- src: ./main.py | ||
authors: | ||
- Jack Crowley | ||
visible: true | ||
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
def sanitize(letter): | ||
print("Checking for contraband...") | ||
return any([i in letter.lower() for i in BANNED_CHARS]) | ||
|
||
def end(): | ||
print("Contraband letters found!\nMessage Deleted!") | ||
exit() | ||
|
||
BANNED_CHARS = "gdvxftundmn'~`@#$%^&*-/.{}" | ||
flag = "camp{PYth0n_M4steR_M2!f45}" | ||
|
||
print("Welcome to the prison's mail center") | ||
msg = input("Please enter your message: ") | ||
|
||
if sanitize(msg): | ||
end() | ||
|
||
try: | ||
x = eval(msg) | ||
if len(x) != len(flag): end() | ||
print(x) | ||
except Exception as e: | ||
print(f'Error occured: {str(e)}; Message could not be sent.') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
def sanitize(letter): | ||
print("Checking for contraband...") | ||
return any([i in letter.lower() for i in BANNED_CHARS]) | ||
|
||
def end(): | ||
print("Contraband letters found!\nMessage Deleted!") | ||
exit() | ||
|
||
BANNED_CHARS = "gdvxftundmn'~`@#$%^&*-/.{}" | ||
flag = "REDACTED" | ||
|
||
print("Welcome to the prison's mail center") | ||
msg = input("Please enter your message: ") | ||
|
||
if sanitize(msg): | ||
end() | ||
|
||
try: | ||
x = eval(msg) | ||
if len(x) != len(flag): end() | ||
print(x) | ||
except Exception as e: | ||
print(f'Error occured: {str(e)}; Message could not be sent.') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# JailBreak | ||
|
||
The `exec` function in python is very dangerous, especially with it executing an input given by the user. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems irrelevant, since the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whoops i changed it after writing the solve path |
||
|
||
This is what `PyJail` problems are built off of, where they restrict inputs, functions, or anything else to make it more challenging to get the flag. | ||
|
||
Based off of the banned keys, `gdvxftundmn'~`\``@#$%^&*-/.{}`, there are only a few functions we can use, one of which is the key to solving the problem, `locals`. | ||
|
||
`locals` is a function that has reference to all of the local parameters, including the `flag` variable which stores the flag. But since the `flag` has banned characters, we must use `chr()` function with the ascii value of each letter and join them together. | ||
|
||
``` | ||
locals()[chr(102)+chr(108)+chr(97)+chr(103)] | ||
``` | ||
|
||
Using this input, the flag will be printed out. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: deploy