package singularity import ( "bytes" "compress/gzip" "errors" "fmt" "html/template" "io/ioutil" "log" "net" "net/http" "net/http/httputil" "net/url" "regexp" "strconv" "strings" "sync" "time" "github.com/gorilla/mux" "github.com/gorilla/securecookie" "github.com/gorilla/websocket" ) // WebsocketClientStateStore keeps track of all targets hooked via websockets type WebsocketClientStateStore struct { sync.RWMutex Sessions map[string]*WebsocketClientState } // WebsocketClientState maintains information about a target hooked via websockets type WebsocketClientState struct { LastSeenTime time.Time Host string WSClient *WSClient } type hookedClientHandler struct { wscss *WebsocketClientStateStore wsHTTPProxyServerPort int } type templateHookedClientData struct { Sessions map[string]*WebsocketClientState WsHTTPProxyServerPort int Hostname string } func (hch *hookedClientHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { funcMap := template.FuncMap{ "FormatDate": func(value time.Time) string { return value.Format(time.RFC3339) }, } const tpl = `