INetworkPacketParser
1.0.0
INetworkPacketParser
是一個輕量級的物件導向的TCP/IP
協定堆疊解析工具。
INetworkPacketParser
是一個輕量級的物件導向的TCP/IP
協定堆疊解析工具。
支援從網路傳輸的二進位資料轉換成OC物件`
IP Packet
封包解析TCP/UDP/ICMP
資料段解析DNS
封包解析(包括請求和回應封包) 支援將OC物件屬性修改,並轉換成可網路直接傳輸的二進位數據
IP Packet
封包構造及竄改TCP/UDP
的資料段構造及竄改resolv.lib
(CocoaPods自動安裝) 支援cocoapods安裝
pod 'INetworkPacketParser'
- (void)test {
// 网络二进制报文
NSString *hex = @"4500003c 734f0000 ff114f69 0a0a0a0a 72727272 cd240035 00284c24 63780100 00010000 00000000 03777777 0669636c 6f756403 636f6d00 00010001";
NSData *rawData = [self dataFromHexString:hex];
// IP数据包解析
IPPacket *packet = [[IPPacket alloc] initWithRawData:rawData];
if (packet.header.transportProtocol == UDP) {
// UDP解析
IPUDPSegment *udpSegment = [[IPUDPSegment alloc] initWithRawData:packet.payload];
if (udpSegment.header.destPort == 53) {
// DNS解析
IPDNSMessage *dnsMessage = [[IPDNSMessage alloc] initWithRawData:udpSegment.payload];
dnsMessage.dnsHeader;
dnsMessage.dnsQuery;
dnsMessage.dnsAnswers;
}
}else if (packet.header.transportProtocol == TCP) {
// TCP解析
IPTCPSegment *tcpSegment = [[IPTCPSegment alloc] initWithRawData:packet.payload];
}
}
smallyou, [email protected]
Github: smallyou | 簡書: 一月二十三