|
|
 |
 |
|
|
 |
|
sniffer技术原理及应用(1)
|
|
|
|
编辑:华夏媒体 作者:未知 来源:网络 时间:2006-07-29 总浏览量:1531 |
|
文字大小:[ 大 中 小 ]
文字颜色: 双击滚屏/单击停止 |
|
[上一页] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [下一页]
|
corresponding code error status = STATUS_INSUFFICIENT_RESOURCES;
}
if(ipFileObject != NULL) ObDereferenceObject(ipFileObject); ipFileObject = NULL; ipDeviceObject = NULL; }
else
return status; } //真正的过滤函数是这个,在最早的IRPdispatch里面传递的这个函数。 //这个函数就是系统传递了一个包头和包内容和包长度之类的东西,你可以在里面进行一些处理, //假如你想让这个包通过的话,就返回PF_FORWARD,或者你不想让包通过的话,就返回PF_D
ROP就拦住了。是不是 //听起来很简单, PF_FORWARD_ACTION cbFilterFunction(IN unsigned char *PacketHeader,IN
unsigned char *Packet, IN unsigned int PacketLength, IN unsigned int
RecvInterfaceIndex, IN unsigned int SendInterfaceIndex, IN unsigned long
RecvLinkNextHop, IN unsigned long SendLinkNextHop) { IPPacket *ipp; TCPHeader *tcph; UDPHeader *udph;
int countRule=0;
struct filterList *aux = first;
//we "extract" the ip Header ipp=(IPPacket *)PacketHeader;
// dprintf("Source: %x\nDestination: %x\nProtocol: %d", ipp->ipSource,
ipp->ipDestination, ipp->ipProtocol);
//TCP -> protocol = 6 //we accept all packets of established connections if(ipp->ipProtocol == 6) { tcph=(TCPHeader *)Packet;
// dprintf("FLAGS: %x\n", tcph->flags); //if we havent the bit SYN activate, we pass the packets if(!(tcph->flags & 0x02)) return PF_FORWARD; }
//otherwise, we compare the packet with our rules while(aux != NULL) { // dprintf("Comparing with Rule %d", countRule);
//if protocol is the same.... if(aux->ipf.protocol == 0 || ipp->ipProtocol ==
aux->ipf.protocol) { //we look in source Address if(aux->ipf.sourceIp != 0 && (ipp->ipSource &
aux->ipf.sourceMask) != aux->ipf.sourceIp) { aux=aux->next; countRule++; continue; } // we look in destination address if(aux->ipf.destinationIp != 0 && (ipp->ipDestination
& aux->ipf.destinationMask) != aux->ipf.destinationIp) { aux=aux->next;
countRule++; continue; } //if we have a tcp packet, we look in ports //tcp, protocol = 6 if(ipp->ipProtocol == 6) { if(aux->ipf.sourcePort == 0 ||
tcph->sourcePort == aux->ipf.sourcePort)
|
|
[上一页] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [下一页]
|
|
|
打印 收藏 关闭 至顶部 |
|
 |
|