我正在尝试用 golang 编写一个 tcp syn 端口扫描器,我在这里找到了 C 版本的解决方案:http: //www.binarytides.com/tcp-syn-portscan-in-c-with-linux-sockets/
我想在 go 中实现它,如何在 golang 中发送这样的tcp 标头:
//TCP Header
tcph->source = htons ( source_port );
tcph->dest = htons (80);
tcph->seq = htonl(1105024978);
tcph->ack_seq = 0;
tcph->doff = sizeof(struct tcphdr) / 4; //Size of tcp header
tcph->fin=0;
tcph->syn=1;
tcph->rst=0;
tcph->psh=0;
tcph->ack=0;
tcph->urg=0;
tcph->window = htons ( 14600 ); // maximum allowed window size
tcph->check = 0; //if you set a checksum to zero, your kernel's IP stack should fill in the correct checksum during transmission
tcph->urg_ptr = 0;
我必须使用系统调用或 cgo 吗?如果有人可以帮助我,我真的很感激。