阅读:1418回复:2
请问:包转发和SSL的问题
前段时间,基于Jeffrey Richter的书里提到的hook技术,在用户空间拦截,实现SSL VPN对现有应用程序的TCP支持,但是对于UDP和netbios不能很好地支持。因此,想在低层一点做。
在kernel mode,不知道该用tdi还是ndis-im。tdi需要对tcp/ip, udp/ip, rawip等分别处理,在ndis-im,对所有的包处理。基于SSL实现加密隧道,一般ssl库(openssl)是在用户空间的呀,如果我想做的底层一点,还有什么可以参考的吗? 另外,我基于http://www.wd-3.com/121503/ExtendingPassThru2.htm做的转发试验总是不成功,这是我在pcausa讨论组问的问题,请帮我分析一下: my xp box is 10.1.1.176, the target box is 10.1.0.232 I redirect 10.1.1.232 to 10.1.0.232 I am running tcpdump on the target box: 19:59:38.517324 10.1.1.176.1803 > 10.1.0.232.ssh: S 2425191351:2425191351(0) win 64240 <mss 1460,nop,nop,sackOK> (DF) 19:59:41.462994 10.1.1.176.1803 > 10.1.0.232.ssh: S 2425191351:2425191351(0) win 64240 <mss 1460,nop,nop,sackOK> (DF) 19:59:47.498883 10.1.1.176.1803 > 10.1.0.232.ssh: S 2425191351:2425191351(0) win 64240 <mss 1460,nop,nop,sackOK> (DF) I connect 10.1.0.232 directly: 20:00:14.358847 10.1.1.176.1804 > 10.1.0.232.ssh: S 2433410273:2433410273(0) win 64240 <mss 1460,nop,nop,sackOK> (DF) 20:00:14.358933 10.1.0.232.ssh > 10.1.1.176.1804: S 3307192023:3307192023(0) ack 2433410274 win 5840 <mss 1460,nop,nop,sackOK> (DF) ...... So, the target box does not send ack to my xp box. Why? I modify the http://www.wd-3.com/121503/ExtendingPassThru2.htm code. I do a little change: 1. I preserve the routine of the FltFilterReceivePacket and FltFilterReceive function, just comment: // // Do Binary Search On Sorted List Of IP Addresses To Block // // if( bsearch( // &PktSrcAddr, // Key To Search For // (pFilterContext->pIPv4BlockAddrArray)->IPAddrArray, // Array Base // (pFilterContext->pIPv4BlockAddrArray)->NumberElements, // Number Of Elements In Array // sizeof( ULONG ), // Bytes Per Element // IPv4AddrCompare // Comparison Function // ) //) // { // // Reject Packets That Have Matching IP Source Address // //++pFilterContext->IPv4Stats.PTRcvPktDropped; // SpinLock Already Held //RcvFltAction = RCV_FLT_BLOCK_PACKET; // } 2. modify the FltFilterSendPacket function. if( bsearch( &IPHeader.ip_dst.s_addr, // Key To Search For (pFilterContext->pIPv4BlockAddrArray)->IPAddrArray, // Array Base (pFilterContext->pIPv4BlockAddrArray)->NumberElements,// Number Of Elements In Array sizeof( ULONG ), // Bytes Per Element IPv4AddrCompare // Comparison Function ) ) { // // Reject Packets That Have Matching IP Source Address // //++pFilterContext->IPv4Stats.MPSendPktsDropped; // SpinLock Already Held //SndFltAction = SND_FLT_BLOCK_PACKET; DbgPrint("destine ip is 0x%X", IPHeader.ip_dst.S_un.S_addr); ModifyOnPacket(pSendPacket); FltReadOnPacket( pSendPacket, &IPHeader, sizeof( IPHeader ), sizeof( struct ether_header ), &NumberOfBytesRead ); if( NumberOfBytesRead != sizeof( IPHeader ) ) { goto ExitTheFilter; } DbgPrint("destine ip is 0x%X", IPHeader.ip_dst.S_un.S_addr); DbgPrint("CheckSum is 0x%X\n", IPHeader.ip_sum); } What's wrong in my code or what else should I do? |
|
沙发#
发布于:2004-03-18 17:46
我用tcpdump再次观察,发现:(10.1.0.159和10.1.0.158是同一台机子的同一个网卡的两个ip)
我从10.1.0.158转向10.1.0.158,中间我也修改了dst_ip,以及重新计算了sum,可以; 17:27:33.636607 oyk.prospero-np > 10.1.0.158.ssh: S 854089020:854089020(0) win 64240 <mss 1460,nop,nop,sackOK> (DF) 4500 0030 f8a7 4000 8006 ebd0 0a01 01b0 0a01 009e 05f5 0016 32e8 5d3c 0000 0000 7002 faf0 dbaf 0000 0204 05b4 0101 0402 17:27:33.636656 10.1.0.158.ssh > oyk.prospero-np: S 4237364942:4237364942(0) ack 854089021 win 5840 <mss 1460,nop,nop,sackOK> (DF) 4500 0030 0000 4000 4006 2479 0a01 009e 0a01 01b0 0016 05f5 fc91 0ece 32e8 5d3d 7012 16d0 b45f 0000 0204 05b4 0101 0402 但是我从10.1.0.159转向10.1.0.158都不行, 7:25:29.308858 oyk.1457 > 10.1.0.158.ssh: S 819893533:819893533(0) win 64240 <mss 1460,nop,nop,sackOK> (DF) 4500 0030 f501 4000 8006 ef76 0a01 01b0 0a01 009e 05b1 0016 30de 951d 0000 0000 7002 faf0 a61b 0000 0204 05b4 0101 0402 158并没有反馈ack给我的xp box,不懂为什么?我读了报文,觉得没问题呀 |
|
板凳#
发布于:2004-03-19 11:14
我发现是我没有计算tcp checksum的问题,现在又进了一步,但是还是不通,请大家指点!!
我加了tcp的checksum,现在出错在握手的第三步, The error info: 10:40:14.639305 10.1.1.176.1664 > 10.1.0.158.ssh: S 3260414032:3260414032(0) win 64240 <mss 1460,nop,nop,sackOK> (DF) 4500 0030 3b7b 4000 8006 a8fd 0a01 01b0 0a01 009e 0680 0016 c255 f850 0000 0000 7002 faf0 b0a2 0000 0204 05b4 0101 0402 10:40:14.639358 10.1.0.158.ssh > 10.1.1.176.1664: S 2757802783:2757802783(0) ack 3260414033 win 5840 <mss 1460,nop,nop,sackOK> (DF) 4500 0030 0000 4000 4006 2479 0a01 009e 0a01 01b0 0016 0680 a460 bb1f c255 f851 7012 16d0 3532 0000 0204 05b4 0101 0402 10:40:14.639486 10.1.1.176.1664 > 10.1.0.158.ssh: R 3260414033:3260414033(0) win 0 4500 0028 3b7c 0000 8006 e904 0a01 01b0 0a01 009e 0680 0016 c255 f851 c255 f851 5004 0000 1dac 0000 0000 0000 0000 第三步,应该是给个ACK,但是给的是RST,为什么? 另外,应答序列号应该是 "a460 bb20",但是却给了个“c255 f851”,为什么? 请高手指点!! thanks |
|