I have a standard web server that serve web pages.
I want to monitor traffic on port 80, intercept every http responses, and add/inject an additionnal header to them.
The process will then act like a proxy between the web server and the client.
Could you please give me some pointers? I'm already aware of SharpPCap, but I'm not sure where to start.
Note: I can't rely on the web server, I can't control it or change it's configuration. However I can install any other process on the same machine.
Thanks a million
I think that SharpPCap is an overkill here.
Try:
listen on a port (say 8080)
for each incoming connection, accept and open one to the server (original one, port 80)
pass everything that comes in from the client straight to the server
pass everything that comes from the server back to the client, monitoring the stream and injecting/modifying if needed
I think what you want to do can be done with IIS 7.0 URL Rewrite module instead of rolling your own code.
http://learn.iis.net/page.aspx/711/modifying-http-response-headers/
Related
I'm not a network expert, but for one of my projects, I need to ensure that the website I'm sending the request to is alive. Some websites do not respond to ping; basically, their configuration prevents response to ping requests.
I was trying to Arping instead of pinging websites, but Arping only works on the local network and will not go beyond the network segment (this).
I can download the whole or part of the webpage and confirm if the content is the same as the previous state, but I rather have one more level of confirmation before downloading Html.
Is there any other method that enables the app to get a response back from non-pingable websites outside the network?
Based on common practices you may use ping, telnet and tracert as a client to the requested server (at this point the website or the service you want to connect) and make sure the 3 command are enable to your side. You may also try to access it to your browser.
If its API you may also try to use POSTMAN and call the service.
Goodluck and happy coding :)
First of all, I'm completely open to suggestions for alternative strategies, since this is not a space I'm hugely familiar with.
I have what I think is a simple problem. I have a client app and a server app, and I want to send a bunch of files from the client to the server. I don't want to require the user to set up file shares or anything, so my thinking was:
I'll have an app on the "server" using HttpListener to listen to file transfer requests from the client.
I'll have an app on the client using WebClient.UploadFile to initiate the transfers.
Twist: The server is a Mac, and I need to use things that are supported by Mono. I'm not looking to have the server install ASP.NET / IIS / whatever. In fact, the less the user has to do, the better. (The user in this case will be in control of both the client and the server, by the way.)
So, short questions:
Is there a better/easier way than WebClient/HttpListener to send a bunch of files from one machine on a LAN to another? TCP-something? Sockets-something-or-other? (You can see my ignorance.)
Assuming I use HTTP, are there more straightforward ways to download files than using an HttpListener and manually parsing the requests to get rid of headers, etc.?
I wanted to know what is the best way to write an agent on Win platform that will be able to monitor browser's communication.
scenario: monitor the user access to predefined url on Chrome, FireFox and IE. On each hit I send the stats to a server with some data (page title).
The ways I found so far are proxy and browser addons. Each has it's own advantages and disadvantages. The main disadvantage of the proxy way is handling of HTTPS communication. The addon disadvantage is the installation (need to install on every browser) and cross-browser support.
Is there another way? some service I can write with .net that will automatically hook on a browser when it is started?
Thanks you.
You do have only two choices - an http proxy, or to write a plugin for every browser. That plugin could just forward data via network to a central service, leaving you with the challenge of coming up with a common set of data that all browsers can provide, plus learning all the plugin models.
In my opinion, though, the only real option is an HTTP(s) proxy because otherwise you have to keep updating your plugins every time browsers change, or deal with the fact that new browsers can come along and be used.
Certainly you won't find a 'user is browsing a url in some browser' event in the OS - all it knows is that a socket connection has been opened on some local port to a remote server's port 80/443 (or whatever).
So I strongly suggest building on top of the excellent work that's behind Fiddler and use the Fiddler Core.
http://www.telerik.com/fiddler/fiddlercore
For https you have to decrypt and re-encrypt with a different certificate. The information that you need is just not available without actually unpacking the request. Fiddler achieves this by opening it's own SSL tunnel to the target server on the client's behalf, whilst acting as an SSL server to the client under a different certificate. So long as the certificate that it uses is fully trusted by the client, no problems occur.
That said, it means that the user cannot personally verify the identify of the target site - therefore your system would have to assume worst case scenario for any invalid SSL certificates and block the connection.
I'm working on a project that has a C# app (running 24/7 as a server) on the client's machine). This app needs to send a file as a byte stream via POST to a server I am currently hosting on my home desktop.
Can this file be received by a C# app running on my server, or does it have to be as ASP app/page?
Also, I know how to send a bytestream via POST, but how will I set my server side app to listen for this incoming data?
I have never done something like this, so I'm looking for some pointers to get me started.
Thanks
Depending on what you need to do with the file, and when it's uploaded, there is nothing wrong with using a tiny asp.net app to do this.
If the only way you can get the file to the server is via http POST, why write your own service/daemon to run a listener? Unless you have some reason not to run it in IIS, I would do it there. There is the full stack available that way for authentication and so on if you should happen to need it. Besides, if you have to upload files via http post, I would bet you will end up wanting other methods available via HTTP as well..
You're looking for this guy:
http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
Using that, you'll create basically a mini HTTP server, listening on some port you specify. You'll then be able to post data to it, and process it accordingly (similar to if the processing code was in an ASPX code-behind).
Assuming your open to sending directly via TCP you can look at this example if you dont wanna go the HTTP way. I personaly like the NetworkStream Class, for sending data over the network painfree.
iam using c#,asp.net and iis, i want to simulate slow internet connection on my pc for testing my app.
is it possible i can control bandwidth of iis.
please dont suggest
System.Threading.Thread.Sleep(someDuration);
in c# file.
You can run Fiddler and use its connection throttling to simulate a slow connection.
Note that you'll need to browse to your machine name, not localhost. (localhost. should also work)
Fiddler will do this for you.
You could find or create a proxy that provides file-configurable or UI-modifyable speed controls. The proxy would get the request from the client, make the request to the server, receive the response, then s-l-o-w-l-y send the response to the client. (It would probaly use some sort of Thread.Sleep(x) in between sending each byte of the response to the client.)
After searching a little on the internet, I found no freeware/FOSS on win32 that does the job for arbitrary ports.
I have a server under tests that listens on port 13000 and a client under test that has a configurable sending port. Many tools, designed for web only, make a throttling tunnel from port 80 to something configurable, but my server will never listen on port 80..
Anyone knows something like unix 'tc' command?
This isn't linked to C#, but I would suggest to slow down the system network (or the vm network ..) instead, it should be much easier to play around.
In linux, we can use tc.
sudo tc qdisc add dev wlp3s0 root netem delay 500ms
To turn it off:
sudo tc qdisc del dev wlp3s0 root netem
Source: http://jvns.ca/blog/2017/04/01/slow-down-your-internet-with-tc/
https://linux.die.net/man/8/tc