20 lines
540 B
Go
20 lines
540 B
Go
package requestmodifiers
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
|
|
"github.com/everywall/ladder/proxychain"
|
|
)
|
|
|
|
func ModifyDomainWithRegex(matchRegex string, replacement string) proxychain.RequestModification {
|
|
match, err := regexp.Compile(matchRegex)
|
|
return func(px *proxychain.ProxyChain) error {
|
|
if err != nil {
|
|
return fmt.Errorf("RequestModification :: ModifyDomainWithRegex error => invalid match regex: %s - %s", matchRegex, err.Error())
|
|
}
|
|
px.Request.URL.Host = match.ReplaceAllString(px.Request.URL.Host, replacement)
|
|
return nil
|
|
}
|
|
}
|