-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathmain.go
73 lines (64 loc) · 1.54 KB
/
main.go
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
// Terms Of Use
// ------------
// Do NOT use this on any computer you do not own or are not allowed to run this on.
// You may NEVER attempt to sell this, it is free and open source.
// The authors and publishers assume no responsibility.
// For educational purposes only.
package main
import (
"fmt"
"os"
"runtime"
"sort"
"github.com/mytechnotalent/turbo-scanner/routine"
"github.com/mytechnotalent/turbo-scanner/services"
)
func main() {
if runtime.GOOS == "windows" {
if len(os.Args) != 2 {
fmt.Println("usage: turbo-scanner_010w.exe <host>")
return
}
} else if runtime.GOOS == "darwin" {
if len(os.Args) != 2 {
fmt.Println("usage: ./turbo-scanner_010m <host>")
return
}
} else if runtime.GOOS == "linux" {
if len(os.Args) != 2 {
fmt.Println("usage: sudo ./turbo-scanner_010l <host>")
return
}
}
host := os.Args[1]
ports := make(chan int, 1000)
results := make(chan int)
var openports []int
for i := 0; i < cap(ports); i++ {
go routine.Routine(&host, ports, results)
}
go func() {
for i := 1; i <= 65535; i++ {
ports <- i
}
}()
for i := 0; i < 65535; i++ {
port := <-results
if port != 0 {
openports = append(openports, port)
}
}
close(ports)
close(results)
sort.Ints(openports)
for _, port := range openports {
fmt.Printf("%d open\n", port)
if runtime.GOOS == "windows" {
fmt.Println(services.WinService(&port))
} else if runtime.GOOS == "darwin" {
fmt.Println(services.MACService(&port))
} else if runtime.GOOS == "linux" {
fmt.Println(services.LinuxService(&port))
}
}
}