Skip to content

Commit

Permalink
Merge pull request #8 from robgonnella/implement-arp-syn-scanner
Browse files Browse the repository at this point in the history
Implement ARP / SYN scanner
  • Loading branch information
robgonnella authored Aug 8, 2023
2 parents 7fe6305 + 6b329fd commit aa2d22c
Show file tree
Hide file tree
Showing 16 changed files with 352 additions and 164 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
with:
go-version: '1.19'

- name: Install make
run: sudo apt update && sudo apt install -y make
- name: Install dependencies
run: sudo apt update && sudo apt install -y make libpcap-dev

- name: Build
run: make
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

- mac
```bash
brew install make go ansible git
brew install make go ansible libpcap git
```

- debian
```bash
sudo apt update && sudo apt install -y make golang ansible git
sudo apt update && sudo apt install -y make golang ansible libpcap-dev git
```

When building from source you may want to add the following lines to one of your
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ managing kubernetes clusters via a terminal ui application.

## Runtime Dependencies

Ops has one external runtime dependencies, [ansible].
Ops has some external runtime dependencies: libpcap, [ansible].

- mac
```bash
brew install ansible
brew install ansible libpcap
```

- debian
```bash
sudo apt update && sudo apt install -y ansible
sudo apt update && sudo apt install -y ansible libpcap-dev
```

## Build Dependencies
Expand Down Expand Up @@ -54,6 +54,7 @@ PATH="${GOPATH}/bin:$PATH"
- dependencies
- golang
- ansible
- libpcap
- git

```bash
Expand All @@ -65,6 +66,7 @@ go install github.com/robgonnella/ops@latest
- golang
- make
- ansible
- libpcap
- git

```bash
Expand All @@ -76,6 +78,7 @@ make install
- use pre-built binaries: https://github.com/robgonnella/ops/releases
- dependencies
- ansible
- libpcap

## Usage

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/apenella/go-ansible v1.1.7
github.com/gdamore/tcell/v2 v2.6.0
github.com/golang/mock v1.6.0
github.com/imdario/mergo v0.3.16
github.com/google/gopacket v1.1.19
github.com/jackpal/gateway v1.0.10
github.com/projectdiscovery/mapcidr v1.1.2
github.com/rivo/tview v0.0.0-20230621164836-6cc0565babaf
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8=
github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand Down Expand Up @@ -203,8 +205,6 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
Expand Down
6 changes: 4 additions & 2 deletions internal/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestCore(t *testing.T) {
mockDetailsScanner := mock_discovery.NewMockDetailScanner(ctrl)
mockConfig := mock_config.NewMockService(ctrl)
mockServerService := mock_server.NewMockService(ctrl)
resultChan := make(chan *discovery.DiscoveryResult)

networkInfo := &util.NetworkInfo{
Hostname: "hostname",
Expand All @@ -41,6 +42,7 @@ func TestCore(t *testing.T) {
mockScanner,
mockDetailsScanner,
mockServerService,
resultChan,
)

conf := config.Config{
Expand Down Expand Up @@ -229,11 +231,11 @@ func TestCore(t *testing.T) {
Do(func([]string) {
wg.Done()
})
mockScanner.EXPECT().Scan(gomock.Any()).DoAndReturn(func(rchan chan *discovery.DiscoveryResult) error {
mockScanner.EXPECT().Scan().DoAndReturn(func() error {
defer wg.Done()
go func() {
for _, r := range discoveryResults {
rchan <- r
resultChan <- r
}
}()
return nil
Expand Down
9 changes: 8 additions & 1 deletion internal/core/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ func CreateNewAppCore(networkInfo *util.NetworkInfo) (*Core, error) {
serverRepo := server.NewSqliteRepo(db)
serverService := server.NewService(*conf, serverRepo)

netScanner, err := discovery.NewNetScanner(conf.Targets)
resultChan := make(chan *discovery.DiscoveryResult)

netScanner, err := discovery.NewARPScanner(
networkInfo,
conf.Targets,
resultChan,
)

if err != nil {
return nil, err
Expand All @@ -95,6 +101,7 @@ func CreateNewAppCore(networkInfo *util.NetworkInfo) (*Core, error) {
netScanner,
detailScanner,
serverService,
resultChan,
)

return New(
Expand Down
Loading

0 comments on commit aa2d22c

Please sign in to comment.