https://alpacahack.com/daily/challenges/private-method
import re
class Main:
# public
def alpaca():
return "đŠ"
# private
def __flag():
return "Alpaca{REDACTED}"
while True:
code = input(">>> Main.").strip()
if re.fullmatch(r"\w+\(\)", code):
print(eval(f"Main.{code}"))
else:
print("Nope")
__dict__ ăšăă class ăźć
šć±æ§ăæ ŒçŽăă attribute ăăă
mappingproxy({
"__module__": "__main__",
"__firstlineno__": 1,
"alpaca": <function Main.alpaca at 0x000001A184A91300>,
"_Main__flag": <function Main.__flag at 0x000001A184A90540>,
"__static_attributes__": (),
"__dict__": <attribute '__dict__' of 'Main' objects>,
"__weakref__": <attribute '__weakref__' of 'Main' objects>,
"__doc__": None,
"__annotations__": {}
})
_Main__flag ăšăăäœăăæȘăă attr ăăăăźă§ăăăăćŒăčă°ăăPython mangles these names with the class name: if class Foo has an attribute named
__a, it cannot be accessed byFoo.__a. (An insistent user could still gain access by callingFoo._Foo__a.)
https://peps.python.org/pep-0008/
__flag ăŻéćžž Main.__flag ă§ăŻăąăŻă»ăčă§ăăȘăăăă©ăăăŠăăąăŻă»ăčăăăäșșăźăăă« __Main._Main__flag ă§ăąăŻă»ăčăćŻèœă§ăă
() ăă€ăăŠăăăă°ćźèĄăăăMain._Main__flag()