Created
July 12, 2020 10:41
-
-
Save songritk/68c7fdb8064e6e7ac15ffaeb274967da to your computer and use it in GitHub Desktop.
cut pcap file header
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<fstream> | |
using namespace std; | |
int printhex(char c){ | |
if(int(c) < 0) { | |
printf("%02x",int(c^0xffffff00)); | |
}else{ | |
printf("%02x",int(c)); | |
} | |
return 0; | |
} | |
int main(){ | |
char x; | |
int count=0; | |
ifstream ifs; | |
streampos pos; | |
streampos stop_pos; | |
ifs.open("arp-1_anon.pcapng", ios::binary|ios::in); | |
ifs.seekg(0, ios_base::end); | |
stop_pos=ifs.tellg(); | |
ifs.seekg(224, ios_base::beg); | |
pos=ifs.tellg(); | |
while(pos!=stop_pos){ | |
if(count%104==0){ | |
cout<<"\n"; | |
} | |
ifs.read(&x,1); | |
printhex(x); | |
pos=ifs.tellg(); | |
count++; | |
} | |
ifs.close(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment