Reputation: 83
I am learning to use Golang to develop hacking tools through Blackhat-Go and port scan scanme.nmap.org on Windows and Linux while doing TCP scanning.Here's my code
package main
import (
"fmt"
"net"
"sort"
)
func worker(ports, result chan int) {
for port := range ports {
address := fmt.Sprintf("scanme.nmap.org:%d", port)
conn, err := net.Dial("tcp", address)
if err != nil {
result <- 0
continue
}
conn.Close()
result <- port
}
}
func main() {
ports := make(chan int, 100)
result := make(chan int)
var openport []int
for i := 0; i < cap(ports); i++ {
go worker(ports, result)
}
go func() {
for i := 0; i < 1024; i++ {
ports <- i
}
}()
for i := 0; i < 1024; i++ {
port := <-result
if port != 0 {
openport = append(openport, port)
}
}
close(ports)
close(result)
sort.Ints(openport)
for _, value := range openport {
fmt.Printf("%d open\n", value)
}
}
Running on Windows shows that port 25 is open.
22 open
25 open
80 open
110 open
However, port 25 is not detected on Linux.
22 open
80 open
110 open
I used NMAP to scan and found that the state of port 25 is Filtered.
25/tcp filtered smtp
Why is port 25 detected on Windows.
any help please.
Upvotes: 4
Views: 558