Skip to content

Commit

Permalink
Merge pull request #32 from piotr-cz/feature/zip-calc-nodejs
Browse files Browse the repository at this point in the history
Add nodejs version of zip password calculator
  • Loading branch information
rgerganov authored Jan 5, 2025
2 parents 8e9f46c + d6e5c1c commit 3bfc8d6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
7 changes: 6 additions & 1 deletion zip_password_calculator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ ro.product.locale.region=GB
Most of these values should be either static or guessable with a bit of detective work.

Example:
```
```sh
$ ./zip_password_calculator.sh build.prop.TEST
15DAA85C8D44B3979CD152A387F6
```

```sh
$ node ./zip_password_calculator.mjs build.prop.TEST
15DAA85C8D44B3979CD152A387F6
```

Run this tool against a file containing the settings for your head unit and get the password, potentially avoiding the need for `bkcrack`.

## USA region, Display Audio Gen 1 (without Nav)
Expand Down
44 changes: 44 additions & 0 deletions zip_password_calculator/zip_password_calculator.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/env node

import { readFile } from 'node:fs/promises'
import { createHash } from 'node:crypto'

const elements = [
'ro.product.model',
'ro.product.brand',
'ro.product.name',
'ro.product.device',
'ro.product.board',
'ro.product.cpu.abi',
'ro.product.cpu.abi2',
'ro.product.manufacturer',
'ro.product.locale.language',
'ro.product.locale.region',
]

const infile = process.argv[2]

if (!infile) {
help()
process.exit(1)
}

const contents = await readFile(infile, 'utf8')

const props = elements.reduce((acc, element) => {
const match = contents.match(`${element}=.*`)
return match ? [...acc, match[0]] : acc
}, []).join('')

const hash1 = createHash('sha512').update(props).digest('hex').toUpperCase()
const hash2 = createHash('sha512').update(hash1).digest('hex').toUpperCase()

console.log(hash2.substring(10, 38))


function help() {
console.info(`Usage: node zip_password_calculator.mjs FILENAME
FILENAME should be a 'build.prop' file containing the following elements:
${elements.join('\n')}`
)
}

0 comments on commit 3bfc8d6

Please sign in to comment.