Skip to content

Commit

Permalink
Merge pull request #14 from robgonnella/add-option-to-output-report-t…
Browse files Browse the repository at this point in the history
…o-file

Adds option to output report to file
  • Loading branch information
robgonnella authored Dec 12, 2023
2 parents 3c7ddd8 + cd6bbb2 commit 64ba443
Show file tree
Hide file tree
Showing 30 changed files with 500 additions and 510 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/
coverage/
reports/
.vscode/
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
################################################################################
FROM golang:1.21-alpine3.18 as builder

ARG BUILD_TAGS

RUN apk update && apk add \
make \
linux-headers \
Expand All @@ -16,13 +18,17 @@ COPY internal internal
COPY pkg pkg
COPY go.mod go.sum main.go Makefile ./

RUN make static
RUN make static build_tags="${BUILD_TAGS}"

################################################################################
# Final
################################################################################
FROM alpine:3.18

RUN apk update && apk add ca-certificates

COPY --from=builder /app/build/go-lanscan /scan

ENTRYPOINT [ "/scan" ]
RUN mkdir -p /reports

ENTRYPOINT [ "/scan", "--out-file", "/reports/scan-report.json" ]
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ tag = $(shell git describe --tags $(shell git rev-list --tags --max-count=1))

flags ?= -ldflags '-s -w'

build_tags ?=

#### Build Objects ####
component = $(app_name)_$(tag)
component_path = $(prefix)/$(component)
Expand Down Expand Up @@ -46,7 +48,7 @@ all: $(app_name)

# builds main executable
$(prefix)/$(app_name): $(go_deps)
go build $(flags) -o $(@)
go build $(flags) -o $(@) -tags $(build_tags)

# build main executable
.PHONY: $(app_name)
Expand Down
30 changes: 1 addition & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# go-lanscan
![Coverage](https://img.shields.io/badge/Coverage-90.6%25-brightgreen)
![Coverage](https://img.shields.io/badge/Coverage-91.2%25-brightgreen)

A network cli and golang package that allows you to perform arp and syn
scanning on a local area network.
Expand Down Expand Up @@ -62,10 +62,6 @@ sudo go-lanscan --no-progress --json

# run only arp scanning (skip syn scanning)
sudo go-lanscan --arp-only

# set accuracy to low, which results in a faster scan but may
# miss some open ports
sudo go-lanscan --accuracy low
```

## Package Usage
Expand Down Expand Up @@ -166,29 +162,5 @@ queries against this file. The file is stored at `~/.config/go-lanscan/oui.txt`
option(arpScanner)
```

- Set accuracy of scanning (LOW, MEDIUM, HIGH). Low results in a faster scan
but may miss some open ports. The default is HIGH. This option can be set
on any scanner

```go
synScanner := scanner.NewSynScanner(
targets,
netInfo,
ports,
listenPort,
synResults,
synDone,
scanner.WithAccuracy(scanner.LOW_ACCURACY),
)

// or
synScanner.SetAccuracy(scanner.LOW_ACCURACY)

// or
option := scanner.WithAccuracy(scanner.LOW_ACCURACY)
option(synScanner)
```


[golang]: https://go.dev/doc/install
[libpcap]: https://github.com/the-tcpdump-group/libpcap
43 changes: 43 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "3"

services:
test-server-1:
build:
context: test-server
dockerfile: Dockerfile
environment:
PORT: '3232'
networks:
go-lanscan_default:

test-server-2:
build:
context: test-server
dockerfile: Dockerfile
environment:
PORT: '2323'
networks:
go-lanscan_default:

go-lanscan:
build:
args:
- BUILD_TAGS=debug
context: .
dockerfile: Dockerfile
command: --ports 2323,3232 --json
depends_on:
- test-server-1
- test-server-2
volumes:
- ./reports:/reports
networks:
go-lanscan_default:

networks:
go-lanscan_default:
driver: bridge
ipam:
config:
- subnet: 172.18.0.1/28
gateway: 172.18.0.1
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,35 @@ go 1.21

require (
github.com/google/gopacket v1.1.19
github.com/jackpal/gateway v1.0.10
github.com/jackpal/gateway v1.0.13
github.com/jedib0t/go-pretty v4.3.0+incompatible
github.com/klauspost/oui v0.0.0-20150225163751-35b4deb627f8
github.com/rs/zerolog v1.31.0
github.com/spf13/cobra v1.7.0
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.8.4
github.com/thediveo/netdb v1.0.2
github.com/thediveo/netdb v1.0.3
go.uber.org/mock v0.3.0
)

require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/errors v0.20.4 // indirect
github.com/go-openapi/strfmt v0.21.7 // indirect
github.com/go-openapi/strfmt v0.21.9 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.mongodb.org/mongo-driver v1.12.1 // indirect
golang.org/x/net v0.16.0 // indirect
golang.org/x/sys v0.13.0 // indirect
github.com/stretchr/objx v0.5.1 // indirect
go.mongodb.org/mongo-driver v1.13.1 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/tools v0.14.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 64ba443

Please sign in to comment.