- 论坛徽章:
- 0
|
static int FIN_scan(const char *ip_addr, const unsigned short port)
{
struct sockaddr_in addr;
int sockfd;
fd_set fdset;
struct timeval timeout;
struct tcphdr *tcp;
struct ip *ip;
char buf[sizeof(struct tcphdr) + sizeof(struct ip)];
int buflen, addrlen;
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
addr.sin_addr.s_addr = inet_addr("119.75.216.30"); //119.75.216.30百度
timeout.tv_sec = TIME_OUT;
timeout.tv_usec = 0;
memset(buf, 0, sizeof(buf));
sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
ip = (struct ip *)buf;
tcp = (struct tcphdr *)(buf + sizeof(struct ip));
buflen = sizeof(struct tcphdr) + sizeof(struct ip);
addrlen = sizeof(struct sockaddr_in);
tcp->source = htons(55555);
tcp->dest = htons(port);
tcp->fin = 1;
tcp->doff = 5;
if (sendto(sockfd, buf, buflen, 0, (struct sockaddr *)&addr, addrlen)
== buflen)
printf("sendto successn");
if (recvfrom(sockfd, buf, buflen, 0, (struct sockaddr *)&addr,
&addrlen) == buflen)
printf("recvfrom successn"); //recvfrom收不到
return 1;
} |
|
|