mirror of
https://github.com/Lorikazzzz/VulnScanner-zmap-alternative-.git
synced 2026-02-04 06:46:00 +02:00
fixed ip output on multiport scan
on -p 80,8080 scans now the ip output will be like shown; ip:8080 ip:80
This commit is contained in:
@@ -92,6 +92,7 @@ typedef struct { //def arg
|
|||||||
uint8_t *probe_payload;
|
uint8_t *probe_payload;
|
||||||
size_t probe_payload_len;
|
size_t probe_payload_len;
|
||||||
struct BlackRock blackrock;
|
struct BlackRock blackrock;
|
||||||
|
int is_multiport;
|
||||||
} scanner_config_t;
|
} scanner_config_t;
|
||||||
|
|
||||||
typedef struct { //scan
|
typedef struct { //scan
|
||||||
|
|||||||
@@ -321,6 +321,7 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
uint64_t total_packets = total_ips * total_ports;
|
uint64_t total_packets = total_ips * total_ports;
|
||||||
stats.total_packets = total_packets;
|
stats.total_packets = total_packets;
|
||||||
|
config.is_multiport = (total_ports > 1);
|
||||||
|
|
||||||
if (total_packets == 0) {
|
if (total_packets == 0) {
|
||||||
fprintf(stderr, "[-] Nothing to scan\n");
|
fprintf(stderr, "[-] Nothing to scan\n");
|
||||||
|
|||||||
@@ -107,36 +107,51 @@ void process_packet(const uint8_t *packet, int length, stats_t *stats,
|
|||||||
atomic_fetch_add(&stats->hosts_up, 1);
|
atomic_fetch_add(&stats->hosts_up, 1);
|
||||||
atomic_fetch_add(&stats->ports_open, 1);
|
atomic_fetch_add(&stats->ports_open, 1);
|
||||||
|
|
||||||
char src_ip_str[16];
|
|
||||||
uint32_t ip_hbo = ntohl(iph->saddr);
|
uint32_t ip_hbo = ntohl(iph->saddr);
|
||||||
|
uint16_t port_hbo = ntohs(tcph->source);
|
||||||
|
char out_str[32];
|
||||||
|
|
||||||
/* Atomic check-and-set in bitset */
|
if (config->is_multiport) {
|
||||||
uint8_t bit = 1 << (ip_hbo & 7);
|
char ip_str[16];
|
||||||
uint8_t *byte_ptr = &seen_ips[ip_hbo >> 3];
|
int_to_ip(iph->saddr, ip_str);
|
||||||
|
snprintf(out_str, sizeof(out_str), "%s:%u", ip_str, port_hbo);
|
||||||
if (!(atomic_fetch_or((_Atomic uint8_t *)byte_ptr, bit) & bit)) {
|
push_to_writer(out_str);
|
||||||
int_to_ip(iph->saddr, src_ip_str);
|
} else {
|
||||||
push_to_writer(src_ip_str);
|
/* Atomic check-and-set in bitset */
|
||||||
|
uint8_t bit = 1 << (ip_hbo & 7);
|
||||||
|
uint8_t *byte_ptr = &seen_ips[ip_hbo >> 3];
|
||||||
|
|
||||||
|
if (!(atomic_fetch_or((_Atomic uint8_t *)byte_ptr, bit) & bit)) {
|
||||||
|
int_to_ip(iph->saddr, out_str);
|
||||||
|
push_to_writer(out_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (tcph->rst) {
|
} else if (tcph->rst) {
|
||||||
atomic_fetch_add(&stats->rst_replies, 1);
|
atomic_fetch_add(&stats->rst_replies, 1);
|
||||||
}
|
}
|
||||||
} else if (iph->protocol == IPPROTO_UDP) {
|
struct udphdr *udph = (struct udphdr *)(packet + offset + (iph->ihl * 4));
|
||||||
// Any UDP data back is a hit
|
|
||||||
atomic_fetch_add(&stats->packets_received, 1);
|
atomic_fetch_add(&stats->packets_received, 1);
|
||||||
atomic_fetch_add(&stats->hosts_up, 1); // Maybe?
|
atomic_fetch_add(&stats->hosts_up, 1);
|
||||||
atomic_fetch_add(&stats->ports_open, 1);
|
atomic_fetch_add(&stats->ports_open, 1);
|
||||||
|
|
||||||
char src_ip_str[16];
|
|
||||||
uint32_t ip_hbo = ntohl(iph->saddr);
|
uint32_t ip_hbo = ntohl(iph->saddr);
|
||||||
|
uint16_t port_hbo = ntohs(udph->source);
|
||||||
uint8_t bit = 1 << (ip_hbo & 7);
|
char out_str[32];
|
||||||
uint8_t *byte_ptr = &seen_ips[ip_hbo >> 3];
|
|
||||||
|
if (config->is_multiport) {
|
||||||
if (!(atomic_fetch_or((_Atomic uint8_t *)byte_ptr, bit) & bit)) {
|
char ip_str[16];
|
||||||
int_to_ip(iph->saddr, src_ip_str);
|
int_to_ip(iph->saddr, ip_str);
|
||||||
push_to_writer(src_ip_str);
|
snprintf(out_str, sizeof(out_str), "%s:%u", ip_str, port_hbo);
|
||||||
|
push_to_writer(out_str);
|
||||||
|
} else {
|
||||||
|
uint8_t bit = 1 << (ip_hbo & 7);
|
||||||
|
uint8_t *byte_ptr = &seen_ips[ip_hbo >> 3];
|
||||||
|
|
||||||
|
if (!(atomic_fetch_or((_Atomic uint8_t *)byte_ptr, bit) & bit)) {
|
||||||
|
int_to_ip(iph->saddr, out_str);
|
||||||
|
push_to_writer(out_str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (iph->protocol == IPPROTO_ICMP) {
|
} else if (iph->protocol == IPPROTO_ICMP) {
|
||||||
|
|||||||
Reference in New Issue
Block a user