I have a C# application and I want to capture outgoing http requests that have been made through the application (I can also identify that it was from the app because I have a specific server name).
When searching on the web all I could find was capturing incoming requests (so the code is on the server side) with TcpListener and HttpListener.
But the code must be client side so it must be outgoing requests.
And I cannot use any third party libraries (like FiddlerCore for example).
So I'm really looking for a code sample to start from.
Do you want to store the request or just access it for debugging?
If you are going after debugging, then you can use Fiddler. Fiddler is an HTTP debugging proxy server application. And if you are planning to modify or read data in the request or the response you can use HTTPRequestWrapper and HTTPResponseWrapper to access.
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 :)
I have a TCP-client written in C#, which sends HTTP requests. When I am sending requests I don't see them in Fiddler. When I send similar requests from Http requester I can see all requests.
What is the reason?
Fiddler registers itself as the default HTTP proxy. Applications are free to ignore that proxy. Your code needs to cooperate with Fiddler. It needs to find out what proxy is set and use it.
The built-in HTTP classes in .NET do that.
I want to write a little c# tool for a web application (which runs inside a browser). Unfortunately, I have no idea how to hang into the HTTP communication.
There are a lot of tools that listen to network traffic and extracting relevant data out of it so I guess there must be a solution. My current approach is to catch the responses by listening on the corresponding port. But:
HTTPListener seems to be a server-side class that accepts HTTP requests
HTTPRequest is just the message object and has to be received before
I don't think TCPListener would be applicable because I don't want to create a connection
Is there another solution how to just get the server response without sending a request? Or might another approach be more reasonable?
I don't want to write a proxy because I simply don't want a server, just a lightweight, easy-to-use tool.
I was not able to find any hints on this topic since all results of my searches were about receiving responses to own requests or similar.
Thanks in advance for any solutions or suggestions!
Phil
If you don't got the idea of the tool, here is an example:
A user has firefox running and navigates to the target web application
He does anything and the web application sends the corresponding data to the web server
The web server processes the request and sends back a response
The web application updates itself inside the browser to display the received data
My tool (C# application) should do the following:
Catch the response of step 3 and evaluate the response to also update its own state
OR: do anything else (suggestions?) to keep its state up-to-date
I have created a WCF server in a PC named PC1. I access the URI http://PC1:8000/ServiceModelSamples/Service using internet explorer from another PC named PC2.
When I debug the messages in Wireshark, I am confused that why there is no HTTP message, even though I specify "http://" in my URI. It only shows TCP protocol, there is no HTTP message or header.
Please advice
To wireshark, any browser request is just another TCP connection. As far as showing the HTTP protocol details is concerned, it might be guessing that traffic on a specific port (80) would be http. Since you are using a non-standard http port, it might not be able to do so.
To confirm this, try loading some other website/webpage (e.g. www.google.com) and see if it is able to show you http details. If it works, then next thing would be try and find some setting/configuration by which you can tell wireshark that it should treat traffic from another port (8000 in your case) as http traffic.
EDIT:
See this question as a guide to configure wireshark for http ports.
HTTP is an application layer protocol that sits on top of TCP, the transport layer protocol.
See http://en.wikipedia.org/wiki/TCP/IP_model for more information.
When you access the service using a browser, a "friendly" service responds to generate a web form to your browser. If you get a web page back in your browser, it is HTTP. That's not part of the "SOAP" spec, but it is part of the MS WCF stack supporting HTTP.
Then, if you fill it out, you might be POSTing or GETing the form, but POST is the default. That's also HTTP. GET is often disabled in WCF.
Then, you get back XMLish stuff in your browser, that also came by HTTP.
So you might just be missing an HTTP protocol decode in wireshark.
EDIT: I didn't see your URL included :8000. Wireshark won't decode that as HTTP unless you force it to, because it's not on the HTTP port. You can right-click on a port 8000 packet and say "follow conversation", and you'll see all the http goodness. You can also force wireshark to decode that stream as HTTP, which will let you "drill into" the packets past the TCP layer.
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/