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 | 简书: 一月二十三