Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f8c250897 | |||
| 5784e61e40 | |||
| 63f88a2076 | |||
|
|
b8223a87ad | ||
| 129335dc2d | |||
|
|
2cb26d6d40 | ||
|
|
54565f90b6 | ||
|
|
42142cbca9 | ||
|
|
2def010612 | ||
|
|
daa7c3b44c | ||
| 422178bc9d | |||
| 736d717676 | |||
| 7f95b19264 | |||
| 354ddbbba9 | |||
| d25436f597 | |||
| b79000accb | |||
| 0e48a34d71 | |||
| 96b378695e | |||
| a485267da8 | |||
| 267a809019 | |||
| 6611641534 | |||
| 12d49fab4e | |||
|
|
4cfd61d077 | ||
|
|
d2fe770463 | ||
|
|
0f74943e92 | ||
|
|
4271551fed | ||
| 76c7797ee2 | |||
| 90e9862982 | |||
| 630a3f9cb9 | |||
| 4e7f5bc75c | |||
| 5b9640e8cb | |||
| 85fa47037d | |||
| 32f36a1100 | |||
|
|
9d528aeaa0 | ||
| 6f1e2a814d | |||
| 4b307fd776 | |||
| 5d65b863f6 | |||
| 8d39bd8ed0 | |||
| 898e0b9e42 |
76
ChangeLog
@@ -1,3 +1,79 @@
|
||||
**v1.3 :**
|
||||
|
||||
Server
|
||||
* Improve filter URL match
|
||||
|
||||
Addon
|
||||
* Minor bug fixes
|
||||
|
||||
CLI
|
||||
|
||||
**v1.2 :**
|
||||
|
||||
Server
|
||||
* Rework UI
|
||||
* Display PHP parsed URL in new URL case, not raw URL
|
||||
* Add a filter for unciphered passwords (supports regular expressions)
|
||||
* Add a button to copy unciphered password into clipboard
|
||||
* Don't clear URL and login when adding a new password
|
||||
* Change alert() by button name update for "Update" and "Copy clipboard" functions
|
||||
|
||||
Addon
|
||||
* Update manifest to v3 (Chrome only)
|
||||
|
||||
CLI
|
||||
|
||||
**v1.1 :**
|
||||
|
||||
Server
|
||||
* Remove old v1 crypto functions & compatibility
|
||||
|
||||
Addon
|
||||
* Add always_disabled feature
|
||||
* Fix bug in gpass icon management
|
||||
* Set activated icon only when a username is filled
|
||||
* Add a checkbox to only copy password into clipboard from popup (and a default behaviour from options)
|
||||
|
||||
CLI
|
||||
|
||||
|
||||
**v1.0 :**
|
||||
|
||||
Server
|
||||
|
||||
* Add clear form button for "Add new password" div
|
||||
* If we have a current URL in add form and we have a password entry that match this URL, go to the last when all is deciphered
|
||||
|
||||
Addon
|
||||
* Remove old v1 crypto functions & compatibility
|
||||
* Remove old firefox addon code
|
||||
* Remove block_url feature to increase websites compatibility
|
||||
* Force copy password into clipboard for @_ request from popup even if we can fill it
|
||||
* Fix a bug: wait for promise before displaying message for clipboard pasted password
|
||||
|
||||
CLI
|
||||
|
||||
**v0.9 :**
|
||||
|
||||
Server
|
||||
|
||||
* Add support for user & url parameters from gPass popup
|
||||
* Fix some minor bugs
|
||||
|
||||
Addon
|
||||
* Move all core functions from mains.js to background.js
|
||||
* Use message interface for IPCs between main.js, background.js and popup.js
|
||||
* Add popup interface :
|
||||
* Safest method to compute masterkey
|
||||
* Direct access to our own gPass server with auto URL and username fill
|
||||
* Add some specific menus :
|
||||
* Access to gPass settings
|
||||
* Allow to disable extension
|
||||
* Update gPass icon when a password field has focus and gPass is ready to work
|
||||
* Add Privacy Policy information
|
||||
|
||||
CLI
|
||||
|
||||
**v0.8.1 :**
|
||||
|
||||
Server
|
||||
|
||||
@@ -2,18 +2,18 @@ gPass web browser extension Privacy Policy
|
||||
------------------------------------------
|
||||
|
||||
|
||||
## Information we collect ##
|
||||
## Information we collect ##
|
||||
|
||||
The gPass extension collect three information once invoked :
|
||||
* Site address URL
|
||||
* Login name
|
||||
* Master key
|
||||
* Login name
|
||||
* Master key
|
||||
|
||||
|
||||
## How we use information we collect ##
|
||||
## How we use information we collect ##
|
||||
|
||||
Once collected, site address and login name are crypted by a derived version of your master key.
|
||||
It's then sent to the server you configured in extension configuration page for comparison.
|
||||
Once collected, site address and login name are encrypted by a derived version of your master key.
|
||||
It's then sent to the server (password server) you configured in extension configuration page for comparison.
|
||||
|
||||
This server has been set up by the user himself (recommended) or by a provider he trust in.
|
||||
|
||||
@@ -21,27 +21,27 @@ The database that the server access to do comparisons only contains the crypted
|
||||
version of your information. They are never decrypted in the server side.
|
||||
|
||||
If a comparison match, the real password is sent back to your extension were
|
||||
it's unencrypted using the same key.
|
||||
it's unencrypted using the same key (derived masterkey).
|
||||
|
||||
Finally, the application context is cleared and nothing is retained in memory
|
||||
Finally, the application context is cleared and nothing is kept in memory
|
||||
nor written anywhere.
|
||||
|
||||
|
||||
## Accessing and updating your personal information ##
|
||||
|
||||
As a user, you can add, edit and delete your crypted information through
|
||||
the web interface of the configuration defined server.
|
||||
As a user, you can add, edit and delete your ciphered information through
|
||||
the web interface of the password server.
|
||||
|
||||
During these operations, no clear information is sent to the server.
|
||||
|
||||
|
||||
## Information we share ##
|
||||
|
||||
Nothing is shared with anyone. Nor on extension side nor on server side.
|
||||
Nothing is shared with anyone. Nor on extension side, nor on server side.
|
||||
|
||||
|
||||
## Information security ##
|
||||
## Information security ##
|
||||
|
||||
Information transmitted to the server are done through an HTTPS AJAX request.
|
||||
Data are crypted using AES 256 CBC algorithm and the master key is prior
|
||||
Data are encrypted using AES 256 CBC algorithm and the master key is prior
|
||||
derived using PKBDF2 algorithm.
|
||||
|
||||
48
README.md
@@ -9,9 +9,9 @@ Everyday we have a lot of passwords to manage corresponding to a lot of accounts
|
||||
* Password are not very strong
|
||||
* We use them for multiple accounts
|
||||
|
||||
The best way to avoid these errors is to have a unique strong password for each account. gPass helps to reach this goal : you keep a subset of passwords (called masterkey) and for each login/password tuple you chose, gPass returns the real password by querying a password server.
|
||||
The best way to avoid these errors is to have a unique strong password for each account. gPass helps to reach this goal : you keep a subset of passwords (called masterkey) and for each login/masterkey tuple you chose, gPass returns the real password by querying a password server.
|
||||
|
||||
To have a high level of security, all information is stored encrypted (server side). Nothing is stored on client. The decryption is done on the fly when it's needed and only with user input. So, a hacker can get your password database, it will not be able to see any information (except if it brute force your masterkey) ! So it's important to choose to strong masterkey !
|
||||
To have a high level of security, all information is stored encrypted (server side). Nothing is stored on client. The decryption is done on the fly when it's needed and only with user input. So, a hacker can get your password database, it will not be able to see any information (except if it brute force or leak your masterkey) ! So it's important to choose a strong masterkey !
|
||||
|
||||
This addon is like [last pass](https://lastpass.com/) one, but I wanted it to be open source and self hostable (be careful on server down !). Moreover, with gPass, you can have multiple master keys !
|
||||
|
||||
@@ -19,21 +19,26 @@ This addon is like [last pass](https://lastpass.com/) one, but I wanted it to be
|
||||
Usage
|
||||
-----
|
||||
|
||||
The first thing to do is to populate your database (from your/a password server) with website/login/password/master key values. You can use "*" character to access to all sub domains of a specific website. If you want to make strong password, there is a password generator. After that, configure your addon in "tools -> addons -> gPass -> preferences" in Firefox or "addons -> gPass -> options" in Chrome to point to your password server (+ username). Be careful, login and password are case sensitive.
|
||||
The first thing to do is to populate your database (from your/a password server) with website address/login/password/master key values. You can use "*" character to access to all subdomains of a specific website (ie *.google.com). If you want to make a strong password, there is a password generator. After that, configure your addon in "tools -> addons -> gPass -> preferences" in Firefox or "More tools -> extensions -> gPass -> options" in Chrome to point to your password server (+ username). **Don't forget to enable addon within private mode**. Be careful, login and password are case sensitive !
|
||||
|
||||
When you're in a login form and you want to use gPass, type your login (case sensitive !) and fill "@@masterkey" in password field. Then submit and password will automatically be replaced by the one in the database (after addon decrypt it).
|
||||
When you're in a login form and you want to use gPass, type your login (case sensitive !) and fill "@@masterkey" in password field (only if gPass icon is green !). Then submit and password will automatically be replaced by the one in the database (after addon decrypt it).
|
||||
|
||||
**You can also type "@_masterkey" to only replace your password without automatic submit. This allows to support more websites.**
|
||||
|
||||
Another option is to enter your credentials in the new popup menu by clicking on gPass icon. If it's possible, gPass will auto fill password field, if not result password is stored into your clipboard. **Popup path is a safest method as website page will never see your masterkey.**
|
||||
|
||||
** Warning ** : Sometimes, addon could make some websites unusable, especially for login form. In this case, you can deactivate it for only one website by clicking right on gPass icon and "disable or enable gPass for this website" in addon menu. It's a local configuration, so it must be done for each browser. gPass can also be disabled for ALL websites thanks to addon menu "Disable or enable gPass for ALL websites". _When gPass is disabled, you can still use popup feature_.
|
||||
|
||||
**You can also type "@_masterkey" to only replace your password without submitting and manually submit. This allows to support more websites.**
|
||||
|
||||
Technical details
|
||||
-----------------
|
||||
|
||||
The two columns in database are "login" and "password".
|
||||
login is compounded by "domain;login" is salted and encrypted with AES 256-CBC
|
||||
The two main columns in database are "login" and "password".
|
||||
login is compounded by "domain;login", salted and encrypted with AES 256-CBC
|
||||
|
||||
The key that encrypt these fields is PBKDF2 (hmac-sha256, masterkey, password_server_url, 1000, 256), IV is PBKDF2 (hmac-sha256, password_server_url, masterkey, 1000, 256)
|
||||
The real key that encrypts these fields is PBKDF2 (hmac-sha256, masterkey, password_server_url, 1000, 256), IV is PBKDF2 (hmac-sha256, password_server_url, masterkey, 1000, 256)
|
||||
|
||||
PBKDF2 level can be changed by user
|
||||
PBKDF2 level can be changed by user.
|
||||
|
||||
Server side is written in PHP (with SQLite3 for database component).
|
||||
|
||||
@@ -41,25 +46,27 @@ Server side is written in PHP (with SQLite3 for database component).
|
||||
Server
|
||||
------
|
||||
|
||||
To host a password server, you need a webserver. Just copy server files in a directory read/write for web server user (www-data). A sample apache2 configuration file is available in resources. Since v0.8 and the use of Crypto API, it's manadatory to have an HTTPS access to the server. Without that, the decryption will fails.
|
||||
To host a password server, you need a webserver. Just copy server files in a directory read/write for web server user (www-data). A sample apache2 configuration file is available in resources. Since v0.8 and the use of Crypto API, **it's manadatory to have an HTTPS access (valid SSL/TLS certificate) to the server**. Without that, the decryption will fails.
|
||||
|
||||
Configuration parameters are in conf.php
|
||||
|
||||
A demonstration server is available [here](https://gpass-demo.soutade.fr). It may not works with HTTPS content because it uses a self-signed SSL certificate. If so, explicitly add the certificate to your browser. It's the default server of package (user demo).
|
||||
A demonstration server is available [here](https://gpass-demo.soutade.fr). It's the default server configuration for fresh installed addon (user demo).
|
||||
|
||||
**Warning** The master key derivation is partially based on account URL. So it's linked to your current server information. You can't move databases from servers with different URLs, you need to export them and import again.
|
||||
**Warning** The master key derivation is partially based on account URL. So it's linked to your current server information. You can't move databases from servers with different URLs, you need to export them and import it again.
|
||||
|
||||
**Server side is available [here](http://indefero.soutade.fr/p/gpass/downloads)**
|
||||
|
||||
Version 0.6 introduces shadow logins. It's a protection again illegal database dump and purge but requires high cpu bandwidth. Database update is transparent.
|
||||
Version 0.6 introduces shadow logins. It's a protection again illegal database dump and purge but requires twice computation. Database update is transparent.
|
||||
|
||||
The principle is to generate a random value (shadow login) that must be encrypted with the masterkey to get an access token. This access token allows to get the true (but encrypted) login/password couple. It's a kind of challenge : if I can encrypt the shadow login, I know the masterkey ! For security reason, the derivation of masterkey for deciphering passwords is different than for encrypting shadow logins (it uses its own salt). It's enabled by default.
|
||||
|
||||
The principle is to generate a random value (shadow login) that must be encrypted with the masterkey to get an access token. This access token allows to get the true (but encrypted) login/password couple. It's a kind of challenge : if I can encrypt the shadow login, I know the masterkey ! For security reason, the derivation of masterkey for deciphering passwords is different than for encrypting shadow logins (it uses its own salt).
|
||||
|
||||
Client
|
||||
------
|
||||
|
||||
Just install the package. You can have debug information by setting DEBUG in main.js.
|
||||
|
||||
|
||||
Command line interface
|
||||
----------------------
|
||||
|
||||
@@ -73,19 +80,8 @@ The dependencies are libcurl and OpenSSL (-dev packages : ie _libcurl4-openssl-d
|
||||
|
||||
A sample configuration file is available _gpass.ini.sample_
|
||||
|
||||
Version Information
|
||||
-------------------
|
||||
|
||||
Current version is 0.8. **(not compatible with 0.7)**
|
||||
|
||||
Firefox will remove support for addons, so the gPass addon code is not supported since v0.8, please migrate to webextension.
|
||||
|
||||
Transition from v0.7 to v0.8 : **Please update your masterkey (even with the same one) to gain a security level of your passwords's wallet.**
|
||||
|
||||
**This version is incompatible from 0.1**. Please use [this script](http://soutade.fr/files/gpass_migrate_0_1.php) to migrate.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
All the code is licensed under GPL v3. Source code is available [here](http://indefero.soutade.fr/p/gpass).
|
||||
All the code is licensed under GPL v3. Source code is available [here](https://forge.soutade.fr/soutade/gPass).
|
||||
|
||||
@@ -1,95 +1,565 @@
|
||||
/*
|
||||
Copyright (C) 2013-2017 Grégory Soutadé
|
||||
|
||||
Copyright (C) 2013-2022 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function url_block_callback(details)
|
||||
import {parseUri} from "./lib/parseuri.js";
|
||||
import {SERVER, GPASS_ICON, wildcard_domain, simple_pbkdf2, crypto_pbkdf2,
|
||||
encrypt_ecb, encrypt_cbc, decrypt_cbc, digest, a2hex, hex2a, debug} from "./lib/misc.js";
|
||||
import {get_preference, set_preference, delete_preference} from "./compat.js";
|
||||
|
||||
var browser = browser || chrome;
|
||||
var protocol_version = 4;
|
||||
var account_url = null;
|
||||
|
||||
function _notification(message, data)
|
||||
{
|
||||
// console.log(JSON.stringify(details));
|
||||
if (details.requestBody)
|
||||
{
|
||||
if (details.requestBody.formData)
|
||||
{
|
||||
for (var key in details.requestBody.formData)
|
||||
{
|
||||
for(var idx in details.requestBody.formData[key])
|
||||
{
|
||||
value = details.requestBody.formData[key][idx];
|
||||
if (value.startsWith("@@") ||
|
||||
value.startsWith("@_"))
|
||||
return {cancel: true};
|
||||
}
|
||||
}
|
||||
}
|
||||
if (message !== data)
|
||||
message += data;
|
||||
|
||||
/*
|
||||
// Analyse POST parameters
|
||||
if (details.method == "POST" && details.requestBody.raw)
|
||||
{
|
||||
alert(details.requestBody.raw);
|
||||
var postedString = decodeURIComponent(String.fromCharCode.apply(null,
|
||||
new Uint8Array(details.requestBody.raw[0].bytes)));
|
||||
if (postedString.indexOf("=@@") != -1 ||
|
||||
postedString.indexOf("=@_") != -1)
|
||||
return {cancel: true};
|
||||
}
|
||||
*/
|
||||
}
|
||||
var options = {
|
||||
type: "basic",
|
||||
title : "gPass",
|
||||
message : message,
|
||||
iconUrl:"icons/gpass_icon_64.png"
|
||||
};
|
||||
|
||||
return {cancel: false};
|
||||
browser.notifications.create("gPass", options, function(){});
|
||||
}
|
||||
|
||||
chrome.runtime.onMessage.addListener(
|
||||
function(request, sender, sendResponse) {
|
||||
async function generate_request(domain, login, mkey, iv)
|
||||
{
|
||||
var v = domain + ";" + login;
|
||||
debug("will encrypt " + v);
|
||||
while ((v.length % 16))
|
||||
v += "\0";
|
||||
var hash = await digest(crypto, v);
|
||||
v += hash.slice(8, 24);
|
||||
var enc = encrypt_cbc(mkey, iv, v);
|
||||
|
||||
if (request.type == "notification")
|
||||
return enc;
|
||||
}
|
||||
|
||||
async function ask_server(logins, domain, wdomain, mkey, sendResponse, options)
|
||||
{
|
||||
var account_url = await get_preference("account_url");
|
||||
|
||||
var salt = parseUri(account_url);
|
||||
salt = salt["host"] + salt["path"];
|
||||
|
||||
debug("salt " + salt);
|
||||
|
||||
var pbkdf2_level = await get_preference("pbkdf2_level");
|
||||
|
||||
var global_iv = await simple_pbkdf2(crypto, salt, mkey, pbkdf2_level);
|
||||
global_iv = global_iv.slice(0, 16);
|
||||
var mkey = crypto_pbkdf2(crypto, mkey, salt, pbkdf2_level);
|
||||
|
||||
debug("global_iv " + a2hex(global_iv));
|
||||
|
||||
var keys = "";
|
||||
var key_index;
|
||||
var a;
|
||||
for(key_index=0, a=0; a<logins.length; a++, key_index++)
|
||||
{
|
||||
var enc = await generate_request(domain, logins[a], mkey, global_iv);
|
||||
keys += (keys.length != 0) ? "&" : "";
|
||||
keys += "k" + key_index + "=" + a2hex(enc);
|
||||
|
||||
if (wdomain != "")
|
||||
{
|
||||
options = {
|
||||
type: "basic",
|
||||
title : "gPass",
|
||||
message : request.options.message,
|
||||
iconUrl:chrome.extension.getURL("icons/gpass_icon_64.png")
|
||||
};
|
||||
|
||||
chrome.notifications.create("gPass", options, function(){});
|
||||
|
||||
window.setTimeout(function() {chrome.notifications.clear("gPass", function(){})}, 2000);
|
||||
}
|
||||
else if (request.type == "block_url")
|
||||
{
|
||||
chrome.tabs.getCurrent(function cb(tab) {
|
||||
if (tab)
|
||||
{
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
url_block_callback,
|
||||
{urls:[request.options.url],
|
||||
"types":["main_frame"],
|
||||
"tabId":tab.id,
|
||||
"windowId":tab.windowId
|
||||
},
|
||||
["blocking", "requestBody"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
url_block_callback,
|
||||
{urls:[request.options.url], "types":["main_frame"]},
|
||||
["blocking", "requestBody"]);
|
||||
}
|
||||
});
|
||||
enc = await generate_request(wdomain, logins[a], mkey, global_iv);
|
||||
keys += (keys.length != 0) ? "&" : "";
|
||||
keys += "k" + (++key_index) + "=" + a2hex(enc);
|
||||
}
|
||||
}
|
||||
|
||||
debug("Keys " + keys);
|
||||
|
||||
var ret = SERVER.OK;
|
||||
|
||||
debug("connect to " + account_url);
|
||||
const headers = {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'};
|
||||
const request = new Request(account_url, {method: 'POST', headers: headers, body: keys});
|
||||
|
||||
const response = await fetch(request).catch((e) => {
|
||||
debug(e);
|
||||
_notification("Network error : check your server address", "");
|
||||
});
|
||||
|
||||
if (response === undefined)
|
||||
{
|
||||
ret = SERVER.ERROR;
|
||||
sendResponse({"value": ret, options:options});
|
||||
return;
|
||||
}
|
||||
|
||||
const responseText = await response.text();
|
||||
|
||||
var ciphered_password = "";
|
||||
var server_pbkdf2_level = 0;
|
||||
var server_version = 0;
|
||||
var matched_key = 0;
|
||||
|
||||
var r = responseText.split("\n");
|
||||
debug("resp " + r);
|
||||
|
||||
for(var a=0; a<r.length; a++)
|
||||
{
|
||||
debug("Analyse " + r[a]);
|
||||
|
||||
var params = r[a].split("=");
|
||||
if (params.length != 2 && params[0] != "<end>")
|
||||
{
|
||||
_notification("Error : It seems that it's not a gPass server",
|
||||
responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(params[0])
|
||||
{
|
||||
case "protocol":
|
||||
debug("protocol : " + params[1]);
|
||||
|
||||
if (params[1].indexOf("gpass-") != 0)
|
||||
{
|
||||
_notification("Error : It seems that it's not a gPass server",
|
||||
responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
var server_protocol_version = params[1].match(/\d+/)[0];
|
||||
|
||||
if (server_protocol_version > protocol_version)
|
||||
{
|
||||
_notification("Protocol version not supported, please upgrade your addon", "");
|
||||
ret = SERVER.FAILED;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (server_protocol_version)
|
||||
{
|
||||
case 2:
|
||||
server_pbkdf2_level = 1000;
|
||||
break;
|
||||
case 3:
|
||||
// Version 3 : nothing special to do
|
||||
case 4:
|
||||
// Version 4 : nothing special to do
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "matched_key":
|
||||
matched_key = params[1];
|
||||
case "pass":
|
||||
ciphered_password = params[1];
|
||||
break;
|
||||
case "pkdbf2_level":
|
||||
case "pbkdf2_level":
|
||||
server_pbkdf2_level = parseInt(params[1].match(/\d+/)[0], 10);
|
||||
if (server_pbkdf2_level != NaN &&
|
||||
server_pbkdf2_level != pbkdf2_level &&
|
||||
server_pbkdf2_level >= 1000) // Minimum level for PBKDF2 !
|
||||
{
|
||||
debug("New pbkdf2 level " + server_pbkdf2_level);
|
||||
pbkdf2_level = server_pbkdf2_level;
|
||||
set_preference("pbkdf2_level", pbkdf2_level, null);
|
||||
ret = SERVER.RESTART_REQUEST;
|
||||
}
|
||||
break;
|
||||
case "<end>":
|
||||
break;
|
||||
default:
|
||||
debug("Unknown command " + params[0]);
|
||||
|
||||
_notification("Error : It seems that it's not a gPass server",
|
||||
responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != SERVER.OK)
|
||||
{
|
||||
sendResponse({"value": ret, options:options});
|
||||
return;
|
||||
}
|
||||
|
||||
if (ciphered_password != "")
|
||||
{
|
||||
debug("Ciphered password : " + ciphered_password);
|
||||
var clear_password = await decrypt_cbc(mkey, global_iv, hex2a(ciphered_password));
|
||||
clear_password = clear_password.replace(/\0*$/, "");
|
||||
clear_password = clear_password.substr(3, clear_password.length);
|
||||
debug("Clear password " + clear_password);
|
||||
sendResponse({"value": ret, "password":clear_password, "options":options});
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("No password found");
|
||||
|
||||
ret = SERVER.FAILED;
|
||||
|
||||
_notification("No password found in database", "")
|
||||
|
||||
sendResponse({"value": ret, "options":options});
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function update_gpass_icon(iconId, tabId)
|
||||
{
|
||||
debug("update_gpass_icon");
|
||||
|
||||
var icon_infos = {"tabId":tabId};
|
||||
var icon_name = "";
|
||||
|
||||
switch (iconId)
|
||||
{
|
||||
case GPASS_ICON.NORMAL: break;
|
||||
case GPASS_ICON.DISABLED:
|
||||
icon_name = "_disabled";
|
||||
break;
|
||||
case GPASS_ICON.ACTIVATED:
|
||||
icon_name = "_activated";
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
debug(icon_name);
|
||||
|
||||
var icon_infos = {};
|
||||
|
||||
icon_infos["path"] = {
|
||||
16:"icons/gpass" + icon_name + "_icon_16.png",
|
||||
32:"icons/gpass" + icon_name + "_icon_32.png",
|
||||
64:"icons/gpass" + icon_name + "_icon_64.png",
|
||||
128:"icons/gpass" + icon_name + "_icon_128.png",
|
||||
};
|
||||
|
||||
if (browser.browserAction)
|
||||
browser.browserAction.setIcon(icon_infos);
|
||||
else
|
||||
browser.action.setIcon(icon_infos);
|
||||
}
|
||||
|
||||
async function is_gpass_enabled(uri)
|
||||
{
|
||||
return await get_preference("always_disabled").then(
|
||||
function(always_disabled) {
|
||||
if (always_disabled)
|
||||
{
|
||||
debug("Always disabled");
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve(1); // null -> enabled, 1 -> disabled
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("Check for enable");
|
||||
var domain = parseUri(uri);
|
||||
domain = domain["host"];
|
||||
debug("Is gpass enabled for " + domain + " ?");
|
||||
|
||||
return get_preference("disable-" + domain);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function save_gpass_enable_config(uri, enable)
|
||||
{
|
||||
var domain = parseUri(uri);
|
||||
domain = domain["host"];
|
||||
|
||||
var key = "disable-" + domain;
|
||||
if (enable)
|
||||
{
|
||||
debug("Enable gpass for " + domain);
|
||||
delete_preference(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("Disable gpass for " + domain);
|
||||
set_preference(key, true, null);
|
||||
}
|
||||
}
|
||||
|
||||
function _query_tabs_is_gpass_enabled(tabs, sendResponse)
|
||||
{
|
||||
if (tabs.length)
|
||||
{
|
||||
is_gpass_enabled(tabs[0].url).then(
|
||||
function (key_present) {
|
||||
var enabled = (key_present == null);
|
||||
update_gpass_icon((enabled)?GPASS_ICON.NORMAL:GPASS_ICON.DISABLED, tabs[0].id);
|
||||
sendResponse({"enabled":enabled});
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("No cur tab");
|
||||
sendResponse({"enabled":true});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function _query_tabs_update_icon(tabs, iconId)
|
||||
{
|
||||
if (tabs.length)
|
||||
{
|
||||
update_gpass_icon(iconId, tabs[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function update_enable(enabled, tab, saveConfig)
|
||||
{
|
||||
var parameters;
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
parameters = {type:"blockForms"};
|
||||
saveConfig = true;// Force save when enable website
|
||||
debug("Now enabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters = {type:"unblockForms"};
|
||||
debug("Now disabled");
|
||||
}
|
||||
|
||||
if (saveConfig)
|
||||
save_gpass_enable_config(tab.url, enabled);
|
||||
update_gpass_icon((enabled)?GPASS_ICON.NORMAL:GPASS_ICON.DISABLED, tab.id);
|
||||
browser.tabs.sendMessage(tab.id, parameters);
|
||||
}
|
||||
|
||||
function gpass_switch_enable(tab)
|
||||
{
|
||||
debug("Switch enable");
|
||||
is_gpass_enabled(tab.url).then(
|
||||
function (key_present)
|
||||
{
|
||||
var enabled = (key_present == null);
|
||||
// Do switch
|
||||
enabled = !enabled;
|
||||
update_enable(enabled, tab, true);
|
||||
});
|
||||
}
|
||||
|
||||
function createMenus(browser)
|
||||
{
|
||||
var title;
|
||||
|
||||
debug("Create menus");
|
||||
|
||||
/* Not supported by Chrome */
|
||||
if (browser.menus.onShown)
|
||||
title = 'Disable form\'s hook for this website';
|
||||
else
|
||||
title = 'Disable or enable form\'s hook for this website';
|
||||
|
||||
/* Enable/disable */
|
||||
browser.menus.create({
|
||||
id: 'switch_enable',
|
||||
title: title,
|
||||
contexts: ['action'],
|
||||
}, () => {console.log(chrome.runtime.lastError);});
|
||||
|
||||
/* Not supported by Chrome */
|
||||
if (browser.menus.onShown)
|
||||
title = 'Disable form\'s hook for ALL websites';
|
||||
else
|
||||
title = 'Disable or enable form\'s hook for ALL websites';
|
||||
|
||||
/* Always enable/disable */
|
||||
browser.menus.create({
|
||||
id: 'always_disable',
|
||||
title: title,
|
||||
contexts: ['action']
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function extension_load()
|
||||
{
|
||||
browser.runtime.onMessage.addListener(
|
||||
function(request, sender, sendResponse) {
|
||||
if (request.type == "password")
|
||||
{
|
||||
var domain = parseUri(request.domain);
|
||||
domain = domain["host"];
|
||||
var wdomain = wildcard_domain(domain);
|
||||
|
||||
ask_server(request.logins, domain,
|
||||
wdomain, request.mkey,
|
||||
sendResponse, request.options);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (request.type == "notification")
|
||||
{
|
||||
_notification(request.options.message, request.options.data);
|
||||
}
|
||||
else if (request.type == "getServerAddress")
|
||||
{
|
||||
get_preference("account_url").then(
|
||||
function (address) {
|
||||
sendResponse({"value" : address});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else if (request.type == "getPopupClipboard")
|
||||
{
|
||||
get_preference("popup_clipboard").then(
|
||||
function (value) {
|
||||
sendResponse({"value" : value});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else if (request.type == "is_gpass_enabled")
|
||||
{
|
||||
browser.tabs.query({active:true, currentWindow:true}).then( (tabs) =>
|
||||
{
|
||||
_query_tabs_is_gpass_enabled(tabs, sendResponse);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else if (request.type == "update_icon")
|
||||
{
|
||||
debug("update_icon");
|
||||
browser.tabs.query({active:true, currentWindow:true}).then( (tabs) =>
|
||||
{
|
||||
_query_tabs_update_icon(tabs, request.icon_id);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("Unknown message " + request.type);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/* Chrome */
|
||||
if (!browser.menus && browser.contextMenus)
|
||||
{
|
||||
browser.menus = browser.contextMenus;
|
||||
}
|
||||
|
||||
browser.runtime.onInstalled.addListener(() => {
|
||||
createMenus(browser)
|
||||
});
|
||||
|
||||
browser.menus.onClicked.addListener(
|
||||
function(info, tab) {
|
||||
switch (info.menuItemId) {
|
||||
|
||||
case 'always_disable':
|
||||
get_preference('always_disabled').then(
|
||||
function (always_disabled) {
|
||||
debug('Change always disable');
|
||||
debug(always_disabled);
|
||||
always_disabled = !always_disabled;
|
||||
|
||||
set_preference('always_disabled', always_disabled,
|
||||
function(error)
|
||||
{
|
||||
browser.tabs.query({active:true, currentWindow:true},
|
||||
(tabs) => {
|
||||
for (var i=0; i<tabs.length; i++)
|
||||
update_enable(!always_disabled, tabs[i], false);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
break;
|
||||
case 'switch_enable':
|
||||
gpass_switch_enable(tab);
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
/* Firefox only */
|
||||
if (browser.menus.onShown)
|
||||
{
|
||||
browser.menus.onShown.addListener(
|
||||
function(info, tab) {
|
||||
is_gpass_enabled(tab.url).then(
|
||||
function (key_present) {
|
||||
enabled = (key_present == null);
|
||||
if (enabled)
|
||||
title = 'Disable gPass for this website';
|
||||
else
|
||||
title = 'Enable gPass for this website';
|
||||
browser.menus.update("switch_enable",
|
||||
{
|
||||
"title":title
|
||||
}
|
||||
);
|
||||
browser.menus.refresh();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
browser.menus.onShown.addListener(
|
||||
function(info, tab) {
|
||||
get_preference('always_disabled').then(
|
||||
function (always_disabled) {
|
||||
if (always_disabled)
|
||||
title = 'Enable gPass for ALL websites';
|
||||
else
|
||||
title = 'Disable gPass for ALL websites';
|
||||
browser.menus.update("always_disable",
|
||||
{
|
||||
"title":title
|
||||
}
|
||||
);
|
||||
browser.menus.refresh();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function self_test()
|
||||
{
|
||||
mkey = crypto_pbkdf2("password", "salt", 4096);
|
||||
res = await encrypt_ecb(mkey, "DDDDDDDDDDDDDDDD");
|
||||
|
||||
reference = new Uint8Array([0xc4, 0x76, 0x01, 0x07, 0xa1, 0xc0, 0x2f, 0x22, 0xee, 0xbe, 0x60,
|
||||
0xff, 0x65, 0x33, 0x5b, 0x9e]);
|
||||
if (res != ab2str(reference))
|
||||
{
|
||||
console.log("Self test ERROR !");
|
||||
}
|
||||
else
|
||||
console.log("Self test OK !");
|
||||
}
|
||||
|
||||
//self_test();
|
||||
extension_load();
|
||||
|
||||
@@ -1,23 +1,29 @@
|
||||
/*
|
||||
Copyright (C) 2013-2017 Grégory Soutadé
|
||||
|
||||
Copyright (C) 2013-2022 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function getPref(key)
|
||||
var default_preferences = {"pbkdf2_level": 1000,
|
||||
"account_url": "https://gpass-demo.soutade.fr/demo",
|
||||
"always_disabled":false,
|
||||
"popup_clipboard":false
|
||||
};
|
||||
|
||||
export function get_preference(key)
|
||||
{
|
||||
// Inspired from https://github.com/akiomik/chrome-storage-promise/
|
||||
var promise = new Promise((resolve, reject) => {
|
||||
@@ -32,14 +38,36 @@ function getPref(key)
|
||||
})
|
||||
.then(function (pref) {
|
||||
if (!pref.hasOwnProperty(key))
|
||||
return default_preferences[key];
|
||||
{
|
||||
if (default_preferences.hasOwnProperty(key))
|
||||
return default_preferences[key];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return pref[key];
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
function setPref(key, value)
|
||||
export function set_preference(key, value, sendResponse)
|
||||
{
|
||||
chrome.storage.local.set({key:value}, function ok() {});
|
||||
var pref = {[key]:value};
|
||||
chrome.storage.local.set(pref, function (result) {
|
||||
if (chrome.runtime.lastError)
|
||||
alert(chrome.runtime.lastError);
|
||||
if (sendResponse)
|
||||
sendResponse(chrome.runtime.lastError);
|
||||
});
|
||||
}
|
||||
|
||||
export function delete_preference(key)
|
||||
{
|
||||
chrome.storage.local.remove(key);
|
||||
}
|
||||
|
||||
export function send_tab_message(tab_id, parameters, callback)
|
||||
{
|
||||
chrome.tabs.sendMessage(tab_id, parameters, {}, callback);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,47 +1,28 @@
|
||||
/*
|
||||
Copyright (C) 2013-2017 Grégory Soutadé
|
||||
|
||||
Copyright (C) 2013-2022 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* from misc.js */
|
||||
/* Can't directly add it, because it's now a module */
|
||||
var DEBUG = false;
|
||||
var protocol_version = 4;
|
||||
var account_url = null;
|
||||
var crypto_v2_logins_size = 0;
|
||||
|
||||
SERVER = {OK : 0, FAILED : 1, RESTART_REQUEST : 2};
|
||||
|
||||
// http://stackoverflow.com/questions/3745666/how-to-convert-from-hex-to-ascii-in-javascript
|
||||
function hex2a(hex) {
|
||||
var str = '';
|
||||
for (var i = 0; i < hex.length; i += 2)
|
||||
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
|
||||
return str;
|
||||
}
|
||||
|
||||
function a2hex(_str_) {
|
||||
var hex = '';
|
||||
for (var i = 0; i < _str_.length; i++)
|
||||
{
|
||||
var c = _str_.charCodeAt(i).toString(16);
|
||||
if (c.length == 1) c = "0" + c;
|
||||
hex += c;
|
||||
}
|
||||
return hex;
|
||||
}
|
||||
var browser = browser || chrome;
|
||||
const SERVER = {OK : 0, FAILED : 1, RESTART_REQUEST : 2};
|
||||
const GPASS_ICON = {NORMAL:0, DISABLED:1, ACTIVATED:2};
|
||||
|
||||
function debug(s)
|
||||
{
|
||||
@@ -49,258 +30,13 @@ function debug(s)
|
||||
console.log(s);
|
||||
}
|
||||
|
||||
async function generate_request(domain, login, mkey, iv, old)
|
||||
function notify(text, data)
|
||||
{
|
||||
if (old)
|
||||
{
|
||||
var v = "@@" + domain + ";" + login;
|
||||
debug("will encrypt " + v);
|
||||
enc = encrypt_ecb(mkey, v);
|
||||
}
|
||||
else
|
||||
{
|
||||
var v = domain + ";" + login;
|
||||
debug("will encrypt " + v);
|
||||
while ((v.length % 16))
|
||||
v += "\0";
|
||||
hash = await digest(v);
|
||||
v += hash.slice(8, 24);
|
||||
enc = encrypt_cbc(mkey, iv, v);
|
||||
}
|
||||
return enc;
|
||||
browser.runtime.sendMessage({type: "notification", options:{"message":text, "data":data}});
|
||||
}
|
||||
|
||||
async function ask_server(form, field, logins, domain, wdomain, mkey, submit)
|
||||
{
|
||||
account_url = await getPref("account_url");
|
||||
|
||||
var salt = parseURI.parseUri(account_url);
|
||||
salt = salt["host"] + salt["path"];
|
||||
|
||||
debug("salt " + salt);
|
||||
|
||||
pbkdf2_level = await getPref("pbkdf2_level");
|
||||
|
||||
global_iv = await simple_pbkdf2(salt, mkey, pbkdf2_level);
|
||||
global_iv = global_iv.slice(0, 16);
|
||||
mkey = crypto_pbkdf2(mkey, salt, pbkdf2_level);
|
||||
|
||||
debug("global_iv " + a2hex(global_iv));
|
||||
|
||||
keys = "";
|
||||
for(key_index=0, a=0; a<logins.length; a++, key_index++)
|
||||
{
|
||||
enc = await generate_request(domain, logins[a], mkey, global_iv, 0);
|
||||
keys += (keys.length != 0) ? "&" : "";
|
||||
keys += "k" + key_index + "=" + a2hex(enc);
|
||||
|
||||
if (wdomain != "")
|
||||
{
|
||||
enc = await generate_request(wdomain, logins[a], mkey, global_iv, 0);
|
||||
keys += (keys.length != 0) ? "&" : "";
|
||||
keys += "k" + (++key_index) + "=" + a2hex(enc);
|
||||
}
|
||||
}
|
||||
|
||||
crypto_v2_logins_size = key_index;
|
||||
if (await getPref("crypto_v1_compatible"))
|
||||
{
|
||||
for(a=0; a<logins.length; a++, key_index++)
|
||||
{
|
||||
enc = await generate_request(domain, logins[a], mkey, global_iv, 1);
|
||||
keys += (keys.length != 0) ? "&" : "";
|
||||
keys += "k" + key_index + "=" + a2hex(enc);
|
||||
|
||||
if (wdomain != "")
|
||||
{
|
||||
enc = await generate_request(wdomain, logins[a], mkey, global_iv, 1);
|
||||
keys += (keys.length != 0) ? "&" : "";
|
||||
keys += "k" + (++key_index) + "=" + a2hex(enc);
|
||||
}
|
||||
}
|
||||
}
|
||||
debug("Keys " + keys);
|
||||
|
||||
var gPassRequest = new XMLHttpRequest();
|
||||
|
||||
var ret = SERVER.OK;
|
||||
|
||||
// gPassRequest.addEventListener("progress", function(evt) { ; }, false);
|
||||
gPassRequest.addEventListener("load", async function(evt) {
|
||||
var ciphered_password = "";
|
||||
var server_pbkdf2_level = 0;
|
||||
var server_version = 0;
|
||||
var matched_key = 0;
|
||||
|
||||
var r = this.responseText.split("\n");
|
||||
debug("resp " + r);
|
||||
|
||||
for(var a=0; a<r.length; a++)
|
||||
{
|
||||
debug("Analyse " + r[a]);
|
||||
|
||||
params = r[a].split("=");
|
||||
if (params.length != 2 && params[0] != "<end>")
|
||||
{
|
||||
notify("Error : It seems that it's not a gPass server",
|
||||
this.responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(params[0])
|
||||
{
|
||||
case "protocol":
|
||||
debug("protocol : " + params[1]);
|
||||
|
||||
if (params[1].indexOf("gpass-") != 0)
|
||||
{
|
||||
notify("Error : It seems that it's not a gPass server",
|
||||
this.responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
server_protocol_version = params[1].match(/\d+/)[0];
|
||||
|
||||
if (server_protocol_version > protocol_version)
|
||||
{
|
||||
notify("Protocol version not supported, please upgrade your addon",
|
||||
"Protocol version not supported, please upgrade your addon");
|
||||
ret = SERVER.FAILED;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (server_protocol_version)
|
||||
{
|
||||
case 2:
|
||||
server_pbkdf2_level = 1000;
|
||||
break;
|
||||
case 3:
|
||||
// Version 3 : nothing special to do
|
||||
case 4:
|
||||
// Version 4 : nothing special to do
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "matched_key":
|
||||
matched_key = params[1];
|
||||
case "pass":
|
||||
ciphered_password = params[1];
|
||||
break;
|
||||
case "pkdbf2_level":
|
||||
case "pbkdf2_level":
|
||||
server_pbkdf2_level = parseInt(params[1].match(/\d+/)[0], 10);
|
||||
if (server_pbkdf2_level != NaN &&
|
||||
server_pbkdf2_level != pbkdf2_level &&
|
||||
server_pbkdf2_level >= 1000) // Minimum level for PBKDF2 !
|
||||
{
|
||||
debug("New pbkdf2 level " + server_pbkdf2_level);
|
||||
pbkdf2_level = server_pbkdf2_level;
|
||||
setPref("pbkdf2_level", pbkdf2_level);
|
||||
ret = SERVER.RESTART_REQUEST;
|
||||
}
|
||||
break;
|
||||
case "<end>":
|
||||
break;
|
||||
default:
|
||||
debug("Unknown command " + params[0]);
|
||||
|
||||
notify("Error : It seems that it's not a gPass server",
|
||||
this.responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != SERVER.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ciphered_password != "")
|
||||
{
|
||||
debug("Ciphered password : " + ciphered_password);
|
||||
if (matched_key >= crypto_v2_logins_size)
|
||||
// Crypto v1
|
||||
{
|
||||
clear_password = await decrypt_ecb(mkey, hex2a(ciphered_password));
|
||||
// Remove trailing \0 and salt
|
||||
clear_password = clear_password.replace(/\0*$/, "");
|
||||
clear_password = clear_password.substr(0, clear_password.length-3);
|
||||
}
|
||||
else
|
||||
{
|
||||
clear_password = await decrypt_cbc(mkey, global_iv, hex2a(ciphered_password));
|
||||
clear_password = clear_password.replace(/\0*$/, "");
|
||||
clear_password = clear_password.substr(3, clear_password.length);
|
||||
}
|
||||
debug("Clear password " + clear_password);
|
||||
field.value = clear_password;
|
||||
// Remove gPass event listener and submit again with clear password
|
||||
if (submit)
|
||||
{
|
||||
form.removeEventListener("submit", on_sumbit, true);
|
||||
// Propagate change
|
||||
change_cb = field.onchange;
|
||||
if (change_cb)
|
||||
change_cb();
|
||||
// Try to type "enter"
|
||||
var evt = new KeyboardEvent("keydown");
|
||||
delete evt.which;
|
||||
evt.which = 13;
|
||||
field.dispatchEvent(evt);
|
||||
// Submit form
|
||||
form.submit();
|
||||
}
|
||||
else
|
||||
{
|
||||
notify("Password successfully replaced",
|
||||
"Password successfully replaced");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("No password found");
|
||||
|
||||
ret = SERVER.FAILED;
|
||||
|
||||
notify("No password found in database",
|
||||
"No password found in database");
|
||||
}
|
||||
}, false);
|
||||
gPassRequest.addEventListener("error", function(evt) {
|
||||
debug("error");
|
||||
ret = false;
|
||||
notify("Error",
|
||||
"Error");
|
||||
}, false);
|
||||
debug("connect to " + account_url);
|
||||
gPassRequest.open("POST", account_url, true);
|
||||
gPassRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||
gPassRequest.send(keys);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function wildcard_domain(domain)
|
||||
{
|
||||
var parts = domain.split(".");
|
||||
|
||||
// Standard root domain (zzz.xxx.com) or more
|
||||
if (parts.length > 2)
|
||||
{
|
||||
res = "*.";
|
||||
for (i=1; i<parts.length; i++)
|
||||
res += parts[i];
|
||||
}
|
||||
// Simple xxx.com
|
||||
else if (parts.length == 2)
|
||||
return "*." + domain;
|
||||
|
||||
return "";
|
||||
}
|
||||
var gpass_enabled = true;
|
||||
|
||||
function _add_name(logins, name)
|
||||
{
|
||||
@@ -317,23 +53,35 @@ function try_get_name(fields, type_filters, match)
|
||||
for (var i=0; i<fields.length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
var to_test = !match;
|
||||
|
||||
for (var a=0; a<type_filters.length; a++)
|
||||
{
|
||||
if ((match && field.getAttribute("type") == type_filters[a]) ||
|
||||
(!match && field.getAttribute("type") != type_filters[a]))
|
||||
{
|
||||
if (field.hasAttribute("name") && field.value != "")
|
||||
{
|
||||
name = field.getAttribute("name");
|
||||
// Subset of common user field
|
||||
if (name == "user") user = field.value;
|
||||
else if (name == "usr") user = field.value;
|
||||
else if (name == "username") user = field.value;
|
||||
else if (name == "login") user = field.value;
|
||||
if (match && field.getAttribute("type") == type_filters[a])
|
||||
{
|
||||
to_test = true;
|
||||
break;
|
||||
}
|
||||
|
||||
_add_name(all_logins, field.value);
|
||||
}
|
||||
if(!match && field.getAttribute("type") == type_filters[a])
|
||||
{
|
||||
to_test = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (to_test)
|
||||
{
|
||||
if (field.hasAttribute("name") && field.value != "")
|
||||
{
|
||||
var name = field.getAttribute("name");
|
||||
// Subset of common user field
|
||||
if (name == "user") user = field.value;
|
||||
else if (name == "usr") user = field.value;
|
||||
else if (name == "username") user = field.value;
|
||||
else if (name == "login") user = field.value;
|
||||
|
||||
_add_name(all_logins, field.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,27 +92,77 @@ function try_get_name(fields, type_filters, match)
|
||||
return all_logins;
|
||||
}
|
||||
|
||||
function get_logins(form, all_logins)
|
||||
{
|
||||
var fields = form.getElementsByTagName("input");
|
||||
var logins = null;
|
||||
|
||||
debug("get_logins");
|
||||
|
||||
var type_filters = new Array();
|
||||
|
||||
// Get all <input type="text"> && <input type="email">
|
||||
type_filters.push("text");
|
||||
type_filters.push("email");
|
||||
if (all_logins)
|
||||
logins = try_get_name(fields, type_filters, true);
|
||||
else
|
||||
{
|
||||
// Get all other fields except text, email and password
|
||||
type_filters.push("password");
|
||||
type_filters.push("hidden");
|
||||
logins = try_get_name(fields, type_filters, false);
|
||||
}
|
||||
|
||||
return logins;
|
||||
}
|
||||
|
||||
function on_focus(e)
|
||||
{
|
||||
if (!gpass_enabled)
|
||||
return;
|
||||
|
||||
var logins = get_logins(this.form, true);
|
||||
var all_logins = get_logins(this.form, false);
|
||||
|
||||
if (logins.length || all_logins.length)
|
||||
{
|
||||
var parameters = {
|
||||
type:"update_icon",
|
||||
icon_id:GPASS_ICON.ACTIVATED,
|
||||
};
|
||||
browser.runtime.sendMessage(parameters, {});
|
||||
}
|
||||
}
|
||||
|
||||
function on_blur(e)
|
||||
{
|
||||
if (!gpass_enabled)
|
||||
return;
|
||||
|
||||
var parameters = {
|
||||
type:"update_icon",
|
||||
icon_id:GPASS_ICON.NORMAL,
|
||||
};
|
||||
browser.runtime.sendMessage(parameters, {});
|
||||
}
|
||||
|
||||
function on_sumbit(e)
|
||||
{
|
||||
var form = this;
|
||||
var fields = form.getElementsByTagName("input");
|
||||
var domain = form.ownerDocument.baseURI;
|
||||
var password_computed = false;
|
||||
|
||||
var domain = parseURI.parseUri(form.ownerDocument.baseURI);
|
||||
domain = domain["host"];
|
||||
var wdomain = wildcard_domain(domain);
|
||||
debug("on_submit");
|
||||
|
||||
type_filters = new Array();
|
||||
// Get all <input type="text"> && <input type="email">
|
||||
type_filters.push("text");
|
||||
type_filters.push("email");
|
||||
logins = try_get_name(fields, type_filters, true);
|
||||
var logins = get_logins(form, true);
|
||||
var all_logins = get_logins(form, false);
|
||||
|
||||
// Get all other fields except text, email and password
|
||||
if (!logins.length)
|
||||
{
|
||||
type_filters.push("password");
|
||||
logins = try_get_name(fields, type_filters, false);
|
||||
}
|
||||
logins = all_logins;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
// Look for <input type="password" value="@@...">
|
||||
for (var i=0; i<fields.length; i++)
|
||||
@@ -373,93 +171,236 @@ function on_sumbit(e)
|
||||
|
||||
if (field.getAttribute("type") == "password")
|
||||
{
|
||||
debug(field.value);
|
||||
password = field.value;
|
||||
if (password.indexOf("@@") != 0 && password.indexOf("@_") != 0)
|
||||
var password = field.value;
|
||||
if (!password.startsWith("@@") && !password.startsWith("@_"))
|
||||
continue;
|
||||
|
||||
// Remove current value to limit master key stealing
|
||||
field.value = "";
|
||||
|
||||
mkey = password.substring(2);
|
||||
password_computed = true;
|
||||
var do_submit = !password.startsWith("@_");
|
||||
var mkey = password.substring(2);
|
||||
|
||||
e.preventDefault();
|
||||
var parameters = {
|
||||
type:"password",
|
||||
logins:logins,
|
||||
domain:domain,
|
||||
mkey:mkey,
|
||||
options:{field_id:i}
|
||||
};
|
||||
|
||||
var ret = ask_server(form, field, logins, domain, wdomain, mkey, (password.indexOf("@@") == 0));
|
||||
|
||||
ret.then(function(ret){
|
||||
switch(ret)
|
||||
{
|
||||
case SERVER.OK:
|
||||
break;
|
||||
case SERVER.FAILED:
|
||||
if (logins !== all_logins)
|
||||
{
|
||||
ask_server(form, field, all_logins, domain, wdomain, mkey, (password.indexOf("@@") == 0));
|
||||
}
|
||||
break;
|
||||
case SERVER.RESTART_REQUEST:
|
||||
i = -1; // Restart loop
|
||||
break;
|
||||
}
|
||||
});
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response) {
|
||||
debug(response);
|
||||
switch(response.value)
|
||||
{
|
||||
case SERVER.OK:
|
||||
var field = fields[response.options.field_id];
|
||||
set_password(form, field, response.password, do_submit)
|
||||
notify("Password successfully replaced", "");
|
||||
break;
|
||||
case SERVER.FAILED:
|
||||
if (logins.length != all_logins.length && all_logins.length != 0)
|
||||
{
|
||||
debug("Try with all logins");
|
||||
parameters[logins] = all_logins;
|
||||
browser.runtime.sendMessage(parameters);
|
||||
}
|
||||
break;
|
||||
case SERVER.RESTART_REQUEST:
|
||||
i = -1; // Restart loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
if (!password_computed)
|
||||
{
|
||||
debug("No password computed");
|
||||
if (form.submit)
|
||||
form.submit();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function document_loaded(doc)
|
||||
function set_password(form, field, password, do_submit)
|
||||
{
|
||||
var has_login_form = false;
|
||||
field.value = password;
|
||||
// Remove gPass event listener and submit again with clear password
|
||||
unblock_all_forms();
|
||||
if (do_submit)
|
||||
{
|
||||
// Propagate change
|
||||
var change_cb = field.onchange;
|
||||
if (change_cb)
|
||||
change_cb();
|
||||
// Try to type "enter"
|
||||
var evt = new KeyboardEvent("keydown");
|
||||
delete evt.which;
|
||||
evt.which = 13;
|
||||
field.dispatchEvent(evt);
|
||||
// Submit form
|
||||
if (form.submit)
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
|
||||
var managed_forms = new Array();
|
||||
|
||||
function block_all_forms(doc, do_block)
|
||||
{
|
||||
var first_time = (managed_forms.length == 0);
|
||||
var cur_focused_element = document.activeElement;
|
||||
|
||||
debug("block all forms");
|
||||
|
||||
gpass_enabled = do_block;
|
||||
|
||||
// If there is a password in the form, add a "submit" listener
|
||||
for(var i=0; i<doc.forms.length; i++)
|
||||
{
|
||||
var form = doc.forms[i];
|
||||
var fields = form.getElementsByTagName("input");
|
||||
for (a=0; a<fields.length; a++)
|
||||
for (var a=0; a<fields.length; a++)
|
||||
{
|
||||
var field = fields[a];
|
||||
if (field.getAttribute("type") == "password")
|
||||
{
|
||||
block_url(form.action);
|
||||
old_cb = form.onsubmit;
|
||||
if (old_cb)
|
||||
form.removeEventListener("submit", old_cb);
|
||||
form.addEventListener("submit", on_sumbit);
|
||||
if (old_cb)
|
||||
form.addEventListener("submit", old_cb);
|
||||
has_login_form = true;
|
||||
if (do_block)
|
||||
{
|
||||
var old_cb = form.onsubmit;
|
||||
if (old_cb)
|
||||
form.removeEventListener("submit", old_cb);
|
||||
form.addEventListener("submit", on_sumbit);
|
||||
if (old_cb)
|
||||
form.addEventListener("submit", old_cb);
|
||||
field.addEventListener("focus", on_focus);
|
||||
field.addEventListener("blur", on_blur);
|
||||
if (cur_focused_element === field)
|
||||
on_focus(null);
|
||||
}
|
||||
if (first_time)
|
||||
managed_forms.push(form);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function unblock_all_forms()
|
||||
{
|
||||
debug("unblock all forms");
|
||||
|
||||
for(var i=0; i<managed_forms.length; i++)
|
||||
{
|
||||
var form = managed_forms[i];
|
||||
|
||||
form.removeEventListener("submit", on_sumbit);
|
||||
|
||||
var fields = form.getElementsByTagName("input");
|
||||
for (var a=0; a<fields.length; a++)
|
||||
{
|
||||
var field = fields[a];
|
||||
if (field.getAttribute("type") == "password")
|
||||
{
|
||||
field.removeEventListener("focus", on_focus);
|
||||
field.removeEventListener("blur", on_blur);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Request can be sent to another URL... */
|
||||
if (has_login_form)
|
||||
block_url("<all_urls>");
|
||||
gpass_enabled = false;
|
||||
}
|
||||
|
||||
document_loaded(document);
|
||||
browser.runtime.onMessage.addListener(
|
||||
function(request, sender, sendResponse) {
|
||||
|
||||
async function self_test()
|
||||
if (request.type == "getUsername")
|
||||
{
|
||||
debug("getUsername");
|
||||
if (managed_forms.length == 1)
|
||||
{
|
||||
var fields = managed_forms[0].getElementsByTagName("input");
|
||||
|
||||
var type_filters = new Array();
|
||||
// Get all <input type="text"> && <input type="email">
|
||||
type_filters.push("text");
|
||||
type_filters.push("email");
|
||||
var logins = try_get_name(fields, type_filters, true);
|
||||
|
||||
if (logins.length == 1)
|
||||
sendResponse(logins[0]);
|
||||
else
|
||||
sendResponse("");
|
||||
}
|
||||
else
|
||||
sendResponse("");
|
||||
}
|
||||
else if (request.type == "setPassword")
|
||||
{
|
||||
debug("setPassword");
|
||||
var response = "";
|
||||
if (managed_forms.length == 1)
|
||||
{
|
||||
var fields = managed_forms[0].getElementsByTagName("input");
|
||||
var password_field = null;
|
||||
|
||||
for (var a=0; a<fields.length; a++)
|
||||
{
|
||||
var field = fields[a];
|
||||
if (field.getAttribute("type") == "password")
|
||||
{
|
||||
if (password_field == null)
|
||||
password_field = field;
|
||||
else
|
||||
{
|
||||
// More than one password field : abort
|
||||
password_field = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (password_field)
|
||||
{
|
||||
set_password(managed_forms[0], password_field,
|
||||
request.password, request.submit);
|
||||
response = "ok";
|
||||
}
|
||||
}
|
||||
sendResponse(response);
|
||||
}
|
||||
else if (request.type == "blockForms")
|
||||
{
|
||||
block_all_forms(document, true);
|
||||
}
|
||||
else if (request.type == "unblockForms")
|
||||
{
|
||||
unblock_all_forms();
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
function document_loaded()
|
||||
{
|
||||
mkey = crypto_pbkdf2("password", "salt", 4096);
|
||||
res = await encrypt_ecb(mkey, "DDDDDDDDDDDDDDDD");
|
||||
|
||||
reference = new Uint8Array([0xc4, 0x76, 0x01, 0x07, 0xa1, 0xc0, 0x2f, 0x22, 0xee, 0xbe, 0x60,
|
||||
0xff, 0x65, 0x33, 0x5b, 0x9e]);
|
||||
if (res != ab2str(reference))
|
||||
{
|
||||
console.log("Self test ERROR !");
|
||||
}
|
||||
else
|
||||
console.log("Self test OK !");
|
||||
var parameters = {
|
||||
"type": "is_gpass_enabled",
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response) {
|
||||
if (response)
|
||||
block_all_forms(document, response.enabled);
|
||||
});
|
||||
}
|
||||
|
||||
console.log("Welcome to gPass web extension v0.8.1 !");
|
||||
document_loaded();
|
||||
|
||||
console.log("Welcome to gPass web extension v0.9 !");
|
||||
console.log("Privacy Policy can be found at http://indefero.soutade.fr/p/gpass/source/tree/master/PrivacyPolicy.md");
|
||||
console.log("");
|
||||
|
||||
//self_test();
|
||||
|
||||
@@ -1,38 +1,32 @@
|
||||
/*
|
||||
Copyright (C) 2013-2017 Grégory Soutadé
|
||||
|
||||
Copyright (C) 2013-2022 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var default_preferences = {"pbkdf2_level": 1000,
|
||||
"account_url": "https://gpass-demo.soutade.fr/demo",
|
||||
"crypto_v1_compatible": true};
|
||||
var DEBUG = false;
|
||||
|
||||
var browser = browser || chrome;
|
||||
var crypto = crypto || window.crypto;
|
||||
export const SERVER = {OK : 0, FAILED : 1, RESTART_REQUEST : 2};
|
||||
export const GPASS_ICON = {NORMAL:0, DISABLED:1, ACTIVATED:2};
|
||||
|
||||
function notify(text, data)
|
||||
export var browser = browser || chrome;
|
||||
|
||||
export function notify(text, data)
|
||||
{
|
||||
browser.runtime.sendMessage({type: "notification", options:{"message":text}});
|
||||
}
|
||||
|
||||
function block_url(url)
|
||||
{
|
||||
debug("Block URL " + url);
|
||||
browser.runtime.sendMessage({type: "block_url", options:{"url":url}});
|
||||
browser.runtime.sendMessage({type: "notification", options:{"message":text, "data":data}});
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers
|
||||
@@ -59,9 +53,9 @@ function str2ab(str) {
|
||||
return bufView;
|
||||
}
|
||||
|
||||
function crypto_pbkdf2(mkey, salt, level)
|
||||
export function crypto_pbkdf2(crypto, mkey, salt, level)
|
||||
{
|
||||
AESCBC = {
|
||||
var AESCBC = {
|
||||
name: "AES-CBC",
|
||||
length: 256,
|
||||
}
|
||||
@@ -88,9 +82,9 @@ function crypto_pbkdf2(mkey, salt, level)
|
||||
});
|
||||
}
|
||||
|
||||
function simple_pbkdf2(mkey, salt, level)
|
||||
export function simple_pbkdf2(crypto, mkey, salt, level)
|
||||
{
|
||||
AESCBC = {
|
||||
var AESCBC = {
|
||||
name: "AES-CBC",
|
||||
length: 256,
|
||||
}
|
||||
@@ -124,10 +118,10 @@ function _encrypt(mkey, iv, data)
|
||||
{
|
||||
while ((data.length % 16))
|
||||
data += "\0";
|
||||
|
||||
|
||||
data = str2ab(data);
|
||||
|
||||
promise = mkey.then(function(mkey){
|
||||
var promise = mkey.then(function(mkey){
|
||||
return crypto.subtle.encrypt({
|
||||
name: "AES-CBC",
|
||||
iv: iv
|
||||
@@ -147,15 +141,15 @@ async function _decrypt(mkey, iv, data)
|
||||
while ((data.length % 16))
|
||||
data += "\0";
|
||||
|
||||
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
pkcs7_padding = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]);
|
||||
var nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
var pkcs7_padding = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]);
|
||||
pkcs7_padding = await _encrypt(mkey, nulliv, ab2str(pkcs7_padding));
|
||||
|
||||
data = str2ab(data + pkcs7_padding);
|
||||
|
||||
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
promise = mkey.then(function(mkey){
|
||||
var promise = mkey.then(function(mkey){
|
||||
return crypto.subtle.decrypt({
|
||||
name: "AES-CBC",
|
||||
iv: iv
|
||||
@@ -170,13 +164,14 @@ async function _decrypt(mkey, iv, data)
|
||||
return promise;
|
||||
}
|
||||
|
||||
async function encrypt_ecb(mkey, data)
|
||||
export async function encrypt_ecb(mkey, data)
|
||||
{
|
||||
var result = "";
|
||||
var res;
|
||||
|
||||
console.log("Encrypt ECB " + data);
|
||||
debug("Encrypt ECB " + data);
|
||||
|
||||
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
var nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
while (data.length > 16)
|
||||
{
|
||||
@@ -191,13 +186,14 @@ async function encrypt_ecb(mkey, data)
|
||||
return result;
|
||||
}
|
||||
|
||||
async function decrypt_ecb(mkey, data)
|
||||
export async function decrypt_ecb(mkey, data)
|
||||
{
|
||||
var result = "";
|
||||
|
||||
console.log("Decrypt ECB " + data);
|
||||
var res;
|
||||
|
||||
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
debug("Decrypt ECB " + data);
|
||||
|
||||
var nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
while (data.length > 16)
|
||||
{
|
||||
@@ -212,29 +208,74 @@ async function decrypt_ecb(mkey, data)
|
||||
return result;
|
||||
}
|
||||
|
||||
async function encrypt_cbc(mkey, iv, data)
|
||||
{
|
||||
console.log("Encrypt CBC " + data);
|
||||
export async function encrypt_cbc(mkey, iv, data)
|
||||
{
|
||||
debug("Encrypt CBC " + data);
|
||||
|
||||
var result = await _encrypt(mkey, str2ab(iv), data);
|
||||
|
||||
|
||||
// Remove PKCS7 padding
|
||||
return result.slice(0, result.length-16);
|
||||
}
|
||||
|
||||
async function decrypt_cbc(mkey, iv, data)
|
||||
export async function decrypt_cbc(mkey, iv, data)
|
||||
{
|
||||
console.log("Decrypt CBC " + data);
|
||||
debug("Decrypt CBC " + data);
|
||||
|
||||
var result = await _decrypt(mkey, str2ab(iv), data);
|
||||
|
||||
// Remove PKCS7 padding
|
||||
return result.slice(0, result.length-16);
|
||||
return result.slice(0, result.length-16);
|
||||
}
|
||||
|
||||
async function digest(data)
|
||||
export async function digest(crypto, data)
|
||||
{
|
||||
return crypto.subtle.digest("SHA-256", str2ab(data)).then(function (hash) {
|
||||
return ab2str(hash);
|
||||
});
|
||||
}
|
||||
|
||||
export function wildcard_domain(domain)
|
||||
{
|
||||
var parts = domain.split(".");
|
||||
|
||||
// Standard root domain (zzz.xxx.com) or more
|
||||
if (parts.length > 2)
|
||||
{
|
||||
var res = "*.";
|
||||
for (var i=1; i<parts.length; i++)
|
||||
res += parts[i] + ".";
|
||||
return res.substr(0, res.length-1);
|
||||
}
|
||||
// Simple xxx.com
|
||||
else if (parts.length == 2)
|
||||
return "*." + domain;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/3745666/how-to-convert-from-hex-to-ascii-in-javascript
|
||||
export function hex2a(hex) {
|
||||
var str = '';
|
||||
for (var i = 0; i < hex.length; i += 2)
|
||||
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
|
||||
return str;
|
||||
}
|
||||
|
||||
export function a2hex(_str_) {
|
||||
var hex = '';
|
||||
for (var i = 0; i < _str_.length; i++)
|
||||
{
|
||||
var c = _str_.charCodeAt(i).toString(16);
|
||||
if (c.length == 1) c = "0" + c;
|
||||
hex += c;
|
||||
}
|
||||
return hex;
|
||||
}
|
||||
|
||||
export function debug(s)
|
||||
{
|
||||
if (DEBUG)
|
||||
console.log(s);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,31 +2,29 @@
|
||||
// (c) Steven Levithan <stevenlevithan.com>
|
||||
// MIT License
|
||||
|
||||
parseURI = {
|
||||
|
||||
parseUri : function (str) {
|
||||
var o = {
|
||||
export function parseUri (str) {
|
||||
var o = {
|
||||
strictMode: false,
|
||||
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
|
||||
q: {
|
||||
name: "queryKey",
|
||||
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
|
||||
name: "queryKey",
|
||||
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
|
||||
},
|
||||
parser: {
|
||||
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
||||
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
|
||||
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
||||
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
|
||||
}},
|
||||
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
|
||||
uri = {},
|
||||
i = 14;
|
||||
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
|
||||
uri = {},
|
||||
i = 14;
|
||||
|
||||
while (i--) uri[o.key[i]] = m[i] || "";
|
||||
while (i--) uri[o.key[i]] = m[i] || "";
|
||||
|
||||
uri[o.q.name] = {};
|
||||
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
|
||||
if ($1) uri[o.q.name][$1] = $2;
|
||||
});
|
||||
uri[o.q.name] = {};
|
||||
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
|
||||
if ($1) uri[o.q.name][$1] = $2;
|
||||
});
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,36 +1,45 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"manifest_version": 3,
|
||||
|
||||
"name": "gPass",
|
||||
"short_name": "gPass",
|
||||
"version": "0.8.1",
|
||||
"version": "1.3",
|
||||
"description": "gPass : global password manager",
|
||||
"icons" : {"16":"icons/gpass_icon_16.png", "32":"icons/gpass_icon_32.png", "64":"icons/gpass_icon_64.png", "128":"icons/gpass_icon_128.png"},
|
||||
"author" : "Grégory Soutadé",
|
||||
"homepage_url" : "http://indefero.soutade.fr/p/gpass",
|
||||
|
||||
"homepage_url" : "https://forge.soutade.fr/soutade/gPass",
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["<all_urls>"],
|
||||
"js": ["lib/parseuri.js", "lib/misc.js", "compat.js", "lib/main.js"],
|
||||
"js": ["lib/main.js"],
|
||||
"run_at" : "document_idle",
|
||||
"all_frames" : true
|
||||
}
|
||||
],
|
||||
|
||||
"background": {
|
||||
"persistent": true,
|
||||
"scripts": ["background.js"]
|
||||
"service_worker": "background.js",
|
||||
"type": "module"
|
||||
},
|
||||
|
||||
"options_page": "options.html",
|
||||
|
||||
"action": {
|
||||
"default_icon": {"32":"icons/gpass_icon_32.png"},
|
||||
"default_title": "Get your password",
|
||||
"default_popup": "popup/popup.html"
|
||||
},
|
||||
|
||||
"host_permissions": [
|
||||
"<all_urls>"
|
||||
],
|
||||
|
||||
"permissions": [
|
||||
"<all_urls>",
|
||||
"activeTab",
|
||||
"notifications",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"tabs",
|
||||
"storage"
|
||||
"storage",
|
||||
"clipboardWrite",
|
||||
"contextMenus"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -8,10 +8,12 @@
|
||||
<b>Account URL</b> URL of your gPass account <input id="account_url" type="text"/><br />
|
||||
<b>WARNING</b> It should be a valid HTTPS URL because navigator doesn't like mixed content (HTTPS/HTTP). If not, requests will silentely failed. If you have an auto-signed certificate, add it to trusted ones.<br/>
|
||||
<br/>
|
||||
<b>PBKDF2 level</b> Number of iterations used to derivate master key <input id="pbkdf2" type="number"/><br />
|
||||
<b>PBKDF2 level</b> Number of iterations used to derivate master key <input id="pbkdf2_level" type="number"/><br />
|
||||
<br/>
|
||||
<b>Always disabled</b> Disable gPass for all websites. You can still use popup, but no hook is attached to login forms <input id="always_disabled" type="checkbox"/><br />
|
||||
<br/>
|
||||
<b>Popup clipboard copy</b> Copy password into clipboard (by default) when using popup <input id="popup_clipboard" type="checkbox"/><br />
|
||||
<br/>
|
||||
<b>Crypto v1 compatible </b> Compatible with old crypto schema (AES ECB). Use it for encrypted passwords with server <= 0.7 <input id="crypto_v1_compatible" type="checkbox"/><br />
|
||||
<br/>
|
||||
<input type="button" id="save" value="Save"/>
|
||||
|
||||
|
||||
@@ -1,40 +1,46 @@
|
||||
var default_preferences = {"pbkdf2_level": 1000,
|
||||
"account_url": "https://gpass-demo.soutade.fr/demo",
|
||||
"crypto_v1_compatible": true};
|
||||
"always_disabled":false,
|
||||
"popup_clipboard":false
|
||||
};
|
||||
|
||||
function save() {
|
||||
var account_url = document.getElementById('account_url').value;
|
||||
var pbkdf2 = document.getElementById('pbkdf2').value;
|
||||
var crypto_v1_compatible = document.getElementById('crypto_v1_compatible').checked;
|
||||
var pbkdf2_level = document.getElementById('pbkdf2_level').value;
|
||||
var always_disabled = document.getElementById('always_disabled').checked;
|
||||
var popup_clipboard = document.getElementById('popup_clipboard').checked;
|
||||
|
||||
chrome.storage.local.set({
|
||||
'account_url': account_url,
|
||||
'pbkdf2': pbkdf2,
|
||||
'crypto_v1_compatible': crypto_v1_compatible,
|
||||
'pbkdf2_level': pbkdf2_level,
|
||||
'always_disabled': always_disabled,
|
||||
'popup_clipboard': popup_clipboard,
|
||||
}, function() {
|
||||
alert('Saved');
|
||||
});
|
||||
}
|
||||
|
||||
chrome.storage.local.get(null, function(prefs) {
|
||||
if (!prefs.hasOwnProperty("account_url"))
|
||||
account_url = default_preferences['account_url'];
|
||||
else
|
||||
account_url = prefs['account_url'];
|
||||
|
||||
if (!prefs.hasOwnProperty("pbkdf2_level"))
|
||||
pbkdf2 = default_preferences['pbkdf2_level'];
|
||||
else
|
||||
pbkdf2 = prefs['pbkdf2_level'];
|
||||
|
||||
if (!prefs.hasOwnProperty("crypto_v1_compatible"))
|
||||
crypto_v1_compatible = default_preferences['crypto_v1_compatible'];
|
||||
else
|
||||
crypto_v1_compatible = prefs['crypto_v1_compatible'];
|
||||
function restoreOption(preferences, pref)
|
||||
{
|
||||
var res;
|
||||
|
||||
document.getElementById('account_url').value = account_url;
|
||||
document.getElementById('pbkdf2').value = pbkdf2;
|
||||
document.getElementById('crypto_v1_compatible').checked = crypto_v1_compatible;
|
||||
if (!preferences.hasOwnProperty(pref))
|
||||
res = default_preferences[pref];
|
||||
else
|
||||
res = preferences[pref];
|
||||
|
||||
var element = document.getElementById(pref);
|
||||
if (element.type == 'checkbox')
|
||||
element.checked = res;
|
||||
else
|
||||
element.value = res;
|
||||
}
|
||||
|
||||
chrome.storage.local.get(null, function(prefs) {
|
||||
restoreOption(prefs, 'account_url');
|
||||
restoreOption(prefs, 'pbkdf2_level');
|
||||
restoreOption(prefs, 'always_disabled');
|
||||
restoreOption(prefs, 'popup_clipboard');
|
||||
});
|
||||
|
||||
document.getElementById('save').addEventListener("click", save);
|
||||
|
||||
1
chrome_addon/popup/compat.js
Symbolic link
@@ -0,0 +1 @@
|
||||
../compat.js
|
||||
1
chrome_addon/popup/misc.js
Symbolic link
@@ -0,0 +1 @@
|
||||
../lib/misc.js
|
||||
14
chrome_addon/popup/popup.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<form id="passwordForm" autocomplete="off">
|
||||
Username <input type="text" id="gPassUsername" autofocus></input><br/> Master key <input type="password" id="gPassMasterKey"/><br/>
|
||||
Copy password into clipboard <input id="clipboard" type="checkbox"/><br />
|
||||
<input id="getButton" type="submit" value="Get"/> <a id="serverLink" href="">Your server</a>
|
||||
</form>
|
||||
<script type="module" src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
189
chrome_addon/popup/popup.js
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
Copyright (C) 2020-2022 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {SERVER, browser, notify, debug} from "./misc.js";
|
||||
import {get_preference, send_tab_message} from "./compat.js";
|
||||
|
||||
var username_filled = false;
|
||||
|
||||
function _server_response(response, tabs, do_submit, force_copy)
|
||||
{
|
||||
debug("Get Response");
|
||||
if (response.value == SERVER.OK)
|
||||
{
|
||||
/* Only copy */
|
||||
if (document.getElementById("clipboard").checked)
|
||||
{
|
||||
navigator.clipboard.writeText(response.password).then(function() {
|
||||
notify("Password pasted into clipboard", "");
|
||||
window.setTimeout(function() {window.close();}, 2000);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Fill + optional copy */
|
||||
var parameters = {
|
||||
"type":"setPassword",
|
||||
"password":response.password,
|
||||
"submit":do_submit,
|
||||
};
|
||||
send_tab_message(tabs[0].id, parameters,
|
||||
function(arg)
|
||||
{
|
||||
debug("Response to setPassword " + arg);
|
||||
if (arg === "" || force_copy)
|
||||
{
|
||||
navigator.clipboard.writeText(response.password).then(function() {
|
||||
notify("Password pasted into clipboard", "");
|
||||
window.setTimeout(function() {window.close();}, 2000);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
notify("Password filled", "");
|
||||
window.setTimeout(function() {window.close();}, 2000);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function _query_tabs_get_password(tabs)
|
||||
{
|
||||
var force_copy = false;
|
||||
|
||||
if (tabs.length <= 0) return;
|
||||
|
||||
var username = document.getElementById("gPassUsername").value;
|
||||
var mkey = document.getElementById("gPassMasterKey").value;
|
||||
|
||||
if (username == "" || mkey == "")
|
||||
return;
|
||||
|
||||
document.getElementById("gPassMasterKey").value = "";
|
||||
|
||||
var do_submit = !mkey.startsWith("@_") && username_filled;
|
||||
|
||||
if (mkey.startsWith("@_"))
|
||||
force_copy = true;
|
||||
|
||||
if (mkey.startsWith("@@") || mkey.startsWith("@_"))
|
||||
mkey = mkey.substring(2);
|
||||
|
||||
var domain = tabs[0].url;
|
||||
|
||||
var logins = new Array();
|
||||
logins.push(username);
|
||||
|
||||
var parameters = {
|
||||
type:"password",
|
||||
logins:logins,
|
||||
domain:domain,
|
||||
mkey:mkey,
|
||||
options:{}
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response)
|
||||
{
|
||||
return _server_response(response, tabs, do_submit, force_copy);
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_password(evt)
|
||||
{
|
||||
debug('get_password');
|
||||
|
||||
evt.preventDefault();
|
||||
|
||||
browser.tabs.query({active:true, currentWindow:true}).then(_query_tabs_get_password);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var pform = document.getElementById("passwordForm");
|
||||
|
||||
if (pform != null)
|
||||
pform.onsubmit = get_password;
|
||||
|
||||
function _query_tabs_init(tabs)
|
||||
{
|
||||
debug("_query_tabs_init");
|
||||
|
||||
if (tabs.length != 1) return;
|
||||
|
||||
/* Fill username */
|
||||
var parameters = {
|
||||
"type":"getUsername"
|
||||
};
|
||||
|
||||
send_tab_message(tabs[0].id, parameters,
|
||||
function (response)
|
||||
{
|
||||
if (response !== undefined && response != "")
|
||||
{
|
||||
document.getElementById("gPassUsername").value = response;
|
||||
document.getElementById("gPassMasterKey").focus();
|
||||
username_filled = true;
|
||||
}
|
||||
});
|
||||
|
||||
/* Clipboard copy */
|
||||
parameters = {
|
||||
"type":"getPopupClipboard"
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response)
|
||||
{
|
||||
document.getElementById("clipboard").checked = response.value;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
/* Setup server link address */
|
||||
parameters = {
|
||||
"type":"getServerAddress"
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response)
|
||||
{
|
||||
if (tabs[0].url === undefined) return true;
|
||||
if (tabs[0].url.startsWith("chrome://newtab/")) tabs[0].url = "";
|
||||
var url = response.value;
|
||||
url = url.substring(0, url.lastIndexOf('/'));
|
||||
url += '?';
|
||||
url += 'url=' + encodeURI(tabs[0].url.split("?")[0]);
|
||||
url += '&user=' + document.getElementById("gPassUsername").value;
|
||||
var link = document.getElementById("serverLink");
|
||||
link.href = url;
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
browser.tabs.query({active:true, currentWindow:true}).then(_query_tabs_init);
|
||||
@@ -1 +0,0 @@
|
||||
../README.md
|
||||
|
Before Width: | Height: | Size: 2.1 KiB |
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var {Cc, Ci} = require("chrome");
|
||||
|
||||
var hmac = Cc["@mozilla.org/security/hmac;1"]
|
||||
.createInstance(Ci.nsICryptoHMAC);
|
||||
|
||||
exports.hmac = {
|
||||
hmac_init : function (key) {
|
||||
var keyObject = Cc["@mozilla.org/security/keyobjectfactory;1"]
|
||||
.getService(Ci.nsIKeyObjectFactory)
|
||||
.keyFromString(Ci.nsIKeyObject.HMAC, key);
|
||||
hmac.init(hmac.SHA256, keyObject);
|
||||
},
|
||||
|
||||
hmac_digest : function (message) {
|
||||
var data = new Uint8Array(message.length);
|
||||
for(i=0; i<message.length; i++)
|
||||
data[i] = message.charCodeAt(i);
|
||||
hmac.update(data, data.length);
|
||||
res = hmac.finish(false);
|
||||
hmac.reset();
|
||||
return res;
|
||||
}
|
||||
};
|
||||
@@ -1,291 +0,0 @@
|
||||
/*
|
||||
* jsaes version 0.1 - Copyright 2006 B. Poettering
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* http://point-at-infinity.org/jsaes/
|
||||
*
|
||||
* This is a javascript implementation of the AES block cipher. Key lengths
|
||||
* of 128, 192 and 256 bits are supported.
|
||||
*
|
||||
* The well-functioning of the encryption/decryption routines has been
|
||||
* verified for different key lengths with the test vectors given in
|
||||
* FIPS-197, Appendix C.
|
||||
*
|
||||
* The following code example enciphers the plaintext block '00 11 22 .. EE FF'
|
||||
* with the 256 bit key '00 01 02 .. 1E 1F'.
|
||||
*
|
||||
* AES_Init();
|
||||
*
|
||||
* var block = new Array(16);
|
||||
* for(var i = 0; i < 16; i++)
|
||||
* block[i] = 0x11 * i;
|
||||
*
|
||||
* var key = new Array(32);
|
||||
* for(var i = 0; i < 32; i++)
|
||||
* key[i] = i;
|
||||
*
|
||||
* AES_ExpandKey(key);
|
||||
* AES_Encrypt(block, key);
|
||||
*
|
||||
* AES_Done();
|
||||
*
|
||||
* Report bugs to: jsaes AT point-at-infinity.org
|
||||
*
|
||||
*/
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/*
|
||||
AES_Init: initialize the tables needed at runtime. Call this function
|
||||
before the (first) key expansion.
|
||||
*/
|
||||
|
||||
function AES_Init() {
|
||||
AES_Sbox_Inv = new Array(256);
|
||||
for(var i = 0; i < 256; i++)
|
||||
AES_Sbox_Inv[AES_Sbox[i]] = i;
|
||||
|
||||
AES_ShiftRowTab_Inv = new Array(16);
|
||||
for(var i = 0; i < 16; i++)
|
||||
AES_ShiftRowTab_Inv[AES_ShiftRowTab[i]] = i;
|
||||
|
||||
AES_xtime = new Array(256);
|
||||
for(var i = 0; i < 128; i++) {
|
||||
AES_xtime[i] = i << 1;
|
||||
AES_xtime[128 + i] = (i << 1) ^ 0x1b;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
AES_Done: release memory reserved by AES_Init. Call this function after
|
||||
the last encryption/decryption operation.
|
||||
*/
|
||||
|
||||
function AES_Done() {
|
||||
delete AES_Sbox_Inv;
|
||||
delete AES_ShiftRowTab_Inv;
|
||||
delete AES_xtime;
|
||||
}
|
||||
|
||||
/*
|
||||
AES_ExpandKey: expand a cipher key. Depending on the desired encryption
|
||||
strength of 128, 192 or 256 bits 'key' has to be a byte array of length
|
||||
16, 24 or 32, respectively. The key expansion is done "in place", meaning
|
||||
that the array 'key' is modified.
|
||||
*/
|
||||
|
||||
function AES_ExpandKey(key) {
|
||||
var kl = key.length, ks, Rcon = 1;
|
||||
switch (kl) {
|
||||
case 16: ks = 16 * (10 + 1); break;
|
||||
case 24: ks = 16 * (12 + 1); break;
|
||||
case 32: ks = 16 * (14 + 1); break;
|
||||
default:
|
||||
alert("AES_ExpandKey: Only key lengths of 16, 24 or 32 bytes allowed!");
|
||||
}
|
||||
for(var i = kl; i < ks; i += 4) {
|
||||
var temp = key.slice(i - 4, i);
|
||||
if (i % kl == 0) {
|
||||
temp = new Array(AES_Sbox[temp[1]] ^ Rcon, AES_Sbox[temp[2]],
|
||||
AES_Sbox[temp[3]], AES_Sbox[temp[0]]);
|
||||
if ((Rcon <<= 1) >= 256)
|
||||
Rcon ^= 0x11b;
|
||||
}
|
||||
else if ((kl > 24) && (i % kl == 16))
|
||||
temp = new Array(AES_Sbox[temp[0]], AES_Sbox[temp[1]],
|
||||
AES_Sbox[temp[2]], AES_Sbox[temp[3]]);
|
||||
for(var j = 0; j < 4; j++)
|
||||
key[i + j] = key[i + j - kl] ^ temp[j];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
AES_Encrypt: encrypt the 16 byte array 'block' with the previously
|
||||
expanded key 'key'.
|
||||
*/
|
||||
|
||||
function AES_Encrypt(block, key) {
|
||||
var l = key.length;
|
||||
AES_AddRoundKey(block, key.slice(0, 16));
|
||||
for(var i = 16; i < l - 16; i += 16) {
|
||||
AES_SubBytes(block, AES_Sbox);
|
||||
AES_ShiftRows(block, AES_ShiftRowTab);
|
||||
AES_MixColumns(block);
|
||||
AES_AddRoundKey(block, key.slice(i, i + 16));
|
||||
}
|
||||
AES_SubBytes(block, AES_Sbox);
|
||||
AES_ShiftRows(block, AES_ShiftRowTab);
|
||||
AES_AddRoundKey(block, key.slice(i, l));
|
||||
}
|
||||
|
||||
/*
|
||||
AES_Decrypt: decrypt the 16 byte array 'block' with the previously
|
||||
expanded key 'key'.
|
||||
*/
|
||||
|
||||
function AES_Decrypt(block, key) {
|
||||
var l = key.length;
|
||||
AES_AddRoundKey(block, key.slice(l - 16, l));
|
||||
AES_ShiftRows(block, AES_ShiftRowTab_Inv);
|
||||
AES_SubBytes(block, AES_Sbox_Inv);
|
||||
for(var i = l - 32; i >= 16; i -= 16) {
|
||||
AES_AddRoundKey(block, key.slice(i, i + 16));
|
||||
AES_MixColumns_Inv(block);
|
||||
AES_ShiftRows(block, AES_ShiftRowTab_Inv);
|
||||
AES_SubBytes(block, AES_Sbox_Inv);
|
||||
}
|
||||
AES_AddRoundKey(block, key.slice(0, 16));
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* The following lookup tables and functions are for internal use only! */
|
||||
|
||||
AES_Sbox = new Array(99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,
|
||||
118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,
|
||||
147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,
|
||||
7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,
|
||||
47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,
|
||||
251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,
|
||||
188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,
|
||||
100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,
|
||||
50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,
|
||||
78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,
|
||||
116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,
|
||||
158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,
|
||||
137,13,191,230,66,104,65,153,45,15,176,84,187,22);
|
||||
|
||||
AES_ShiftRowTab = new Array(0,5,10,15,4,9,14,3,8,13,2,7,12,1,6,11);
|
||||
|
||||
function AES_SubBytes(state, sbox) {
|
||||
for(var i = 0; i < 16; i++)
|
||||
state[i] = sbox[state[i]];
|
||||
}
|
||||
|
||||
function AES_AddRoundKey(state, rkey) {
|
||||
for(var i = 0; i < 16; i++)
|
||||
state[i] ^= rkey[i];
|
||||
}
|
||||
|
||||
function AES_ShiftRows(state, shifttab) {
|
||||
var h = new Array().concat(state);
|
||||
for(var i = 0; i < 16; i++)
|
||||
state[i] = h[shifttab[i]];
|
||||
}
|
||||
|
||||
function AES_MixColumns(state) {
|
||||
for(var i = 0; i < 16; i += 4) {
|
||||
var s0 = state[i + 0], s1 = state[i + 1];
|
||||
var s2 = state[i + 2], s3 = state[i + 3];
|
||||
var h = s0 ^ s1 ^ s2 ^ s3;
|
||||
state[i + 0] ^= h ^ AES_xtime[s0 ^ s1];
|
||||
state[i + 1] ^= h ^ AES_xtime[s1 ^ s2];
|
||||
state[i + 2] ^= h ^ AES_xtime[s2 ^ s3];
|
||||
state[i + 3] ^= h ^ AES_xtime[s3 ^ s0];
|
||||
}
|
||||
}
|
||||
|
||||
function AES_MixColumns_Inv(state) {
|
||||
for(var i = 0; i < 16; i += 4) {
|
||||
var s0 = state[i + 0], s1 = state[i + 1];
|
||||
var s2 = state[i + 2], s3 = state[i + 3];
|
||||
var h = s0 ^ s1 ^ s2 ^ s3;
|
||||
var xh = AES_xtime[h];
|
||||
var h1 = AES_xtime[AES_xtime[xh ^ s0 ^ s2]] ^ h;
|
||||
var h2 = AES_xtime[AES_xtime[xh ^ s1 ^ s3]] ^ h;
|
||||
state[i + 0] ^= h1 ^ AES_xtime[s0 ^ s1];
|
||||
state[i + 1] ^= h2 ^ AES_xtime[s1 ^ s2];
|
||||
state[i + 2] ^= h1 ^ AES_xtime[s2 ^ s3];
|
||||
state[i + 3] ^= h2 ^ AES_xtime[s3 ^ s0];
|
||||
}
|
||||
}
|
||||
|
||||
function bin2String (array) {
|
||||
var result = "";
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
result += String.fromCharCode(parseInt(array[i], 2));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function string2Bin (str) {
|
||||
var result = [];
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
result.push(str.charCodeAt(i));
|
||||
}
|
||||
while ((result.length % 16))
|
||||
result.push(0);
|
||||
return result;
|
||||
}
|
||||
|
||||
function bin2String (array) {
|
||||
return String.fromCharCode.apply(String, array);
|
||||
}
|
||||
|
||||
// http://osama-oransa.blogspot.fr/2012/03/using-aes-encrypting-in-java-script.html
|
||||
exports.aes = {
|
||||
init : function (myKey){
|
||||
AES_Init();
|
||||
var key = string2Bin(myKey);
|
||||
AES_ExpandKey(key);
|
||||
return key;
|
||||
},
|
||||
|
||||
encrypt : function ( inputStr,key ) {
|
||||
var block = string2Bin(inputStr);
|
||||
AES_Encrypt(block, key);
|
||||
var data=bin2String(block);
|
||||
return data;
|
||||
},
|
||||
|
||||
decrypt : function ( inputStr,key ) {
|
||||
block = string2Bin(inputStr);
|
||||
AES_Decrypt(block, key);
|
||||
var data=bin2String(block);
|
||||
return data;
|
||||
},
|
||||
|
||||
encryptLongString : function( myString,key ) {
|
||||
if(myString.length>16){
|
||||
var data='';
|
||||
for(var i=0;i<myString.length;i=i+16){
|
||||
data+=this.encrypt(myString.substr(i,16),key);
|
||||
}
|
||||
return data;
|
||||
}else{
|
||||
return this.encrypt(myString,key);
|
||||
}
|
||||
},
|
||||
|
||||
decryptLongString : function ( myString,key ) {
|
||||
if(myString.length>16){
|
||||
var data='';
|
||||
for(var i=0;i<myString.length;i=i+16){
|
||||
data+=this.decrypt(myString.substr(i,16),key);
|
||||
}
|
||||
return data;
|
||||
}else{
|
||||
return this.decrypt(myString,key);
|
||||
}
|
||||
},
|
||||
|
||||
finish : function(){
|
||||
AES_Done();
|
||||
},
|
||||
};
|
||||
@@ -1,427 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013-2014 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var {Cc, Ci} = require("chrome");
|
||||
var notifications = require("sdk/notifications");
|
||||
var self = require("sdk/self");
|
||||
var prefSet = require("sdk/simple-prefs");
|
||||
|
||||
var pkdbf2 = require("lib/pkdbf2").pkdbf2;
|
||||
var aes = require("lib/jsaes").aes;
|
||||
var parseURI = require("lib/parseuri").parseURI;
|
||||
var DEBUG = false;
|
||||
var pkdbf2_level = getPref("pkdbf2_level");
|
||||
var protocol_version = 3;
|
||||
SERVER = {OK : 0, FAILED : 1, RESTART_REQUEST : 2};
|
||||
|
||||
// http://stackoverflow.com/questions/3745666/how-to-convert-from-hex-to-ascii-in-javascript
|
||||
function hex2a(hex) {
|
||||
var str = '';
|
||||
for (var i = 0; i < hex.length; i += 2)
|
||||
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
|
||||
return str;
|
||||
}
|
||||
|
||||
function a2hex(str) {
|
||||
var hex = '';
|
||||
for (var i = 0; i < str.length; i++)
|
||||
{
|
||||
var c = str.charCodeAt(i).toString(16);
|
||||
if (c.length == 1) c = "0" + c;
|
||||
hex += c;
|
||||
}
|
||||
return hex;
|
||||
}
|
||||
|
||||
function debug(s)
|
||||
{
|
||||
if (DEBUG)
|
||||
console.log(s);
|
||||
}
|
||||
|
||||
function notify(text, data)
|
||||
{
|
||||
var icon = self.data.url("gpass_icon_64.png");
|
||||
notifications.notify({
|
||||
title: "gPass",
|
||||
text: text,
|
||||
data: data,
|
||||
iconUrl: icon,
|
||||
});
|
||||
}
|
||||
|
||||
function getPref(key)
|
||||
{
|
||||
return prefSet.prefs[key];
|
||||
}
|
||||
|
||||
function setPref(key, value)
|
||||
{
|
||||
prefSet.prefs[key] = value;
|
||||
}
|
||||
|
||||
function generate_request(domain, login, mkey)
|
||||
{
|
||||
var v = "@@" + domain + ";" + login;
|
||||
debug("will encrypt " + v);
|
||||
debug("with " + a2hex(mkey));
|
||||
var enc = aes.encryptLongString(v, aes.init(mkey));
|
||||
aes.finish();
|
||||
debug("res " + a2hex(enc));
|
||||
|
||||
return enc;
|
||||
}
|
||||
|
||||
function ask_server(form, field, logins, domain, wdomain, mkey, salt, submit)
|
||||
{
|
||||
var a, b;
|
||||
|
||||
mkey = pkdbf2.pkdbf2(mkey, salt, pkdbf2_level, 256/8);
|
||||
|
||||
keys = "";
|
||||
for(a=0, b=logins.length; a<logins.length; a++)
|
||||
{
|
||||
enc = generate_request(domain, logins[a], mkey);
|
||||
|
||||
keys += (keys.length != 0) ? "&" : "";
|
||||
keys += "k" + a + "=" + a2hex(enc);
|
||||
|
||||
if (wdomain != "")
|
||||
{
|
||||
enc = generate_request(wdomain, logins[a], mkey);
|
||||
|
||||
keys += (keys.length != 0) ? "&" : "";
|
||||
keys += "k" + (b++) + "=" + a2hex(enc);
|
||||
}
|
||||
}
|
||||
|
||||
debug("Keys " + keys);
|
||||
|
||||
var gPassRequest = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
|
||||
createInstance(Ci.nsIXMLHttpRequest);
|
||||
var ret = SERVER.OK;
|
||||
|
||||
// gPassRequest.addEventListener("progress", function(evt) { ; }, false);
|
||||
gPassRequest.addEventListener("load", function(evt) {
|
||||
var ciphered_password = "";
|
||||
var server_pkdbf2_level = 0;
|
||||
var server_version = 0;
|
||||
|
||||
var r = this.responseText.split("\n");
|
||||
debug("resp " + r);
|
||||
|
||||
for(var a=0; a<r.length; a++)
|
||||
{
|
||||
debug("Analyse " + r[a]);
|
||||
|
||||
params = r[a].split("=");
|
||||
if (params.length != 2 && params[0] != "<end>")
|
||||
{
|
||||
notify("Error : It seems that it's not a gPass server",
|
||||
this.responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(params[0])
|
||||
{
|
||||
case "protocol":
|
||||
debug("protocol : " + params[1]);
|
||||
|
||||
if (params[1].indexOf("gpass-") != 0)
|
||||
{
|
||||
notify("Error : It seems that it's not a gPass server",
|
||||
this.responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
server_protocol_version = params[1].match(/\d+/)[0];
|
||||
|
||||
if (server_protocol_version > protocol_version)
|
||||
{
|
||||
notify("Protocol version not supported, please upgrade your addon",
|
||||
"Protocol version not supported, please upgrade your addon");
|
||||
ret = SERVER.FAILED;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (server_protocol_version)
|
||||
{
|
||||
case 2:
|
||||
server_pkdbf2_level = 1000;
|
||||
break;
|
||||
case 3:
|
||||
// Version 3 : nothing special to do
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "pass":
|
||||
ciphered_password = params[1];
|
||||
break;
|
||||
case "pkdbf2_level":
|
||||
server_pkdbf2_level = parseInt(params[1].match(/\d+/)[0], 10);
|
||||
if (server_pkdbf2_level != NaN &&
|
||||
server_pkdbf2_level != pkdbf2_level &&
|
||||
server_pkdbf2_level >= 1000) // Minimum level for PKDBF2 !
|
||||
{
|
||||
debug("New pkdbf2 level " + server_pkdbf2_level);
|
||||
pkdbf2_level = server_pkdbf2_level;
|
||||
setPref("pkdbf2_level", pkdbf2_level);
|
||||
ret = SERVER.RESTART_REQUEST;
|
||||
}
|
||||
break;
|
||||
case "<end>":
|
||||
break;
|
||||
default:
|
||||
debug("Unknown command " + params[0]);
|
||||
|
||||
notify("Error : It seems that it's not a gPass server",
|
||||
this.responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != SERVER.OK)
|
||||
return;
|
||||
|
||||
if (ciphered_password != "")
|
||||
{
|
||||
debug("Ciphered password : " + ciphered_password);
|
||||
clear_password = aes.decryptLongString(hex2a(ciphered_password), aes.init(mkey));
|
||||
aes.finish();
|
||||
// Remove trailing \0 and salt
|
||||
clear_password = clear_password.replace(/\0*$/, "");
|
||||
clear_password = clear_password.substr(0, clear_password.length-3);
|
||||
debug("Clear password " + clear_password);
|
||||
field.value = clear_password;
|
||||
// Remove gPass event listener and submit again with clear password
|
||||
if (submit)
|
||||
{
|
||||
form.removeEventListener("submit", on_sumbit, true);
|
||||
form.submit();
|
||||
}
|
||||
else
|
||||
{
|
||||
notify("Password successfully replaced",
|
||||
"Password successfully replaced");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("No password found");
|
||||
|
||||
ret = SERVER.FAILED;
|
||||
|
||||
notify("No password found in database",
|
||||
"No password found in database");
|
||||
}
|
||||
}, false);
|
||||
gPassRequest.addEventListener("error", function(evt) {
|
||||
debug("error");
|
||||
ret = false;
|
||||
notify("Error",
|
||||
"Error");
|
||||
}, false);
|
||||
debug("connect to " + getPref("account_url"));
|
||||
gPassRequest.open("POST", getPref("account_url"), true);
|
||||
gPassRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||
gPassRequest.send(keys);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function wildcard_domain(domain)
|
||||
{
|
||||
var parts = domain.split(".");
|
||||
|
||||
if (parts.length >= 3)
|
||||
{
|
||||
// Seems to be a two level root domain (ie zzz.xxx.co.uk ...)
|
||||
if (parts[parts.length-2].lenght <= 3)
|
||||
{
|
||||
if (parts.length > 3)
|
||||
return "*" + "." + parts[parts.length-3] + "." + parts[parts.length-2] + "." + parts[parts.length-1];
|
||||
}
|
||||
// Standard root domain (zzz.xxx.com)
|
||||
else
|
||||
return "*" + "." + parts[parts.length-2] + "." + parts[parts.length-1];
|
||||
}
|
||||
// Simple xxx.com
|
||||
else if (parts.length == 2)
|
||||
return "*" + "." + parts[0] + "." + parts[1];
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
function _add_name(logins, name)
|
||||
{
|
||||
for(var i=0; i<logins.length; i++)
|
||||
if (logins[i] == name) return ;
|
||||
logins.push(name);
|
||||
}
|
||||
|
||||
function try_get_name(fields, type_filters, match)
|
||||
{
|
||||
var user = null;
|
||||
var all_logins = new Array();
|
||||
|
||||
for (var i=0; i<fields.length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
|
||||
for (var a=0; a<type_filters.length; a++)
|
||||
{
|
||||
if ((match && field.getAttribute("type") == type_filters[a]) ||
|
||||
(!match && field.getAttribute("type") != type_filters[a]))
|
||||
{
|
||||
if (field.hasAttribute("name") && field.value != "")
|
||||
{
|
||||
name = field.getAttribute("name");
|
||||
// Subset of common user field
|
||||
if (name == "user") user = field.value;
|
||||
else if (name == "usr") user = field.value;
|
||||
else if (name == "username") user = field.value;
|
||||
else if (name == "login") user = field.value;
|
||||
|
||||
_add_name(all_logins, field.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
return new Array(user);
|
||||
else
|
||||
return all_logins;
|
||||
}
|
||||
|
||||
function on_sumbit(e)
|
||||
{
|
||||
var form = this;
|
||||
var fields = form.getElementsByTagName("input");
|
||||
|
||||
var domain = parseURI.parseUri(form.ownerDocument.baseURI);
|
||||
domain = domain["host"];
|
||||
var wdomain = wildcard_domain(domain);
|
||||
|
||||
var salt = parseURI.parseUri(getPref("account_url"));
|
||||
salt = salt["host"] + salt["path"];
|
||||
|
||||
debug("salt " + salt);
|
||||
|
||||
type_filters = new Array();
|
||||
// Get all <input type="text"> && <input type="email">
|
||||
type_filters.push("text");
|
||||
type_filters.push("email");
|
||||
logins = try_get_name(fields, type_filters, true);
|
||||
|
||||
// Get all other fields except text, email and password
|
||||
if (!logins.length)
|
||||
{
|
||||
type_filters.push("password");
|
||||
logins = try_get_name(fields, type_filters, false);
|
||||
}
|
||||
|
||||
// Look for <input type="password" value="@@...">
|
||||
for (var i=0; i<fields.length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
|
||||
if (field.getAttribute("type") == "password")
|
||||
{
|
||||
debug(field.value);
|
||||
password = field.value;
|
||||
if (password.indexOf("@@") != 0 && password.indexOf("@_") != 0)
|
||||
continue;
|
||||
|
||||
mkey = password.substring(2);
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
var ret = ask_server(form, field, logins, domain, wdomain, mkey, salt, (password.indexOf("@@") == 0));
|
||||
|
||||
switch(ret)
|
||||
{
|
||||
case SERVER.OK:
|
||||
break;
|
||||
case SERVER.FAILED:
|
||||
if (logins !== all_logins)
|
||||
{
|
||||
ret = ask_server(form, field, all_logins, domain, wdomain, mkey, salt, (password.indexOf("@@") == 0));
|
||||
if (ret == SERVER.OK)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SERVER.RESTART_REQUEST:
|
||||
i = -1; // Restart loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function document_loaded(event)
|
||||
{
|
||||
var doc = event.target;
|
||||
// If there is a password in the form, add a "submit" listener
|
||||
for(var i=0; i<doc.forms.length; i++)
|
||||
{
|
||||
var form = doc.forms[i];
|
||||
var fields = form.getElementsByTagName("input");
|
||||
for (a=0; a<fields.length; a++)
|
||||
{
|
||||
var field = fields[a];
|
||||
if (field.getAttribute("type") == "password")
|
||||
{
|
||||
form.addEventListener("submit", on_sumbit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var httpRequestObserver =
|
||||
{
|
||||
observe: function(subject, topic, data)
|
||||
{
|
||||
if (topic == "content-document-global-created")
|
||||
{
|
||||
subject.addEventListener("DOMContentLoaded", document_loaded, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var observerService = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
||||
observerService.addObserver(httpRequestObserver, "content-document-global-created", false);
|
||||
|
||||
function self_test()
|
||||
{
|
||||
if((res = a2hex(pkdbf2.pkdbf2("password", "salt", 4096, 256/8))) !=
|
||||
"c5e478d59288c841aa530db6845c4c8d962893a001ce4e11a4963873aa98134a")
|
||||
console.log("PKDBF2 failed " + res);
|
||||
else
|
||||
console.log("All is OK ! ");
|
||||
}
|
||||
|
||||
// self_test();
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var hmac = require("lib/hmac").hmac;
|
||||
|
||||
exports.pkdbf2 = {
|
||||
|
||||
pkdbf2 : function(password, salt, iterations, outlen) {
|
||||
var result = "";
|
||||
var temp = "";
|
||||
var temp2 = "";
|
||||
var temp_res = "";
|
||||
var temp_res2 = "";
|
||||
|
||||
hmac.hmac_init(password);
|
||||
for (i=1; result.length < outlen; i++)
|
||||
{
|
||||
temp = hmac.hmac_digest(salt +
|
||||
String.fromCharCode((i & 0xff000000) >> 24) +
|
||||
String.fromCharCode((i & 0x00ff0000) >> 16) +
|
||||
String.fromCharCode((i & 0x0000ff00) >> 8) +
|
||||
String.fromCharCode((i & 0x000000ff) >> 0)
|
||||
);
|
||||
temp_res = temp;
|
||||
|
||||
for(a=1; a<iterations; a++)
|
||||
{
|
||||
temp2 = hmac.hmac_digest(temp);
|
||||
temp_res2 = "";
|
||||
for(b = 0; b<temp_res.length; b++)
|
||||
temp_res2 += String.fromCharCode(temp_res.charCodeAt(b) ^ temp2.charCodeAt(b));
|
||||
temp_res = temp_res2;
|
||||
temp = temp2;
|
||||
}
|
||||
|
||||
result += temp_res;
|
||||
}
|
||||
|
||||
return result.substr(0, outlen);
|
||||
}
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"name": "gpass",
|
||||
"fullName": "gPass",
|
||||
"id": "jid1-eNs887pPJU8aNg@jetpack",
|
||||
"main": "lib/main.js",
|
||||
"description": "gPass : global password manager",
|
||||
"author": "Grégory Soutadé",
|
||||
"license": "GNU GPL v3",
|
||||
"homepage" : "http://indefero.soutade.fr/p/gpass",
|
||||
"icon" : "data/gpass_icon_64.png",
|
||||
"version": "0.7.0",
|
||||
"preferences": [
|
||||
{
|
||||
"name": "account_url",
|
||||
"title": "Account URL",
|
||||
"description": "URL of your gPass account",
|
||||
"type": "string",
|
||||
"value": "http://gpass-demo.soutade.fr/demo"
|
||||
},
|
||||
{
|
||||
"name": "pkdbf2_level",
|
||||
"title": "PKDBF2 Level",
|
||||
"description": "Number of iterations used to derivate master key",
|
||||
"type": "integer",
|
||||
"value": 1000,
|
||||
"hidden" : true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
var main = require("./main");
|
||||
|
||||
exports["test main"] = function(assert) {
|
||||
assert.pass("Unit test running!");
|
||||
};
|
||||
|
||||
exports["test main async"] = function(assert, done) {
|
||||
assert.pass("async Unit test running!");
|
||||
done();
|
||||
};
|
||||
|
||||
require("sdk/test").run(exports);
|
||||
@@ -1,77 +1,544 @@
|
||||
function url_block_callback(details)
|
||||
/*
|
||||
Copyright (C) 2013-2020 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var browser = browser || chrome;
|
||||
var protocol_version = 4;
|
||||
var account_url = null;
|
||||
|
||||
function _notification(message, data)
|
||||
{
|
||||
//console.log(details);
|
||||
if (details.requestBody)
|
||||
if (message !== data)
|
||||
message += data;
|
||||
|
||||
options = {
|
||||
type: "basic",
|
||||
title : "gPass",
|
||||
message : message,
|
||||
iconUrl: browser.runtime.getURL("icons/gpass_icon_64.png")
|
||||
};
|
||||
|
||||
browser.notifications.create("gPass", options, function(){});
|
||||
|
||||
window.setTimeout(function() {browser.notifications.clear("gPass", function(){})}, 2000);
|
||||
}
|
||||
|
||||
async function generate_request(domain, login, mkey, iv)
|
||||
{
|
||||
var v = domain + ";" + login;
|
||||
debug("will encrypt " + v);
|
||||
while ((v.length % 16))
|
||||
v += "\0";
|
||||
hash = await digest(v);
|
||||
v += hash.slice(8, 24);
|
||||
enc = encrypt_cbc(mkey, iv, v);
|
||||
|
||||
return enc;
|
||||
}
|
||||
|
||||
async function ask_server(logins, domain, wdomain, mkey, sendResponse, options)
|
||||
{
|
||||
account_url = await get_preference("account_url");
|
||||
|
||||
var salt = parseURI.parseUri(account_url);
|
||||
salt = salt["host"] + salt["path"];
|
||||
|
||||
debug("salt " + salt);
|
||||
|
||||
pbkdf2_level = await get_preference("pbkdf2_level");
|
||||
|
||||
global_iv = await simple_pbkdf2(salt, mkey, pbkdf2_level);
|
||||
global_iv = global_iv.slice(0, 16);
|
||||
mkey = crypto_pbkdf2(mkey, salt, pbkdf2_level);
|
||||
|
||||
debug("global_iv " + a2hex(global_iv));
|
||||
|
||||
keys = "";
|
||||
for(key_index=0, a=0; a<logins.length; a++, key_index++)
|
||||
{
|
||||
if (details.requestBody.formData)
|
||||
enc = await generate_request(domain, logins[a], mkey, global_iv);
|
||||
keys += (keys.length != 0) ? "&" : "";
|
||||
keys += "k" + key_index + "=" + a2hex(enc);
|
||||
|
||||
if (wdomain != "")
|
||||
{
|
||||
for (var key in details.requestBody.formData)
|
||||
enc = await generate_request(wdomain, logins[a], mkey, global_iv);
|
||||
keys += (keys.length != 0) ? "&" : "";
|
||||
keys += "k" + (++key_index) + "=" + a2hex(enc);
|
||||
}
|
||||
}
|
||||
|
||||
debug("Keys " + keys);
|
||||
|
||||
var gPassRequest = new XMLHttpRequest();
|
||||
|
||||
var ret = SERVER.OK;
|
||||
|
||||
// gPassRequest.addEventListener("progress", function(evt) { ; }, false);
|
||||
gPassRequest.addEventListener("load", async function(evt) {
|
||||
var ciphered_password = "";
|
||||
var clear_password = "";
|
||||
var server_pbkdf2_level = 0;
|
||||
var server_version = 0;
|
||||
var matched_key = 0;
|
||||
|
||||
var r = this.responseText.split("\n");
|
||||
debug("resp " + r);
|
||||
|
||||
for(var a=0; a<r.length; a++)
|
||||
{
|
||||
debug("Analyse " + r[a]);
|
||||
|
||||
params = r[a].split("=");
|
||||
if (params.length != 2 && params[0] != "<end>")
|
||||
{
|
||||
for(var idx in details.requestBody.formData[key])
|
||||
_notification("Error : It seems that it's not a gPass server",
|
||||
this.responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(params[0])
|
||||
{
|
||||
case "protocol":
|
||||
debug("protocol : " + params[1]);
|
||||
|
||||
if (params[1].indexOf("gpass-") != 0)
|
||||
{
|
||||
value = details.requestBody.formData[key][idx];
|
||||
if (value.startsWith("@@") ||
|
||||
value.startsWith("@_"))
|
||||
return {cancel: true};
|
||||
_notification("Error : It seems that it's not a gPass server",
|
||||
this.responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
server_protocol_version = params[1].match(/\d+/)[0];
|
||||
|
||||
if (server_protocol_version > protocol_version)
|
||||
{
|
||||
_notification("Protocol version not supported, please upgrade your addon", "");
|
||||
ret = SERVER.FAILED;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (server_protocol_version)
|
||||
{
|
||||
case 2:
|
||||
server_pbkdf2_level = 1000;
|
||||
break;
|
||||
case 3:
|
||||
// Version 3 : nothing special to do
|
||||
case 4:
|
||||
// Version 4 : nothing special to do
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "matched_key":
|
||||
matched_key = params[1];
|
||||
case "pass":
|
||||
ciphered_password = params[1];
|
||||
break;
|
||||
case "pkdbf2_level":
|
||||
case "pbkdf2_level":
|
||||
server_pbkdf2_level = parseInt(params[1].match(/\d+/)[0], 10);
|
||||
if (server_pbkdf2_level != NaN &&
|
||||
server_pbkdf2_level != pbkdf2_level &&
|
||||
server_pbkdf2_level >= 1000) // Minimum level for PBKDF2 !
|
||||
{
|
||||
debug("New pbkdf2 level " + server_pbkdf2_level);
|
||||
pbkdf2_level = server_pbkdf2_level;
|
||||
set_preference("pbkdf2_level", pbkdf2_level, null);
|
||||
ret = SERVER.RESTART_REQUEST;
|
||||
}
|
||||
break;
|
||||
case "<end>":
|
||||
break;
|
||||
default:
|
||||
debug("Unknown command " + params[0]);
|
||||
|
||||
_notification("Error : It seems that it's not a gPass server",
|
||||
this.responseText);
|
||||
ret = SERVER.FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Analyse POST parameters
|
||||
if (details.method == "POST" && details.requestBody.raw)
|
||||
if (ret != SERVER.OK)
|
||||
{
|
||||
alert(details.requestBody.raw);
|
||||
var postedString = decodeURIComponent(String.fromCharCode.apply(null,
|
||||
new Uint8Array(details.requestBody.raw[0].bytes)));
|
||||
if (postedString.indexOf("=@@") != -1 ||
|
||||
postedString.indexOf("=@_") != -1)
|
||||
return {cancel: true};
|
||||
sendResponse({"value": ret, options:options});
|
||||
return;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
return {cancel: false};
|
||||
if (ciphered_password != "")
|
||||
{
|
||||
debug("Ciphered password : " + ciphered_password);
|
||||
clear_password = await decrypt_cbc(mkey, global_iv, hex2a(ciphered_password));
|
||||
clear_password = clear_password.replace(/\0*$/, "");
|
||||
clear_password = clear_password.substr(3, clear_password.length);
|
||||
debug("Clear password " + clear_password);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("No password found");
|
||||
|
||||
ret = SERVER.FAILED;
|
||||
|
||||
_notification("No password found in database", "")
|
||||
}
|
||||
|
||||
sendResponse({"value": ret, "password":clear_password, "options":options});
|
||||
}, false);
|
||||
gPassRequest.addEventListener("error", function(evt) {
|
||||
debug("error");
|
||||
ret = false;
|
||||
_notification("Error");
|
||||
}, false);
|
||||
debug("connect to " + account_url);
|
||||
gPassRequest.open("POST", account_url, true);
|
||||
gPassRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
|
||||
gPassRequest.send(keys);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
browser.runtime.onMessage.addListener(
|
||||
function(request) {
|
||||
function update_gpass_icon(iconId, tabId)
|
||||
{
|
||||
debug("update_gpass_icon");
|
||||
|
||||
if (request.type == "notification")
|
||||
icon_infos = {"tabId":tabId};
|
||||
icon_name = "";
|
||||
|
||||
switch (iconId)
|
||||
{
|
||||
case GPASS_ICON.NORMAL: break;
|
||||
case GPASS_ICON.DISABLED:
|
||||
icon_name = "_disabled";
|
||||
break;
|
||||
case GPASS_ICON.ACTIVATED:
|
||||
icon_name = "_activated";
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
debug(icon_name);
|
||||
|
||||
icon_infos["path"] = {
|
||||
16:"icons/gpass" + icon_name + "_icon_16.png",
|
||||
32:"icons/gpass" + icon_name + "_icon_32.png",
|
||||
64:"icons/gpass" + icon_name + "_icon_64.png",
|
||||
128:"icons/gpass" + icon_name + "_icon_128.png",
|
||||
};
|
||||
|
||||
browser.browserAction.setIcon(icon_infos);
|
||||
}
|
||||
|
||||
async function is_gpass_enabled(uri)
|
||||
{
|
||||
return await get_preference("always_disabled").then(
|
||||
function(always_disabled) {
|
||||
if (always_disabled)
|
||||
{
|
||||
debug("Always disabled");
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve(1); // null -> enabled, 1 -> disabled
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("Check for enable");
|
||||
var domain = parseURI.parseUri(uri);
|
||||
domain = domain["host"];
|
||||
debug("Is gpass enabled for " + domain + " ?");
|
||||
|
||||
return get_preference("disable-" + domain);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function save_gpass_enable_config(uri, enable)
|
||||
{
|
||||
var domain = parseURI.parseUri(uri);
|
||||
domain = domain["host"];
|
||||
|
||||
key = "disable-" + domain;
|
||||
if (enable)
|
||||
{
|
||||
debug("Enable gpass for " + domain);
|
||||
delete_preference(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("Disable gpass for " + domain);
|
||||
set_preference(key, true, null);
|
||||
}
|
||||
}
|
||||
|
||||
function _query_tabs_is_gpass_enabled(tabs, sendResponse)
|
||||
{
|
||||
if (tabs.length)
|
||||
{
|
||||
is_gpass_enabled(tabs[0].url).then(
|
||||
function (key_present) {
|
||||
enabled = (key_present == null);
|
||||
update_gpass_icon((enabled)?GPASS_ICON.NORMAL:GPASS_ICON.DISABLED, tabs[0].id);
|
||||
sendResponse({"enabled":enabled});
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("No cur tab");
|
||||
sendResponse({"enabled":true});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function _query_tabs_update_icon(tabs, iconId)
|
||||
{
|
||||
if (tabs.length)
|
||||
{
|
||||
update_gpass_icon(iconId, tabs[0].id);
|
||||
}
|
||||
}
|
||||
|
||||
function update_enable(enabled, tab, saveConfig)
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
parameters = {type:"blockForms"};
|
||||
saveConfig = true;// Force save when enable website
|
||||
debug("Now enabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
parameters = {type:"unblockForms"};
|
||||
debug("Now disabled");
|
||||
}
|
||||
|
||||
if (saveConfig)
|
||||
save_gpass_enable_config(tab.url, enabled);
|
||||
update_gpass_icon((enabled)?GPASS_ICON.NORMAL:GPASS_ICON.DISABLED, tab.id);
|
||||
browser.tabs.sendMessage(tab.id, parameters);
|
||||
}
|
||||
|
||||
function gpass_switch_enable(tab)
|
||||
{
|
||||
debug("Switch enable");
|
||||
is_gpass_enabled(tab.url).then(
|
||||
function (key_present)
|
||||
{
|
||||
options = {
|
||||
type: "basic",
|
||||
title : "gPass",
|
||||
message : request.options.message,
|
||||
iconUrl:browser.extension.getURL("icons/gpass_icon_64.png")
|
||||
};
|
||||
enabled = (key_present == null);
|
||||
// Do switch
|
||||
enabled = !enabled;
|
||||
update_enable(enabled, tab, true);
|
||||
});
|
||||
}
|
||||
|
||||
browser.notifications.create("gPass", options);
|
||||
function extension_load()
|
||||
{
|
||||
browser.runtime.onMessage.addListener(
|
||||
function(request, sender, sendResponse) {
|
||||
if (request.type == "password")
|
||||
{
|
||||
var domain = parseURI.parseUri(request.domain);
|
||||
domain = domain["host"];
|
||||
var wdomain = wildcard_domain(domain);
|
||||
|
||||
window.setTimeout(function() {browser.notifications.clear("gPass")}, 2000);
|
||||
}
|
||||
else if (request.type == "block_url")
|
||||
{
|
||||
browser.tabs.getCurrent().then(
|
||||
function onGot(tab) {
|
||||
if (tab)
|
||||
{
|
||||
browser.webRequest.onBeforeRequest.addListener(
|
||||
url_block_callback,
|
||||
{"urls":[request.options.url],
|
||||
"types":["main_frame"],
|
||||
"tabId":tab.id,
|
||||
"windowId":tab.windowId
|
||||
},
|
||||
["blocking", "requestBody"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
browser.webRequest.onBeforeRequest.addListener(
|
||||
url_block_callback,
|
||||
{"urls":[request.options.url], "types":["main_frame"]},
|
||||
["blocking", "requestBody"]);
|
||||
}
|
||||
});
|
||||
ask_server(request.logins, domain,
|
||||
wdomain, request.mkey,
|
||||
sendResponse, request.options);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (request.type == "notification")
|
||||
{
|
||||
_notification(request.options.message, request.options.data);
|
||||
}
|
||||
else if (request.type == "getServerAddress")
|
||||
{
|
||||
get_preference("account_url").then(
|
||||
function (address) {
|
||||
sendResponse({"value" : address});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else if (request.type == "getPopupClipboard")
|
||||
{
|
||||
get_preference("popup_clipboard").then(
|
||||
function (value) {
|
||||
sendResponse({"value" : value});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else if (request.type == "is_gpass_enabled")
|
||||
{
|
||||
browser.tabs.query({active:true, currentWindow:true},
|
||||
function cb(tabs) {
|
||||
_query_tabs_is_gpass_enabled(tabs, sendResponse);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else if (request.type == "update_icon")
|
||||
{
|
||||
debug("update_icon");
|
||||
browser.tabs.query({active:true, currentWindow:true},
|
||||
function cb(tabs) {
|
||||
_query_tabs_update_icon(tabs, request.icon_id);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
debug("Unknown message " + request.type);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (!browser.menus && browser.contextMenus)
|
||||
browser.menus = browser.contextMenus;
|
||||
|
||||
/* Settings */
|
||||
browser.menus.create({
|
||||
id: 'settings',
|
||||
title: 'gPass Settings',
|
||||
contexts: ['browser_action']
|
||||
});
|
||||
|
||||
/* Not supported by Chrome */
|
||||
if (browser.menus.onShown)
|
||||
title = 'Disable gPass for this website';
|
||||
else
|
||||
title = 'Disable or enable gPass for this website';
|
||||
|
||||
/* Enable/disable */
|
||||
browser.menus.create({
|
||||
id: 'switch_enable',
|
||||
title: title,
|
||||
contexts: ['browser_action']
|
||||
});
|
||||
|
||||
/* Not supported by Chrome */
|
||||
if (browser.menus.onShown)
|
||||
title = 'Disable gPass for ALL websites';
|
||||
else
|
||||
title = 'Disable or enable gPass for ALL websites';
|
||||
|
||||
/* Always enable/disable */
|
||||
browser.menus.create({
|
||||
id: 'always_disable',
|
||||
title: title,
|
||||
contexts: ['browser_action']
|
||||
});
|
||||
|
||||
browser.menus.onClicked.addListener(
|
||||
function(info, tab) {
|
||||
switch (info.menuItemId) {
|
||||
case 'settings':
|
||||
browser.runtime.openOptionsPage();
|
||||
break;
|
||||
|
||||
case 'always_disable':
|
||||
get_preference('always_disabled').then(
|
||||
function (always_disabled) {
|
||||
debug('Change always disable');
|
||||
debug(always_disabled);
|
||||
always_disabled = !always_disabled;
|
||||
|
||||
set_preference('always_disabled', always_disabled,
|
||||
function(error)
|
||||
{
|
||||
browser.tabs.query({},
|
||||
function cb(tabs) {
|
||||
for (i=0; i<tabs.length; i++)
|
||||
update_enable(!always_disabled, tabs[i], false);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
break;
|
||||
case 'switch_enable':
|
||||
gpass_switch_enable(tab);
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (browser.menus.onShown)
|
||||
{
|
||||
browser.menus.onShown.addListener(
|
||||
function(info, tab) {
|
||||
is_gpass_enabled(tab.url).then(
|
||||
function (key_present) {
|
||||
enabled = (key_present == null);
|
||||
if (enabled)
|
||||
title = 'Disable gPass for this website';
|
||||
else
|
||||
title = 'Enable gPass for this website';
|
||||
browser.menus.update("switch_enable",
|
||||
{
|
||||
"title":title
|
||||
}
|
||||
);
|
||||
browser.menus.refresh();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
browser.menus.onShown.addListener(
|
||||
function(info, tab) {
|
||||
get_preference('always_disabled').then(
|
||||
function (always_disabled) {
|
||||
if (always_disabled)
|
||||
title = 'Enable gPass for ALL websites';
|
||||
else
|
||||
title = 'Disable gPass for ALL websites';
|
||||
browser.menus.update("always_disable",
|
||||
{
|
||||
"title":title
|
||||
}
|
||||
);
|
||||
browser.menus.refresh();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function self_test()
|
||||
{
|
||||
mkey = crypto_pbkdf2("password", "salt", 4096);
|
||||
res = await encrypt_ecb(mkey, "DDDDDDDDDDDDDDDD");
|
||||
|
||||
reference = new Uint8Array([0xc4, 0x76, 0x01, 0x07, 0xa1, 0xc0, 0x2f, 0x22, 0xee, 0xbe, 0x60,
|
||||
0xff, 0x65, 0x33, 0x5b, 0x9e]);
|
||||
if (res != ab2str(reference))
|
||||
{
|
||||
console.log("Self test ERROR !");
|
||||
}
|
||||
else
|
||||
console.log("Self test OK !");
|
||||
}
|
||||
|
||||
//self_test();
|
||||
|
||||
extension_load();
|
||||
|
||||
@@ -1,29 +1,40 @@
|
||||
/*
|
||||
Copyright (C) 2013-2017 Grégory Soutadé
|
||||
|
||||
Copyright (C) 2013-2020 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function getPref(key)
|
||||
var default_preferences = {"pbkdf2_level": 1000,
|
||||
"account_url": "https://gpass-demo.soutade.fr/demo",
|
||||
"always_disabled":false,
|
||||
"popup_clipboard":false
|
||||
};
|
||||
|
||||
function get_preference(key)
|
||||
{
|
||||
return browser.storage.local.get(key)
|
||||
.then(
|
||||
function (pref) {
|
||||
if (!pref.hasOwnProperty(key))
|
||||
return default_preferences[key];
|
||||
{
|
||||
if (default_preferences.hasOwnProperty(key))
|
||||
return default_preferences[key];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return pref[key];
|
||||
}
|
||||
,
|
||||
@@ -33,7 +44,23 @@ function getPref(key)
|
||||
);
|
||||
}
|
||||
|
||||
function setPref(key, value)
|
||||
function set_preference(key, value, sendResponse)
|
||||
{
|
||||
browser.storage.local.set({key:value});
|
||||
browser.storage.local.set({[key]:value});
|
||||
if (sendResponse)
|
||||
sendResponse(true);
|
||||
}
|
||||
|
||||
function delete_preference(key)
|
||||
{
|
||||
browser.storage.local.remove(key);
|
||||
}
|
||||
|
||||
function send_tab_message(tab_id, parameters, callback)
|
||||
{
|
||||
browser.tabs.sendMessage(tab_id, parameters).then(
|
||||
function cb(response) {
|
||||
callback(response);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../chrome_addon/lib/
|
||||
406
firefox_webextension/lib/main.js
Normal file
@@ -0,0 +1,406 @@
|
||||
/*
|
||||
Copyright (C) 2013-2020 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var gpass_enabled = true;
|
||||
|
||||
function _notification(message, data)
|
||||
{
|
||||
if (message !== data)
|
||||
message += data;
|
||||
|
||||
options = {
|
||||
type: "basic",
|
||||
title : "gPass",
|
||||
message : message,
|
||||
iconUrl: browser.runtime.getURL("icons/gpass_icon_64.png")
|
||||
};
|
||||
|
||||
browser.notifications.create(options).then(
|
||||
function created(notification_id)
|
||||
{
|
||||
window.setTimeout(function() {
|
||||
browser.notifications.clear(notification_id);
|
||||
}, 2000);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function _add_name(logins, name)
|
||||
{
|
||||
for(var i=0; i<logins.length; i++)
|
||||
if (logins[i] == name) return ;
|
||||
logins.push(name);
|
||||
}
|
||||
|
||||
function try_get_name(fields, type_filters, match)
|
||||
{
|
||||
var user = null;
|
||||
var all_logins = new Array();
|
||||
|
||||
for (var i=0; i<fields.length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
var to_test = !match;
|
||||
|
||||
for (var a=0; a<type_filters.length; a++)
|
||||
{
|
||||
if (match && field.getAttribute("type") == type_filters[a])
|
||||
{
|
||||
to_test = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if(!match && field.getAttribute("type") == type_filters[a])
|
||||
{
|
||||
to_test = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (to_test)
|
||||
{
|
||||
if (field.hasAttribute("name") && field.value != "")
|
||||
{
|
||||
name = field.getAttribute("name");
|
||||
// Subset of common user field
|
||||
if (name == "user") user = field.value;
|
||||
else if (name == "usr") user = field.value;
|
||||
else if (name == "username") user = field.value;
|
||||
else if (name == "login") user = field.value;
|
||||
|
||||
_add_name(all_logins, field.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
return new Array(user);
|
||||
else
|
||||
return all_logins;
|
||||
}
|
||||
|
||||
function get_logins(form, all_logins)
|
||||
{
|
||||
var fields = form.getElementsByTagName("input");
|
||||
var logins = null;
|
||||
|
||||
debug("get_logins");
|
||||
|
||||
var type_filters = new Array();
|
||||
|
||||
// Get all <input type="text"> && <input type="email">
|
||||
type_filters.push("text");
|
||||
type_filters.push("email");
|
||||
if (all_logins)
|
||||
logins = try_get_name(fields, type_filters, true);
|
||||
else
|
||||
{
|
||||
// Get all other fields except text, email and password
|
||||
type_filters.push("password");
|
||||
type_filters.push("hidden");
|
||||
logins = try_get_name(fields, type_filters, false);
|
||||
}
|
||||
|
||||
return logins;
|
||||
}
|
||||
|
||||
function on_focus(e)
|
||||
{
|
||||
if (!gpass_enabled)
|
||||
return;
|
||||
|
||||
var logins = get_logins(this.form, true);
|
||||
var all_logins = get_logins(this.form, false);
|
||||
|
||||
if (logins.length || all_logins.length)
|
||||
{
|
||||
parameters = {
|
||||
type:"update_icon",
|
||||
icon_id:GPASS_ICON.ACTIVATED,
|
||||
};
|
||||
browser.runtime.sendMessage(parameters, {});
|
||||
}
|
||||
}
|
||||
|
||||
function on_blur(e)
|
||||
{
|
||||
if (!gpass_enabled)
|
||||
return;
|
||||
|
||||
parameters = {
|
||||
type:"update_icon",
|
||||
icon_id:GPASS_ICON.NORMAL,
|
||||
};
|
||||
browser.runtime.sendMessage(parameters, {});
|
||||
}
|
||||
|
||||
function on_sumbit(e)
|
||||
{
|
||||
var form = this;
|
||||
var fields = form.getElementsByTagName("input");
|
||||
var domain = form.ownerDocument.baseURI;
|
||||
var password_computed = false;
|
||||
|
||||
debug("on_submit");
|
||||
|
||||
logins = get_logins(form, true);
|
||||
all_logins = get_logins(form, false);
|
||||
|
||||
if (!logins.length)
|
||||
logins = all_logins;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
// Look for <input type="password" value="@@...">
|
||||
for (var i=0; i<fields.length; i++)
|
||||
{
|
||||
var field = fields[i];
|
||||
|
||||
if (field.getAttribute("type") == "password")
|
||||
{
|
||||
password = field.value;
|
||||
if (!password.startsWith("@@") && !password.startsWith("@_"))
|
||||
continue;
|
||||
|
||||
// Remove current value to limit master key stealing
|
||||
field.value = "";
|
||||
password_computed = true;
|
||||
do_submit = !password.startsWith("@_");
|
||||
mkey = password.substring(2);
|
||||
|
||||
parameters = {
|
||||
type:"password",
|
||||
logins:logins,
|
||||
domain:domain,
|
||||
mkey:mkey,
|
||||
options:{field_id:i}
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response) {
|
||||
debug(response);
|
||||
var field = fields[response.options.field_id];
|
||||
switch(response.value)
|
||||
{
|
||||
case SERVER.OK:
|
||||
set_password(form, field, response.password, do_submit)
|
||||
notify("Password successfully replaced", "");
|
||||
break;
|
||||
case SERVER.FAILED:
|
||||
if (logins.length != all_logins.length)
|
||||
{
|
||||
parameters[logins] = all_logins;
|
||||
browser.runtime.sendMessage(parameters);
|
||||
}
|
||||
break;
|
||||
case SERVER.RESTART_REQUEST:
|
||||
i = -1; // Restart loop
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!password_computed)
|
||||
{
|
||||
debug("No password computed");
|
||||
form.submit();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function set_password(form, field, password, do_submit)
|
||||
{
|
||||
field.value = password;
|
||||
// Remove gPass event listener and submit again with clear password
|
||||
unblock_all_forms();
|
||||
if (do_submit)
|
||||
{
|
||||
// Propagate change
|
||||
change_cb = field.onchange;
|
||||
if (change_cb)
|
||||
change_cb();
|
||||
// Try to type "enter"
|
||||
var evt = new KeyboardEvent("keydown");
|
||||
delete evt.which;
|
||||
evt.which = 13;
|
||||
field.dispatchEvent(evt);
|
||||
// Submit form
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
|
||||
var managed_forms = new Array();
|
||||
|
||||
function block_all_forms(doc, do_block)
|
||||
{
|
||||
var first_time = (managed_forms.length == 0);
|
||||
var cur_focused_element = document.activeElement;
|
||||
|
||||
debug("block all forms");
|
||||
|
||||
gpass_enabled = do_block;
|
||||
|
||||
// If there is a password in the form, add a "submit" listener
|
||||
for(var i=0; i<doc.forms.length; i++)
|
||||
{
|
||||
var form = doc.forms[i];
|
||||
var fields = form.getElementsByTagName("input");
|
||||
for (var a=0; a<fields.length; a++)
|
||||
{
|
||||
var field = fields[a];
|
||||
if (field.getAttribute("type") == "password")
|
||||
{
|
||||
if (do_block)
|
||||
{
|
||||
old_cb = form.onsubmit;
|
||||
if (old_cb)
|
||||
form.removeEventListener("submit", old_cb);
|
||||
form.addEventListener("submit", on_sumbit);
|
||||
if (old_cb)
|
||||
form.addEventListener("submit", old_cb);
|
||||
field.addEventListener("focus", on_focus);
|
||||
field.addEventListener("blur", on_blur);
|
||||
if (cur_focused_element === field)
|
||||
on_focus(null);
|
||||
}
|
||||
if (first_time)
|
||||
managed_forms.push(form);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function unblock_all_forms()
|
||||
{
|
||||
debug("unblock all forms");
|
||||
|
||||
for(var i=0; i<managed_forms.length; i++)
|
||||
{
|
||||
var form = managed_forms[i];
|
||||
|
||||
form.removeEventListener("submit", on_sumbit);
|
||||
|
||||
var fields = form.getElementsByTagName("input");
|
||||
for (var a=0; a<fields.length; a++)
|
||||
{
|
||||
var field = fields[a];
|
||||
if (field.getAttribute("type") == "password")
|
||||
{
|
||||
field.removeEventListener("focus", on_focus);
|
||||
field.removeEventListener("blur", on_blur);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gpass_enabled = false;
|
||||
}
|
||||
|
||||
browser.runtime.onMessage.addListener(
|
||||
function(request, sender, sendResponse) {
|
||||
|
||||
if (request.type == "getUsername")
|
||||
{
|
||||
debug("getUsername");
|
||||
if (managed_forms.length == 1)
|
||||
{
|
||||
fields = managed_forms[0].getElementsByTagName("input");
|
||||
|
||||
type_filters = new Array();
|
||||
// Get all <input type="text"> && <input type="email">
|
||||
type_filters.push("text");
|
||||
type_filters.push("email");
|
||||
logins = try_get_name(fields, type_filters, true);
|
||||
|
||||
if (logins.length == 1)
|
||||
sendResponse(logins[0]);
|
||||
else
|
||||
sendResponse("");
|
||||
}
|
||||
else
|
||||
sendResponse("");
|
||||
}
|
||||
else if (request.type == "setPassword")
|
||||
{
|
||||
debug("setPassword");
|
||||
var response = "";
|
||||
if (managed_forms.length == 1)
|
||||
{
|
||||
fields = managed_forms[0].getElementsByTagName("input");
|
||||
password_field = null;
|
||||
|
||||
for (a=0; a<fields.length; a++)
|
||||
{
|
||||
field = fields[a];
|
||||
if (field.getAttribute("type") == "password")
|
||||
{
|
||||
if (password_field == null)
|
||||
password_field = field;
|
||||
else
|
||||
{
|
||||
// More than one password field : abort
|
||||
password_field = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (password_field)
|
||||
{
|
||||
set_password(managed_forms[0], password_field,
|
||||
request.password, request.submit);
|
||||
response = "ok";
|
||||
}
|
||||
}
|
||||
sendResponse(response);
|
||||
return true;
|
||||
}
|
||||
else if (request.type == "blockForms")
|
||||
{
|
||||
block_all_forms(document, true);
|
||||
}
|
||||
else if (request.type == "unblockForms")
|
||||
{
|
||||
unblock_all_forms();
|
||||
}
|
||||
});
|
||||
|
||||
function document_loaded()
|
||||
{
|
||||
parameters = {
|
||||
"type": "is_gpass_enabled",
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response) {
|
||||
if (response)
|
||||
block_all_forms(document, response.enabled);
|
||||
});
|
||||
}
|
||||
|
||||
document_loaded();
|
||||
|
||||
console.log("Welcome to gPass web extension v0.9 !");
|
||||
console.log("Privacy Policy can be found at http://indefero.soutade.fr/p/gpass/source/tree/master/PrivacyPolicy.md");
|
||||
console.log("");
|
||||
279
firefox_webextension/lib/misc.js
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
Copyright (C) 2013-2020 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var DEBUG = false;
|
||||
|
||||
SERVER = {OK : 0, FAILED : 1, RESTART_REQUEST : 2};
|
||||
GPASS_ICON = {NORMAL:0, DISABLED:1, ACTIVATED:2};
|
||||
|
||||
var browser = browser || chrome;
|
||||
var crypto = crypto || window.crypto;
|
||||
|
||||
function notify(text, data)
|
||||
{
|
||||
browser.runtime.sendMessage({type: "notification", options:{"message":text, "data":data}});
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers
|
||||
function ab2str(buf) {
|
||||
return String.fromCharCode.apply(null, new Uint8Array(buf));
|
||||
}
|
||||
|
||||
// https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String
|
||||
function str2ab2(str) {
|
||||
var chars = []
|
||||
for (var i=0, strLen=str.length; i < strLen; i++) {
|
||||
chars.push(str.charCodeAt(i));
|
||||
}
|
||||
return new Uint8Array(chars);
|
||||
}
|
||||
|
||||
function str2ab(str) {
|
||||
var buf = new ArrayBuffer(str.length);
|
||||
// var buf = new ArrayBuffer(str.length*2); // 2 bytes for each char
|
||||
var bufView = new Uint8Array(buf);
|
||||
for (var i=0, strLen=str.length; i < strLen; i++) {
|
||||
bufView[i] = str.charCodeAt(i);
|
||||
}
|
||||
return bufView;
|
||||
}
|
||||
|
||||
function crypto_pbkdf2(mkey, salt, level)
|
||||
{
|
||||
AESCBC = {
|
||||
name: "AES-CBC",
|
||||
length: 256,
|
||||
}
|
||||
|
||||
var key = str2ab(mkey);
|
||||
return crypto.subtle.importKey("raw", key, {name: "PBKDF2"}, false, ["deriveBits", "deriveKey"])
|
||||
.then(function(key){
|
||||
//sha-256
|
||||
return crypto.subtle.deriveKey({
|
||||
name: "PBKDF2",
|
||||
salt: str2ab(salt),
|
||||
iterations: level,
|
||||
hash: "SHA-256",
|
||||
}, key, AESCBC, false, ["encrypt", "decrypt", "unwrapKey", "wrapKey"])
|
||||
.then(function(key) {
|
||||
return key;
|
||||
})
|
||||
.catch(function(err){
|
||||
console.log("Error derive key " + err);
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log("Error import key" + err);
|
||||
});
|
||||
}
|
||||
|
||||
function simple_pbkdf2(mkey, salt, level)
|
||||
{
|
||||
AESCBC = {
|
||||
name: "AES-CBC",
|
||||
length: 256,
|
||||
}
|
||||
|
||||
var key = str2ab(mkey);
|
||||
return crypto.subtle.importKey("raw", key, {name: "PBKDF2"}, false, ["deriveBits", "deriveKey"])
|
||||
.then(function(key){
|
||||
//sha-256
|
||||
return crypto.subtle.deriveKey({
|
||||
name: "PBKDF2",
|
||||
salt: str2ab(salt),
|
||||
iterations: level,
|
||||
hash: "SHA-256",
|
||||
}, key, AESCBC, true, ["unwrapKey", "wrapKey"])
|
||||
.then(function(key) {
|
||||
return crypto.subtle.exportKey("raw", key)
|
||||
.then(function (key) {
|
||||
return ab2str(key);
|
||||
});
|
||||
})
|
||||
.catch(function(err){
|
||||
console.log("Error derive key " + err);
|
||||
});
|
||||
})
|
||||
.catch(function(err) {
|
||||
console.log("Error import key" + err);
|
||||
});
|
||||
}
|
||||
|
||||
function _encrypt(mkey, iv, data)
|
||||
{
|
||||
while ((data.length % 16))
|
||||
data += "\0";
|
||||
|
||||
data = str2ab(data);
|
||||
|
||||
promise = mkey.then(function(mkey){
|
||||
return crypto.subtle.encrypt({
|
||||
name: "AES-CBC",
|
||||
iv: iv
|
||||
}, mkey, data)})
|
||||
.then(function(encrypted) {
|
||||
return ab2str(encrypted);
|
||||
})
|
||||
.catch(function(encryption) {
|
||||
console.log("Encryption rejected " + encryption);
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
async function _decrypt(mkey, iv, data)
|
||||
{
|
||||
while ((data.length % 16))
|
||||
data += "\0";
|
||||
|
||||
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
pkcs7_padding = new Uint8Array([16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]);
|
||||
pkcs7_padding = await _encrypt(mkey, nulliv, ab2str(pkcs7_padding));
|
||||
|
||||
data = str2ab(data + pkcs7_padding);
|
||||
|
||||
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
promise = mkey.then(function(mkey){
|
||||
return crypto.subtle.decrypt({
|
||||
name: "AES-CBC",
|
||||
iv: iv
|
||||
}, mkey, data)})
|
||||
.then(function(decrypted) {
|
||||
return ab2str(decrypted);
|
||||
})
|
||||
.catch(function(decryption) {
|
||||
console.log("Decryption rejected " + decryption);
|
||||
});
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
async function encrypt_ecb(mkey, data)
|
||||
{
|
||||
var result = "";
|
||||
|
||||
debug("Encrypt ECB " + data);
|
||||
|
||||
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
while (data.length > 16)
|
||||
{
|
||||
res = await _encrypt(mkey, nulliv, data.slice(0, 16));
|
||||
// Remove PKCS7 padding
|
||||
result += res.slice(0, 16);
|
||||
data = data.slice(16);
|
||||
}
|
||||
res = await _encrypt(mkey, nulliv, data);
|
||||
result += res.slice(0, 16);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async function decrypt_ecb(mkey, data)
|
||||
{
|
||||
var result = "";
|
||||
|
||||
debug("Decrypt ECB " + data);
|
||||
|
||||
nulliv = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||
|
||||
while (data.length > 16)
|
||||
{
|
||||
res = await _decrypt(mkey, nulliv, data.slice(0, 16));
|
||||
// Remove PKCS7 padding
|
||||
result += res.slice(0, 16);
|
||||
data = data.slice(16);
|
||||
}
|
||||
res = await _decrypt(mkey, nulliv, data);
|
||||
result += res.slice(0, 16);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async function encrypt_cbc(mkey, iv, data)
|
||||
{
|
||||
debug("Encrypt CBC " + data);
|
||||
|
||||
var result = await _encrypt(mkey, str2ab(iv), data);
|
||||
|
||||
// Remove PKCS7 padding
|
||||
return result.slice(0, result.length-16);
|
||||
}
|
||||
|
||||
async function decrypt_cbc(mkey, iv, data)
|
||||
{
|
||||
debug("Decrypt CBC " + data);
|
||||
|
||||
var result = await _decrypt(mkey, str2ab(iv), data);
|
||||
|
||||
// Remove PKCS7 padding
|
||||
return result.slice(0, result.length-16);
|
||||
}
|
||||
|
||||
async function digest(data)
|
||||
{
|
||||
return crypto.subtle.digest("SHA-256", str2ab(data)).then(function (hash) {
|
||||
return ab2str(hash);
|
||||
});
|
||||
}
|
||||
|
||||
function wildcard_domain(domain)
|
||||
{
|
||||
var parts = domain.split(".");
|
||||
|
||||
// Standard root domain (zzz.xxx.com) or more
|
||||
if (parts.length > 2)
|
||||
{
|
||||
res = "*.";
|
||||
for (i=1; i<parts.length; i++)
|
||||
res += parts[i] + ".";
|
||||
return res.substr(0, res.length-1);
|
||||
}
|
||||
// Simple xxx.com
|
||||
else if (parts.length == 2)
|
||||
return "*." + domain;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/3745666/how-to-convert-from-hex-to-ascii-in-javascript
|
||||
function hex2a(hex) {
|
||||
var str = '';
|
||||
for (var i = 0; i < hex.length; i += 2)
|
||||
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
|
||||
return str;
|
||||
}
|
||||
|
||||
function a2hex(_str_) {
|
||||
var hex = '';
|
||||
for (var i = 0; i < _str_.length; i++)
|
||||
{
|
||||
var c = _str_.charCodeAt(i).toString(16);
|
||||
if (c.length == 1) c = "0" + c;
|
||||
hex += c;
|
||||
}
|
||||
return hex;
|
||||
}
|
||||
|
||||
function debug(s)
|
||||
{
|
||||
if (DEBUG)
|
||||
console.log(s);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
// (c) Steven Levithan <stevenlevithan.com>
|
||||
// MIT License
|
||||
|
||||
exports.parseURI = {
|
||||
parseURI = {
|
||||
|
||||
parseUri : function (str) {
|
||||
var o = {
|
||||
@@ -3,16 +3,16 @@
|
||||
|
||||
"name": "gPass",
|
||||
"short_name": "gPass",
|
||||
"version": "0.8.1",
|
||||
"version": "1.3",
|
||||
"description": "gPass : global password manager",
|
||||
"icons" : {"16":"icons/gpass_icon_16.png", "32":"icons/gpass_icon_32.png", "64":"icons/gpass_icon_64.png", "128":"icons/gpass_icon_128.png"},
|
||||
"author" : "Grégory Soutadé",
|
||||
"homepage_url" : "http://indefero.soutade.fr/p/gpass",
|
||||
|
||||
"homepage_url" : "https://forge.soutade.fr/soutade/gPass",
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["<all_urls>"],
|
||||
"js": ["lib/parseuri.js", "lib/misc.js", "compat.js", "lib/main.js"],
|
||||
"js": ["lib/misc.js", "lib/main.js"],
|
||||
"run_at" : "document_idle",
|
||||
"all_frames" : true
|
||||
}
|
||||
@@ -20,18 +20,28 @@
|
||||
|
||||
"background": {
|
||||
"persistent": true,
|
||||
"scripts": ["background.js"]
|
||||
"scripts": ["lib/parseuri.js", "lib/misc.js", "compat.js", "background.js"]
|
||||
},
|
||||
|
||||
"options_ui": { "page":"options.html" },
|
||||
"options_ui": {
|
||||
"page":"options.html",
|
||||
"browser_style": true
|
||||
},
|
||||
|
||||
"browser_action": {
|
||||
"default_icon": "icons/gpass_icon_32.png",
|
||||
"default_title": "Get your password",
|
||||
"default_popup": "popup/popup.html",
|
||||
"browser_style": true
|
||||
},
|
||||
|
||||
"permissions": [
|
||||
"<all_urls>",
|
||||
"activeTab",
|
||||
"notifications",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"tabs",
|
||||
"storage",
|
||||
"activeTab"
|
||||
"clipboardWrite",
|
||||
"menus"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../chrome_addon/options.html
|
||||
23
firefox_webextension/options.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>gPass</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<b>Account URL</b> URL of your gPass account <input id="account_url" type="text"/><br />
|
||||
<b>WARNING</b> It should be a valid HTTPS URL because navigator doesn't like mixed content (HTTPS/HTTP). If not, requests will silentely failed. If you have an auto-signed certificate, add it to trusted ones.<br/>
|
||||
<br/>
|
||||
<b>PBKDF2 level</b> Number of iterations used to derivate master key <input id="pbkdf2_level" type="number"/><br />
|
||||
<br/>
|
||||
<b>Always disabled</b> Disable gPass for all websites. You can still use popup, but no hook is attached to login forms <input id="always_disabled" type="checkbox"/><br />
|
||||
<br/>
|
||||
<b>Popup clipboard copy</b> Copy password into clipboard (by default) when using popup <input id="popup_clipboard" type="checkbox"/><br />
|
||||
<br/>
|
||||
<br/>
|
||||
<input type="button" id="save" value="Save"/>
|
||||
|
||||
<script type="text/javascript" src="options.js">
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,39 +1,51 @@
|
||||
var default_preferences = {"pbkdf2_level": 1000,
|
||||
"account_url": "https://gpass-demo.soutade.fr/demo",
|
||||
"crypto_v1_compatible": true};
|
||||
"always_disabled":false,
|
||||
"popup_clipboard":false
|
||||
};
|
||||
|
||||
function save() {
|
||||
var account_url = document.getElementById('account_url').value;
|
||||
var pbkdf2 = document.getElementById('pbkdf2').value;
|
||||
var crypto_v1_compatible = document.getElementById('crypto_v1_compatible').checked;
|
||||
var pbkdf2_level = document.getElementById('pbkdf2_level').value;
|
||||
var always_disabled = document.getElementById('always_disabled').checked;
|
||||
var popup_clipboard = document.getElementById('popup_clipboard').checked;
|
||||
|
||||
browser.storage.local.set({
|
||||
"account_url":account_url,
|
||||
"pbkdf2_level":pbkdf2,
|
||||
"crypto_v1_compatible": crypto_v1_compatible,
|
||||
"pbkdf2_level":pbkdf2_level,
|
||||
"always_disabled": always_disabled,
|
||||
"popup_clipboard": popup_clipboard,
|
||||
})
|
||||
.then(function ok() { alert("Saved"); },
|
||||
function err() { alert("Cannot save your preferences");}
|
||||
);
|
||||
}
|
||||
|
||||
function restoreOption(preferences, pref)
|
||||
{
|
||||
var res;
|
||||
|
||||
if (!preferences.hasOwnProperty(pref))
|
||||
res = default_preferences[pref];
|
||||
else
|
||||
res = preferences[pref];
|
||||
|
||||
var element = document.getElementById(pref);
|
||||
if (element.type == 'checkbox')
|
||||
element.checked = res;
|
||||
else
|
||||
element.value = res;
|
||||
}
|
||||
|
||||
function restoreOptions()
|
||||
{
|
||||
document.getElementById('account_url').value = default_preferences['account_url'];
|
||||
document.getElementById('pbkdf2').value = default_preferences['pbkdf2_level'];
|
||||
document.getElementById('crypto_v1_compatible').checked = default_preferences["crypto_v1_compatible"];
|
||||
|
||||
browser.storage.local.get().then(
|
||||
function(prefs)
|
||||
{
|
||||
if (prefs.hasOwnProperty("account_url"))
|
||||
document.getElementById('account_url').value = prefs["account_url"];
|
||||
|
||||
if (prefs.hasOwnProperty("pbkdf2_level"))
|
||||
document.getElementById('pbkdf2').value = prefs["pbkdf2_level"];
|
||||
|
||||
if (prefs.hasOwnProperty("crypto_v1_compatible"))
|
||||
document.getElementById('crypto_v1_compatible').checked = prefs["crypto_v1_compatible"];
|
||||
restoreOption(prefs, 'account_url');
|
||||
restoreOption(prefs, 'pbkdf2_level');
|
||||
restoreOption(prefs, 'always_disabled');
|
||||
restoreOption(prefs, 'popup_clipboard');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
1
firefox_webextension/popup/compat.js
Symbolic link
@@ -0,0 +1 @@
|
||||
../compat.js
|
||||
1
firefox_webextension/popup/misc.js
Symbolic link
@@ -0,0 +1 @@
|
||||
../lib/misc.js
|
||||
16
firefox_webextension/popup/popup.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<form id="passwordForm" autocomplete="off">
|
||||
Username <input type="text" id="gPassUsername" autofocus></input><br/> Master key <input type="password" id="gPassMasterKey"/><br/>
|
||||
Copy password into clipboard <input id="clipboard" type="checkbox"/><br />
|
||||
<input id="getButton" type="submit" value="Get"/> <a id="serverLink" href="">Your server</a>
|
||||
</form>
|
||||
<script src="misc.js"></script>
|
||||
<script src="compat.js"></script>
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
185
firefox_webextension/popup/popup.js
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
Copyright (C) 2020 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var username_filled = false;
|
||||
|
||||
function _server_response(response, tabs, do_submit, force_copy)
|
||||
{
|
||||
debug("Get Response");
|
||||
if (response.value == SERVER.OK)
|
||||
{
|
||||
/* Only copy */
|
||||
if (document.getElementById("clipboard").checked)
|
||||
{
|
||||
navigator.clipboard.writeText(response.password).then(function() {
|
||||
notify("Password pasted into clipboard", "");
|
||||
window.close();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Fill + optional copy */
|
||||
parameters = {
|
||||
"type":"setPassword",
|
||||
"password":response.password,
|
||||
"submit":do_submit
|
||||
};
|
||||
send_tab_message(tabs[0].id, parameters,
|
||||
function(arg)
|
||||
{
|
||||
debug("Response to setPassword " + arg);
|
||||
if (arg === "" || force_copy)
|
||||
{
|
||||
navigator.clipboard.writeText(response.password).then(function() {
|
||||
notify("Password pasted into clipboard", "");
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
notify("Password filled", "");
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function _query_tabs_get_password(tabs)
|
||||
{
|
||||
var force_copy = false;
|
||||
|
||||
if (tabs.length <= 0) return;
|
||||
|
||||
var username = document.getElementById("gPassUsername").value;
|
||||
var mkey = document.getElementById("gPassMasterKey").value;
|
||||
|
||||
if (username == "" || mkey == "")
|
||||
return;
|
||||
|
||||
document.getElementById("gPassMasterKey").value = "";
|
||||
|
||||
var do_submit = !mkey.startsWith("@_") && username_filled;
|
||||
|
||||
if (mkey.startsWith("@_"))
|
||||
force_copy = true;
|
||||
|
||||
if (mkey.startsWith("@@") || mkey.startsWith("@_"))
|
||||
mkey = mkey.substring(2);
|
||||
|
||||
var domain = tabs[0].url;
|
||||
|
||||
var logins = new Array();
|
||||
logins.push(username);
|
||||
|
||||
parameters = {
|
||||
type:"password",
|
||||
logins:logins,
|
||||
domain:domain,
|
||||
mkey:mkey,
|
||||
options:{}
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response)
|
||||
{
|
||||
return _server_response(response, tabs, do_submit, force_copy);
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_password(evt)
|
||||
{
|
||||
debug('get_password');
|
||||
|
||||
evt.preventDefault();
|
||||
|
||||
browser.tabs.query({active:true, currentWindow:true}, _query_tabs_get_password);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pform = document.getElementById("passwordForm");
|
||||
|
||||
if (pform != null)
|
||||
pform.onsubmit = get_password;
|
||||
|
||||
function _query_tabs_init(tabs)
|
||||
{
|
||||
debug("_query_tabs_init");
|
||||
|
||||
if (tabs.length != 1) return;
|
||||
|
||||
/* Fill username */
|
||||
parameters = {
|
||||
"type":"getUsername"
|
||||
};
|
||||
|
||||
send_tab_message(tabs[0].id, parameters,
|
||||
function (response)
|
||||
{
|
||||
if (response !== undefined && response != "")
|
||||
{
|
||||
document.getElementById("gPassUsername").value = response;
|
||||
document.getElementById("gPassMasterKey").focus();
|
||||
username_filled = true;
|
||||
}
|
||||
});
|
||||
|
||||
/* Clipboard copy */
|
||||
parameters = {
|
||||
"type":"getPopupClipboard"
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response)
|
||||
{
|
||||
document.getElementById("clipboard").checked = response.value;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
/* Setup server link address */
|
||||
parameters = {
|
||||
"type":"getServerAddress"
|
||||
};
|
||||
|
||||
browser.runtime.sendMessage(parameters, {},
|
||||
function (response)
|
||||
{
|
||||
url = response.value;
|
||||
url = url.substring(0, url.lastIndexOf('/'));
|
||||
url += '?';
|
||||
url += 'url=' + encodeURI(tabs[0].url.split("?")[0]);
|
||||
url += '&user=' + document.getElementById("gPassUsername").value;
|
||||
link = document.getElementById("serverLink");
|
||||
link.href = url;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
browser.tabs.query({active:true, currentWindow:true}, _query_tabs_init);
|
||||
@@ -8,10 +8,16 @@
|
||||
AuthType Basic
|
||||
AuthName "Private"
|
||||
AuthUserFile /private/_pwd/user
|
||||
Require valid-user
|
||||
Options +FollowSymlinks
|
||||
# Uncomment to remove password for internal network
|
||||
# <RequireAny>
|
||||
# Require ip 192.168.0.0/24
|
||||
Require valid-user
|
||||
# </RequireAny>
|
||||
</Location>
|
||||
|
||||
<Location "/users/">
|
||||
Options +FollowSymlinks
|
||||
Allow from all
|
||||
Satisfy Any
|
||||
</Location>
|
||||
|
||||
BIN
resources/gpass_activated_icon.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
resources/gpass_activated_icon.xcf
Normal file
BIN
resources/gpass_disabled_icon.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
resources/gpass_disabled_icon.xcf
Normal file
BIN
resources/icons/gpass_activated_icon_128.png
Normal file
|
After Width: | Height: | Size: 9.5 KiB |
BIN
resources/icons/gpass_activated_icon_16.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
resources/icons/gpass_activated_icon_32.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
resources/icons/gpass_activated_icon_64.png
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
resources/icons/gpass_disabled_icon_128.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
resources/icons/gpass_disabled_icon_16.png
Normal file
|
After Width: | Height: | Size: 785 B |
BIN
resources/icons/gpass_disabled_icon_32.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
resources/icons/gpass_disabled_icon_64.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 40 KiB |
39
server/_user
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (C) 2013-2015 Grégory Soutadé
|
||||
Copyright (C) 2013-2020 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
@@ -63,30 +63,31 @@ $PROTOCOL_VERSION = 4;
|
||||
|
||||
$db = load_database();
|
||||
|
||||
$res = "";
|
||||
|
||||
$statement = $db->prepare("SELECT password FROM gpass WHERE login=:login");
|
||||
|
||||
echo "protocol=gpass-$PROTOCOL_VERSION\n";
|
||||
if ($PBKDF2_LEVEL != 1000)
|
||||
echo "pbkdf2_level=$PBKDF2_LEVEL\n";
|
||||
|
||||
for ($i=0; $i<$MAX_PASSWORDS_PER_REQUEST && isset($_POST["k$i"]); $i++)
|
||||
if ($db)
|
||||
{
|
||||
$statement->bindValue(":login", addslashes($_POST["k$i"]));
|
||||
$result = $statement->execute();
|
||||
$row = $result->fetchArray(SQLITE3_ASSOC);
|
||||
$result->finalize();
|
||||
if (isset($row["password"]))
|
||||
{
|
||||
echo "matched_key=" . $i . "\n";
|
||||
echo "pass=" . $row["password"] . "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
$statement = $db->prepare("SELECT password FROM gpass WHERE login=:login");
|
||||
|
||||
$statement->close();
|
||||
for ($i=0; $i<$MAX_PASSWORDS_PER_REQUEST && isset($_POST["k$i"]); $i++)
|
||||
{
|
||||
$statement->bindValue(":login", addslashes($_POST["k$i"]));
|
||||
$result = $statement->execute();
|
||||
$row = $result->fetchArray(SQLITE3_ASSOC);
|
||||
$result->finalize();
|
||||
if (isset($row["password"]))
|
||||
{
|
||||
echo "matched_key=" . $i . "\n";
|
||||
echo "pass=" . $row["password"] . "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$statement->close();
|
||||
}
|
||||
|
||||
echo "<end>";
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -79,10 +79,4 @@ $REQUESTS_MIN_DELAY=1000;
|
||||
*/
|
||||
$CLEAR_TIME=15*60*1000;
|
||||
|
||||
/*
|
||||
The first crypto schema use an AES-ECB process to encrypt logins.
|
||||
It's used until version 0.7.
|
||||
Since version 0.8, we use AES-CBC + SHA256.
|
||||
*/
|
||||
$CRYPTO_V1_COMPATIBLE=1;
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (C) 2013-2017 Grégory Soutadé
|
||||
Copyright (C) 2013-2019 Grégory Soutadé
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
@@ -241,18 +241,21 @@ function delete_entry($user, $login, $access_token)
|
||||
}
|
||||
|
||||
$result = $db->exec("DELETE FROM gpass WHERE login='" . $login . "'");
|
||||
$db->close();
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
echo "Error " . $db->lastErrorMsg();
|
||||
return false;
|
||||
$ret = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "OK";
|
||||
return true;
|
||||
$ret = true;
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function update_entry($user, $mkey, $old_login, $url, $login, $password, $shadow_login, $salt, $old_access_token, $new_access_token)
|
||||
@@ -329,4 +332,4 @@ function get_secure_entries($user, $access_tokens)
|
||||
$db->close();
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (C) 2013-2017 Grégory Soutadé
|
||||
|
||||
|
||||
This file is part of gPass.
|
||||
|
||||
|
||||
gPass is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
gPass is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -50,7 +50,7 @@ else
|
||||
if (isset($_POST['get_passwords']) && isset($_POST['user']))
|
||||
return list_entries($user);
|
||||
|
||||
if (isset($_POST['add_entry']) && isset($_POST['user']) &&
|
||||
if (isset($_POST['add_entry']) && isset($_POST['user']) &&
|
||||
isset($_POST['login']) && isset($_POST['password']) &&
|
||||
isset($_POST['shadow_login']) && isset($_POST['salt']) &&
|
||||
isset($_POST['access_token']) )
|
||||
@@ -61,7 +61,7 @@ else
|
||||
$salt,
|
||||
$access_token);
|
||||
|
||||
if (isset($_POST['delete_entry']) && isset($_POST['user']) &&
|
||||
if (isset($_POST['delete_entry']) && isset($_POST['user']) &&
|
||||
isset($_POST['login']) && isset($_POST['access_token']))
|
||||
return delete_entry($user,
|
||||
$login,
|
||||
@@ -69,17 +69,16 @@ else
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
|
||||
<link rel="icon" type="image/png" href="resources/favicon.png" />
|
||||
<link rel="stylesheet" type="text/css" href="resources/gpass.css" />
|
||||
<link rel="icon" type="image/png" href="/resources/favicon.png" />
|
||||
<link rel="stylesheet" type="text/css" href="/resources/gpass.css" />
|
||||
<script language="javascript">
|
||||
<?php
|
||||
echo "pbkdf2_level=$PBKDF2_LEVEL; use_shadow_logins=$USE_SHADOW_LOGINS;\n";
|
||||
echo "CLEAR_TIME=$CLEAR_TIME; // Clear master key after 15 minutes\n";
|
||||
echo "CRYPTO_V1_COMPATIBLE=$CRYPTO_V1_COMPATIBLE;\n";
|
||||
?>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
window.onscroll = function(ev) {
|
||||
@@ -96,7 +95,41 @@ else
|
||||
|
||||
setTimeout(scrollToTop, 24);
|
||||
}
|
||||
</script>
|
||||
|
||||
function enableMenu(elem, divFrom)
|
||||
{
|
||||
elem.style.display = "block";
|
||||
divFrom.style['font-weight'] = "bold";
|
||||
divFrom.style['text-decoration'] = "underline";
|
||||
}
|
||||
|
||||
function disableMenu(elem, divFrom)
|
||||
{
|
||||
elem.style.display = "none";
|
||||
divFrom.style['font-weight'] = "normal";
|
||||
divFrom.style['text-decoration'] = "";
|
||||
}
|
||||
|
||||
function switchMenuDisplay(id)
|
||||
{
|
||||
const array1 = ['admin', 'add_new_password', 'update_masterkey', 'export_database'];
|
||||
|
||||
for (const _id of array1)
|
||||
{
|
||||
elem = document.getElementById(_id);
|
||||
divFrom = document.getElementById("menu_" + _id);
|
||||
if (_id === id)
|
||||
{
|
||||
if (elem.style.display == "block")
|
||||
disableMenu(elem, divFrom);
|
||||
else
|
||||
enableMenu(elem, divFrom);
|
||||
}
|
||||
else
|
||||
disableMenu(elem, divFrom);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script src="resources/misc.js"></script>
|
||||
<script src="resources/gpass.js"></script>
|
||||
<script src="resources/pwdmeter.js"></script>
|
||||
@@ -104,9 +137,15 @@ else
|
||||
</head>
|
||||
<body onload="start();">
|
||||
<div><a id="buttonTop" class="cInvisible" onclick="scrollToTop();"></a></div>
|
||||
<div id="menu">
|
||||
<div id="logo">
|
||||
<a href="http://indefero.soutade.fr/p/gpass"><img src="resources/gpass.png" alt="logo"/></a>
|
||||
</div>
|
||||
<?php if ($ADMIN_MODE) echo "<div id=\"menu_admin\" onclick=\"switchMenuDisplay('admin');\">Create user</div>\n";?>
|
||||
<div id="menu_add_new_password" onclick="switchMenuDisplay('add_new_password');">Add a new password</div>
|
||||
<div id="menu_update_masterkey" onclick="switchMenuDisplay('update_masterkey');">Update master key</div>
|
||||
<div id="menu_export_database" onclick="switchMenuDisplay('export_database');">Export database</div>
|
||||
</div>
|
||||
|
||||
<div id="admin" <?php if (!$ADMIN_MODE) echo "style=\"display:none\"";?> >
|
||||
<form method="post">
|
||||
@@ -141,7 +180,7 @@ else
|
||||
}
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo ' <b>Master key </b> <input id="master_key" type="password" onkeypress="if (event.keyCode == 13) update_master_key(true);"/>';
|
||||
echo ' <b>Master key </b> <input id="master_key" type="password" onchange="update_master_key(true);"/>';
|
||||
echo "<input type=\"button\" value=\"See\" onclick=\"update_master_key(true);\" />" . "\n";
|
||||
|
||||
if (!isset($_SERVER['HTTPS']))
|
||||
@@ -156,29 +195,28 @@ else
|
||||
|
||||
if ($user != "")
|
||||
{
|
||||
echo "<b>Add a new password</b><br/>\n";
|
||||
echo "<div class=\"title\">Add a new password</div>\n";
|
||||
|
||||
echo 'URL <input type="text" name="url"/>';
|
||||
echo 'login <input type="text" name="login" />';
|
||||
echo 'URL <input type="text" id="new_url" name="url" value="' . (parse_url(filter_input(INPUT_GET, "url", FILTER_SANITIZE_SPECIAL_CHARS))['host'] ?: "") . '"/>';
|
||||
echo 'login <input type="text" id="new_login" name="login" value="' . (filter_input(INPUT_GET, "user", FILTER_SANITIZE_SPECIAL_CHARS) ?: "") . '"/>';
|
||||
echo 'password <input id="new_password" type="text" name="password"/>';
|
||||
echo 'master key <input type="text" name="mkey" onkeypress="if (event.keyCode == 13) add_password();" onkeyup="chkPass(this.value);"/>';
|
||||
echo 'master key <input type="text" name="mkey" id="new_mkey" onchange="add_password();" onkeyup="chkPass(this.value);"/>';
|
||||
echo '<input type="button" value="Generate password" onClick="generate_password();"/>';
|
||||
echo '<input type="button" value="Generate simple password" onClick="generate_simple_password();"/>';
|
||||
echo "<input type=\"button\" name=\"add\" value=\"Add\" onclick=\"add_password();\"/>";
|
||||
echo "<br />";
|
||||
echo '<div><a href="http://en.wikipedia.org/wiki/Password_strength">Master key strength</a><div id="scorebarBorder"><div id="score">0%</div><div id="scorebar"> </div></div></div>';
|
||||
echo "<input type=\"button\" name=\"clear\" value=\"Clear Form\" onclick=\"clear_form();\"/>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div id="passwords">
|
||||
</div>
|
||||
<div id="update_masterkey">
|
||||
<?php
|
||||
global $user;
|
||||
|
||||
if ($user != "")
|
||||
{
|
||||
echo "<b>Update Masterkey</b><br/>\n";
|
||||
echo "<div class=\"title\">Update Masterkey</div>\n";
|
||||
|
||||
echo 'Old master key <input type="text" id="oldmkey"/>';
|
||||
echo 'New master key <input type="text" id="newmkey" onkeyup="chkPass(this.value);"/>';
|
||||
@@ -192,13 +230,20 @@ if ($user != "")
|
||||
|
||||
if ($user != "")
|
||||
{
|
||||
echo "<b>Export</b><br/>\n";
|
||||
echo "<div class=\"title\">Export</div>\n";
|
||||
|
||||
echo '<input type="button" value="Export" onclick="export_database();"/>';
|
||||
echo '<a id="export_link">Download</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<div id="filter">
|
||||
Filter <input id='password_filter' value=<?php echo "'" . (parse_url(filter_input(INPUT_GET, "url", FILTER_SANITIZE_SPECIAL_CHARS))['host'] ?: "") . "'" ?> onchange='password_filter_changed();'/>
|
||||
<input type="button" onclick="password_filter_changed();" value="Apply"/>
|
||||
<input type="button" onclick="document.getElementById('password_filter').value = '';password_filter_changed();" value="Clear"/>
|
||||
</div>
|
||||
<div id="passwords"></div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,34 +1,61 @@
|
||||
|
||||
body {
|
||||
background-image:linear-gradient(#0096ff 30%, white);
|
||||
background-color:#2d2e44;
|
||||
height:100%; width:100%;
|
||||
color:white;
|
||||
}
|
||||
|
||||
input {
|
||||
opacity:0.9;
|
||||
}
|
||||
#logo {
|
||||
display:inline;
|
||||
}
|
||||
|
||||
#logo img{
|
||||
display:inline;
|
||||
width:250px;
|
||||
height:170px;
|
||||
margin-right:4%;
|
||||
}
|
||||
|
||||
#menu {
|
||||
display:block;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
margin-top:30px;
|
||||
margin-bottom:40px;
|
||||
text-align:center;
|
||||
padding-bottom:10pt;
|
||||
}
|
||||
|
||||
#menu div {
|
||||
display:inline;
|
||||
margin-right:2%;
|
||||
font-size:x-large;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size:xx-large;
|
||||
font-weight:bold;
|
||||
margin-bottom:20pt;
|
||||
}
|
||||
|
||||
#admin {
|
||||
border-style:solid;
|
||||
border-width:5px;
|
||||
border-color:red;
|
||||
padding : 15px;
|
||||
margin : 15px;
|
||||
border-radius: 25px;
|
||||
border-style:solid;
|
||||
border-width:5px;
|
||||
border-color:grey;
|
||||
display:none;
|
||||
}
|
||||
|
||||
#admin form {
|
||||
text-align : center;
|
||||
}
|
||||
|
||||
#admin input {
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
#user {
|
||||
border-style:solid;
|
||||
border-width:5px;
|
||||
border-color:green;
|
||||
padding : 15px;
|
||||
margin : 15px;
|
||||
text-align:center;
|
||||
@@ -45,10 +72,12 @@ body {
|
||||
text-align : center;
|
||||
}
|
||||
|
||||
#selected_user {
|
||||
margin-left:10px;
|
||||
margin-right:10px;
|
||||
}
|
||||
|
||||
#passwords {
|
||||
border-style:solid;
|
||||
border-width:5px;
|
||||
border-color:grey;
|
||||
padding : 15px;
|
||||
margin : 15px;
|
||||
}
|
||||
@@ -57,34 +86,37 @@ body {
|
||||
padding:10px;
|
||||
text-align:center;
|
||||
font-size:xx-large;
|
||||
}
|
||||
|
||||
.hash {
|
||||
width : 700px;
|
||||
color:#de0036;
|
||||
}
|
||||
|
||||
#add_new_password {
|
||||
border-radius: 25px;
|
||||
border-style:solid;
|
||||
border-width:5px;
|
||||
border-color:blue;
|
||||
border-color:grey;
|
||||
padding : 15px;
|
||||
margin : 15px;
|
||||
display:none;
|
||||
}
|
||||
|
||||
#update_masterkey {
|
||||
border-style:solid;
|
||||
border-width:5px;
|
||||
border-color:yellow;
|
||||
padding : 15px;
|
||||
margin : 15px;
|
||||
border-radius: 25px;
|
||||
border-style:solid;
|
||||
border-width:5px;
|
||||
border-color:grey;
|
||||
display:none;
|
||||
}
|
||||
|
||||
#export_database {
|
||||
border-style:solid;
|
||||
border-width:5px;
|
||||
border-color:pink;
|
||||
padding : 15px;
|
||||
margin : 15px;
|
||||
border-radius: 25px;
|
||||
border-style:solid;
|
||||
border-width:5px;
|
||||
border-color:grey;
|
||||
display:none;
|
||||
}
|
||||
|
||||
#export_link {
|
||||
@@ -92,6 +124,10 @@ body {
|
||||
visibility:hidden;
|
||||
}
|
||||
|
||||
#filter {
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
.error {
|
||||
text-align:center;
|
||||
color:red;
|
||||
|
||||
@@ -109,6 +109,20 @@ function generate_simple_password()
|
||||
document.getElementById("new_password").value = _generate_random(8, symbols);
|
||||
}
|
||||
|
||||
function clear_form()
|
||||
{
|
||||
div = document.getElementById("add_new_password");
|
||||
|
||||
inputs = div.getElementsByTagName("input");
|
||||
|
||||
for(i=0; i<inputs.length; i++)
|
||||
{
|
||||
if (inputs[i].type == "text" ||
|
||||
inputs[i].type == "password")
|
||||
inputs[i].value = "";
|
||||
}
|
||||
}
|
||||
|
||||
function url_domain(data) {
|
||||
var uri = parseUri(data)
|
||||
return uri['host'];
|
||||
@@ -145,7 +159,9 @@ var current_user = "";
|
||||
var current_mkey = "";
|
||||
var clearTimer = null;
|
||||
var global_iv = null;
|
||||
var server_url = document.documentURI;
|
||||
var server_url = window.location.href.split('?')[0];
|
||||
var clear_passwords = new Array();
|
||||
var block_filter = true;
|
||||
|
||||
function PasswordEntry (ciphered_login, ciphered_password, salt, shadow_login) {
|
||||
this.ciphered_login = ciphered_login;
|
||||
@@ -211,7 +227,6 @@ function PasswordEntry (ciphered_login, ciphered_password, salt, shadow_login) {
|
||||
if (masterkey == this.masterkey)
|
||||
return (this.unciphered == true);
|
||||
|
||||
var old = false;
|
||||
var iv = await global_iv;
|
||||
iv = iv.slice(0, 16);
|
||||
var login = await decrypt_cbc(masterkey, iv, hex2a(this.ciphered_login));
|
||||
@@ -223,38 +238,16 @@ function PasswordEntry (ciphered_login, ciphered_password, salt, shadow_login) {
|
||||
{
|
||||
login = login.slice(0, login.length-16).replace(/\0*$/, "");
|
||||
}
|
||||
else if (CRYPTO_V1_COMPATIBLE)
|
||||
{
|
||||
login = await decrypt_ecb(masterkey, hex2a(this.ciphered_login));
|
||||
if (login.indexOf("@@") != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
login = login.replace(/\0*$/, "");
|
||||
// Remove @@
|
||||
login = login.substring(2);
|
||||
old = true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
infos = login.split(";");
|
||||
this.clear_url = infos[0];
|
||||
this.clear_login = infos[1];
|
||||
if (old)
|
||||
{
|
||||
this.clear_password = await decrypt_ecb(masterkey, hex2a(this.ciphered_password));
|
||||
// Remove salt
|
||||
this.clear_password = this.clear_password.replace(/\0*$/, "");
|
||||
this.clear_password = this.clear_password.substr(0, this.clear_password.length-3);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.clear_password = await decrypt_cbc(masterkey, iv, hex2a(this.ciphered_password));
|
||||
// Remove salt
|
||||
this.clear_password = this.clear_password.replace(/\0*$/, "");
|
||||
this.clear_password = this.clear_password.substr(3, this.clear_password.length);
|
||||
}
|
||||
this.clear_password = await decrypt_cbc(masterkey, iv, hex2a(this.ciphered_password));
|
||||
// Remove salt
|
||||
this.clear_password = this.clear_password.replace(/\0*$/, "");
|
||||
this.clear_password = this.clear_password.substr(3, this.clear_password.length);
|
||||
this.unciphered = true;
|
||||
this.masterkey = masterkey;
|
||||
|
||||
@@ -434,6 +427,51 @@ async function get_ciphered_credentials(masterkey)
|
||||
req.send("get_secure_passwords=1&user=" + current_user + "&access_tokens=" + access_tokens);
|
||||
}
|
||||
|
||||
function password_filter_changed()
|
||||
{
|
||||
if (block_filter) return;
|
||||
|
||||
filter = document.getElementById('password_filter').value ;
|
||||
if (filter !== '')
|
||||
filter = '.*' + filter + '.*';
|
||||
|
||||
password_div = document.getElementById("clear_passwords");
|
||||
password_div.removeAllChilds();
|
||||
|
||||
for (idx in clear_passwords)
|
||||
{
|
||||
div = clear_passwords[idx];
|
||||
if (typeof(div) === 'function')
|
||||
continue;
|
||||
if (filter === '')
|
||||
password_div.appendChild(div);
|
||||
else
|
||||
{
|
||||
childs = clear_passwords[idx].children;
|
||||
for (elem_idx in childs)
|
||||
{
|
||||
elem = childs[elem_idx];
|
||||
if (elem.name == 'url')
|
||||
{
|
||||
// Remove * for wildcards domains
|
||||
target_url = elem.value.replace('*', '') ;
|
||||
|
||||
try {
|
||||
if (target_url.match(filter) || filter.match(target_url))
|
||||
password_div.appendChild(div);
|
||||
}
|
||||
/* Forgive re errors */
|
||||
catch(error)
|
||||
{
|
||||
// console.log(error);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function change_master_key(warning_unciphered)
|
||||
{
|
||||
var nb_unciphered = 0;
|
||||
@@ -447,9 +485,6 @@ async function change_master_key(warning_unciphered)
|
||||
nb_unciphered++;
|
||||
}
|
||||
|
||||
if (!nb_unciphered && warning_unciphered)
|
||||
alert("No password unciphered with this master key !");
|
||||
|
||||
password_div = document.getElementById("passwords");
|
||||
password_div.removeAllChilds();
|
||||
|
||||
@@ -457,6 +492,11 @@ async function change_master_key(warning_unciphered)
|
||||
div.setAttribute("id", "nb_unciphered_passwords");
|
||||
password_div.appendChild(div);
|
||||
|
||||
div = document.createElement("div");
|
||||
div.setAttribute("id", "clear_passwords");
|
||||
password_div.appendChild(div);
|
||||
|
||||
clear_passwords = new Array();
|
||||
for(i=0; i<passwords.length; i++)
|
||||
{
|
||||
if (passwords[i].isUnciphered(current_mkey))
|
||||
@@ -475,6 +515,7 @@ async function change_master_key(warning_unciphered)
|
||||
url = document.createElement("input");
|
||||
url.setAttribute("type", "text");
|
||||
url.setAttribute("name", "url");
|
||||
url.setAttribute("id", "unciph_url_" + i);
|
||||
url.setAttribute("value", passwords[i].clear_url);
|
||||
div.appendChild(url);
|
||||
|
||||
@@ -501,13 +542,23 @@ async function change_master_key(warning_unciphered)
|
||||
update_button = document.createElement("input");
|
||||
update_button.setAttribute("type", "button");
|
||||
update_button.setAttribute("value", "Update");
|
||||
update_button.setAttribute("onclick", "update_entry(\"unciph_entry_" + i + "\");");
|
||||
update_button.setAttribute("onclick", "update_entry(this, \"unciph_entry_" + i + "\");");
|
||||
div.appendChild(update_button);
|
||||
|
||||
password_div.appendChild(div);
|
||||
clipboard_button = document.createElement("input");
|
||||
clipboard_button.setAttribute("type", "button");
|
||||
clipboard_button.setAttribute("name", "copy_button");
|
||||
clipboard_button.setAttribute("value", "Copy password");
|
||||
clipboard_button.setAttribute("onclick", "copy_clipboard(this, \"unciph_entry_" + i + "\");");
|
||||
div.appendChild(clipboard_button);
|
||||
|
||||
clear_passwords.push(div);
|
||||
}
|
||||
}
|
||||
|
||||
if (warning_unciphered && !nb_unciphered)
|
||||
alert("No password unciphered with this master key !");
|
||||
|
||||
div = document.createElement("div");
|
||||
div.setAttribute("id", "nb_ciphered_passwords");
|
||||
password_div.appendChild(div);
|
||||
@@ -530,13 +581,15 @@ async function change_master_key(warning_unciphered)
|
||||
url.setAttribute("class", "hash");
|
||||
url.setAttribute("type", "text");
|
||||
url.setAttribute("name", "URL");
|
||||
url.setAttribute("size", "32");
|
||||
div.appendChild(url);
|
||||
|
||||
div.appendChild(document.createTextNode("password"));
|
||||
password = document.createElement("input");
|
||||
password.setAttribute("class", "hash");
|
||||
password.setAttribute("class", "password_hash");
|
||||
password.setAttribute("type", "text");
|
||||
password.setAttribute("name", "password");
|
||||
password.setAttribute("size", "40");
|
||||
div.appendChild(password);
|
||||
|
||||
delete_button = document.createElement("input");
|
||||
@@ -566,6 +619,8 @@ async function change_master_key(warning_unciphered)
|
||||
input.value = "";
|
||||
|
||||
update_stats();
|
||||
block_filter = false;
|
||||
password_filter_changed();
|
||||
}
|
||||
|
||||
function update_master_key(warning_unciphered)
|
||||
@@ -613,7 +668,11 @@ function update_master_key(warning_unciphered)
|
||||
|
||||
function start()
|
||||
{
|
||||
select_widget = document.getElementById('selected_user') ;
|
||||
new_url = document.getElementById('new_url') ;
|
||||
if (new_url.value !== "")
|
||||
switchMenuDisplay('add_new_password');
|
||||
|
||||
select_widget = document.getElementById('selected_user') ;
|
||||
|
||||
if (select_widget == null) return;
|
||||
|
||||
@@ -753,16 +812,14 @@ function add_password()
|
||||
|
||||
for(i=0; i<inputs.length; i++)
|
||||
{
|
||||
if (inputs[i].getAttribute("type") == "text" ||
|
||||
inputs[i].getAttribute("type") == "password")
|
||||
name = inputs[i].getAttribute("name");
|
||||
if (name === "password" || name === "mkey")
|
||||
inputs[i].value = "";
|
||||
}
|
||||
|
||||
startClearTimer();
|
||||
});
|
||||
|
||||
window.scrollTo(0,document.body.scrollHeight);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -827,7 +884,7 @@ function delete_entry(entry_number)
|
||||
update_stats();
|
||||
}
|
||||
|
||||
function update_entry(entry_number)
|
||||
function update_entry(button, entry_number)
|
||||
{
|
||||
var url = "";
|
||||
var login = "";
|
||||
@@ -891,7 +948,14 @@ function update_entry(entry_number)
|
||||
passwords[found] = pentry;
|
||||
ciphered_login.setAttribute("login", pentry.ciphered_login);
|
||||
|
||||
alert("Entry updated");
|
||||
if (button !== null)
|
||||
{
|
||||
old_value = button.value;
|
||||
button.value = "Updated";
|
||||
window.setTimeout(() => { button.value = old_value; }, 2000);
|
||||
}
|
||||
else
|
||||
alert("Entry updated");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -958,6 +1022,39 @@ async function update_masterkey()
|
||||
}
|
||||
}
|
||||
|
||||
function copy_clipboard(button, entry_number)
|
||||
{
|
||||
var password = "";
|
||||
|
||||
entry = document.getElementById(entry_number);
|
||||
|
||||
if (entry == null) {
|
||||
alert(entry_number + " not found");
|
||||
return;
|
||||
}
|
||||
|
||||
inputs = entry.getElementsByTagName("input");
|
||||
|
||||
for(i=0; i<inputs.length; i++)
|
||||
{
|
||||
if (inputs[i].getAttribute("name") == "password")
|
||||
{
|
||||
inputs[i].select();
|
||||
document.execCommand('copy');
|
||||
inputs[i].setSelectionRange(0,0); // Unselect
|
||||
if (button !== null)
|
||||
{
|
||||
old_value = button.value;
|
||||
button.value = "Copied";
|
||||
window.setTimeout(() => { button.value = old_value; }, 2000);
|
||||
}
|
||||
else
|
||||
alert('Password copied into clipboard');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function makeText(text) {
|
||||
var data = new Blob([text], {type: 'application/xml'});
|
||||
|
||||
|
||||