Coder Social home page Coder Social logo

Comments (4)

dreadl0ck avatar dreadl0ck commented on May 28, 2024

Sorry, the generated install script was out of date.

I did not notice, because I use my zeus build system to compile.

You can use this until I've updated the generated one in the repo:

#!/bin/bash
# generated by ZEUS v0.8.4
# Timestamp: [Wed Sep 25 17:38:19 2019]


VERSION="0.4.0"
go build -ldflags "-X github.com/dreadl0ck/netcap.Version=v${VERSION}" -o $(go env GOPATH)/bin/net.capture -i github.com/dreadl0ck/netcap/cmd/capture
go build -ldflags "-X github.com/dreadl0ck/netcap.Version=v${VERSION}" -o $(go env GOPATH)/bin/net.label -i github.com/dreadl0ck/netcap/cmd/label
go build -ldflags "-X github.com/dreadl0ck/netcap.Version=v${VERSION}" -o $(go env GOPATH)/bin/net.collect -i github.com/dreadl0ck/netcap/cmd/collect
go build -ldflags "-X github.com/dreadl0ck/netcap.Version=v${VERSION}" -o $(go env GOPATH)/bin/net.agent -i github.com/dreadl0ck/netcap/cmd/agent
go build -ldflags "-X github.com/dreadl0ck/netcap.Version=v${VERSION}" -o $(go env GOPATH)/bin/net.proxy -i github.com/dreadl0ck/netcap/cmd/proxy
go build -ldflags "-X github.com/dreadl0ck/netcap.Version=v${VERSION}" -o $(go env GOPATH)/bin/net.export -i github.com/dreadl0ck/netcap/cmd/export
go build -ldflags "-X github.com/dreadl0ck/netcap.Version=v${VERSION}" -o $(go env GOPATH)/bin/net.dump -i github.com/dreadl0ck/netcap/cmd/dump
go build -ldflags "-X github.com/dreadl0ck/netcap.Version=v${VERSION}" -o $(go env GOPATH)/bin/net.util -i github.com/dreadl0ck/netcap/cmd/util
echo done

from netcap.

aaronfderybel avatar aaronfderybel commented on May 28, 2024

Currently working using VM so I can make checkpoints for installing.
I'm not a linux or go expert, but i've provided information in every step.
I hope it will be clear to you.

I've installed using iso file from: http://releases.ubuntu.com/18.04/
Commands i've used in order:

sudo go apt-get install golang-go
sudo apt install-git
# -d should ensure that nothing is built/installed yet
go get -d github.com/dreadl0ck/netcap/...

#after adapting install-netcap.sh is mentioned above
chmod u+x install-netcdap.sh
./install-netcap.sh

#noticed libpcap was not installed
sudo apt-get install libpcap0.8-dev
apt-get update
apt install golang
./install-netcap.sh

#received an error with the proxy part of the script.
#just removed the line of proxy
./install-netcap.sh

The proxy error I get is:

# github.com/dreadl0ck/netcap/cmd/proxy
../../cmd/proxy/reverseProxy.go:69:10: proxy.rp.ErrorHandler undefined (type *httputil.ReverseProxy has no field or method ErrorHandler)

So I removed that line in the 'install-netcap.sh' script and tried again with success.

The problem I have now is when I run from project root 'home/go/':
go test -v -bench=. ./...

I get a bunch of 'package not found errors'

....
cannot find package "github.com/bradleyfalzon/tlsx" in any of:
	/usr/lib/go-1.10/src/github.com/bradleyfalzon/tlsx (from $GOROOT)
	/home/aaron/go/src/github.com/bradleyfalzon/tlsx (from $GOPATH)
.....

Also when running a netcap command: net.capture, net.dump, ...
net.capture: command not found.

result of command go env:

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/aaron/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/aaron/go"
GORACE=""
GOROOT="/usr/lib/go-1.10"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build387425093=/tmp/go-build -gno-record-gcc-switches"

Did I do something wrong during the install ?
Does it have to do something with my $GOROOT or $GOPATH variables ?

Again i'm not a linux or go guy, but the netcap tool shows a lot of promise for my current research project. So any info you need I can provide with the VM checkpoints.

Any help is appreciated

from netcap.

dreadl0ck avatar dreadl0ck commented on May 28, 2024
  1. Looks like you've installed go-1.10, which is an old version and is lacking some some features Netcap is using. Please install the latest go 1.13, this is the reason for the package not found errors.

  2. Your GOPATH looks okay to me, but why are you executing the tests from the go path?

The problem I have now is when I run from project root 'home/go/':
go test -v -bench=. ./...

Your project root is not your Gopath, instead the repository is located at 'home/go/src/github.com/dreadl0ck/netcap'. If you run the tests from there with the correct go version installed it should work.

  1. If you're having trouble to compile you can always use the precompiled releases for a Quickstart: https://github.com/dreadl0ck/netcap/releases

Let me know if that helps

from netcap.

aaronfderybel avatar aaronfderybel commented on May 28, 2024

Hello,

I currently made a workable version of netcap (by removing the proxy line in the install-netcap.sh), I also added for net.capture, net.dump, ... so I can run it from any directory.
It might not be perfect but for my purposes it's fine, so i'm closing the issue for now.

Just for your information and others interested I provide you with the results of testing out different ways to build netcap.

Build 1. The way mentioned in previous post. I can test the commands manually by going to the ~/go/bin directory and running the examples from quickstart:

./net.capture -iface eth0
./net.dump -r TCP.ncap.gz

I added aliases in the ~/.bashrc file using this guide: https://www.hostingadvice.com/how-to/set-command-aliases-linuxubuntudebian/
This allows to call the net.capture from any directory and is my current build.

When running the test command from home/go/src/github.com/dreadl0ck/netcap i get the following output:

go test -v -bench=. ./...
# github.com/dreadl0ck/netcap/cmd/proxy
cmd/proxy/reverseProxy.go:69:10: proxy.rp.ErrorHandler undefined (type *httputil.ReverseProxy has no field or method ErrorHandler)
FAIL	github.com/dreadl0ck/netcap/collector [build failed]
FAIL	github.com/dreadl0ck/netcap/types [build failed]
FAIL	github.com/dreadl0ck/netcap/utils [build failed]

This is because i didn't install proxy I believe

Build 2. I downloaded source code and pre-compiled binaries from: https://github.com/dreadl0ck/netcap/releases

When i run the tests I get a bunch of invalid psuedo-version errors.
this link describes how to work around this:
https://tip.golang.org/doc/go1.13#version-validation

After using the replace command in go.mod to work around these errors I ran the tests:

go test -v -bench=. ./...
?   	github.com/dreadl0ck/netcap	[no test files]
?   	github.com/dreadl0ck/netcap/cmd/agent	[no test files]
?   	github.com/dreadl0ck/netcap/cmd/capture	[no test files]
?   	github.com/dreadl0ck/netcap/cmd/collect	[no test files]
?   	github.com/dreadl0ck/netcap/cmd/dump	[no test files]
?   	github.com/dreadl0ck/netcap/cmd/export	[no test files]
?   	github.com/dreadl0ck/netcap/cmd/label	[no test files]
?   	github.com/dreadl0ck/netcap/cmd/proxy	[no test files]
?   	github.com/dreadl0ck/netcap/cmd/util	[no test files]
--- FAIL: BenchmarkReadPcapNG
    pcap_test.go:16: open ../pcaps/Monday-WorkingHours.pcapng: no such file or directory
--- FAIL: BenchmarkReadPcapNGZeroCopy
    pcap_test.go:33: open ../pcaps/Monday-WorkingHours.pcapng: no such file or directory
--- FAIL: BenchmarkReadPcap
    pcap_test.go:66: open ../pcaps/maccdc2012_00000.pcap: no such file or directory
FAIL
exit status 1
FAIL	github.com/dreadl0ck/netcap/collector	0.022s
?   	github.com/dreadl0ck/netcap/encoder	[no test files]
?   	github.com/dreadl0ck/netcap/io	[no test files]
?   	github.com/dreadl0ck/netcap/label	[no test files]
?   	github.com/dreadl0ck/netcap/metrics	[no test files]
=== RUN   TestMarshal
--- PASS: TestMarshal (0.00s)
goos: linux
goarch: amd64
pkg: github.com/dreadl0ck/netcap/types
BenchmarkMarshal   	 7507203	       149 ns/op	      64 B/op	       1 allocs/op
BenchmarkUnmarshal 	 5260093	       220 ns/op	      40 B/op	       2 allocs/op
PASS
ok  	github.com/dreadl0ck/netcap/types	2.710s
=== RUN   TestTimeToString
--- PASS: TestTimeToString (0.00s)
=== RUN   TestStringToTime
--- PASS: TestStringToTime (0.00s)
goos: linux
goarch: amd64
pkg: github.com/dreadl0ck/netcap/utils
BenchmarkTimeToStringOld        	 3414663	       356 ns/op	      64 B/op	       4 allocs/op
BenchmarkTimeToString           	 6117429	       198 ns/op	      80 B/op	       3 allocs/op
BenchmarkStringToTime           	 6281578	       188 ns/op	      32 B/op	       1 allocs/op
BenchmarkStringToTimeFieldsFunc 	 4941349	       247 ns/op	      32 B/op	       1 allocs/op
BenchmarkProgressOld            	55323696	        20.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkProgress               	20557132	        61.2 ns/op	      16 B/op	       2 allocs/op
PASS
ok  	github.com/dreadl0ck/netcap/utils	9.311s
FAIL

Some test files aren't found, maybe this has to do with the invalid psuedo versions I replaced.
Other tests might fail because the test pcap is not there: ../pcaps/Monday-WorkingHours.pcapng

I hope this information helps you or other people
Thanks again for your time and effort @dreadl0ck

from netcap.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.