Skip to content

Instantly share code, notes, and snippets.

@asika32764
Created March 27, 2016 20:23
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 asika32764/63691006866594f7aeda to your computer and use it in GitHub Desktop.
Save asika32764/63691006866594f7aeda to your computer and use it in GitHub Desktop.
<?php
ini_set('display_errors', true); error_reporting(-1); // <- for debugging purposes only
$socket=socket_create(AF_INET, SOCK_RAW, SOL_TCP);
if ( !$socket ) {
$errno = socket_last_error();
$error = sprintf('%s (%d)', socket_strerror($errno), $errno);
trigger_error($error, E_USER_ERROR);
}
// if ( !socket_connect($socket, '106.187.102.58', 80) ) {
// $errno = socket_last_error($socket);
// $error = sprintf('%s (%d)', socket_strerror($errno), $errno);
// trigger_error($error, E_USER_ERROR);
// }
// $buff='P\00\00\00\e5G\1f\b9\c6\acB\84\15\e7\b3*\17\ab\00G2\n\9c\ba{\a9}\dab"\c31\ed\f7\94\fc\aeX\ab\13\r/\02\ce\83f\bc?\96q\10M\b0\f4\a0\b1\95X\d0\85\10\df$|\de$\b4\f6m\a9\ff%Z\b4\d8\aa\da\bb';
$buff='c46413fa29d994de80642c8b08004500003412f7400080060000732b2bdc6abb663a24330050d872f8f8000000008002200070230000020405b40103030801010402';
// $buff = '\c4d\13\fa)\d9\94\de\80d,\8b\08\00E\00\004\12\f7@\00\80\06\00\00s++\dcj\bbf:$3\00P\d8r\f8\f8\00\00\00\00\80\02 \00p#\00\00\02\04\05\b4\01\03\03\08\01\01\04\02';
$length = strlen($buff);
$sent = socket_sendto($socket, $buff, $length, MSG_OOB, '106.187.102.58', 80);
if ( FALSE===$sent ) {
$errno = socket_last_error($socket);
$error = sprintf('%s (%d)', socket_strerror($errno), $errno);
trigger_error($error, E_USER_ERROR);
}
else if ( $length!==$sent ) {
$msg = sprintf('only %d of %d bytes sent', $length, $sent);
trigger_error($msg, E_USER_NOTICE);
}
echo $sent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment