当前位置:毕业生轻松求职网求职就业电脑培训学习网络知识网络基础知识高级扫描技术ICMP、TCP、UDP原理
高级扫描技术ICMP、TCP、UDP原理

高级扫描技术ICMP、TCP、UDP原理

11-27 02:17:21  浏览次数:429次  栏目:网络基础知识
标签:网络基础,计算机网络基础知识,http://www.qiuzhi56.com 高级扫描技术ICMP、TCP、UDP原理,http://www.qiuzhi56.com
ipHeader.total_len=htons(sizeof(ipHeader)+sizeof(tcpHeader));
ipHeader.ident=1;
ipHeader.frag_and_flags=0;
ipHeader.ttl=128;
ipHeader.proto=IPPROTO_TCP;
ipHeader.checksum=0;
ipHeader.sourceIP=inet_addr("本地地址");
ipHeader.destIP=inet_addr(argv[1]);

//填充TCP首部
tcpHeader.th_dport=htons(atoi(argv[2]));
tcpHeader.th_sport=htons(SOURCE_PORT); //源端口号
tcpHeader.th_seq=htonl(0x12345678);
tcpHeader.th_ack=0;
tcpHeader.th_lenres=(sizeof(tcpHeader)/4<<4|0);
tcpHeader.th_flag=2; //修改这里来实现不同的标志位探测,2是SYN,1是FIN,16是ACK探测 等等
tcpHeader.th_win=htons(512);
tcpHeader.th_urp=0;
tcpHeader.th_sum=0;

psdHeader.saddr=ipHeader.sourceIP;
psdHeader.daddr=ipHeader.destIP;
psdHeader.mbz=0;
psdHeader.ptcl=IPPROTO_TCP;
psdHeader.tcpl=htons(sizeof(tcpHeader));

//计算校验和
memcpy(szSendBuf, &psdHeader, sizeof(psdHeader));
memcpy(szSendBuf+sizeof(psdHeader), &tcpHeader, sizeof(tcpHeader));
tcpHeader.th_sum=checksum((USHORT *)szSendBuf,sizeof(psdHeader)+sizeof(tcpHeader));

memcpy(szSendBuf, &ipHeader, sizeof(ipHeader));
memcpy(szSendBuf+sizeof(ipHeader), &tcpHeader, sizeof(tcpHeader));
memset(szSendBuf+sizeof(ipHeader)+sizeof(tcpHeader), 0, 4);
ipHeader.checksum=checksum((USHORT *)szSendBuf, sizeof(ipHeader)+sizeof(tcpHeader));

memcpy(szSendBuf, &ipHeader, sizeof(ipHeader));

rect=sendto(sock, szSendBuf, sizeof(ipHeader)+sizeof(tcpHeader),
0, (struct sockaddr*)&addr_in, sizeof(addr_in));
if (rect==SOCKET_ERROR)
{
printf("send error!:%d
",WSAGetLastError());
return false;
}
else
printf("send ok!
");

closesocket(sock);
WSACleanup();

return 0;
}

-------------------------------------------

reference:

1、《Breaking into computer networks from the Internet》 Roelof Temmingh & SensePost (Pty) Ltd
2、Phrack #49,《Port Scanning without the SYN flag》
3、Phrack #51,《The Art of Port Scanning》
4、Sys-Security Group《ICMP Usage in Scanning》

上一页  [1] [2] 

,高级扫描技术ICMP、TCP、UDP原理
《高级扫描技术ICMP、TCP、UDP原理》相关文章

tag: 网络基础知识,网络基础,计算机网络基础知识,电脑培训学习 - 网络知识 - 网络基础知识