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

Function ExtractTaskID

internal/toolinjection/injection.go:46–67  ·  view source on GitHub ↗

ExtractTaskID extracts the encoded task ID from an injected call ID. Returns (taskID, true) on success or (0, false) if the ID is not injected or cannot be parsed. Handles both canonical and underscore-stripped markers.

(callID string)

Source from the content-addressed store, hash-verified

44// Returns (taskID, true) on success or (0, false) if the ID is not injected
45// or cannot be parsed. Handles both canonical and underscore-stripped markers.
46func ExtractTaskID(callID string) (uint32, bool) {
47 // Try canonical marker first.
48 idx := strings.Index(callID, InjectedIDMarker)
49 markerLen := len(InjectedIDMarker)
50 if idx < 0 {
51 // Try underscore-stripped variant.
52 idx = strings.Index(callID, InjectedIDMarkerNoUnderscore)
53 markerLen = len(InjectedIDMarkerNoUnderscore)
54 }
55 if idx < 0 {
56 return 0, false
57 }
58 hex8 := callID[idx+markerLen:]
59 if len(hex8) < 8 {
60 return 0, false
61 }
62 val, err := strconv.ParseUint(hex8[:8], 16, 32)
63 if err != nil {
64 return 0, false
65 }
66 return uint32(val), true
67}
68
69// encodeTaskID encodes a task ID as 8 hex characters.
70func encodeTaskID(taskID uint32) string {

Calls

no outgoing calls