CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2012
    Posts
    25

    Question How to drop packet Using C++?

    Hi for all.
    I want to drop packets using C ++ based on the destination IP address
    For example: the packet to IP address 8.8.8.8 will be drop.
    Currently, I have captured packet network card using C++
    If anyone have any links or comments, please share with me
    thank you

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to drop packet Using C++?

    Are you planning a Packet drop attack?
    Victor Nijegorodov

  3. #3
    Join Date
    Jul 2012
    Posts
    25

    Re: How to drop packet Using C++?

    Quote Originally Posted by VictorN View Post
    Are you planning a Packet drop attack?
    Hi Sir .
    Not so
    I will have a list of banned IP, In my LAN, the packet if the same destination IP in banned list, drop the packet
    For example :
    List IP : 8.8.8.8
    123.456.789.123
    9.9.9.9

    Packet have IP destination 8.8.8.8 will drop
    Packet have IP destination 7.7.7.7 will not drop

    Currently, I have captured packet network card using C++ . Now, I need to find some C ++ code how to drop packets with IP destination
    I have read http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx . I think we dropped packet using based on Filter Hook Driver
    Thank sir .
    Last edited by headshot; September 7th, 2012 at 04:36 AM.

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: How to drop packet Using C++?

    Quote Originally Posted by headshot View Post
    Hi Sir .
    Not so
    I will have a list of banned IP, In my LAN, the packet if the same destination IP in banned list, drop the packet
    I don't think you will get an answer here on an open board such as this one, regardless of your intent. It's similar to someone asking "how do I prevent someone from stopping a running process" or "how do I get a process to always restart when someone kills the process". The person that asks these types of questions may not have bad intentions, but posting code to do such things can easily be taken by someone to create their own malicious applications.

    Regards,

    Paul McKenzie

  5. #5
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How to drop packet Using C++?

    In addition to what Paul already said about responsibility. The subject is indeed very sensitive and specific. Filtering packets is about network security in general. This kind of stuff itself is implied to be developed by people skilled enough in the subject. And being skilled enough immediately excludes any possibility for asking general/trivial/weird/non-professional questions on public boards. Sorry, no intention to offend, but you are to gain this kind of skills somewhere else. Besides, this particular forum never discusses kernel drivers stuff. As for C++, AFAIK, kernel drivers typically get written in pure C, just because Windows does not provide standard C++ runtime in kernel mode. Though, I may be wrong here, and something might change in Windows world for last few years.
    Best regards,
    Igor

  6. #6
    Join Date
    Jul 2012
    Posts
    25

    Re: How to drop packet Using C++?

    Hi Paul and Igor
    I am currently studying and researching. Thank you so much advice from you.
    I try to do a program packet filtering and blocking packet. Accordingly we block packets based on the destination IP address. This module is located at the Server, it can control the packet network card
    Currently I have built the captured packets into the network card based on Winsock
    I also have built a database destination IP banned list which packets forward.

    What I need to do now is find out how to delete the packet based on the destination IP address
    If you have many years of experience in C + +, you can put a few ideas to do this or a link where you can see it
    thank you again for your reply

  7. #7
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How to drop packet Using C++?

    You don't need to repeat the background in every message. As for the many years C++ experience, C++ itself has nothing to do with your problem. Imagine I have C++ experience but never dealt with network drivers, what kind of ideas I can put? It's a very beginner's thing to think that some language experience is equivalent to experience in a technology on some reason you are particularly interested in.
    Best regards,
    Igor

  8. #8
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: How to drop packet Using C++?

    it depends entirely how your code works now.
    If what you have now is a "monitor" or "sniffer", something that merely inspects passing packets between a sender and a receiver, then there may not be much you can do, if at all.

    If you are actually sitting "in between" the receiver and the sender, then the answer is simple, simply do not pass such packets along to the receiver, and you may or may not have to send failure/abort or other forms of no-reception to the sender.

    Without more details about what you're actually doing, it's impossible to give any clear recommendations.

    there are many ways in windows where you can intercept or momitor passing network traffic. This is affterall what stuff like filrewalls, proxy's and such do. All of these require administrative access to even install the approproate drivers, so security is for all intents and purposes a non-issue, if you have admin level access, you can do just about anything anyway.

    You can hook into the network API's,
    you can install your own filter driver
    you can install your own network card drivers
    you can use the proxy/firewall/throttling callbacks
    you can use TDI or write your own TDI filter
    write your own NDIS driver
    you can install your own protocols
    you wcan use the Windows Filtering platform
    etc etc etc...

    Most of this is all well documented, especially the higher level api's, the lower level api's tend to be more exotic.

    Networking is commonly said to have 7 layers (the "old" OSI model), there are documented API's, drivers, filters, hooks on pretty much every one of those levels, ... and then there are ways to patch into those drivers by less orthodox approaches.

  9. #9
    Join Date
    Jul 2012
    Posts
    25

    Re: How to drop packet Using C++?

    Hi Oreubens .
    I use sniffer in my computer . When i go to google.com in web browser such as firefox , IE ,etc.. Application will drop packet because IP google.com in banned IP .
    Name:  sshot-1.png
Views: 2498
Size:  21.3 KB .
    I have captured packet .
    I`ll using Filter Hook Driver drop packet follow IP destination
    I just find some link
    http://en.wikipedia.org/wiki/Network..._Specification
    http://en.wikipedia.org/wiki/Windows_Filtering_Platform (I think in here )
    Last edited by headshot; September 7th, 2012 at 10:50 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured