How to capture the network traffic generated by an applet in browser - language-agnostic

I want to find out how a java applet in a browser communicates with a server. Is possible to capture the network traffic?

Take a look at WireShark, it can do captures and protocol analysis, so it is probably what you want.
You just tell it to listen on your outgoing network interface, and it will capture the packets and allow you to view them. You will probably want to filter by the server IP, so you don't see all the other junk that is going on at the same time.

maybe you could use FireBug (Firefox extension) to monitor the traffic but I'm not sure if it works with Java Applets because applets run in the JVM. Give it a try.

Related

Monitoring headless Chrome

I'm using Chrome in headless mode via CDP (Chrome devtools protocol) to do HTML to PDF conversions. Works well but I do not trust Chrome to run forever and want to build a guardian service to monitor its responsiveness and if necessary kill the process and relaunch it.
What would be a good indicator of health? What I'm looking for is a low overhead test I can perform at fairly frequent intervals so that the restart latency is minimised.
I could try to perform some kind of CDP command if anyone has a suggestion and a reliable way to determine success.
I can't think of anything else, that's why I've thrown it open for suggestions.
My best suggestion for this case is to use the Target domain. Listening to some of the events that are fired from the target domain will give you some information regarding the state of your browser, such as TargetCrashed.
On top of that, you could use basic domains like Runtime (provides the evaluate method), SystemInfo or Browser to send the browser requests in order to check its health.

Video and audio stream - server to clients only

Is there a way to stream a video and audio on a website just to the clients, using a camera installed on the server - for instance, like youtube does ?
I've started reading webrtc, but if I use webrtc I should create a stun/turn server and other things, which for one way stream I think is not necessary (this is just my understanding of the things..) because I don't need anything from the clients, literally, neither their video, or audio..
So is there a way to achieve this using html5, streaming just in one direction:
server (camera) -> clients
Is there something about this out there, or should I stick with webrtc ?
I'm going to explain a possible solution for this scenario, there might be others, but I hope mine gives you a rough idea of how you could do it and a start point to explore more about the amazing possibilities of WebRTC. Please let me know if something is not understood.
So, WebRTC is a free, open project that provides browsers and mobile applications with Real-Time Communications (RTC) capabilities via simple APIs. Sweet, that is: WebRTC has a quite good browser support (not in every browser though, Safari just started supporting it a month ago with Safari 11). But in this case we want to use WebRTC in the server side. At the end of the day we can still think about peer-to-peer real time communication, where one of our peers is the server.
I don't know if you are familiar with Node.js, but I recommend you to write your Server app with it (<3 Javascript!):
There are a few libraries that wrap WebRTC functionality to be used in the server side, like node-webrtc and node-rtc-peer-connection.
But I recommend you to to take a look at electron-werbrtc, since
the others might be using deprecated methods or be incomplete.
electron-webrtc runs a headless Electron client in the background to
use Chromium's built-in WebRTC implementation. So with it you should
be able to access the Camera in your server and create a stream to be
served to the other peer (the browser).
All above would be the WebRTC related tasks, in this case: streaming video peer(server)-to-peer(browser).
Now, let's talk about signaling process, stun and turn.
Signaling: imagine now a scenario peer-to-peer with 2 browsers, they want to establish a direct connection and stream video and audio between each other. But they don't know each other, like if I don't know your home address, I can't send you a letter. So they need a service that helps them know each other, so they can have the other's IP. This should be done by what is called "a signaling server". If somehow you know the other peer IP, you wouldn't need a signaling server.
STUN/TURN: the scheme above works perfectly in a local area network where each peer has its own IP address and there are no firewalls and routers between them. But otherwise, you can have peers behind a NAT or firewalls, and then your signaling server won't be able to make both peers to discover themselves. If you have peers behind a NAT, you'll need a STUN server, and if you have peers behind firewalls you'll need a TURN server. This is a bit simplified, but I just want you to have the general picture of when you might need STUN/TURN servers.
To better understand Signaling, STUN and TURN, there is a very graphic article that explains them perfectly.
Now, for your scenario:
I think you prob don't need STUN/TURN servers and also you prob don't need to implement the signaling process, because the browsers that are supposed to receive the stream from the server will know that server address, right? So they can establish a WebRTC connection with it.
EDIT: it is likely that you will need to implement some sort of handshake between the server and the clients (browsers), so this will be the signaling process. This is not part of WebRTC and this is why you need to implement it yourself. As I said, it is the way 2 peers can discover each other, but they also exchange information as their local media conditions, like codecs, resolutions they can handle, etc. For your case, your signaling server could be hosted in the same server you use to strea: you can build a small node.js app that runs there and that manages all the signaling process easily, it is not a big deal. I recommend you to read this article, and specially the section "How can I build a signaling service?". In general all WebRTC articles from that site are very helpful.
Does this make sense to you? I think with it you can start digging a little bit more and see if with this is enough or you need to implement more stuff. Hope it helps!

How do web browsers monitor network of current open webpage?

Most modern browsers can display the network traffic of the currently open webpage and its dependencies in its dev tools.
When the browser sends the initial HTTP request for a webpage, it uses the response to display the webpage. A javascript file that the webpage depends on may send another request through AJAX.
Does the browser monitor the execution of the javascript file and display the subsequent requests in the original page's network log?
EDIT: For a bit of background, I'm trying to write a python program that will display all the network traffic generated by a webpage and its dependancies.
if you use chrome browser, you can use network feature on Developer tools.
through this feature, you can monitor all of network activities on page.
for monitoring execution of javascript, search firebug on google.
How do web browsers monitor network of current open webpage?
The short answer: the browser knows about all this, because it has to prepare and send/receive all requests to the webserver. That's his job, and involves much more than monitoring only.
Does the browser monitor the execution of the javascript file and
display the subsequent requests in the original page's network log?
The browser not only has to monitor the execution of the script, it has to execute the script itself. The script then forwards the subsequent request to that same browser, thus no need for the browser to monitor the script to get that information.
For a bit of background, I'm trying to write a python program that
will display all the network traffic generated by a webpage and its
dependancies.
Since this seems to be for educational purposes, you might want to start with writing a plugin for the browser to get an idea of what's happening inside (this will be mostly in JavaScript). In your plugin you can make direct API-calls to the browser-engine, or use call-backs to get notified when requests are made or pages/images arrive.
To monitor that traffic from within a stand-alone application, more work needs to be done. You'll have to sit somewhere in between the browser and your network card. This can be done by:
Writing some kind of proxy to catch and forward the HTTP-traffic and direct your browser to that proxy.
Using a library such as libpcap to catch all network traffic and analyzing the TCP-packets.

http trace utility

I need to trace/sniff http traffic from other machines (for example from my android phone or ios device). In the past I used MSSOAPT (described here http://www.devproconnections.com/article/net-framework2/microsoft-soap-trace-tool) and it was perfect, I need something similar, and now it should have syntax highlighting for json and be able to unzip content :).
I would like to tell my android to go to http://my.machine.home/Foo?bar and this proxy should forward this to other server such as http://google.com/Foo?bar and it should print complete trafic.
I would prefer if the solution would not require proxy configuration on my device, but just would forward all requests sent to the process.
and it does not have to be free
If you are on Windows, Fiddler as a great free tool.
On other platforms, you could use the free and open-source WebScarab. The UI is not as easy to use as Fiddler, and although it runs on Windows, I rather prefer Fiddler there.
Look at charle proxy it is very easy to use and has all your requirements fulfilled.

HTML5 Stress Testing

We have a webapp that's backed by a java spring web application. Apparently our Rational Robot tool that we normally would use to stress test a browser application doesn't deal with the HTML5'ness of our app. We are considering simply scripting the raw http requests to beat on the application, but wondering if anyone knows of any tools out there to do the same without having to craft all of the http requests by hand?
Apache JMeter allows you to record all http requests by setting it up as a proxy. You can then save those requests and play them back in multiple threads to simulate users.
Fiddler with our free stress testing add-on called StresStimulus is another proxy that records HTTP requests and replays them with configurable user ramping.
If you have anything a bit complex, it would be easier to record a script in one of the load testing tools. I have used WebLOAD in the past, which handles things like fetching all the sub-components, script correlation, AJAX recording, etc.
You can record straight from the Android device, or use a desktop browser you like.