Skip to content

Instantly share code, notes, and snippets.

@lt
lt / sniff.php
Created December 9, 2016 16:41
Minimal PHP packet sniffer
<?php declare(strict_types=1);
$socket = socket_create(AF_INET, SOCK_RAW, SOL_TCP);
if (!$socket) {
$errorCode = socket_last_error();
throw new \RuntimeException(socket_strerror($errorCode), $errorCode);
}
const IP_HDR = 'Cversion_ihl/Ctos/ntot_len/nid/nfrag_off/Cttl/Cprotocol/ncheck/Nsaddr/Ndaddr/';

Keybase proof

I hereby claim:

  • I am lt on github.
  • I am lt (https://keybase.io/lt) on keybase.
  • I have a public key whose fingerprint is 6A4D B222 AA19 7E6E 63D0 4DF4 493D B208 C886 9F3B

To claim this, I am signing this object: