Added some URI and Domain capabilities

This commit is contained in:
Loweel 2019-12-12 15:53:51 +01:00
parent 9c76a6581b
commit f93b12cb1a
2 changed files with 33 additions and 11 deletions

View file

@ -1,24 +1,25 @@
STATS: {
"BLOCKLEARN": 3,
"DOWNGRADE": 12,
"GENERATION": 2,
"LEARN-BAD": 12,
"MEH": 10,
"PASSLEARN": 2,
"YOUNG": 15
"PASSLEARN": 28
}
WORKING: {
"22170": "BAD",
"28765": "BAD",
"3672": "BAD",
"/": "GOOD",
"/bau/21770/qualcosa": "BAD",
"/bau/26179/qualcosa": "BAD",
"/bau/4415/qualcosa": "BAD",
"1.1": "MEH",
"7.58.0": "MEH",
"8089": "BAD",
"accept": "MEH",
"agent": "MEH",
"curl": "MEH",
"google": "GOOD",
"get": "MEH",
"host": "MEH",
"http": "MEH",
"localhost": "BAD",
"qualcosa": "BAD",
"user": "MEH"
"user": "MEH",
"www.google.com": "GOOD"
}
LEARNING: {}

View file

@ -11,6 +11,23 @@ import (
"strings"
)
//Zregexp is the regular expression used by ZARDOZ to process headers
var Zregexp string
func init() {
var expressions = []string{
`([ ]([A-Za-z0-9-_]+\.)*\w+)`, // domain name
`([ ]/[A-Za-z0-9-_/.]*[ ])`, // URI path (also partial)
`[[:alpha:]]{4,32}`, // alpha digit token
`([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})`, // IP address
`([0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12})`, // UUID
}
Zregexp = strings.Join(expressions, "|")
}
func passAndLearn(resp *http.Response) error {
ProxyFlow.response = resp
@ -69,7 +86,11 @@ func blockAndlearn(resp *http.Response) error {
func sanitizeHeaders(s string) string {
re := regexp.MustCompile(`[[:alnum:]]{6,32}|[[:alpha:]]{4,32}|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|([0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12})`)
re, rerr := regexp.Compile(Zregexp)
if rerr != nil {
log.Println("Error Compiling regular expression: ", Zregexp)
}
matched := re.FindAllString(s, -1)
uMatched := Unique(matched)