Is Perl really not good at this low level packet handling things?
Any other languages would have the same problem. The reason it's hard it's because p0f uses an undocumented communication format that varies from machine to machine.
I did adjust the bigendian to little endian on PC.
I thought that if you didn't specify one, it would use the machine's native byte order. Are you sure you need to specify the ByteOrder and alignments?
The pack did pack src, dst ip into query , but response always says no connection
IP addresses are usually big endian (i.e. in the same order as in dotted form) on all systems.
01 01 A8 C0
should be
C0 A8 01 01
(192.168.1.1)
Use tag to mark the appropriate fields as big endian. That means you should have:
my $c = Convert::Binary::C->new(); eval { $c->parse_file("p0f-query.h"); 1 } or die("Unable to parse p0f-query.h: $@\n"); $c->tag('p0f_query.src_ad', ByteOrder => 'BigEndian'); $c->tag('p0f_query.dst_ad', ByteOrder => 'BigEndian'); $c->tag('p0f_response.genre', Format => 'String'); $c->tag('p0f_response.detail', Format => 'String'); $c->tag('p0f_response.link', Format => 'String'); $c->tag('p0f_response.tos', Format => 'String');
The port might need to be big endian too.
In reply to Re^19: p0fq.pl and pack
by ikegami
in thread p0fq.pl and pack?
by macli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |