From dba1391a0811b3817a5270d07203c17da2c082dc Mon Sep 17 00:00:00 2001 From: Brendan LE GLAUNEC Date: Thu, 19 Oct 2017 20:32:23 +0200 Subject: [PATCH] Fix dictionary path for binary & use glide in CI --- .travis.yml | 6 ++---- Dockerfile | 5 +++-- README.md | 4 ++-- cameradar/cameradar.go | 11 ++++++++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1ec13ac..99729a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,10 +22,8 @@ install: - docker build -t cameradar . script: -- go get github.com/andelf/go-curl -- go get github.com/pkg/errors -- go get gopkg.in/go-playground/validator.v9 -- go get github.com/stretchr/testify/assert +- curl https://glide.sh/get | sh +- glide install # Run unit tests - go test # Launch a fake camera to check if cameradar is able to access it diff --git a/Dockerfile b/Dockerfile index 58b3285..3ec021f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,5 +23,6 @@ RUN apk --update add --no-cache nmap nmap-nselibs nmap-scripts \ curl-dev WORKDIR /app/cameradar -COPY --from=build-env /go/src/github.com/EtixLabs/cameradar/ /app/ -ENTRYPOINT ["/app/cameradar/cameradar"] \ No newline at end of file +COPY --from=build-env /go/src/github.com/EtixLabs/cameradar/dictionaries/ /app/dictionaries/ +COPY --from=build-env /go/src/github.com/EtixLabs/cameradar/cameradar/ /app/cameradar/ +ENTRYPOINT ["/app/cameradar/cameradar", "-r", "/app/dictionaries/routes", "-c", "/app/dictionaries/credentials.json"] \ No newline at end of file diff --git a/README.md b/README.md index f34778c..f3be60c 100644 --- a/README.md +++ b/README.md @@ -146,8 +146,8 @@ With the above result, the RTSP URL would be `rtsp://admin:12345@173.16.100.45:5 * **"-p, --ports"**: (Default: `554,8554`) Set custom ports. * **"-s, --speed"**: (Default: `4`) Set custom nmap discovery presets to improve speed or accuracy. It's recommended to lower it if you are attempting to scan an unstable and slow network, or to increase it if on a very performant and reliable network. See [this for more info on the nmap timing templates](https://nmap.org/book/man-performance.html). * **"-T, --timeout"**: (Default: `2000`) Set custom timeout value in miliseconds after which an attack attempt without an answer should give up. It's recommended to increase it when attempting to scan unstable and slow networks or to decrease it on very performant and reliable networks. -* **"-r, --custom-routes"**: (Default: `dictionaries/routes`) Set custom dictionary path for routes -* **"-c, --custom-credentials"**: (Default: `dictionaries/credentials.json`) Set custom dictionary path for credentials +* **"-r, --custom-routes"**: (Default: `/dictionaries/routes`) Set custom dictionary path for routes +* **"-c, --custom-credentials"**: (Default: `/dictionaries/credentials.json`) Set custom dictionary path for credentials * **"-o, --nmap-output"**: (Default: `/tmp/cameradar_scan.xml`) Set custom nmap output path * **"-l, --log"**: Enable debug logs (nmap requests, curl describe requests, etc.) * **"-h"** : Display the usage information diff --git a/cameradar/cameradar.go b/cameradar/cameradar.go index ec2d96a..7ea3007 100644 --- a/cameradar/cameradar.go +++ b/cameradar/cameradar.go @@ -15,6 +15,7 @@ package main import ( "fmt" "os" + "strings" "time" "github.com/EtixLabs/cameradar" @@ -26,11 +27,11 @@ import ( ) type options struct { - Target string `short:"t" long:"target" description:"The target on which to scan for open RTSP streams - required" required:"true"` + Target string `short:"t" long:"target" description:"The target on which to scan for open RTSP streams - required (ex: 172.16.100.0/24)" required:"true"` Ports string `short:"p" long:"ports" description:"The ports on which to search for RTSP streams" default:"554,8554"` OutputFile string `short:"o" long:"nmap-output" description:"The path where nmap will create its XML result file" default:"/tmp/cameradar_scan.xml"` - Routes string `short:"r" long:"custom-routes" description:"The path on which to load a custom routes dictionary" default:"../dictionaries/routes"` - Credentials string `short:"c" long:"custom-credentials" description:"The path on which to load a custom credentials JSON dictionary" default:"../dictionaries/credentials.json"` + Routes string `short:"r" long:"custom-routes" description:"The path on which to load a custom routes dictionary" default:"/src/github.com/EtixLabs/cameradar/dictionaries/routes"` + Credentials string `short:"c" long:"custom-credentials" description:"The path on which to load a custom credentials JSON dictionary" default:"/src/github.com/EtixLabs/cameradar/dictionaries/credentials.json"` Speed int `short:"s" long:"speed" description:"The nmap speed preset to use" default:"4"` Timeout int `short:"T" long:"timeout" description:"The timeout in miliseconds to use for attack attempts" default:"2000"` EnableLogs bool `short:"l" long:"log" description:"Enable the logs for nmap's output to stdout"` @@ -45,6 +46,10 @@ func main() { w := startSpinner(options.EnableLogs) + gopath := os.Getenv("GOPATH") + options.Credentials = strings.Replace(options.Credentials, "", gopath, 1) + options.Routes = strings.Replace(options.Routes, "", gopath, 1) + credentials, err := cmrdr.LoadCredentials(options.Credentials) if err != nil { color.Red("Invalid credentials dictionary: %s", err.Error())