📜 ⬆️ ⬇️

As I was called paranoid and what came of it

When did the leaks of the password / hash databases start from different forums and social services? networks, I began to think about how and where to store my passwords so that they can be quickly changed and not forgotten. So I came across the program KeePass Password Safe , I will not write about its capabilities as there are plenty of articles on Habré and the topic of this article is not about its capabilities. As KeePass exploited, plug-ins overlaid, especially for browsing with browsers, LastPass was discarded because I didn’t want to store passwords (especially to working systems) somewhere near my uncle, and it’s not a fact that they will not be merged from there either.

At first, Firefox had the KeeFox extension, but since KeePassRPC (the KeePass plugin) only works, then this extension has long been disabled and not used. Then the PassIFox extension was found (it works through the KeePass plugin - KeePassHttp ) with ChromeIPass right away - but for Opera 11, Opera 12 (here and hereinafter implied on the Presto engine and this is my main browser) there was no good integration, it was only The UserJS script that adds the page address to the window title, even an extension was created that does the same thing - so that KeePass can determine the address for which you need to find a login and password for the substitution by Ctrl + Alt + A (standard KeePass auto-fill hot key) . Since I don’t have modern JavaScript skills , I tried my luck on OperaFan with a request to write / remake an extension for Opera - where I was called paranoid. Continuing the story of porting Chrome IPass in Opera 12 (without much technical details) under the cut.

Important

Immediately, I’ll make a reservation that not everything I managed to port, but for me it turned out quite workable, given the lack of an alternative. Please do not kick for mistakes and implementation errors. If someone tells me something, I will be grateful.
I understand that Opera on the Presto engine is already a corpse, but as I wrote above, this is my main browser and so far I don’t see a replacement for it in terms of memory consumption, speed and the ability to finish the functionality. I use the latest build of Opera AC with the buns drilled under it.

The first approach to the projectile


For porting to Opera, the ChromeIPass extension was chosen because looking inside it and LastPass, RoboForm Lite and seeing approximately similar calls for Opera and Chrome - I made an assumption that they are closest (over time I realized that I was very wrong).
The first patient was selected at that time version of ChromeIPass 1.0.7. There was no password memorization functionality, poorly small knowledge about writing extensions and their interaction with the browser, little free time, the LastPass extension, like RoboForm, was written universal under Opera, Chrome and Safari and had huge dimensions. There was a simple replacement of chrome.extension.sendMessage with opera.extension.postMessage with natural “epic fail”. In general, having made several attempts, I abandoned porting, although there were few scripts and I was ready to accept the addition of passwords through KeePass itself.
')

The second approach to the projectile


Two months ago, I discovered that the version of ChromeIPass is already 2.6.6 and there appeared a password memorization function and a number of other goodies. And it even works without any changes in Opera (on the blink engine), slipping it in developer mode, and then it can be converted to NEX.
This time it was decided to unambiguously achieve a working result. Thoroughly reading about the interaction of the Injected script, Background script and Popup script in Opera, googling, looking at other extensions, having climbed the already closed forum and blogs on My Opera (I even had to dig into the Web Archive and google cache) - I started to work.

The config.xml was created, the files were placed in the necessary directories, the chrome.extension.sendMessage was replaced with opera.extension.postMessage (in some places on e.source.postMessage where it was necessary to respond to the event - and not just send, e - this event , because in Chrome IPass there is an event object defined in event.js).

All calls using Chuck's callback mechanism have been reworked to simply send events and add responses to these events in event handlers, where these callback functions are defined.

Redone chrome.tabs. *. AddListener on opera.extension.tabs. * (For Opera, events must be in lower case otherwise it does not work) in init.js.
Opera.extension.tabs.onupdate in Opera (chrome.tabs.onUpdated.addListener in Chrome) does not work .

Debugging is enabled (displaying messages in the console) where it was, adding its own debugging messages to understand what and how it interacts with.

Added a new extension in developer mode to a separately installed opera and launched Dragonfly.

A lot of useful information was taken from the posts and blog of Joel Spadin aka spadija on my.opera.com and its tab vault and autostack extensions .

For a start, I checked how the extension works with KeePass, in this part I didn’t alter almost anything. works "with a bang."

The introduction of CSS was done ( it was here ), as it later discovered the same method used in the documentation

Then there was a struggle for the boot sequence of the Injected scripts (there are three of them in ChromeIPass: the main one and two converted jQuery and jQuery UI). In Chrome, this is easier than in the Opera.
The solution was found on the my.opera forum (no longer available) and for jQuery (in ChromeIPass, jQuery was renamed cIPJQ, so that there would be no conflict with the loaded jQuery from sites), the code for its initialization in init.js was added, so that errors would not fall out and have worked
var cIPJQ; if (typeof cIPJQ === 'undefined') { if (typeof window.cIPJQ !== 'undefined') { cIPJQ = window.cIPJQ.noConflict(true); } else { opera.postError(['Error: could not load jQuery']); } } 

I came up with a rake that opera.extension.bgProcess is a window object - not the background script itself.

Replaced work with the replacement of addresses for the popup, the solution was taken from here , while it is still in the Google cache.

But with the ports had to tinker the longest. So if you make the transfer of the port from the popup script to the injected script and back ( as indicated in the documentation ), the e.source.postMessage stops working on the events from the popup script in the background script. I had to create another MessageChannel for the popup script to work with the background script. And "poking" the closure of these all MessageChannel, because There are problems that when creating tabs, the function opera.extension.tabs.getSelected () returns a tab with port = null.

In order to embed images, I first tried opera.extension.getFile () , but it turned out to be asynchronous, so it implemented the loading of images as well as loading CSS (via XMLHttpRequest) and when introducing styles, it replaced base64-encoded images.

Actually the expansion itself:
rghost , sendspace
with not commented out postError
rghost , sendspace

Restrictions




Thanks for attention!

Source: https://habr.com/ru/post/216239/


All Articles