Install • Get Started • Changelog • Contributing • License
go get github.com/edoardottt/defangoCLI:
go install github.com/edoardottt/defango/cmd/defango@latestpackage main
import (
"fmt"
"log"
"github.com/edoardottt/defango"
)
func main() {
fmt.Println(defango.IP("8.8.8.8:53")) // 8[.]8[.]8[.]8[:]53
u, err := defango.URL("http://malicious.example.link.com:666/m4lw4r3.exe")
if err != nil {
log.Fatal(err)
}
fmt.Println(u) // hxxp://malicious[.]example[.]link[.]com[:]666/m4lw4r3[.]exe
fmt.Println(defango.Email("mailto:edoardott@gmail.com")) // mailto[:]edoardott@gmail[.]com
// Defang only the IoCs in a text.
fmt.Println(defango.Text("C2 at evil.com, payload: https://1.2.3.4/x.exe"))
// C2 at evil[.]com, payload: hxxps://1[.]2[.]3[.]4/x[.]exe
fmt.Println(defango.Refang("hxxps://evil[.]com")) // https://evil.com
fmt.Println(defango.IsDefanged("hxxps://evil[.]com")) // true
}http, https, ftp and file become hxxp, hxxps, fxp and fxle; any other scheme gets [://].
Pass defango.HostOnly() to URL or Text to leave paths and queries as they are.
The CLI defangs its standard input, or refangs it with -r:
$ echo "C2 at evil.com, payload: https://1.2.3.4/x.exe" | defango
C2 at evil[.]com, payload: hxxps://1[.]2[.]3[.]4/x[.]exe
$ echo "hxxps://evil[.]com" | defango -r
https://evil.comRead the full package documentation here.
Detailed changes for each release are documented in the release notes.
Just open an issue / pull request.
Before opening a pull request, download golangci-lint and run
golangci-lint runIf there aren't errors, go ahead :)
This repository is under MIT License.
edoardottt.com to contact me.