Skip to content

Commit

Permalink
v0.1.12: add detector-furui.html
Browse files Browse the repository at this point in the history
  • Loading branch information
taichunmin committed Jan 11, 2023
1 parent db976c0 commit f07b3cb
Show file tree
Hide file tree
Showing 9 changed files with 746 additions and 197 deletions.
9 changes: 7 additions & 2 deletions documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ toc:
URL: <http://taichunmin.idv.tw/pn532.js/m1-uid-scanner.html>
This tools can scan UID of NFC Type A Tags via Web Bluetooth or Web Serial.
- name: Mifare Key Detector
- name: Key Detector for 北方智能卡
description: |
URL: <http://taichunmin.idv.tw/pn532.js/mf-key-detector.html>
URL: <http://taichunmin.idv.tw/pn532.js/detector-shop143630998.html>
This tools is only support supercard [單卡嗅探王](https://lihi1.com/MAU73). It can change uid and type of supercard, or do reader-only attack to recover key.
- name: Key Detector for 福睿
description: |
URL: <http://taichunmin.idv.tw/pn532.js/detector-furui.html>
This tools is only support supercard [福睿偵測卡](https://lihi1.com/0vzx7). It can change uid and type of supercard, or do reader-only attack to recover key.
- name: other
children:
- Pn532Frame
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pn532.js",
"version": "0.1.11",
"version": "0.1.12",
"author": "taichunmin <[email protected]>",
"browser": "dist/pn532.min.js",
"description": "pn532.js is a JavaScript library for PN532 base on Web Bluetooth and Web Serial.",
Expand All @@ -25,14 +25,14 @@
"web-serial-polyfill": "^1.0.14"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^23.0.5",
"@rollup/plugin-json": "^5.0.2",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"cross-env": "^7.0.3",
"dayjs": "^1.11.7",
"documentation": "^14.0.1",
"dotenv": "^16.0.3",
"eslint": "^8.30.0",
"eslint": "^8.31.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.6.0",
Expand All @@ -47,7 +47,7 @@
"livereload": "^0.9.3",
"node-watch": "^0.7.3",
"pug": "^3.0.2",
"rollup": "^3.7.4",
"rollup": "^3.9.1",
"rollup-plugin-terser": "^7.0.2",
"serve-static": "^1.15.0",
"web-streams-polyfill": "^3.2.1"
Expand Down
11 changes: 11 additions & 0 deletions src/Packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ export default class Packet extends Uint8Array {
return chunks
}

/**
* The xor value of every byte in the Packet.
* @example
* console.log(Packet.fromHex('01020304').xor)
* // 4
* @member {number}
*/
get xor () {
return _.reduce(this, (xor, v) => xor ^ v, 0)
}

/**
* hex string of the Packet
* @example
Expand Down
5 changes: 5 additions & 0 deletions src/Packet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ test('Packet#chunk()', async () => {
expect(actual[1].hex).toEqual('03')
})

test('Packet#xor', async () => {
const actual = Packet.fromHex('01020304').xor
expect(actual).toEqual(0x04)
})

test('Packet#hex', async () => {
const actual = new Packet([0, 1, 2])
expect(actual.hex).toEqual('000102')
Expand Down
16 changes: 12 additions & 4 deletions src/plugin/Hf14a.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ export default class Pn532Hf14a {
}
}

/**
* Check sector key of Mifare card.
* @memberof Pn532Hf14a
* @instance
* @async
* @param {object} args
* @param {number} args.sectorMax How many sectors to read from target.
* @param {Packet[]} args.keys Array of 6 bytes keys to be check.
* @returns {Promise<Packet[]>} Resolve with array of sector key As and key Bs. Odd Index (`0`, `2`, `4`...) are Key A, even index (`1`, `3`, `5`...) are Key B. If the sector key is not found, the value will be `null`.
*/
async function mfCheckKeys ({ sectorMax = 16, keys } = {}) {
try {
keys = mfKeysUniq(keys)
Expand Down Expand Up @@ -535,8 +545,7 @@ export default class Pn532Hf14a {
try {
const oldUid = (await inListPassiveTarget())?.[0]?.uid
if (!oldUid) throw new Error('Failed to select card')
const data = Packet.merge(uid, Packet.fromHex('00080400000000000000BEAF'))
for (const b of uid) data[4] ^= b // bcc
const data = Packet.merge(uid, new Packet([uid.xor]), Packet.fromHex('080400000000000000BEAF'))
if (Packet.isLen(sak, 1)) data.set(sak, 5)
if (Packet.isLen(atqa, 2)) data.set(atqa.slice().reverse(), 6)
let isSuccess = false
Expand Down Expand Up @@ -1062,8 +1071,7 @@ export default class Pn532Hf14a {
*/
async function mfSetUidGen1a ({ atqa = null, sak = null, uid } = {}) {
if (!Packet.isLen(uid, 4)) throw new TypeError('invalid 4 bytes uid')
const data = Packet.merge(uid, Packet.fromHex('00080400000000000000BEAF'))
for (const b of uid) data[4] ^= b // bcc
const data = Packet.merge(uid, new Packet([uid.xor]), Packet.fromHex('080400000000000000BEAF'))
if (Packet.isLen(sak, 1)) data.set(sak, 5)
if (Packet.isLen(atqa, 2)) data.set(atqa.slice().reverse(), 6)
await mfWriteBlockGen1a({ block: 0, data })
Expand Down
Loading

0 comments on commit f07b3cb

Please sign in to comment.