Packet sniffing - TechRepublic
General discussion
October 7, 2010 at 09:11 AM
karimkhan_it

Packet sniffing

by karimkhan_it . Updated 15 years, 9 months ago

Hi,
I am karimkhan , I have a problem with JPCAP. I get all packets using JPCAP library. Also i have installed winpcap.

Everything seems to be fine. but when i try to print the header and data of a packet, i get to see some junk characters. Guess its a machine language.

Packet pack = captor.getPacket();

if (pack instanceof TCPPacket) {
TCPPacket tcpPacket = (TCPPacket) pack;
System.out.println(tcpPacket.dst_ip);
System.out.println(tcpPacket.dst_port);
byte[] data = tcpPacket.data;
String isoData = new String(data); //, “ISO-8859-1”
System.out.println(“Packet :”+ isoData);
writer.writePacket(pack);

Output looks like :\��jh�٤&p����juqy��>~/a�.ε�ī5���B�=ٓ�=��[���_�rY]:���w�с���W��'{{O�6�eC<�a��GL ڢ��'�=�t�nE�j:n -o^{7�jbj�5���.����f�-tM�)t�8�*�t'�V쑀2Io(��) Al��700���P����U�b�w9�o��syWwso�z�%��x��}�f�A�J��w�<��R>�?+y������R_��ڂV�Im�e�l��=15�M��t��F}���֌
�8����WG�#uiz�^|�6��Y���]�pg��[!���o���GN_ٳ���H@�”qn��{ f��L������ȯ�d�.)������b껛�C�4�� S�1�M�;V��Ih^���2��U�Z�y��7}���E��[�>}�vq��_�/��
M�Q���ؿQWȠ8E}q!D:��:�ǟ�T���n�����;�t뽆~hs�&�E�1�a*���; ���������Spyu1C7�D[՚����w�/D{~v�D���{O���o|z�o�����frAC���L�zh������ .�”qn��{ f��~h���t�B��92� XW�N|=���-�W 0����n�Ѻ@?L�Č6F�����у�_�?�

The header and data is some junk. Can you help me out? What is the reason for this? How do i get a meaningful header and data of the packet after identifying the packet as TCP, UDP or ICMP etc..

This discussion is locked

All Comments