LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How to export just source/destination field of pcap file into a plain text file (https://www.linuxquestions.org/questions/linux-networking-3/how-to-export-just-source-destination-field-of-pcap-file-into-a-plain-text-file-4175526212/)

kikilinux 11-22-2014 03:06 PM

How to export just source/destination field of pcap file into a plain text file
 
I have a pcap file which I want to extract specific fields into a text file.
for example I need to extract source and destination IP field from a pcap file into a file like bellow:
Code:

1079733053 453496064
1079733007 2326590059
1079733006 3827200703

Does it exist any way to extract these field just like above or any way same the above?

Keith Hedger 11-22-2014 04:36 PM

Take a look at awk.
P.S. Might have been helpful to include a sample of the source file you are trying to manipulate, asnot everyone will know the format of a pcap file.

nini09 11-25-2014 02:50 PM

Following link is pcap format, http://wiki.wireshark.org/Development/LibpcapFileFormat.
In packet data section, it should be normal Ethernet format.

Keith Hedger 11-25-2014 04:43 PM

Really doesn't help, I'm not going to spend a couple of hours trying to sort out the various fields from the data structures because you can't be bothered just to attatch an example file like you was asked for, I am just getting so fed up with peolple on these forums wanting it all done for them, they can't even be bothered to supply data and info they have been asked for by the people that they expect to help them.
I am un subscribing from this thread, good luck!

kikilinux 11-26-2014 10:30 AM

Dear Keith Hedger
Tnx to answer
Maybe I am still working on ur answer and I have not obtain any results.
Maybe if I got answer I tell ur answer was helpful.

kikilinux 11-27-2014 07:13 AM

I've employ wireshark to open pcap files and then export it as "plain text" file and then in packet format option I unchecked packet detailed.
The result file was as follow :
Quote:

1 0.000000 51.142.253.91 15.236.229.88 TCP 54 compaq-wcp > 22746 [SYN] Seq=0 Win=512 Len=0
It is enaugh for me to solve my problem.
To select source IP and destination IP I employed the bellow command:
Quote:

cat myfile | while read f1 f2 f3 f4 f5
do
// The code effects on f3 and f4
done
awk seems good tools, I am working on it for future purposes.


All times are GMT -5. The time now is 12:25 PM.