Loading src/main-globals.h +0 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,5 @@ extern unsigned control_c_pressed; extern time_t global_now; extern uint64_t global_tcb_count; #endif src/main-status.c +15 −6 Original line number Diff line number Diff line Loading @@ -30,7 +30,8 @@ status_print( double x, uint64_t total_tcbs, uint64_t total_synacks, uint64_t total_syns) uint64_t total_syns, uint64_t exiting) { double elapsed_time; double rate; Loading Loading @@ -135,9 +136,18 @@ status_print( syn_rate, synack_rate, tcb_rate, global_tcb_count total_tcbs ); } else if (rate > 0) { } else { if (control_c_pressed) { fprintf(stderr, "rate:%6.2f-kpps, %5.2f%% done, waiting %llu-secs, found=%llu \r", x/1000.0, percent_done, exiting, total_synacks ); } else { fprintf(stderr, "rate:%6.2f-kpps, %5.2f%% done,%4u:%02u:%02u remaining, found=%llu \r", x/1000.0, Loading @@ -146,10 +156,9 @@ status_print( (unsigned)(time_remaining/60)%60, (unsigned)(time_remaining)%60, total_synacks //global_tcb_count, //synack_rate ); } } fflush(stderr); /* Loading src/main-status.h +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ struct Status }; void status_print(struct Status *status, uint64_t count, uint64_t max_count, double x, uint64_t total_tcbs, uint64_t total_synacks, uint64_t total_syns); void status_print(struct Status *status, uint64_t count, uint64_t max_count, double x, uint64_t total_tcbs, uint64_t total_synacks, uint64_t total_syns, uint64_t exiting); void status_finish(struct Status *status); void status_start(struct Status *status); Loading src/main.c +58 −13 Original line number Diff line number Diff line Loading @@ -271,15 +271,24 @@ transmit_thread(void *v) /*aka. scanning_thread() */ unsigned src_port_mask; uint64_t seed = masscan->seed; uint64_t repeats = 0; /* --infinite repeats */ uint64_t total_syns = 0; uint64_t *status_syn_count; LOG(1, "xmit: starting transmit thread #%u\n", parms->nic_index); parms->total_syns = &total_syns; /* export a pointer to this variable outside this threads so * that the 'status' system can print the rate of syns we are * sending */ status_syn_count = (uint64_t*)malloc(sizeof(uint64_t)); *status_syn_count = 0; parms->total_syns = status_syn_count; /* Normally, we have just one source address. In special cases, though * we can have multiple. */ get_sources(masscan, parms->nic_index, &src_ip, &src_ip_mask, &src_port, &src_port_mask); LOG(1, "xmit: starting transmit thread #%u\n", parms->nic_index); /* "THROTTLER" rate-limits how fast we transmit, set with the * --max-rate parameter */ Loading Loading @@ -399,7 +408,7 @@ infinite: ); batch_size--; packets_sent++; total_syns++; (*status_syn_count)++; /* * SEQUENTIALLY INCREMENT THROUGH THE RANGE Loading Loading @@ -448,6 +457,8 @@ infinite: */ rawsock_flush(adapter); control_c_pressed = 1; /* * We are done transmitting. However, response packets will take several * seconds to arrive. Therefore, sit in short loop waiting for those Loading Loading @@ -519,11 +530,17 @@ receive_thread(void *v) struct DedupTable *dedup; struct PcapFile *pcapfile = NULL; struct TCP_ConnectionTable *tcpcon = 0; uint64_t total_synacks = 0; uint64_t total_tcbs = 0; uint64_t *status_synack_count; uint64_t *status_tcb_count; /* some status variables */ status_synack_count = (uint64_t*)malloc(sizeof(uint64_t)); *status_synack_count = 0; parms->total_synacks = status_synack_count; parms->total_synacks = &total_synacks; parms->total_tcbs = &total_tcbs; status_tcb_count = (uint64_t*)malloc(sizeof(uint64_t)); *status_tcb_count = 0; parms->total_tcbs = status_tcb_count; LOG(1, "recv: start receive thread #%u\n", parms->nic_index); Loading Loading @@ -780,7 +797,7 @@ receive_thread(void *v) ip_me, ip_them, port_me, port_them, seqno_me, seqno_them+1); total_tcbs++; (*status_tcb_count)++; } tcpcon_handle(tcpcon, tcb, TCP_WHAT_SYNACK, Loading Loading @@ -850,7 +867,7 @@ receive_thread(void *v) /* verify: ignore duplicates */ if (dedup_is_duplicate(dedup, ip_them, port_them, ip_me, port_me)) continue; total_synacks++; (*status_synack_count)++; /* * This is where we do the output Loading Loading @@ -907,6 +924,7 @@ end: /* Thread is about to exit */ parms->done_receiving = 1; } Loading Loading @@ -1179,7 +1197,8 @@ main_scan(struct Masscan *masscan) * namely packets/second. */ status_print(&status, min_index, range, rate, total_tcbs, total_synacks, total_syns); total_tcbs, total_synacks, total_syns, 0); /* Sleep for almost a second */ pixie_mssleep(750); Loading @@ -1204,10 +1223,34 @@ main_scan(struct Masscan *masscan) unsigned transmit_count = 0; unsigned receive_count = 0; unsigned i; double rate = 0; uint64_t total_tcbs = 0; uint64_t total_synacks = 0; uint64_t total_syns = 0; pixie_mssleep(750); status_print(&status, masscan->resume.index, range, 0, 0, 0, 0); /* Find the minimum index of all the threads */ min_index = UINT64_MAX; for (i=0; i<masscan->nic_count; i++) { struct ThreadPair *parms = &parms_array[i]; if (min_index > parms->my_index) min_index = parms->my_index; rate += parms->throttler->current_rate; if (parms->total_tcbs) total_tcbs += *parms->total_tcbs; if (parms->total_synacks) total_synacks += *parms->total_synacks; if (parms->total_syns) total_syns += *parms->total_syns; } status_print(&status, masscan->resume.index, range, rate, total_tcbs, total_synacks, total_syns, masscan->wait - (time(0) - now)); if (time(0) - now >= masscan->wait) control_c_pressed_again = 1; Loading @@ -1220,6 +1263,8 @@ main_scan(struct Masscan *masscan) } pixie_mssleep(750); if (transmit_count < masscan->nic_count) continue; control_c_pressed = 1; Loading src/proto-tcp.c +0 −6 Original line number Diff line number Diff line Loading @@ -24,10 +24,6 @@ #include "string_s.h" #include "main-globals.h" /* [GLOBALS] * I want to print the number of TCBs in status messages, so I'm hacking this count * in here */ uint64_t global_tcb_count; /*************************************************************************** Loading Loading @@ -377,7 +373,6 @@ tcpcon_destroy_tcb( tcb->next = tcpcon->freed_list; tcpcon->freed_list = tcb; tcpcon->active_count--; global_tcb_count = tcpcon->active_count; } Loading Loading @@ -469,7 +464,6 @@ tcpcon_create_tcb( banout_init(&tcb->banout); tcpcon->active_count++; global_tcb_count = tcpcon->active_count; } return tcb; Loading Loading
src/main-globals.h +0 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,5 @@ extern unsigned control_c_pressed; extern time_t global_now; extern uint64_t global_tcb_count; #endif
src/main-status.c +15 −6 Original line number Diff line number Diff line Loading @@ -30,7 +30,8 @@ status_print( double x, uint64_t total_tcbs, uint64_t total_synacks, uint64_t total_syns) uint64_t total_syns, uint64_t exiting) { double elapsed_time; double rate; Loading Loading @@ -135,9 +136,18 @@ status_print( syn_rate, synack_rate, tcb_rate, global_tcb_count total_tcbs ); } else if (rate > 0) { } else { if (control_c_pressed) { fprintf(stderr, "rate:%6.2f-kpps, %5.2f%% done, waiting %llu-secs, found=%llu \r", x/1000.0, percent_done, exiting, total_synacks ); } else { fprintf(stderr, "rate:%6.2f-kpps, %5.2f%% done,%4u:%02u:%02u remaining, found=%llu \r", x/1000.0, Loading @@ -146,10 +156,9 @@ status_print( (unsigned)(time_remaining/60)%60, (unsigned)(time_remaining)%60, total_synacks //global_tcb_count, //synack_rate ); } } fflush(stderr); /* Loading
src/main-status.h +1 −1 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ struct Status }; void status_print(struct Status *status, uint64_t count, uint64_t max_count, double x, uint64_t total_tcbs, uint64_t total_synacks, uint64_t total_syns); void status_print(struct Status *status, uint64_t count, uint64_t max_count, double x, uint64_t total_tcbs, uint64_t total_synacks, uint64_t total_syns, uint64_t exiting); void status_finish(struct Status *status); void status_start(struct Status *status); Loading
src/main.c +58 −13 Original line number Diff line number Diff line Loading @@ -271,15 +271,24 @@ transmit_thread(void *v) /*aka. scanning_thread() */ unsigned src_port_mask; uint64_t seed = masscan->seed; uint64_t repeats = 0; /* --infinite repeats */ uint64_t total_syns = 0; uint64_t *status_syn_count; LOG(1, "xmit: starting transmit thread #%u\n", parms->nic_index); parms->total_syns = &total_syns; /* export a pointer to this variable outside this threads so * that the 'status' system can print the rate of syns we are * sending */ status_syn_count = (uint64_t*)malloc(sizeof(uint64_t)); *status_syn_count = 0; parms->total_syns = status_syn_count; /* Normally, we have just one source address. In special cases, though * we can have multiple. */ get_sources(masscan, parms->nic_index, &src_ip, &src_ip_mask, &src_port, &src_port_mask); LOG(1, "xmit: starting transmit thread #%u\n", parms->nic_index); /* "THROTTLER" rate-limits how fast we transmit, set with the * --max-rate parameter */ Loading Loading @@ -399,7 +408,7 @@ infinite: ); batch_size--; packets_sent++; total_syns++; (*status_syn_count)++; /* * SEQUENTIALLY INCREMENT THROUGH THE RANGE Loading Loading @@ -448,6 +457,8 @@ infinite: */ rawsock_flush(adapter); control_c_pressed = 1; /* * We are done transmitting. However, response packets will take several * seconds to arrive. Therefore, sit in short loop waiting for those Loading Loading @@ -519,11 +530,17 @@ receive_thread(void *v) struct DedupTable *dedup; struct PcapFile *pcapfile = NULL; struct TCP_ConnectionTable *tcpcon = 0; uint64_t total_synacks = 0; uint64_t total_tcbs = 0; uint64_t *status_synack_count; uint64_t *status_tcb_count; /* some status variables */ status_synack_count = (uint64_t*)malloc(sizeof(uint64_t)); *status_synack_count = 0; parms->total_synacks = status_synack_count; parms->total_synacks = &total_synacks; parms->total_tcbs = &total_tcbs; status_tcb_count = (uint64_t*)malloc(sizeof(uint64_t)); *status_tcb_count = 0; parms->total_tcbs = status_tcb_count; LOG(1, "recv: start receive thread #%u\n", parms->nic_index); Loading Loading @@ -780,7 +797,7 @@ receive_thread(void *v) ip_me, ip_them, port_me, port_them, seqno_me, seqno_them+1); total_tcbs++; (*status_tcb_count)++; } tcpcon_handle(tcpcon, tcb, TCP_WHAT_SYNACK, Loading Loading @@ -850,7 +867,7 @@ receive_thread(void *v) /* verify: ignore duplicates */ if (dedup_is_duplicate(dedup, ip_them, port_them, ip_me, port_me)) continue; total_synacks++; (*status_synack_count)++; /* * This is where we do the output Loading Loading @@ -907,6 +924,7 @@ end: /* Thread is about to exit */ parms->done_receiving = 1; } Loading Loading @@ -1179,7 +1197,8 @@ main_scan(struct Masscan *masscan) * namely packets/second. */ status_print(&status, min_index, range, rate, total_tcbs, total_synacks, total_syns); total_tcbs, total_synacks, total_syns, 0); /* Sleep for almost a second */ pixie_mssleep(750); Loading @@ -1204,10 +1223,34 @@ main_scan(struct Masscan *masscan) unsigned transmit_count = 0; unsigned receive_count = 0; unsigned i; double rate = 0; uint64_t total_tcbs = 0; uint64_t total_synacks = 0; uint64_t total_syns = 0; pixie_mssleep(750); status_print(&status, masscan->resume.index, range, 0, 0, 0, 0); /* Find the minimum index of all the threads */ min_index = UINT64_MAX; for (i=0; i<masscan->nic_count; i++) { struct ThreadPair *parms = &parms_array[i]; if (min_index > parms->my_index) min_index = parms->my_index; rate += parms->throttler->current_rate; if (parms->total_tcbs) total_tcbs += *parms->total_tcbs; if (parms->total_synacks) total_synacks += *parms->total_synacks; if (parms->total_syns) total_syns += *parms->total_syns; } status_print(&status, masscan->resume.index, range, rate, total_tcbs, total_synacks, total_syns, masscan->wait - (time(0) - now)); if (time(0) - now >= masscan->wait) control_c_pressed_again = 1; Loading @@ -1220,6 +1263,8 @@ main_scan(struct Masscan *masscan) } pixie_mssleep(750); if (transmit_count < masscan->nic_count) continue; control_c_pressed = 1; Loading
src/proto-tcp.c +0 −6 Original line number Diff line number Diff line Loading @@ -24,10 +24,6 @@ #include "string_s.h" #include "main-globals.h" /* [GLOBALS] * I want to print the number of TCBs in status messages, so I'm hacking this count * in here */ uint64_t global_tcb_count; /*************************************************************************** Loading Loading @@ -377,7 +373,6 @@ tcpcon_destroy_tcb( tcb->next = tcpcon->freed_list; tcpcon->freed_list = tcb; tcpcon->active_count--; global_tcb_count = tcpcon->active_count; } Loading Loading @@ -469,7 +464,6 @@ tcpcon_create_tcb( banout_init(&tcb->banout); tcpcon->active_count++; global_tcb_count = tcpcon->active_count; } return tcb; Loading