Skip to content

Commit

Permalink
added pcapng skipping of too small packets
Browse files Browse the repository at this point in the history
  • Loading branch information
rke committed Jun 24, 2021
1 parent fa661a9 commit c3f12cc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pcapng.c
Expand Up @@ -196,6 +196,15 @@ int fix_pcapng(FILE *pcap, FILE *pcap_fix) {

}

if (bh.total_length < 12) {
printf("[-] Block too small ==> SKIPPING\n");

/* reset input file pointer to next block */
fseeko(pcap, pos+bh.total_length, SEEK_SET);

continue;
}

if (verbose >= 1) printf("[*] Assuming this blocks size as %" PRIu32 " bytes.\n", bh.total_length);
else printf("[-] Invalid Block size => CORRECTED.\n");

Expand Down Expand Up @@ -1733,7 +1742,7 @@ int find_valid_block(FILE *pcap, off_t filesize) {
if (check == bh.total_length) {
/* also the second block size value is correct! */

if (verbose >= 1) printf("[+] FOUND: Block (Type: 0x%08" PRIx32 ") at Position %" FMT_OFF_T "\n", bh.block_type, i);
if (verbose >= 1) printf("[+] FOUND: Block (Type: 0x%08" PRIx32 ", Length: %u) at Position %" FMT_OFF_T "\n", bh.block_type, bh.total_length, i);

/* set pointer to next block position */
fseeko(pcap, i, SEEK_SET);
Expand Down

0 comments on commit c3f12cc

Please sign in to comment.