Skip to content

Commit

Permalink
fix: ndpi build error by bumping go-dpi dependency, invoke maltego tr…
Browse files Browse the repository at this point in the history
…ansform init only when the transform tool is used, extended findExecutable util
  • Loading branch information
dreadl0ck committed Jan 20, 2022
1 parent dd97177 commit 18674f4
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 27 deletions.
6 changes: 3 additions & 3 deletions cmd/transform/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var (
)

// update the default linux paths for specific OSes
func init() {
func initTransformTool() {
if runtime.GOOS == platformLinux {
out, err := exec.Command("uname", "-a").CombinedOutput()
if err != nil {
Expand All @@ -55,7 +55,7 @@ func init() {
if strings.Contains(string(out), "kali") {

// prefer codium over xdg-open
if path := findExecutable("codium"); path != "" {
if path := findExecutable("codium", true); path != "" {
defaultOpenCommandLinux = path
} else {
// default to use xdg-open
Expand All @@ -69,7 +69,7 @@ func init() {

if runtime.GOOS == platformDarwin {
// use visual studio code to open files if its installed
if path := findExecutable("code"); path != "" {
if path := findExecutable("code", true); path != "" {
defaultOpenCommandDarwin = path
}
}
Expand Down
1 change: 1 addition & 0 deletions cmd/transform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func Run() {
}

log.Println("os.Args:", os.Args)
initTransformTool()

for _, f := range []func(){
startCaptureProcess,
Expand Down
10 changes: 6 additions & 4 deletions cmd/transform/openConnectionInWireshark.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func makeOutFilePath(in, bpf string, lt maltego.LocalTransform, flows bool, bpfS
return name, false
}

func findExecutable(name string) string {
func findExecutable(name string, ignoreErr bool) string {

var paths []string

Expand All @@ -101,7 +101,9 @@ func findExecutable(name string) string {
path, err = exec.LookPath(p)
if err != nil {
paths = append(paths, p)
maltego.Die("executable not found", "paths tried:\n"+strings.Join(paths, "\n")+"\n$PATH = "+os.Getenv("PATH"))
if !ignoreErr {
maltego.Die(name + " executable not found", "paths tried:\n"+strings.Join(paths, "\n")+"\n$PATH = "+os.Getenv("PATH"))
}
}
}
}
Expand All @@ -123,7 +125,7 @@ func openConnectionInWireshark() {
if !exists {
log.Println(tcpdump, args)

out, err := exec.Command(findExecutable(tcpdump), args...).CombinedOutput()
out, err := exec.Command(findExecutable(tcpdump, false), args...).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand All @@ -133,7 +135,7 @@ func openConnectionInWireshark() {

log.Println(wireshark, outFile)

out, err := exec.Command(findExecutable(wireshark), outFile).CombinedOutput()
out, err := exec.Command(findExecutable(wireshark, false), outFile).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/transform/openDeviceTrafficInWireshark.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func openDeviceTrafficInWireshark() {
if !exists {
log.Println(tcpdump, args)

out, err := exec.Command(findExecutable(tcpdump), args...).CombinedOutput()
out, err := exec.Command(findExecutable(tcpdump, false), args...).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand All @@ -47,7 +47,7 @@ func openDeviceTrafficInWireshark() {

log.Println(wireshark, outFile)

out, err := exec.Command(findExecutable(wireshark), outFile).CombinedOutput()
out, err := exec.Command(findExecutable(wireshark, false), outFile).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/transform/openFileInDisassembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func makeOpenDisasmCmd(loc string) (openCmd string, args []string) {
// use the platform defaults
switch runtime.GOOS {
case platformDarwin:
openCmd = findExecutable(defaultDisasmCommandMacOS)
openCmd = findExecutable(defaultDisasmCommandMacOS, false)
args = []string{"-e", loc}
case platformWindows:
openCmd = "C:\\Program Files\\IDA Freeware 7.0\\ida64.exe"
args = []string{loc}
case platformLinux:
openCmd = findExecutable("ida64")
openCmd = findExecutable("ida64", false)
args = []string{loc}
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/transform/openFlowInWireshark.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func openFlowInWireshark() {
if !exists {
log.Println(tcpdump, args)

out, err := exec.Command(findExecutable(tcpdump), args...).CombinedOutput()
out, err := exec.Command(findExecutable(tcpdump, false), args...).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand All @@ -47,7 +47,7 @@ func openFlowInWireshark() {

log.Println(wireshark, outFile)

out, err := exec.Command(findExecutable(wireshark), outFile).CombinedOutput()
out, err := exec.Command(findExecutable(wireshark, false), outFile).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/transform/openHostTrafficInWireshark.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func openHostTrafficInWireshark() {
if !exists {
log.Println(tcpdump, args)

out, err := exec.Command(findExecutable(tcpdump), args...).CombinedOutput()
out, err := exec.Command(findExecutable(tcpdump, false), args...).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand All @@ -48,7 +48,7 @@ func openHostTrafficInWireshark() {

log.Println(wireshark, outFile)

out, err := exec.Command(findExecutable(wireshark), outFile).CombinedOutput()
out, err := exec.Command(findExecutable(wireshark, false), outFile).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/transform/openServiceInWireshark.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func openServiceInWireshark() {
if !exists {
log.Println(tcpdump, args)

out, err := exec.Command(findExecutable(tcpdump), args...).CombinedOutput()
out, err := exec.Command(findExecutable(tcpdump, false), args...).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand All @@ -47,7 +47,7 @@ func openServiceInWireshark() {

log.Println(wireshark, outFile)

out, err := exec.Command(findExecutable(wireshark), outFile).CombinedOutput()
out, err := exec.Command(findExecutable(wireshark, false), outFile).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/transform/openSoftwareTrafficInWireshark.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func openSoftwareTrafficInWireshark() {
if !exists {
log.Println(tcpdump, args)

out, err := exec.Command(findExecutable(tcpdump), args...).CombinedOutput()
out, err := exec.Command(findExecutable(tcpdump, false), args...).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand All @@ -48,7 +48,7 @@ func openSoftwareTrafficInWireshark() {

log.Println(wireshark, outFile)

out, err := exec.Command(findExecutable(wireshark), outFile).CombinedOutput()
out, err := exec.Command(findExecutable(wireshark, false), outFile).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/transform/openTrafficForPortInWireshark.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func openTrafficForPortInWireshark() {
if !exists {
log.Println(tcpdump, args)

out, err := exec.Command(findExecutable(tcpdump), args...).CombinedOutput()
out, err := exec.Command(findExecutable(tcpdump, false), args...).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand All @@ -47,7 +47,7 @@ func openTrafficForPortInWireshark() {

log.Println(wireshark, outFile)

out, err := exec.Command(findExecutable(wireshark), outFile).CombinedOutput()
out, err := exec.Command(findExecutable(wireshark, false), outFile).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/transform/openTrafficInWireshark.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func openTrafficInWireshark() {
if !exists {
log.Println(tcpdump, args)

out, err := exec.Command(findExecutable(tcpdump), args...).CombinedOutput()
out, err := exec.Command(findExecutable(tcpdump, false), args...).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand All @@ -47,7 +47,7 @@ func openTrafficInWireshark() {

log.Println(wireshark, outFile)

out, err := exec.Command(findExecutable(wireshark), outFile).CombinedOutput()
out, err := exec.Command(findExecutable(wireshark, false), outFile).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/transform/openVulnerabilityTrafficInWireshark.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func openVulnerabilityTrafficInWireshark() {
if !exists {
log.Println(tcpdump, args)

out, err := exec.Command(findExecutable(tcpdump), args...).CombinedOutput()
out, err := exec.Command(findExecutable(tcpdump, false), args...).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand All @@ -47,7 +47,7 @@ func openVulnerabilityTrafficInWireshark() {

log.Println(wireshark, outFile)

out, err := exec.Command(findExecutable(wireshark), outFile).CombinedOutput()
out, err := exec.Command(findExecutable(wireshark, false), outFile).CombinedOutput()
if err != nil {
maltego.Die(err.Error(), "open file failed:\n"+string(out))
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/denisbrodbeck/machineid v1.0.1
github.com/dlclark/regexp2 v1.4.0
github.com/dreadl0ck/cryptoutils v0.0.0-20200425144202-4608665a89a4
github.com/dreadl0ck/go-dpi v0.0.0-20200912122706-f830a777c45f
github.com/dreadl0ck/go-dpi v1.0.1
github.com/dreadl0ck/gopacket v1.1.16-0.20201228223815-140074f06498
github.com/dreadl0ck/ja3 v1.0.1-dreadl0ck-gopacket.0.20200917082239-a29743a537b2
github.com/dreadl0ck/maltego v0.0.2
Expand Down Expand Up @@ -66,7 +66,7 @@ require (
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83
golang.org/x/mod v0.4.1 // indirect
golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d
golang.org/x/sys v0.0.0-20210915083310-ed5796bab164 // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
golang.org/x/tools v0.1.0 // indirect
gonum.org/v1/gonum v0.9.1
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ github.com/dreadl0ck/cryptoutils v0.0.0-20200425144202-4608665a89a4 h1:CQVDSWmSo
github.com/dreadl0ck/cryptoutils v0.0.0-20200425144202-4608665a89a4/go.mod h1:Hv2i5yZ/n12s4y3LXmn8GfP7FatOIQkJeii8jMIt78s=
github.com/dreadl0ck/go-dpi v0.0.0-20200912122706-f830a777c45f h1:Lthma7ytUyGiaCHoOqxpPC57HLDAQ6xfwjWGTSUxlys=
github.com/dreadl0ck/go-dpi v0.0.0-20200912122706-f830a777c45f/go.mod h1:ShxssMM64chljQ3QxF9QQY8FSUoQMvMVA5NSmB1Xx10=
github.com/dreadl0ck/go-dpi v1.0.1 h1:INQbp9vxl9Hlsf7Z87TDpnZmoY62BdgzpfS91IyBLb8=
github.com/dreadl0ck/go-dpi v1.0.1/go.mod h1:ShxssMM64chljQ3QxF9QQY8FSUoQMvMVA5NSmB1Xx10=
github.com/dreadl0ck/gopacket v1.1.16-0.20200114112008-4960f4b77557/go.mod h1:d7HEeaw/pAxzNTUprrDDpb7RxPsWA9i3NFp1ZfBNl50=
github.com/dreadl0ck/gopacket v1.1.16-0.20200322190608-ceb6f481d0e7/go.mod h1:G6cJViboLOuUCto9bY0+lSiMRkFcJPVITDqPM5/ShkI=
github.com/dreadl0ck/gopacket v1.1.16-0.20200831153559-a0d2e73e902d/go.mod h1:AO4gQoj71eHM7uHvvmIi0V4/vM8LJ1nuGPq9PVNHCrQ=
Expand Down Expand Up @@ -719,6 +721,8 @@ golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210915083310-ed5796bab164 h1:7ZDGnxgHAMw7thfC5bEos0RDAccZKxioiWBhfIe+tvw=
golang.org/x/sys v0.0.0-20210915083310-ed5796bab164/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
Expand Down

0 comments on commit 18674f4

Please sign in to comment.