Skip to content

Instantly share code, notes, and snippets.

@gamemann
Last active May 8, 2020 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamemann/9f0d42c25151d0f2e1630840d04fd599 to your computer and use it in GitHub Desktop.
Save gamemann/9f0d42c25151d0f2e1630840d04fd599 to your computer and use it in GitHub Desktop.
Payload matching attempt via goto.
// Payload match.
if (filter[i]->payloadLen > 0)
{
// Initialize packet data.
for (uint16_t j = 0; j < MAX_PCKT_LENGTH; j++)
{
if ((j + 1) > filter[i]->payloadLen)
{
break;
}
uint8_t *byte = data + sizeof(struct ethhdr) + (iph->ihl * 4) + l4headerLen + j;
if (byte + 1 > (uint8_t *)data_end)
{
break;
}
if (*(byte) == filter[i]->payloadMatch[j])
{
continue;
}
goto test;
}
continue;
}
test:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment