How to create a simple TCP port scanner in GE language
This article mainly introduces "how to use GE language to create a simple TCP port scanner". In daily operation, I believe many people have doubts about how to use GE language to create a simple TCP port scanner. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the questions of "how to use GE language to create a simple TCP port scanner". Next, please follow the editor to study!
TCP scanning essence
When we use TCP to connect, we need to know the ip:port of the other machine.
Normal handshake
If the connection is successful, the process is as follows.
Connection failed
If there is normal, there is failure. If it is shut down by the connecting party, the process is as follows.
If there is a firewall
Another possibility is that the port is open, but the firewall blocks, and the process is as follows.
Code
Once you understand the essence, you can start playing with the code.
In Go, we usually use net.Dial for TCP connections.
There are only two situations.
Success: return conn.
Failed: err! = nil.
Ordinary version
Relatively speaking, at the beginning, we may not be too bold, we all write prototypes first, regardless of performance.
Code
Package main import ("fmt"net") func main () {var ip = "192.168.43.34" for I: = 21; I