How to catch a flash stream url from browser plugin - browser

My question has similar point like this one.
I’m wondering how I can catch a media URL which SWF loads from browser add-on. Let’s say YouTube flash player starts playing or loading some video (let it be via http) and I want to know that url. Just like browser plugins from “RealDownloader” and “Moyea YouTube FLV Downloader” does. I’m newbie with plugin development and flash and I want to know what technologies it may be. XPCOM, NPAPI, ActiveX, or simple API hooking. Any ideas how this may be accomplished?

NPAPI plugins typically ask the browser to load data for them, they don't do it themselves. This means that a browser extension can intercept these requests. This can be done for example by implementing a content policy. Requests initiated by a plugin will cause a shouldLoad call with type OBJECT_SUBREQUEST.
The simpler option is using HTTP observers - but this way you won't recognize requests initiated by Flash, they will look just like any other request processed by the browser.

Firebug does that, and it's open source. Why not study it a little?
https://github.com/firebug/

It's easy if you only want to get the url from a single swf in a single website. for example if all you need are urls from that swf,you can keep only one instance of your browser open and use a tool to intercept its http requests.

Related

Register custom file protocols in Chrome/Firefox extension?

I want to register a custom file protocol in Chrome or Firefox, much like the way Electron does (please see their API for doing this: https://www.electronjs.org/docs/api/protocol). I am wondering if there is a way to implement this as a browser extension, or I have to modify the source code of the browsers.
I expect that the API would look like this (just a pseudocode to help explain what I mean):
registerHandler('myprotocol://', req => {
response('<body>You requested: ' + req.url);
});
Clarification: navigator.registerProtocolHandler is NOT what I need. What it does is to register a protocol that, when clicked, opens an external application to deal with that. But what I want is a protocol handler scheme that works in a request--response way, e.g. can be used in JS/CSS/HTML queries and responds with a content that can be rendered within the browser.
I would answer my own question because I found exactly what I need here: https://github.com/mozilla/libdweb
This is an experimental feature of Firefox Nightly that allows one to register a custom protocol and serve all requests to that protocol using firefox addon. This is not a WebExtension standard nor does it work on browser other than Nightly, but I'm glad to hear that someone is doing this.

How can I communicate in a secure way with my firefox extension

I am working on a webpage that depends on browser extensions to perform certain tasks.
From the webpage I can communicate with the chrome browser using 'externally_connectable' and:
chrome.runtime.sendMessage(string extensionId, any message, object options, function responseCallback)
The good thing here is that from the point of view of my website I am sure I am communicating with my extension and not with a 'reverse engineered' version of my extension.
In firefox extensions however there is no support for externally_connectable and I have to use events or window.postmessage:
const event = new CustomEvent('msg-for-content-script');
document.querySelector('body').dispatchEvent(event);
This works ok, but the problem is that when somebody manages to reverse engineer my extension I am not able to check whether the extension I am communicating with is really my extension.
Is there anybody who can give advice on how to make sure that I am communicating with the right extension?

How to control web browser using some programming language?

I am looking for a way to control a web browser such as firefox or chrome. I need something like "selenium webdriver" but that will allow me to open many instances URL load, get http headers, response code, get response content, load time, etc.
Is there any library, framework, api that I could use to do it? I couldn't find one exactly that does all, selenium opens browser and go to url but I can't get http headers
Selenium and Jellyfish are strong options in general. Jellyfish is an option that uses Node.js - although I have no experience with it, I've heard good things from my colleagues.
If you just want to get headers and such, you could use the cURL library or wget. I've used cURL with NuSOAP to query XML web services in PHP, for example. The downside is that these are not functional browsers, and merely perform the HTTP requests and consume the response.
http://seleniumhq.org/
https://github.com/admc/jellyfish
http://curl.haxx.se/

how to perform a post through chrome extention?

How can I perform a post through the chrome extention, lets say I want to send the current tab page title to a webpage
You can do POST XHRs from chrome extensions to any URL, as long as you have host permissions defined in your manifest. See these docs.
In a chrome extension the best way to try and do what i think you want is via a content script see documentation a word of warning however pinging your server with a POST request every time someone with your extension installed opens a web page is going to be extremely heavy going on your servers especially if you have a lot of installs. A possible solution is to use the content script to keep tally of the sites a user visits and save this data in a HTML5 database (wich chrome supports) then using background.html sending the data at given intervals in bulk with an AJAX request, this will significantly cut down the number of times your server is pinged.

How can I pass a message from outside URL to my Chrome Extension?

I know there's a way for extensions and pages to communicate locally, but I need to send a message from an outside URL, have my Chrome Extension listen for it.
I have tried easyXDM in the background page, but it seems to stop listening after awhile, as if Google "turns off" the Javascript in the background page after awhile.
I think you may try some walk around and build a site with some specific data structure, and then implement a content script which will look for this specific that specific data structure, and when i finds one it can fetch the data you want to be passed to your extension.
Yes, you need a content script that communicates with the page using DOM Events.. Instructions on how to do that are here:
http://code.google.com/chrome/extensions/content_scripts.html#host-page-communication

Resources