I am testing a CTF challenge on Vercel. The challenge is made with Flask and required subprocess.
Is this something that can be done on Vercel? Sorry if its a noobie question.
The challenge gets deployed but the commands are not executed.
The relevant code is this:
if command_part:
try:
if platform.system() == 'Windows':
command_part = command_part.replace('ls', 'dir').replace('cat', 'type')
output = subprocess.check_output(shlex.split(command_part), shell=(platform.system() == 'Windows'), stderr=subprocess.STDOUT, text=True).strip()
if "is not recognized as an internal or external command" in output:
message = f'"{text_part}" reported to admin.\n\n"{command_part}" command not allowed.'
else:
message = f'"{text_part}" reported to admin.\n\n{output}'
except subprocess.CalledProcessError as e:
output = e.output.strip()
if "is not recognized as an internal or external command" in output:
message = f'"{text_part}" reported to admin.\n\n"{command_part}" command not allowed.'
else:
message = f'"{text_part}" reported to admin.\n\n{output}'
else:
message = f'"{text_part}" reported to admin.'