Last active
June 4, 2022 15:53
-
-
Save jheise/c1dcdc0a5adf8442d205000b302851f3 to your computer and use it in GitHub Desktop.
collecting useful intelligence from an http request in golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Record struct { | |
RemoteAddr string `json:"remoteaddr"` | |
Method string `json:"method"` | |
RequestURI string `json:"requesturi"` | |
Headers http.Header `json:"headers"` | |
UserAgent string `json:"UserAgent"` | |
PostForm url.Values `json:"postform"` | |
EventTime uint64 `json:"eventtime"` | |
HoneypotName string `json:"honeypotname"` | |
} | |
func GenerateRecord(r *http.Request) Record{ | |
data := Record{} | |
data.RemoteAddr = r.RemoteAddr | |
data.Method = r.Method | |
data.RequestURI = r.RequestURI | |
data.Headers = r.Header | |
data.UserAgent = r.UserAgent() | |
r.ParseForm() | |
data.PostForm = r.PostForm | |
data.EventTime = uint64(time.Now().Unix()) | |
return data | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment