Capture all packets sent from and to application - c#

I would like to capture all packets sent and received by application. Then edit some of them before they reach their destination (and delay them in some cases).
What is the best way to "inject" in that path of packets?
I want to do it with C++ and Windows api. (Maybe C# with pInvoke).

There'd no quick solution. You'll need a driver. Here's an example:
http://code.msdn.microsoft.com/windowshardware/NDISLWFSYS-Sample-NDIS-60-42b76875

Related

Is it possible to mix audio tracks on the fly constantly and stream the result to a browser?

I'm currently trying to work out how and if it's possible to mix audio tracks dynamically in a server environment and stream that result to a client/browser.
Scenario: Let's say we have 3 audio tracks: A, B, and C. I want to be able to mix these in and out on the server according to some code (running constantly) and push the resulting audio as a stream to a consumer/browser. Let's assume for simplicity that A, B, and C are 8 second, looping wav files playing simultaneously and that each of these needs to change in volume randomly at each iteration.
I've looked at SoX, icecast, and some other language specific libraries but so far I don't actually know how this would work. I can't wrap my head around the idea of streaming audio (with no beginning or end point) that is being dynamically rendered constantly, and how the layers would keep in sync with each other. I'm able to use PHP, C# or Node.JS as the backend coding language.
If anyone has any ideas for how to structure a program like this, I'd appreciate the tips.
One possible answer to your question may include a combination of buffering audio packets on the client side with WebAudio as well as sending packets from the server using BinaryJS, which is based on NodeJS. It is likely that other valid implementation strategies exist.

Using agsXMPP , can it send images?

I found this lib here
http://www.ag-software.de/agsxmpp-sdk/
hacked on this example here:
http://www.dotnetcurry.com/ShowArticle.aspx?ID=346
It works pretty well actually but I am wondering if one could rig up a message thats an image that would show up in the others (google talk client) or some other client for display? I poked around on the web, couldn't figure out definitively if this is possible...their site says the api supports XML-RPC, could that do it?
Just want to know im not going down a dead end for this functionality...if XMPP jabber even supports it.
This library seems not to support XEP 0231, the specification that "defines an XMPP protocol extension for including or referring to small bits of binary data in an XML stanza."

Including Javascript on all websites on machine

I noticed that when using a 3G dongle to access the web. A javacript script is included at the end of any page that I visit. but just for (html, htm, php, asp, aspx). The script adds the functionality to download reduced quality images instead of full size, to save on bandwidth. However, it's function is irrelevant to my question.
I need to be able to do the same thing. For any request that comes into my machine, I would like a javascript include. But not a BHO or browser extention.
Does anyone know how this is done?
You would probably need to write a Web proxy engine to achieve this. Then you would configure it as either a transparent proxy (perhaps you would need to implement a network card driver for this), or configure all browsers on the machine to direct traffic through the proxy.
A 3G dongle may achieve this through various means, e.g. a filter inserted somewhere in the driver software, or may be even some processing occurs right in the hardware (less likely in my opinion).
I think I am going to use FiddlerCore as a service to do this. It seems to be a nice clean way of doing this.
http://www.fiddler2.com/Fiddler/Core/

How to capture visited URLs and their html by any browsers

I want to find a decent solution to track URLs and html content that users are visiting and provide more information to user. The solution should bring minimum impacts to end users.
I don't want to write plugins for different browsers. It's hard to maintain.
I don't accept proxy method, since I don't want to change any of user's proxy settings.
My application is writen in C# and targeting to Windows. It's best if the solution can support other OS as well.
Based on my research, I found following methods that looks working for me, but all of them have their drawbacks, I can't determine which one is the best.
Use WinPcap
WinPcap sniffers all TCP packets without changing any of user settings but only requires to install the WinPcap setup, which is acceptable to me. But I have two questions:
a. how to convert TCP packet into URL and HTML
b. Does it really impact the performance? I don't know if sniffer all TCP traffic is overhead for this requirment.
Find history files for different browsers
This way looks like the easist one, but I wonder if the solution is stable. I am not sure if the browser will stably write the history and when it writes to. My application will popup information before the user leave the current page. The solution won't work for me if browser writes to history file when user close the browser.
Use FindWindow or accessiblity object or COM interface to find the UI element which contains the URL
I find this way is not complete, for example, Chrome will only show the active tab's URL but not all of them.
Another drawback is that I have to request the URL another time to get its HTML content.
Any comment or suggestion is welcome.
BTW, I am not doing any spyware. The application is trying to find all RSS feeds from web page and show them to end users. I can easily do that in a browser plugin but I really want to support multiple broswers with single UI. Thanks.
Though this is very old post, I thought to just give an input.
Approach 1 of WinPcap is the best one. This will work for any browser, even builtin browser of any other installed application. The approach will be less resource consuming too.
There is a library Pcap.Net that has HTTP parser. You can construct http stream and use its httpresponsedatagram to parse the body that can be consumed by your application.
This link helped giving more insight to me -
Tcp Session Reconstruction with Winpcap

Reading from USB device and sending queries to it, in C#

I've read this: https://stackoverflow.com/questions/1176053/, which was an insightful article.
However, I have no great background in WMI, and I found the large amount of documentation to be overwhelming. I can't find what I'm looking for.
The situation is that I have a device that will send data over the USB port, to the soundcard of the PC in question.
Consider camera-software. You connect your camera, start the program, and you can control the program with the camera, and vica versa. For instance, you can press a button on the camera and it'll start transmitting to the program. Or you can click a button in the program and it will start querying for data.
I need to find a way to query and catch this data, safely and correct.
It's probably a Stream of bytes, but searching for that doesn't produce any results.
I'm thinking I first need to somehow connect.
Then send the query.
Then receive.
However, connecting and querying both is something that I can't find in the example code, or the System.Management documentation on MSDN.
I don't think that WMI code would be relevant for you, I think that's just able to get out basic information about the device. If you want to actually read and send data to it you'll have to use different APIs.
When I've done any USB develoment it's been mostly using HID which is fairly straightforward, but I don't think you can transfer audio streams using HID, you'll need to use the Audio class driver. Though you might need to use HID to find out information about the soundcard.
Some useful links to get you started are:
Jan Axelson's website (author of USB Complete) - http://janaxelson.com/usbc.htm
A USB HID Component for C# - http://www.codeproject.com/KB/cs/USB_HID.aspx?msg=2004501
A USB library for .Net - http://www.icsharpcode.net/OpenSource/SharpUSBLib/
A Java sample for a webcam app - http://www.mutong.com/fischer/java/usbcam/
Here is another great one for reading and writing to USB devices:
http://winusbnet.codeplex.com/

Categories