From 6fbc23bb5c5ebfffbe44cb8c9a98dd560df11047 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 14 Sep 2024 00:01:59 +0100 Subject: [PATCH] [approved.pl]: Add approved.pl --- approved.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 approved.pl diff --git a/approved.pl b/approved.pl new file mode 100755 index 0000000..ddcd1d1 --- /dev/null +++ b/approved.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl +# Read the contents of flag.txt. You can only use commands in the approved list. +# Hint: You can supply whatever parameters you like to the command! + +my @approved_commands = ("ls", "pwd", "whoami"); + +while (1) { + printf("\n> "); + my $command = ; + + foreach my $approved_command (@approved_commands) { + if ($command =~ /^$approved_command/) { + print(`$command`); + last; + } + } +}