Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: "1.24.13"
cache: true
cache: false

- name: Go mod tidy
run: go mod tidy
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: "1.24.13"
cache: true
cache: false

- name: Go mod tidy
run: go mod tidy
Expand All @@ -75,7 +75,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: "1.24.13"
cache: true
cache: false

- name: Go mod tidy
run: go mod tidy
Expand All @@ -95,7 +95,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: "1.24.13"
cache: true
cache: false

- name: Go mod tidy
run: go mod tidy
Expand Down
5 changes: 5 additions & 0 deletions client/command/testsupport/recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ func (r *RecorderRPC) RefreshModule(ctx context.Context, in *implantpb.Request,
return r.taskResponse(ctx, "RefreshModule", in)
}

func (r *RecorderRPC) UnloadModule(ctx context.Context, in *implantpb.Request, opts ...grpc.CallOption) (*clientpb.Task, error) {
return r.taskResponse(ctx, "UnloadModule", in)
}

func (r *RecorderRPC) ExecuteModule(ctx context.Context, in *implantpb.ExecuteModuleRequest, opts ...grpc.CallOption) (*clientpb.Task, error) {
return r.taskResponse(ctx, "ExecuteModule", in)
}
Expand Down Expand Up @@ -763,6 +767,7 @@ var methodTaskTypes = map[string]string{
"ListModule": consts.ModuleListModule,
"LoadModule": consts.ModuleLoadModule,
"RefreshModule": consts.ModuleRefreshModule,
"UnloadModule": consts.ModuleUnloadModule,
"ListAddon": consts.ModuleListAddon,
"LoadAddon": consts.ModuleLoadAddon,
"ExecuteAddon": consts.ModuleExecuteAddon,
Expand Down
2 changes: 1 addition & 1 deletion external/IoM-go
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ require (
github.com/alibabacloud-go/tea v1.4.0 // indirect
github.com/alibabacloud-go/tea-utils/v2 v2.0.7 // indirect
github.com/aliyun/credentials-go v1.4.7 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aws/aws-sdk-go-v2 v1.41.1 // indirect
github.com/aws/aws-sdk-go-v2/config v1.32.8 // indirect
Expand Down Expand Up @@ -241,7 +240,7 @@ replace (
replace (
github.com/chainreactors/IoM-go => ./external/IoM-go
github.com/chainreactors/proxyclient => github.com/chainreactors/proxyclient v1.0.3
github.com/chainreactors/rem => ../rem
github.com/chainreactors/rem => ./external/rem
github.com/chainreactors/tui => ./external/tui
github.com/reeflective/console => ./external/console
github.com/reeflective/readline => ./external/readline
Expand Down
6 changes: 2 additions & 4 deletions server/internal/configs/config_runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package configs
import (
"bytes"
"encoding/binary"
"errors"
"os"
"path/filepath"
"testing"

"github.com/chainreactors/IoM-go/consts"
types "github.com/chainreactors/IoM-go/types"
"github.com/chainreactors/malice-network/helper/implanttypes"
chunkparser "github.com/chainreactors/malice-network/server/internal/parser"
maleficparser "github.com/chainreactors/malice-network/server/internal/parser/malefic"
Expand Down Expand Up @@ -233,8 +231,8 @@ func TestPacketLengthConfigDrivesChunkingAndParserLimits(t *testing.T) {
}

_, _, err = parser.ReadHeader(newTestHeaderConn(9, allowed+1))
if !errors.Is(err, types.ErrPacketTooLarge) {
t.Fatalf("expected ErrPacketTooLarge, got %v", err)
if err != nil {
t.Fatalf("expected oversized packet to be accepted with warning, got %v", err)
}
}

Expand Down
21 changes: 16 additions & 5 deletions server/internal/core/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ func (c *Connection) runtimeErrorHandler(scope string) GoErrorHandler {
)
}

func (c *Connection) closeWithError(err error) error {
Connections.remove(c.SessionID, err)
return err
}

func (c *Connection) runReceiveLoop() error {
for c.IsAlive() {
select {
Expand Down Expand Up @@ -285,25 +290,31 @@ func (c *Connection) Handler(ctx context.Context, conn *cryptostream.Conn) error
var err error
_, length, err := c.Parser.ReadHeader(conn)
if err != nil {
return fmt.Errorf("error reading header:%s %w", conn.RemoteAddr(), err)
return c.closeWithError(fmt.Errorf("error reading header:%s %w", conn.RemoteAddr(), err))
}
GoGuarded("connection-send-call:"+c.SessionID, func() error {
return c.Send(ctx, conn)
}, c.runtimeErrorHandler("send call"))

return c.buildResponse(conn, length)
if err := c.buildResponse(conn, length); err != nil {
return c.closeWithError(err)
}
return nil
}

func (c *Connection) HandlerSimplex(ctx context.Context, conn *cryptostream.Conn) error {
var err error
_, length, err := c.Parser.ReadHeader(conn)
if err != nil {
return fmt.Errorf("error reading header:%s %w", conn.RemoteAddr(), err)
return c.closeWithError(fmt.Errorf("error reading header:%s %w", conn.RemoteAddr(), err))
}
if err := c.Send(ctx, conn); err != nil {
return err
return c.closeWithError(err)
}
if err := c.buildResponse(conn, length); err != nil {
return c.closeWithError(err)
}
return c.buildResponse(conn, length)
return nil
}

type connections struct {
Expand Down
Loading