Skip to content

Commit

Permalink
Add fix to avoid missing open ports
Browse files Browse the repository at this point in the history
The fix will improve the port coverage from ~15% up to ~99%.

An added delay of 0.00015s between tcp requests will increase the overall scan time to around 30 seconds but avoids flooding the target. Increasing the delay (`SCAN_DELAY_NS`) further eventually leads to a 100% reliability but also increase the scan time.

Close #1
  • Loading branch information
Cr4ckC4t committed Jul 31, 2021
1 parent faae5a0 commit 6ee4d6f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions portcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <netinet/ip.h>

#define RECV_TIMEOUT_S 2
#define SCAN_DELAY_NS 150000L // Specify the time to wait between tcp requests in nano seconds (0.00015s)

// Format colors
#define FC_END "\033[0m"
Expand Down Expand Up @@ -193,6 +194,11 @@ int main(int argc, char** argv) {
fprintf(stderr, "%s[!]%s Error sending SYN packet. Error code [%s%d%s]: %s\n", FC_RED, FC_END, FC_RED, errno, FC_END, strerror(errno));
exit(EXIT_FAILURE);
}

truct timespec tim;
tim.tv_sec = 0;
tim.tv_nsec = SCAN_DELAY_NS;
nanosleep(&tim, NULL);
}
pthread_join(recv_thread, NULL);
fprintf(stderr, "\n%s[+]%s Scan done\n", FC_GREEN, FC_END);
Expand Down

0 comments on commit 6ee4d6f

Please sign in to comment.