Created
August 26, 2024 20:23
-
-
Save Wind010/79a4f46d3650ade333dc17b100c9919d to your computer and use it in GitHub Desktop.
Just some easier code for Duplicati Login with known NONCE and Salted Password.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const base64Decode = str => Uint8Array.from(atob(str), c => c.charCodeAt(0)); | |
const base64Encode = bytes => btoa(String.fromCharCode(...new Uint8Array(bytes))); | |
const generatePassword = async (nounce, saltedPassword) => { | |
const bytesNounce = base64Decode(nounce); | |
const bytesSaltedPassword = base64Decode(saltedPassword); | |
const concatenatedBytes = new Uint8Array([...bytesNounce, ...bytesSaltedPassword]); | |
const hash = await crypto.subtle.digest('SHA-256', concatenatedBytes); | |
return base64Encode(hash); | |
}; | |
const urlEncode = str => encodeURIComponent(str).replace(/%20/g, '+'); | |
const nounce = 'NONCE'; | |
const saltedPassword = 'SALTED_PASSWORD'; | |
generatePassword(nounce, saltedPassword).then(noncedPassword => { | |
console.log(noncedPassword, urlEncode(noncedPassword)); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
import base64 | |
from urllib.parse import unquote, quote_plus | |
def generate_password(nounce: str, salted_password: str): | |
bytes_nounce, bytes_salted_password = base64.b64decode(unquote(nounce)), base64.b64decode(salted_password) | |
hex_nounce, hex_salted_password = bytes_nounce.hex(), bytes_salted_password.hex() | |
hex_concatenated = hex_nounce + hex_salted_password | |
concatenated_bytes = bytes.fromhex(hex_concatenated) | |
sha256_hash = hashlib.sha256(concatenated_bytes).digest() | |
return base64.b64encode(sha256_hash).decode('utf-8') | |
nonced_password = generate_password('NONCE', 'SALTED_PASSWORD') | |
url_encoded_nonced_password = quote_plus(nonced_password) | |
print(nonced_password, url_encoded_nonced_password) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment