Exemplo n.º 1
0
		server char(12),
		source char(12),
		ended char(12),
		server char(12),
		time datetime,
		clear_code char(32)
	);
*/
if (!file_exists('capture.hex')) {
    die;
}
$t = new TCPDUMP_UDP_Decode('capture.hex');
$i = new IAX_Decode();
$blocks = $t->getBlocks();
foreach ($blocks as $block) {
    $i->load($block['data']);
    switch ($i->messagetype) {
        case 'new':
            CallRegister::register($i, $block['header']['dst']['ip'], $block['header']['src']['ip']);
            break;
        case 'hangup':
            $call = CallRegister::retrieve($i->fields['scalli'], $block['header']['dst']['ip']);
            if ($call['user']) {
                print "INSERT INTO call_log SET \n" . " number='{$call['dst']}', \n" . " user='******'user']}', \n" . " server='{$call['server']}', \n" . " source='{$call['source']}', \n" . " ended='{$call['ended']}', \n" . " time='" . date('Y-m-d H:i:s', strtotime($block['header']['time'])) . "', \n" . " clear_code='{$i->data['hangup_cause']}';\n\n";
            }
            CallRegister::unregister($i, $block['header']['dst']['ip'], $block['header']['src']['ip']);
            break;
        case 'accept':
            break;
    }
}
Exemplo n.º 2
0
$captureTypes = array('register_attempt', 'register_accept', 'accept', 'new', 'auth_challenge', 'auth_response', 'hangup');
// batch mode
//$packets = $t->getPackets();
//foreach($packets as $packet){
// stream mode
while ($packet = $t->getPacket()) {
    if (@$packet['udp']) {
        $i->load($packet['udp']['packet']);
        print_r($i);
    }
    if ($i->messagetype) {
        //!='voice' && $i->messagetype!='acknowledge'){
        //		print "{$packet['capture_packet']['length']} {$i->messagetype} \n";
    }
    if ('new' == $i->messagetype) {
        $call = CallRegister::register($i, $packet['ip']['header']['dst'], $packet['ip']['header']['src']);
    }
    if (in_array($i->messagetype, $captureTypes)) {
        //	if(!is_array($captureTypes) || in_array($i->messagetype, $captureTypes)){
        $call = CallRegister::retrieve($i->fields['dcalli'], $packet['ip']['header']['dst']);
        if (!$call['user']) {
            $call = CallRegister::retrieve($i->fields['scalli'], $packet['ip']['header']['dst']);
        }
        if ($call['user']) {
            print "INSERT INTO call_packets SET \n" . " number='{$call['dst']}', \n" . " user='******'user']}', \n" . " server=inet_aton('{$call['server']}'), \n" . " source=inet_aton('{$call['source']}'), \n" . " type='{$i->messagetype}', \n" . " time='" . date('Y-m-d H:i:s', strtotime($packet['capture_packet']['time'])) . "', \n" . " packet=unhex('" . bin2hex($packet['packet']) . "');\n\n";
        }
    }
    if ('hangup' == $i->messagetype) {
        CallRegister::unregister($i, $packet['ip']['header']['dst'], $packet['ip']['header']['src']);
    }
}