MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / PlanUpload

Function PlanUpload

internal/sessions/transfer.go:116–143  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Transfer planning --------------------------------------------------------------------------- PlanUpload decides the transfer strategy and chunk count for an upload.

(data []byte, userAgent string)

Source from the content-addressed store, hash-verified

114
115// PlanUpload decides the transfer strategy and chunk count for an upload.
116func PlanUpload(data []byte, userAgent string) TransferPlan {
117 binary := IsBinary(data)
118 size := len(data)
119 profile := MatchAgentProfile(userAgent)
120
121 plan := TransferPlan{
122 TotalSize: size,
123 IsBinary: binary,
124 AgentName: profile.Name,
125 }
126
127 if !binary && size <= smallFileThreshold {
128 plan.Strategy = StrategyDirectTool
129 plan.NumChunks = 1
130 return plan
131 }
132
133 // Shell + base64 path.
134 plan.Strategy = StrategyShellBase64
135 plan.ChunkSize = profile.ChunkSizeBytes
136
137 if size <= profile.ChunkSizeBytes {
138 plan.NumChunks = 1
139 } else {
140 plan.NumChunks = int(math.Ceil(float64(size) / float64(profile.ChunkSizeBytes)))
141 }
142 return plan
143}
144
145// PlanDownload decides the transfer strategy and chunk count for a download.
146// fileSize should be obtained from a probe command; if 0 or negative the plan

Calls 2

IsBinaryFunction · 0.85
MatchAgentProfileFunction · 0.85