-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.go
More file actions
78 lines (63 loc) · 2 KB
/
Copy pathmain.go
File metadata and controls
78 lines (63 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package main
import (
"bufio"
"fmt"
"net"
"os"
"strconv"
"strings"
//l "./latex"
p "./pcap"
)
func listInterfaces() []string {
interfaces, err := net.Interfaces()
var ifaceArr []string
if err != nil {
fmt.Print(fmt.Errorf("listInterfaces: %+v\n", err.Error()))
os.Exit(1)
}
for _, iface := range interfaces {
arr, _ := iface.Addrs()
if len(arr) == 0 {
continue
}
ifaceArr = append(ifaceArr, iface.Name)
}
for index, iface := range ifaceArr {
fmt.Println(index, ": ", iface)
}
return ifaceArr
}
func readUserInput(size int) int {
reader := bufio.NewReader(os.Stdin)
count := 0
for {
fmt.Print("Enter index of the device: ")
indexStr, _ := reader.ReadString('\n')
indexStr = strings.Replace(indexStr, "\n", "", -1)
index, convErr := strconv.Atoi(indexStr)
if convErr != nil {
fmt.Println("Cannot convert input to int")
os.Exit(1)
}
if index >= 0 && index < size {
return index
}
if count == 2 {
fmt.Println("Invalid choices made. Shutting down...")
os.Exit(1)
}
fmt.Println("Invalid choice. ( 0 -", size-1, ")")
}
}
func main() {
// http://www.ascii-art.de/ascii/s/sharks.txt
shark := " ^`. o\n ^_ \\ \\ o o\n \\ \\ { \\ o\n { \\ / `~~~--__\n { \\___----~~' `~~-_ ______ _____\n \\ /// a `~._(_||___)________/___\n / /~~~~-, ,__. , /// __,,,,) o ______/ \\ \n \\/ \\/ `~~~; ,---~~-_`~= \\ \\------o-' \\ \n / / / /\n '._.' _/_/\n ';|\\ \n -David 'TAZ' Baltazar- \n"
fmt.Println(shark, "\n|:|:|:|:|:| GoShark |:|:|:|:|:|")
fmt.Println("Available connected interfaces")
iface := listInterfaces()
input := readUserInput(len(iface))
p.Capture(iface[input])
//l.MakeReport("toRead.txt")
os.Exit(0)
}