Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
pyjail2
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Crowley committed Jun 3, 2024
1 parent 9041932 commit 1c3c18d
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pyjail-2/chall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: JailBreak 2
categories:
- misc
value: 125
flag: bcactf{PyTH0n_M4st3R_Pr0veD}
description: |-
The prison has increased security measures since you last escaped it.
Can you still manage to escape?
hints:
- What in python is evaluated to a number?
files:
- src: ./main.py
authors:
- Jack Crowley
visible: true
#TODO Deployment
27 changes: 27 additions & 0 deletions pyjail-2/deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def sanitize(letter):
print("Checking for contraband...")
return any([i in letter.lower() for i in BANNED_CHARS])

def end():
print("Contraband letters found!\nMessages Deleted!")
exit()

BANNED_CHARS = "gdvxfiyundmn'~`@#$%^&.{}0123456789"
flag = "bcactf{PyTH0n_M4st3R_Pr0veD}"

print("Welcome to the prison's mail center")

msg = input("\nPlease enter your message: ")

while msg != "":
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.')

msg = input("\nPlease enter your message: ")
27 changes: 27 additions & 0 deletions pyjail-2/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def sanitize(letter):
print("Checking for contraband...")
return any([i in letter.lower() for i in BANNED_CHARS])

def end():
print("Contraband letters found!\nMessages Deleted!")
exit()

BANNED_CHARS = "gdvxfiyundmnet/\\'~`@#$%^&.{}0123456789"
flag = "REDACTED"

print("Welcome to the prison's mail center")

msg = input("\nPlease enter your message: ")

while msg != "":
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.')

msg = input("\nPlease enter your message: ")
7 changes: 7 additions & 0 deletions pyjail-2/solve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# JailBreak 2

Unlike the first JailBreak, this time the security measures banned numbers. However, this does not factor into the fact the both `True` and `False` are counted as 1 and 0 respectedly. Using the `bool` function, which when presented with a not empty argument evaluates to true, we can then do math to get the the needed ascii values, counting the `bool("a")` as 1.

```
locals()[chr(((bool("a")+bool("a")+bool("a")+bool("a")+bool("a"))*(bool("a")+bool("a")))**(bool("a")+bool("a"))+bool("a")+bool("a"))+chr(((bool("a")+bool("a")+bool("a")+bool("a")+bool("a"))*(bool("a")+bool("a")))**(bool("a")+bool("a"))+(bool("a")+bool("a")+bool("a")+bool("a"))*(bool("a")+bool("a")))+chr(((bool("a")+bool("a")+bool("a")+bool("a")+bool("a"))*(bool("a")+bool("a")))**(bool("a")+bool("a"))-bool("a")-bool("a")-bool("a"))+chr(((bool("a")+bool("a")+bool("a")+bool("a")+bool("a"))*(bool("a")+bool("a")))**(bool("a")+bool("a"))+bool("a")+bool("a")+bool("a"))]
```

0 comments on commit 1c3c18d

Please sign in to comment.