本來想簡單復現學學的 但Zeek坑點比較多 就簡單寫篇文章記錄一下
1、簡介
哥斯拉:webshell管理工具 現今比較好用的webshell管理工具 流量加密 生成馬天然免殺 插件多
Zeek:一個比較成熟的網絡分析/監控框架 也有編寫專門的zeek語言 感覺可以專門當個語言來學了 
        2、下載哥斯拉
鏈接:https://github.com/BeichenDream/Godzilla/releases
  
界面也是好看了不少 前幾個版本以前經常被吐槽難看

3、下載哥斯拉源碼
本來想反編譯的 有現成反編譯好的項目,也是最新版 鏈接:https://github.com/808Mak1r/GodzillaSource
直接下載就行,git clone git://github.com/808Mak1r/GodzillaSource 會稍微快點 
         
         
        
4、簡單的流程過一遍
翻下加密的方法,定位到Godzilla\shells\cryptions\phpXor\template目錄下的PhpXor里的E函數,這里將payload加密的方法,進行了先異或,后base64加密再url編碼再轉為byte,再發送

生成個木馬看看

大致邏輯和工具源碼里的一樣 進行解碼執行
 
傳到服務端連上去
 
連接時候有三個數據包,第一個包長度30893 第二個37 第三個 51
 
將post data url解碼 扔進shell解密打印

第一個解密 看麻了 一大堆操作先放着
 
第二個解密為 methodNametest
 
第三個解密為 methodName getBasicsInfo 看其他表哥的分析這空白的是=號 之前也遇到過
 
5、Zeek捕獲哥斯拉流量
安裝一些依賴和下載可以參考 https://zeek-docs-cn.readthedocs.io/zh_CN/chinese/install/install.html
因為比較大 所以得忍一下
下的時候最好git設置一下
git config --global http.postBuffer 1048576000 #設置緩存大小
#只有十分鍾(600秒)傳輸速率都低於 1KB/s 的話才會timeout
git config --global http.lowSpeedLimit 1000 git config --global http.lowSpeedTime 600
我一般都是有現成的直接用 沒有的再造 之前有S4KUR4寫好的zeek哥斯拉檢測代碼 但直接貼上去報錯了
error in ././try.zeek, line 8: no such field in record (c$http$client_body) error in ././try.zeek, line 8: no such field in record (c$http$server_body)
這zeek的錯誤貌似不太好查 看來還是得學學語法
event http_message_done(c: connection, is_orig: bool, stat: http_message_stat) { if ( c?$http && c$http?$status_code && c$http?$method ) { if ( c$http$status_code == 200 && c$http$method == "POST" ) { local key_str: string = c$http$uid + "$_$" + cat(c$id$orig_h) + "$_$" + cat(c$id$orig_p) + "$_$" + cat(c$http$status_code) + "$_$" + cat(c$id$resp_h)+ "$_$" + cat(c$id$resp_p) + "$_$" + c$http$uri; local observe_str: string = cat(c$http$ts) + "$_$" + c$http$client_body + "$_$" + c$http$server_body; SumStats::observe("godzilla_webshell_event", SumStats::Key($str=key_str), SumStats::Observation($str=observe_str)); } } }
 
簡單打印個helloworld

官方文檔http的位置 https://zeek-docs-cn.readthedocs.io/ 這里的函數是內置的一個函數 在解析 HTTP 消息結束時會調用

有點感覺到這個中英混合的文檔不太簡單
 
后面終於追到了那些調用的變量對應的地方
找到了一個在線調的 方便多了 對應的打印出來

但之前直接跑那兩個報錯 在文檔還沒找到 用於獲取請求包和返回包的data的
c$http$client_body
c$http$server_body
嘗試一下老版本的特性也不太行
 
github再搜一下 確認是自定義的

后面找了找了找資料自己定義了兩個.zeek
vim /usr/local/zeek/share/zeek/base/protocols/http/request.zeek
##! This script reassembles full HTTP bodies and raises an event with the ##! complete contents. module HTTP; export { redef record Info += { request_body: string &log &optional; }; } ## Users write a handler for this event to process the current HTTP body. event http_entity_data(c: connection , is_orig: bool , length: count , data: string ) &priority=5 { set_state(c,is_orig); if(is_orig) { c$http$request_body = data; } }
用之前也最好測試一下有沒有語法問題

vim /usr/local/zeek/share/zeek/base/protocols/http/response.zeek
module HTTP; export { redef record Info += { response_body: string &log &optional; }; ## Flag that indicates whether to hook reply bodies. const hook_reply_bodies = T &redef; } ## Users write a handler for this event to process the current HTTP body. event http_begin_entity(c: connection, is_orig: bool) { if ( (is_orig) || (! is_orig && ! hook_reply_bodies) ) return; c$http$response_body= ""; } event http_entity_data(c: connection, is_orig: bool, length: count, data: string) &priority=5 { c$http$response_body += data; }
vim /usr/local/zeek/share/zeek/base/protocols/http/__load__.zeek 添加
@load ./request
@load ./response 
        成功獲取到了請求包的data數據
event http_message_done(c: connection, is_orig: bool, stat: http_message_stat)#http消息完成便會調用 { if ( c?$http && c$http?$status_code && c$http?$method )#如果是http請求 { if ( c$http$status_code == 200 && c$http$method == "POST" )#如果http等於200且為post { #c$http$uid 用戶id 標識符 #c$id$orig_h 來源ip #c$id$orig_p 來源端口 #c$http$status_code 請求的狀態碼 #c$id$resp_h 服務端ip #c$id$resp_p 服務端端口 #c$http$uri 請求使用的url #c$http$ts 請求的時間戳 #c$http$request_body 請求包的body #c$http$response_body 返回包的body print c$http$request_body; print c$http$response_body; } } }

 

6、捕獲哥斯拉流量
現在該捕獲了 被zeek搞得有點心累 這里直接簡單無腦捕獲 他第二個返回包的內容 固定是這一串 11cd6a8758984163fL1tMGI4YTljMv79NDQm7r9PZzBiOA==6c37ac826a2a04bc最終代碼如下 太忙了(懶了)有些bug還有優化都沒調 有時間再弄
event http_message_done(c: connection, is_orig: bool, stat: http_message_stat)#http消息完成便會調用 { if ( c?$http && c$http?$status_code && c$http?$method )#如果是http請求 { if ( c$http$status_code == 200 && c$http$method == "POST" )#如果http等於200且為post { #c$http$uid 用戶id 標識符 #c$id$orig_h 來源ip #c$id$orig_p 來源端口 #c$http$status_code 請求的狀態碼 #c$id$resp_h 服務端ip #c$id$resp_p 服務端端口 #c$http$uri 請求使用的url #c$http$ts 請求的時間戳 #c$http$request_body 請求包的body #c$http$response_body 返回包的body if("11cd6a8758984163fL1tMGI4YTljMv79NDQm7r9PZzBiOA==6c37ac826a2a04bc" in c$http$response_body){ print "[+]find godzilla"; print "emergency url is "+c$http$uri; print fmt("attacker ip is: %s", c$id$orig_h); } } } }

參考
https://my.oschina.net/u/4587690/blog/4451917
https://mp.weixin.qq.com/s/qnrizGo_B12RzmEF6nePDA
https://zeek-docs-cn.readthedocs.io/zh_CN/chinese/install/install.html
