Click here to Skip to main content
Licence GPL3
First Posted 23 Oct 2007
Views 50,300
Downloads 3,092
Bookmarked 108 times

Internet Traffic Firewall and Sniffer

By | 23 Oct 2007 | Article
The article demonstrates internet packets interception with firewall capabilities based on IpFilterDriver driver and sending TCP/UDP/ICMP packets using raw sockets with IP spoofing support.

Introduction

Some time ago, I developed a Sniffer/Firewall GUI application which allows monitoring internet traffic, sending raw TCP/UDP/ICMP packets with any source IP you'd like using raw sockets. It is based on IpFilterDriver. I used Developing Firewalls for Windows 2000/XP article when studying how to intercept internet traffic and wrote a simple driver with Windows 2000 DDK for that purpose. I developed and used it successfully under WinXP. However, I recently migrated to Vista and it is not able to intercept internet traffic under that OS but is executing all functions without error. The Vista firewall does not use IpFilterDriver as it is disabled and I do not use any additional ones. However I tried to turn off Vista's firewall but the interception still did not occur.

Background

You need to have an understanding of TCP/IP for sending raw packets and interpreting intercepted traffic contents. If you'd like to extend the developed driver and figure out why it does not capture packets under Vista, you should have experience with DDK.

Using the Code

The MFC application is developed with SDI Document/View architecture. Go to FireWall menu and click IPhookON. This will start the userdrv.sys driver and IpFilterDriver. The first one is developed by me to intercept packets using ipfltdrv.sys windows driver. If no errors are encountered you'll notice IpFilter: ON displayed at the status bar right corner. To stop interception click IPhookOFF. The same procedure applies if you want to enable raw sockets, click Packs->StartRAW. After rawsock: ON notification in the status bar you'll be able to send raw sockets. Just go to Packs->IP4 menu and choose TCP, UDP or ICMP one. The two wide edit boxes in the middle of the dialog are source and destination IPs in text format like 127.0.0.1. The same for the ports, first is the source and second edit box is the destination one. The bottom large edit box is for the text message you want to send (currently supports only text data, just meddle with the code to add binary).

Through the Settings... menu you can control FireWall parameters sent to userdrv.sys.

firewall settings

Drop TCP SYN and drop TCP RST enable it to drop incoming TCP SYN packets and outgoing TCP RST packets. The latter is useful if you initiate connection with raw sockets and prevent windows from sending reset packets to the remote host. Drop ICMP * tells the driver to drop incoming ICMP packets of the corresponding type. UDP range is the allowed interval of incoming UDP packets ports. You can also log packets to windows\pmyfire.log file by checking the bottom box.

You may also use promiscuous mode to track the packets using FireWall->PromiscON but without controlling the traffic.

The additional helper classes I developed in the project are:

  • CPacket
  • CDriver

With CPacket class you can send TCP, UDP and ICMP raw packets.

int sendudp(SOCKET s, ip4_header *, 
    udp_header *, char *data = 0, int size = 0);

int sendtcp(SOCKET s, ip4_header *, 
    tcp_header *, char *data = 0, int size = 0);

int sendicmp(SOCKET s, ip4_header *, icmp_header *);

With CDriver class you can start, stop, send IOCTL codes to system drivers and remove them from the registry.

bool drvStart(LPCTSTR, LPCTSTR servpath = 0, 
    LPCTSTR linkname = 0, LPCTSTR info = 0);

DWORD drvIOCTL(DWORD code, LPVOID in = 0, DWORD inlen = 0, 
    LPVOID out = 0, DWORD outlen = 0);

bool drvStop(LPCTSTR servname = 0, DWORD timeout = 30000);

bool drvDelete(LPCTSTR servname = 0);

Just have a look at the CSnifferDoc class on how to use them properly.

Points of Interest

The nice feature you may find in the context menu clicking on a particular packet. You may actually create a fake connection by using CSnifferDoc::Onsynack, CSnifferDoc::Onack, CSnifferDoc::OnPshack, CSnifferDoc::OnFinack. Do not forget to drop outgoing TCP reset packets. The intruder thinks you have got a lot of open ports (depends on which SYN you reply ACK) to his delight and rubs his hands! You may confuse him quite a lot by sending fake data also. Works fine in text messages after he got himself 'connected' to port 80.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

About the Author

Chesnokov Yuriy

Engineer

Russian Federation Russian Federation

Member

Former Cambridge University postdoc (http://www-ucc-old.ch.cam.ac.uk/research/yc274-research.html), Department of Chemistry, Unilever Centre for Molecular Informatics, where I worked on the problem of complexity analysis of cardiac data.
 
As a subsidiary result we achieved 1st place in the annual PhysioNet/Computers in Cardiology Challenge 2006: QT Interval Measurement (http://physionet.org/challenge/2006/)
 
My research intrests are: digital signal processing in medicine, image and video processing, pattern recognition, AI, computer vision.
 
My recent publications are:
 
Complexity and spectral analysis of the heart rate variability dynamics for distant prediction of paroxysmal atrial fibrillation with artificial intelligence methods. Artificial Intelligence in Medicine. 2008. V43/2. PP. 151-165 (http://dx.doi.org/10.1016/j.artmed.2008.03.009)
 
Face Detection C++ Library with Skin and Motion Analysis. Biometrics AIA 2007 TTS. 22 November 2007, Moscow, Russia. (http://www.dancom.ru/rus/AIA/2007TTS/ProgramAIA2007TTS.html)
 
Screening Patients with Paroxysmal Atrial Fibrillation (PAF) from Non-PAF Heart Rhythm Using HRV Data Analysis. Computers in Cardiology 2007. V. 34. PP. 459–463 (http://www.cinc.org/archives/2007/pdf/0459.pdf)
 
Distant Prediction of Paroxysmal Atrial Fibrillation Using HRV Data Analysis. Computers in Cardiology 2007. V. 34. PP. 455-459 (http://www.cinc.org/archives/2007/pdf/0455.pdf)
 
Individually Adaptable Automatic QT Detector. Computers in Cardiology 2006. V. 33. PP. 337-341 http://www.cinc.org/archives/2006/pdf/0337.pdf)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionCan you send sniffer.rc2 file? PinmemberMember 2688480:03 14 Nov '11  
GeneralRejecting outgoing ip connections Pinmemberseer_tenedos212:08 2 Jun '10  
GeneralRe: Rejecting outgoing ip connections PinmemberChesnokov Yuriy22:15 2 Jun '10  
Generalbad word filter to protect my kids. with [***********] 's PinmemberZUPERKOOL9:13 7 Feb '10  
AnswerRe: bad word filter to protect my kids. with [***********] 's PinmemberChesnokov Yuriy20:23 7 Feb '10  
General[Message Deleted] Pinmemberit.ragester21:55 2 Apr '09  
Generalres folder has been missed Pinmemberhakem7:30 13 Feb '09  
AnswerRe: res folder has been missed PinmemberChesnokov Yuriy20:17 19 Feb '09  
GeneralDRIVER_IRQL_NOT_LESS_OR_EQUAL PinmemberKerem Guemruekcue7:22 29 Jun '08  
Answerdata compression program to gui Pinmembergeetikasuri6:32 10 Dec '07  
GeneralI'm sorry... PinmemberSlimFast200023:06 23 Oct '07  
GeneralRe: I'm sorry... demo.zip should be uploaded PinmemberChesnokov Yuriy0:17 24 Oct '07  
GeneralRe: I'm sorry... demo.zip should be uploaded PinmemberSlimFast20000:59 24 Oct '07  
Generalsniffer_demo.zip PinmemberChesnokov Yuriy22:01 23 Oct '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 24 Oct 2007
Article Copyright 2007 by Chesnokov Yuriy
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid