FireBreath 2.0 with WebExtension

280 views
Skip to first unread message

Hau5

unread,
Aug 16, 2017, 3:50:25 PM8/16/17
to firebreath-dev
Got the web extension to work on chrome and IE. Firefox dropped NPAPI support and now supports Native Messaging using WebExtension. All I need to do is register or add the plug in but I cannot figure out how. I tried fixing the mimtype in the background.js file and using about:debugging but it didn't work. Also tried registering the mezolla.json that is in the debug file with no luck.. Anyone out there who has done this? 

Richard Bateman

unread,
Aug 16, 2017, 5:25:13 PM8/16/17
to FireBreath Dev Group
For the plugin itself, register or add it like a normal NPAPI plugin
and it should then work. the native messaging extension should get
installed by the _DevInstall target (in dev mode) but you need to make
sure your prod installer puts it where it needs to be.

Richard
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "firebreath-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to firebreath-de...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Billy Simon

unread,
Aug 16, 2017, 7:50:57 PM8/16/17
to firebre...@googlegroups.com
I've gone through the process of migrating to Firefox a Chrome Extension implemented along with a Native Messaging Host. Mozilla provides a very handy guide to migrating extensions from Chrome at https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging (Porting section).

In my case the Native Messaging Host binary worked as is with my Firefox extension. Registration of NMH for Firefox varies slightly. Firefox uses a different registry key than Chrome and Firefox NMH's manifest uses the key "allowed_extensions" instead of "allowed_origins". Also I think Mozilla maximum native message size is smaller than Chrome, at leas according to my tests.

Regarding the extension side In my case I just had make a few changes to the manifest file and repackage the extension files using xpi format (zip and rename with xpi exntesion). Firefox official namespace is "browser" instead of "chrome" namespace, but it also supports "chrome" namespace in order to easy porting. The process of publishing your extension is easier in Firefox because Mozilla allows you to self host your xpi. Mozilla just verifies your extension files and signs your XPI with their private key. The process is automated and takes a few seconds.




On Wed, Aug 16, 2017 at 1:42 PM, Hau5 <karim....@gmail.com> wrote:
Got the web extension to work on chrome and IE. Firefox dropped NPAPI support and now supports Native Messaging using WebExtension. All I need to do is register or add the plug in but I cannot figure out how. I tried fixing the mimtype in the background.js file and using about:debugging but it didn't work. Also tried registering the mezolla.json that is in the debug file with no luck.. Anyone out there who has done this? 

--

---
You received this message because you are subscribed to the Google Groups "firebreath-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebreath-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Ing. Billy Simón C. Msc
MCPD: Enterprise Developer
MCPD: Web Developer, MCSD.Net
Gerente de Tecnología
Tel. 2234-9900
www.hermes-soft.com

Billy Simon

unread,
Aug 16, 2017, 7:55:51 PM8/16/17
to firebre...@googlegroups.com
Regarding Mac and Linux my NMH binary also worked as is with Firefox. The HMH' manifest file is is the same that in Windows but the binary path. The NMH' manifest path in Linux and Mac is different that Chrome.

Hau5

unread,
Aug 22, 2017, 10:02:36 AM8/22/17
to firebreath-dev
Thank you all for the help. I have managed to build it all and have written a small documentation that could help others later on. My only problem now is seeing the extension on IE 11 on windows 10 (both 32 and 64 don't work even after registering the dlls with the correct regsvr32).

Here is the steps that I followed to make this work. I hope it helps others and if anyone knows how the heck to get it to appear in windows 10 IE11 I would REALLY appreciate it.

Clone FireBreath 2.0 and then run git init command to update the boost module

Using cmd go to the direcotry that firebreath has been cloned in:
>cd FireBreath

Using cmd run the prep script for the visual studio that you have installed and the build you desire (64 bit is marked with x64 in the end of the name ie prep2013x64). I have visual studio 2013 with update 4 (Please note, visual studio 2013 without the update generates an error, you NEED to have the update for it to compile correctly):
> prep2013.cmd examples\EchoTestPlugin EchoPlugin

Open the project using EchoTestPlugin.sln

Hit the build button and wait. This takes a while to compile the first time you build it.

The first part to do is to is to register the npEchoTestPlugin.dll so that you can use it in internet explorer (without doing anything further) and in chrome and firefox by following the next steps.  All you need to do is head to the debug directory in cmd and then use the command "regsvr32 npEchoTestPlugin.dll" and you will get a message that you application has been successfuly register. You can now call the plugin from Internet explorer.

After you have built the dll you will need to register the two .json files (one for firefox and one for chrome). This step is essential and was one of the hardest things I had to figure out. Here are the two commands I used in cmd for this specific project:

For Chrome:

REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\org.firebreath.firewyrmhost" /ve /t REG_SZ /d "C:\Users\Administrator\FireBreath\EchoBuild\Debug\org.firebreath.firewyrmhost_chrome.json" /f

For FireFox

REG ADD "HKCU\Software\Mozilla\NativeMessagingHosts\org.firebreath.firewyrmhost" /ve /t REG_SZ /d "C:\Users\Administrator\FireBreath\EchoBuild\Debug\org.firebreath.firewyrmhost_mozilla.json" /f

A little explanation: Right after the ADD you only need to change the last part (org.firebreath.firewyrmhost) if you create a different plug in; This needs to be exactly like the the first part of the .json file name (org.firebreath.firewyrmhost_mozilla.json) to make things simple.  As for the last address before the /f, you will need to put the local location of the .json files on your pc.

Another VERY important minor modification you need to make the mozilla .json file (org.firebreath.firewyrmhost_mozilla.json)  that can be done before or after you register the file: You need to add id of the application in the allowed_extension, here is my file and you need to have yours the same as mine if you are trying to make the EchoPlugin work:

{
 "name": "org.firebreath.firewyrmhost",
 "description": "FireBreath FireWyrm Native Messaging Wyrmhole",
 "path": "C:/Users/Administrator/FireBreath/EchoBuild/Debug/FireWyrmNativeMessageHost.exe",
 "type": "stdio",
 "allowed_extensions": ["firewy...@firebreath.org"]
}

The format is very important here for the allowed_extensions, you need to first put the name of the plugin (firewyrmhost) then @ then the company (firebreath) and then the web extension (.org). To simplify things, you can look at the "name" section in the beginning and do it in reverse and just change the first . to @

    You need to do this because if you do not then the plugin in you install will not be able to call the c++ plugin         and you will get an error in the console that says: "host disconnected".

You will need to do a minor change to the manifest.json so that firefox add-on will install properly.  Inside you will find a line that says:

     "id": "",

You will need to change it to be exactly like you set the allowed_extensions in the org.firebreath.firewyrmhost_mozilla.json file so it will be like follows:

    "id": "firewy...@firebreath.org",

You will also need to change the "path" so that you point to the FireWyrmNativeMessageHost.exe in both the json files that are produced.

    **Side note: When trying to generate the project for 64bit, both the json files for mozella and firefox are not generated so     you will need to generate a 32 bit project and copy those files. They should work

You will now need to do a minor change to the background.js so that the firefox add on can work. Using an editor open background.js; a couple of lines down you will find this line:

    var mimeType = "<enter-mime-here>"; //ex: application/x-fbtestplugin

You will need to change it to the name of the app (in the case of the EchoPlugin it will be "application/x-echotestplugin" The new line will need to look like this:

    var mimeType = "application/x-echotestplugin";


Next you need to install the plugin into chrome. To do that you need to start chrome and go to "chrome://extensions/".

In chrome://extensions you need to first enable the "Developer mode" in the top right section.

After you have ticked that toggle you need to hit "Load unpacked extension" and head to the EchoBuild fold and select the NativeMessageExtension and press ok

The Plug in should now appear underneath. If you see an error that says "There were warnings when trying to install this extension: Unrecognized manifest key 'applications'."  do not worry as it will work regardless of it. I still havent figured out how to fix that but it didnt cause me any issues. You are now set on chrome and can run the Test.html that was posted by ... and here is the link...  (You need to click initialize plugin first) then try running the other buttons and inspect the results inside the console section in the "Inspect"

To install the addon into firefox run firefox and go to "about:debugging" and enable the "Enable add-on debugging" toggle. Then after you have enabled it, you will need click on "Load Temporary Add-on" and go the EchoBuild fold and select the NativeMessageExtension, you will find in there the background.js that you edited before. Select it and click ok. Then you should see the plug in installed in the Temporary Extension. Please note that this will install the add-on until you close firefox. So everytime you run firefox you will need to do that. This is not the case with chrome but you will be getting notifications to disable the debug in chrome.

You can now use the plugin in both chrome and firefox. Please note I have reached to the point were I can run the plugins in debug mode in both browsers. To run the plugin in release mode you need to do a couple of further steps which are described in firefox and chrome sites. I will do that soon but I havent done it. I am sure it will be an easy task as the hard part Tis now behind us.


Best,
K



On Thursday, August 17, 2017 at 2:55:51 AM UTC+3, Billy Simon wrote:
Regarding Mac and Linux my NMH binary also worked as is with Firefox. The HMH' manifest file is is the same that in Windows but the binary path. The NMH' manifest path in Linux and Mac is different that Chrome.
On Wed, Aug 16, 2017 at 5:50 PM, Billy Simon <billy...@gmail.com> wrote:
I've gone through the process of migrating to Firefox a Chrome Extension implemented along with a Native Messaging Host. Mozilla provides a very handy guide to migrating extensions from Chrome at https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Native_messaging (Porting section).

In my case the Native Messaging Host binary worked as is with my Firefox extension. Registration of NMH for Firefox varies slightly. Firefox uses a different registry key than Chrome and Firefox NMH's manifest uses the key "allowed_extensions" instead of "allowed_origins". Also I think Mozilla maximum native message size is smaller than Chrome, at leas according to my tests.

Regarding the extension side In my case I just had make a few changes to the manifest file and repackage the extension files using xpi format (zip and rename with xpi exntesion). Firefox official namespace is "browser" instead of "chrome" namespace, but it also supports "chrome" namespace in order to easy porting. The process of publishing your extension is easier in Firefox because Mozilla allows you to self host your xpi. Mozilla just verifies your extension files and signs your XPI with their private key. The process is automated and takes a few seconds.



On Wed, Aug 16, 2017 at 1:42 PM, Hau5 <karim....@gmail.com> wrote:
Got the web extension to work on chrome and IE. Firefox dropped NPAPI support and now supports Native Messaging using WebExtension. All I need to do is register or add the plug in but I cannot figure out how. I tried fixing the mimtype in the background.js file and using about:debugging but it didn't work. Also tried registering the mezolla.json that is in the debug file with no luck.. Anyone out there who has done this? 

--

---
You received this message because you are subscribed to the Google Groups "firebreath-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebreath-de...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Ing. Billy Simón C. Msc
MCPD: Enterprise Developer
MCPD: Web Developer, MCSD.Net
Gerente de Tecnología
Tel. 2234-9900
www.hermes-soft.com

Richard Bateman

unread,
Aug 22, 2017, 2:27:35 PM8/22/17
to FireBreath Dev Group
To make it work with activex you need to run RegSvr32 on it. Also note
that a lot of the commands you're mentioning here are automatically
done by the *_DevInstall target.

Richard

Hau5

unread,
Aug 23, 2017, 2:56:40 AM8/23/17
to firebreath-dev
I did run regsvr32 and I am sure the doll registered as I was able to call it from all other browsers except from internet explorer. It didn't even appear in the list of addons in IE 11 windows 10 x64. I used the example project. (Echotestplugin) to keep matters straight forward but no luck seeing the addon in the list even. I first attempted to run the x64 but addon (need x64 Bc my addon will call hardware that only work using x64) and afterwards I re-preped the project from the start for x32. The dll registered using syswow64 regsvr and was visible to other browsers but no on the internet explorer addon list. I tried everything from setting enhanced protection mode to enable 64 bit for protection mode. Can anyone attach a very simple plugin that the know registered and appeared in I.E. 11 x64 device. I used VS2013 and I am thinking of trying to create the plug in with another vs (vs2010 or vs 2015) maybe that will fix the issue. I am using firebreath 2.0.

Hau5

unread,
Aug 23, 2017, 3:07:02 AM8/23/17
to firebreath-dev
I have been comparing registery entries between the working x32 and windows 10 x64 and from what I can see the dll registry entries appear to be almost identical minus some parts that are extra in windows 10 Bc it is x64. Maybe you can tell me what could be missing in there that would result in the dll not showing up in the addon list. I am really lost, I don't understand why it would register and not appear in the list yet at the same time before registering the plugin doesn't work on other browsers until I do regsvr32. Doesn't chrome and Firefox use native messaging? Why do they require regsvr and if chrome and Firefox work after regsvr doesn't that mean it has been registered correctly or am I mistaken since one uses native messaging and the other uses activex? Maybe the activex parameters are wrong in my project or something?

Hau5

unread,
Aug 24, 2017, 5:01:23 AM8/24/17
to firebreath-dev
Okay so after long hours I managed to figure out why the plugin was not appearing in the add-on list in IE11 in windows 10. Usually, in older windows, when I did a regsvr32 the plugin will automatically be added to the IE explorer add-on list, however, in the windows 10 IE11 it appeared that the plugin will ONLY show after it has been loaded by the HTML page. So if you run the FBcontrol.html page after you do a regsvr32 the plugin will magically appear in the add-on list and then it will remain there. This is very confusing from microsoft bc the earlier windows didn't behave this way. 

Now, another important point, if you are installing a x32 bit plugin and run the page from your local drive it will be loaded as there appears to be no restrictions for x32 bit plugins. However, it is not that simple for the x64 bit plugin, attempting to just load the plugin using the test page will not work. This occurs for a number of reasons that were a pain in the butt to discover. First of all, you need to go into IE advanced settings and check the "enable 64-bit processes for enhanced protection mode" but by itself it won't do you any good. You need to then go to the security tab and check "enabled protected mode" for both internet and local intranet. Now, this is the tricky part, if you load the page from your local computer (double clicking fbcontrol.html) it will still not work bc IE runs all local sits in x32 bit tabs so the x64 bit plugin will NOT load. To make it work, I had to host my site locally on my local intranet (i.e. 192.168.2.5/FBControl.html) and then the plugin will load bc I enabled protected mode for local intranet OR host the page online (I used neocities.org which lets you host a single page website for free) and then I loaded the page from there and it worked! 

Till now I have not figured out how to run local files in protected mode (which allows for x64 bit tabs) that will load the plugin, but please take note of all of this as I have read only a LOT of people with the same issue of the plugin not showing up in the list and this is the way to make it happen.

Best,
K

Richard Bateman

unread,
Aug 24, 2017, 11:13:36 AM8/24/17
to FireBreath Dev Group
I've actually seen that happen in previous versions of windows as
well; I hadn't realized that you were just relying on the list
(probably because I didn't read carefully enough).

The way we deploy our plugin on windows is we have both a 32 bit and a
64 bit version; given that firefox and chrome have both dropped
support for plugins, though, it might make sense to just drop the 64
bit version and only worry about 32 bit, unless there is some reason
that you actually need a 64 bit process; 32 bit seems to work just
fine in IE11.

Richard

Chang Sub Shin

unread,
Sep 27, 2017, 7:22:52 PM9/27/17
to firebreath-dev
Hi Hau5,

I been looking for browser extension to access USB Card Reader. Then found this forum. Can you please advice me how to access USB Card Reader from browsers?

Regards,
Chang Shin

Richard Bateman

unread,
Sep 27, 2017, 7:53:43 PM9/27/17
to FireBreath Dev Group
Hi Chang Shin,

That's a very broad question. You're going to have to figure most of
it out yourself -- we're not going to do your job for you. That said,
here are some of the things you'll need to figure out:

1. You need more than just a browser extension; AFAIK chrome
extensions can't access a usb card reader directly, so you'll need
something like a native messaging host on Chrome or Firefox.
FireBreath 2 can be used to create a browser plugin (not the same as
an extension) for older browsers and IE as well as a native message
host that can work with chrome and firefox.

2. FireBreath plugins are written in C++, so to use FireBreath you'd
need to know how to do what you need in C++

3. Once you know how to do it in C++ you just need to experiment with
FireBreath 2 and figure out how to make a plugin and add your C++ code
to it. There are lots of resources about this on firebreath.org

Hope that helps,

Richard

Chang Sub Shin

unread,
Oct 4, 2017, 7:35:53 PM10/4/17
to firebreath-dev
Hi Richard,

I got the native messaging to access java api. it works. but I an sill researching how to communicate between the extension and web page.


Chang
Reply all
Reply to author
Forward
0 new messages