Skip to content

Commit

Permalink
add a check for /challenge shellscript
Browse files Browse the repository at this point in the history
  • Loading branch information
zardus committed May 23, 2024
1 parent 7a873df commit 4aa7420
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions chio.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,17 @@ def check_shellscript(process):
assert os.path.basename(process.exe()) in [ 'sh', 'bash' ], f"Process interpreter must be 'sh' or 'bash'. Yours is: {os.path.basename(process.exe())}"
assert len(process.cmdline()) == 2 and process.cmdline()[1].endswith(".sh"), "The shell process must be executing a shell script that you wrote like this: `bash my_script.sh`"

def check_challenge_shellscript(process):
print_test("Checking to make sure the process is a non-interactive shell script running in /challenge.")

assert os.path.basename(process.exe()) in [ 'sh', 'bash' ], f"Process interpreter must be 'sh' or 'bash'. Yours is: {os.path.basename(process.exe())}"
assert len(process.cmdline()) == 2 and process.cmdline()[1].startswith("/challenge"), f"The shell process must be executing a shell script under /challenge! Yours is: {process.cmdline()[1]}"

PROCESS_TYPE_CHECKERS = {
'python': check_python,
'bash': check_bash,
'shellscript': check_shellscript,
'challenge_shellscript': lambda p: check_challenge_shellscript(p),
'ipython': check_ipython,
'binary': check_binary,
'netcat': lambda p: check_exe_basename(p, 'nc'),
Expand Down

0 comments on commit 4aa7420

Please sign in to comment.