Skip to content

Commit

Permalink
Add support for 'sessionid' cookie as alternative to "SACSID" cookie
Browse files Browse the repository at this point in the history
SACSID already expires after 24 hours, whereas 'sessionid' cookie expires
after 2 weeks. So using 'sessionid' instead of SACSID improves the situation.
Using SACSID is still supported though to remain compatibility. This resolves
github issue #3.
  • Loading branch information
sndirsch committed Nov 19, 2019
1 parent 9223d4f commit f4071d6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
8 changes: 6 additions & 2 deletions ice/ingress-ice.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ice]
#> Your Google login and password
# Authentication via login/password currently not working at all; use cookies, i.e. SACSID/CSRF options below (issue #1)
# Authentication via login/password currently not working at all; use cookies, i.e. SACSID/sessionid and CSRF options below (issue #1)
#login=
#password=
#> Your area link. To get it, visit https://intel.ingress.com/intel, scroll the map to your location and press [LINK] at the top right corner. Copy that link and paste it here.
Expand Down Expand Up @@ -53,8 +53,12 @@ consoleLog=

[cookies]
#> If set, will use cookies for authentication instead of login/password
# Firefox: use Webdeveloper/Storage Inspector on https://intel.ingress.com/intel (csrftoken/SACSID)
# Firefox: use Webdeveloper/Storage Inspector on https://intel.ingress.com/intel (csrftoken/SACSID/sessionid)
# Either specify 'SACSID' or 'sessionid' cookie (or both)
# SACSID already expires after 24 hours!
SACSID=
# 'sessionid' expires after two weeks, so this is preferred
sessionid=
CSRF=

[Amazon-S3]
Expand Down
3 changes: 3 additions & 0 deletions ice/modules/ice-30-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ if (
) && (
typeof config.SACSID == 'undefined' || config.SACSID === '' ||
typeof config.CSRF == 'undefined' || config.CSRF === ''
) && (
typeof config.sessionid == 'undefined' || config.sessionid === '' ||
typeof config.CSRF == 'undefined' || config.CSRF === ''
)
) || (
typeof config.area == 'undefined' || config.area === ''
Expand Down
14 changes: 11 additions & 3 deletions ice/modules/ice-60-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,21 @@ function main() {
*/
function ice() {
greet();
if (config.SACSID == undefined || config.SACSID == '') {
if ((config.SACSID == undefined || config.SACSID == '') &&
(config.sessionid == undefined || config.sessionid == '')) {
loadCookies();
}
if (config.SACSID == undefined || config.SACSID == '') {
if ((config.SACSID == undefined || config.SACSID == '') &&
(config.sessionid == undefined || config.sessionid == '')) {
firePlainLogin();
} else {
addCookies(config.SACSID, config.CSRF);
if (config.SACSID == undefined) {
config.SACSID=''
}
if (config.sessionid == undefined) {
config.sessionid=''
}
addCookies(config.SACSID, config.CSRF, config.sessionid);
announce('Using cookies to log in');
afterCookieLogin();
}
Expand Down
15 changes: 13 additions & 2 deletions ice/modules/ice-70-login-cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/*global cookiespath */

/**
* Checks if cookies file exists. If so, it sets SACSID and CSRF vars
* Checks if cookies file exists. If so, it sets SACSID/sessionid and CSRF vars
* @returns {boolean}
* @author mfcanovas (github.com/mfcanovas)
* @since 3.2.0
Expand All @@ -34,6 +34,8 @@ function loadCookies() {
config.SACSID = line[1];
} else if(line[0] === 'csrftoken') {
config.CSRF = line[1];
} else if(line[0] === 'sessionid') {
config.sessionid = line[1];
}
}
stream.close();
Expand All @@ -46,7 +48,7 @@ function loadCookies() {
* @param {String} csrf
* @since 3.1.0
*/
function addCookies(sacsid, csrf) {
function addCookies(sacsid, csrf, sessionid) {
phantom.addCookie({
name: 'SACSID',
value: sacsid,
Expand All @@ -61,6 +63,14 @@ function addCookies(sacsid, csrf) {
domain: 'intel.ingress.com',
path: '/'
});
phantom.addCookie({
name: 'sessionid',
value: sessionid,
domain: 'intel.ingress.com',
path: '/',
httponly: true,
secure: true
});
}


Expand All @@ -79,6 +89,7 @@ function afterCookieLogin() {
if(config.login && config.password) {
page.deleteCookie('SACSID');
page.deleteCookie('csrftoken');
page.deleteCookie('sessionid');
firePlainLogin();
return;
} else {
Expand Down

0 comments on commit f4071d6

Please sign in to comment.