Extract sessions from IndexedDB
We can extract sessions from IndexedDB by using the following javascript.
Javascript
function getResultFromRequest(request) { return new Promise((resolve, reject) => { request.onsuccess = function (event) { resolve(request.result); }; }); } async function getDB() { var request = window.indexedDB.open( "wawc" ); return await getResultFromRequest(request); } async function readAllKeyValuePairs() { var db = await getDB(); var objectStore = db.transaction( "user" ).objectStore( "user" ); var request = objectStore.getAll(); return await getResultFromRequest(request); } session = await readAllKeyValuePairs(); console.log(session); |
We can try to execute the above code in the browser’s console or tab where we had opened Web-Whatsapp and we will see the output as follows containing session key-value pairs.
Now we get those key-value pairs as text by running the following line of code.
Javascript
JSON.stringify(session); |
Now let’s copy that text to a file to save a session and clear both localStorage and IndexedDB to log out. Now we can run the following code to inject a session by assigning the value of the session string we just copied to a file to variable SESSION_STRING. Then refresh the page and we will log in again without scanning the QR code.
Javascript
function getResultFromRequest(request) { return new Promise((resolve, reject) => { request.onsuccess = function (event) { resolve(request.result); }; }) } async function getDB() { var request = window.indexedDB.open( "wawc" ); return await getResultFromRequest(request); } async function injectSession(SESSION_STRING) { var session = JSON.parse(SESSION_STRING); var db = await getDB(); var objectStore = db.transaction( "user" , "readwrite" ).objectStore( "user" ); for ( var keyValue of session) { var request = objectStore.put(keyValue); await getResultFromRequest(request); } } var SESSION_STRING = "" ; await injectSession(SESSION_STRING); |
Share WhatsApp Web without Scanning QR code using Python
Prerequisite: Selenium, Browser Automation Using Selenium
In this article, we are going to see how to share your Web-WhatsApp with anyone over the Internet without Scanning a QR code.