擼了一個(gè)XX: 叫做PyRat

PyRat

PyRat,基于python XmlRPC完成的遠(yuǎn)控開(kāi)源項(xiàng)目,包括客戶(hù)端和服務(wù)端。

申明:項(xiàng)目?jī)H供技術(shù)交流,請(qǐng)勿用于商業(yè)及非法用途,如產(chǎn)生任何法律糾紛均與本人無(wú)關(guān)!

項(xiàng)目地址:https://github.com/anhkgg/PyRat

  1. 由于XmlRPC基于http協(xié)議,所以PyRat能夠無(wú)視防火墻,更加優(yōu)雅得進(jìn)行通信和控制。
  2. python的跨平臺(tái)特性,使得PyRat客戶(hù)端可以支持Windows/Linux/Macos等不同平臺(tái),目前測(cè)試通過(guò)支持Windows/Ubuntu/Macos平臺(tái)。
  3. 服務(wù)端命令行控制和管理,逼格滿(mǎn)滿(mǎn)。
  4. 目前客戶(hù)端支持基本信息、上傳、下載、cmdshell、運(yùn)行軟件、結(jié)束進(jìn)程、更新、卸載等功能

依賴(lài)

  1. python2.7
  2. colorama (服務(wù)端)

TODO

  1. 增加更多功能,比如文件操作,批量斷點(diǎn)文件傳輸,遠(yuǎn)程桌面,截屏,賬戶(hù)操作等等
  2. 服務(wù)端可視化
  3. 交互式shell
  4. 歡迎PR

基本使用

客戶(hù)端

> python .\pyratcli.py localhost 80

服務(wù)端

> python pyratsvr.py 80
--------------------Python RAT-----------------------
--------------------anhkgg---------------------------
--------------------Copyright (c) 2018---------------

軟件僅供技術(shù)交流,請(qǐng)勿用于商業(yè)及非法用途,如產(chǎn)生法律糾紛與本人無(wú)關(guān)!

--------------------Task command---------------------
--|(l)ist (a)live (k)ill (s)elect (p)rint (c)mdshell (n)ew (d)ownload (r)unexec (u)pload (t)erminate (q)uit (h)elp|--

cmd >

客戶(hù)端上線(xiàn)后,服務(wù)端會(huì)提示,并且將最新上線(xiàn)客戶(hù)端設(shè)置未默認(rèn)操作目標(biāo)。

cmd >test-3333333 is online.
Auto set target test-3333333

help或者h可列出服務(wù)端支持的所有命令。

cmd >help
(l)ist:     list all clients
(a)live:    list alive clients
(k)ill:     delete client
(s)elect:   select target client
(p)rint:    show current client
(c)mdshell: create a cmdshell, type q to exit cmdshell
(n)ew:      update client version
(d)ownload: let client download a file
(r)unexec:  let client run a exe
(u)pload:   upload a file to client
(t)erminate:terminate process
(q)uit:     quit server

客戶(hù)端管理

服務(wù)端使用sqlite保存客戶(hù)端基礎(chǔ)信息以及任務(wù)信息,通過(guò)命令可以對(duì)客戶(hù)端進(jìn)行管理。

//枚舉所有客戶(hù)端
cmd >l
test-3333333 offline 2018-03-20 22:46:59!
id     | client_id                  | version  | localip              | remoteip             | username             | osversion  | firsttime            | lasttime             | status
10     | test-3333333     | 0.1.0    | 192.168.149.1        | 114.245.47.12        | test            | Windows10.0.16299 | 2018-03-17 12:39:56  | 2018-03-20 22:46:59  | 0
cmd >
//枚舉在線(xiàn)客戶(hù)端
cmd >a
no alive client
//刪除客戶(hù)端數(shù)據(jù)庫(kù)記錄或者卸載客戶(hù)端
cmd >k
target cid(or ALL):test-3333333
Do you want to uninstall client?(Y/N)

如果需要控制客戶(hù)端時(shí),需要通過(guò)select或者s選擇要操作的客戶(hù)目標(biāo)。

cmd >c //想進(jìn)入cmdshell,提示無(wú)目標(biāo)
Please first set target client by (s)elect command.
cmd >s //設(shè)置目標(biāo)
client_id:test-3333333
Set target client: test-3333333
//查看當(dāng)前目標(biāo)
cmd >p
test-3333333

cmdshell

通過(guò)cmdshellc進(jìn)入cmdshell,除非主動(dòng)輸入q,否則一直在cmdshell操作目錄。

cmdshell記錄操作目錄,比如cd c:\,下次操作會(huì)在該目錄下進(jìn)行,實(shí)現(xiàn)了類(lèi)似管道連接的cmdshell。

另外若通過(guò)cmdshell啟動(dòng)進(jìn)程,某些進(jìn)程可能會(huì)阻塞消息返回,所以不推薦使用,而是使用runexec來(lái)代替。

cmd >c
RAT-CMD > dir
RAT-CMD > test-3333333 do cmdshell(195) dir True
驅(qū)動(dòng)器 D 中的卷是 gitrepo
卷的序列號(hào)是 EB2F-5AC0

D:\PyRat\client 的目錄

2018/02/24  09:40    <DIR>          .
2018/02/24  09:40    <DIR>          ..
2018/03/20  22:46             4,919 pyratcli.py
2018/03/20  23:01                28 cmd.log
2018/03/17  12:39             1,322 pyratfc.py
2018/03/17  11:19             2,500 osver.py
2018/03/17  12:39             2,161 pyratfc.pyc
               5 個(gè)文件         10,930 字節(jié)
               2 個(gè)目錄 647,836,565,504 可用字節(jié)

RAT-CMD > ver
RAT-CMD > test-3333333 do cmdshell(196) ver True

Microsoft Windows [版本 10.0.16299.309]

RAT-CMD > tasklist
RAT-CMD > test-3333333 do cmdshell(197) tasklist True

映像名稱(chēng)                       PID 會(huì)話(huà)名              會(huì)話(huà)#       內(nèi)存使用
========================= ======== ================ =========== ============
System Idle Process              0 Services                   0          8 K
System                           4 Services                   0      3,564 K
smss.exe                       360 Services                   0        412 K
csrss.exe                      492 Services                   0      1,700 K
Calculator.exe               21656 RDP-Tcp#85                 1     56,772 K
RAT-CMD > tasklist |findstr Cal
RAT-CMD > test-3333333 do cmdshell(200) tasklist |findstr Cal True
Calculator.exe               21656 RDP-Tcp#85                 1     51,856 K
RAT-CMD > taskkill /IM Calculator.exe
RAT-CMD > test-3333333 do cmdshell(201) taskkill /IM Calculator.exe True
成功: 給進(jìn)程 "Calculator.exe" 發(fā)送了終止信號(hào),進(jìn)程的 PID 為 21656。
RAT-CMD > taskkill /PID 21656
RAT-CMD > test-3333333 do cmdshell(202) taskkill /PID 21656 True
成功: 給進(jìn)程發(fā)送了終止信號(hào),進(jìn)程的 PID 為 21656。

文件操作

支持文件上傳和下載,其中下載支持下載網(wǎng)絡(luò)文件和服務(wù)端本地文件,暫時(shí)只支持單文件上傳和下載。

cmd >d
url(type N to download local file):N //選擇下載本地文件
local file:db.db
dest path:db.db
cmd >test-3333333 do download(203) local db.db db.db True
download success

cmd >d
url(type N to download local file):https://dl.360safe.com/360/inst.exe //下載網(wǎng)絡(luò)文件
dest path:inst.exe
cmd >test-3333333 do download(204) net https://dl.360safe.com/360/inst.exe inst.exe True
download success

運(yùn)行軟件

cmd >r
run target:inst.exe
runexec inst.exe

結(jié)束進(jìn)程

cmd > t
Select type(name/pid):name
process name:notepad.exe
cmd >test-3333333 do terminate(212) name notepad.exe True
成功: 給進(jìn)程 "notepad.exe" 發(fā)送了終止信號(hào),進(jìn)程的 PID 為 25416。
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容