
PyRat、python xmlrpcによるRAT
PyRat は、Python の XmlRPC に基づいて作成されたオープンソースの遠隔操作プロジェクトで、クライアントとサーバー(コントロール側とも呼びます。以下、総称してサーバーと呼びます)を含みます。
声明:本プロジェクトは技術交流のみを目的としています。商用利用や不正な目的には使用しないでください。万一、法的紛争が発生しても、作者とは一切関係ありません。
クライアント
> python .\pyratcli.py localhost 80
サーバー
> python pyratsvr.py 80
--------------------Python RAT-----------------------
--------------------anhkgg---------------------------
--------------------Copyright (c) 2018---------------
软件仅供技术交流,请勿用于商业及非法用途,如产生法律纠纷与本人无关!
--------------------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 >
クライアントがオンラインになるとサーバー側に通知され、最新にオンラインになったクライアントがデフォルトの操作対象に設定されます。
cmd >test-3333333 is online.
Auto set target test-3333333
helpまたはhで、サーバーがサポートするすべてのコマンドを一覧表示できます。
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
サーバーは sqlite を使用してクライアントの基本情報とタスク情報を保存し、コマンドを使ってクライアントを管理できます。
//枚举所有客户端
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 >
//枚举在线客户端
cmd >a
no alive client
//删除客户端数据库记录或者卸载客户端
cmd >k
target cid(or ALL):test-3333333
Do you want to uninstall client?(Y/N)
クライアントを制御する必要がある場合は、selectまたはsで操作対象のクライアントを選択します。
cmd >c //想进入cmdshell,提示无目标
Please first set target client by (s)elect command.
cmd >s //设置目标
client_id:test-3333333
Set target client: test-3333333
//查看当前目标
cmd >p
test-3333333
cmdshellまたはcで cmdshell に入ります。明示的にqを入力しない限り、cmdshell の操作ディレクトリで作業し続けます。
cmdshell は操作ディレクトリを記録します。たとえば cd c:\ を実行すると、次回の操作はそのディレクトリで行われ、パイプ接続のような cmdshell を実現します。
また、cmdshell からプロセスを起動すると、一部のプロセスがメッセージの返信をブロックする可能性があるため、お勧めしません。代わりにrunexecを使用してください。
cmd >c
RAT-CMD > dir
RAT-CMD > test-3333333 do cmdshell(195) dir True
驱动器 D 中的卷是 gitrepo
卷的序列号是 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 个文件 10,930 字节
2 个目录 647,836,565,504 可用字节
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
映像名称 PID 会话名 会话# 内存使用
========================= ======== ================ =========== ============
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
成功: 给进程 "Calculator.exe" 发送了终止信号,进程的 PID 为 21656。
RAT-CMD > taskkill /PID 21656
RAT-CMD > test-3333333 do cmdshell(202) taskkill /PID 21656 True
成功: 给进程发送了终止信号,进程的 PID 为 21656。
ファイルのアップロードとダウンロードをサポートします。ダウンロードでは、ネットワーク上のファイルとサーバー側のローカルファイルの両方をダウンロードできます。現時点では単一ファイルのアップロード・ダウンロードのみ対応しています。
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 //下载网络文件
dest path:inst.exe
cmd >test-3333333 do download(204) net https://dl.360safe.com/360/inst.exe inst.exe True
download success
cmd >r
run target:inst.exe
runexec inst.exe
cmd > t
Select type(name/pid):name
process name:notepad.exe
cmd >test-3333333 do terminate(212) name notepad.exe True
成功: 给进程 "notepad.exe" 发送了终止信号,进程的 PID 为 25416。
クライアントが Linux 上で動作し、サーバーが Windows プラットフォームの場合、中国語が文字化けする可能性があります。これは、2つのプラットフォームで使用されるエンコーディングが異なるためです。現在は未対応です。
