Skip to content

Instantly share code, notes, and snippets.

@0xquad
Created March 25, 2024 20:13
Show Gist options
  • Save 0xquad/0497648c1b48a5bf0b833eea3d70acba to your computer and use it in GitHub Desktop.
Save 0xquad/0497648c1b48a5bf0b833eea3d70acba to your computer and use it in GitHub Desktop.
Migrating from TeamPass 2.x to Bitwarden/Vaultwarden
// On TeamPass version 2.x, login on the web interface and use
// the following in the dev console to retrieve all passwords in an array
// that can be imported directly to Vaultwarden/Bitwarden:
elem = document.createElement('textarea');
KEY = 'paste-here-the-session-key-from-the-html-source';
$.post("sources/items.queries.php", {
type: "lister_items_groupe", id: 1, restricted: '', start: 0,
uniqueLoadData: '', key: KEY,
nb_items_to_display_once: 999
},
data => {
let Dec = d => prepareExchangedData(d, 'decode', KEY);
let Enc = d => prepareExchangedData(d, 'encode', KEY);
data = Dec(data);
let allItems = {items:[]};
Object.keys(data.html_json).map(k => parseInt(k)).forEach(k => {
querydata = JSON.stringify({
"id": k,
"folder_id": "1",
"salt_key_required": "0",
"salt_key_set": "0",
"expired_item": "",
"restricted": "",
"page": "items"
});
$.post('sources/items.queries.php', {
type : 'show_details_item',
data : Enc(querydata),
key : KEY
},
data => {
let item = Dec(data);
// populate using the Bitwarden JSON import format
let newItem = {
"id": crypto.randomUUID(),
"organizationId": null,
"folderId": null,
"type": 1,
"reprompt": 0,
"name": (elem.innerHTML=item.label,elem.value),
"notes": (elem.innerHTML=item.description,elem.value).replaceAll('<br />', '\n'),
"favorite": false,
"fields": [
{
"name": "email",
"value": (elem.innerHTML=item.email,elem.value),
"type": 0
}
],
"login": {
"uris": item.url ? [
{
"match": null,
"uri": (elem.innerHTML=item.url,elem.value)
}
] : undefined,
"username": (elem.innerHTML=item.login,elem.value),
"password": item.pw
},
"collectionIds": null
};
allItems.items.push(newItem);
}
);
});
console.log(allItems);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment