diff --git a/src/scan.c b/src/scan.c index c1bc05d..9a67731 100644 --- a/src/scan.c +++ b/src/scan.c @@ -20,27 +20,31 @@ static void dispatch_callback(u_char *user, const struct pcap_pkthdr *h, const struct iphdr *iphdr = (struct iphdr *)(bytes + sizeof(struct ether_header)); - printf("uwu\n"); - if (iphdr->protocol == IPPROTO_TCP && h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct tcphdr)) { tcp_response( - (const struct tcphdr *)(iphdr + sizeof(struct iphdr)), + (const struct tcphdr *)(bytes + + sizeof(struct ether_header) + + sizeof(struct iphdr)), data); } if (iphdr->protocol == IPPROTO_UDP && h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct udphdr)) { udp_response( - (const struct udphdr *)(iphdr + sizeof(struct iphdr)), + (const struct udphdr *)(bytes + + sizeof(struct ether_header) + + sizeof(struct iphdr)), data); } if (iphdr->protocol == IPPROTO_ICMP && h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct icmphdr)) { icmp_response( - (const struct icmphdr *)(iphdr + sizeof(struct iphdr)), + (const struct icmphdr *)(bytes + + sizeof(struct ether_header) + + sizeof(struct iphdr)), data); } } diff --git a/src/thread.c b/src/thread.c index 31c2e71..fc4f166 100644 --- a/src/thread.c +++ b/src/thread.c @@ -19,11 +19,11 @@ void *routine(void *p_data) port <= thread_data->port_end; port++) { scan_data.port = port; scan_data.response = - &thread_data->responses[thread_data->port_start - port]; + &thread_data->responses[port - thread_data->port_start]; if (scan(&scan_data)) return NULL; - printf("state of port %d: %d\n", port, - scan_data.response->state); + printf("%d: %s\n", port, + scan_data.response->state == 1 ? "OPEN" : "CLOSED"); } return p_data;