Files
flipperNfcToBin/index.html
2025-03-27 22:31:01 +00:00

136 lines
4.9 KiB
HTML

3<!DOCTYPE html>
<html>
<body>
<title>Flipper <-> Mifare classic Binary coverter</title>
<h2>Mifare classic converter</h2>
<p>I take absolutely no liabilty for use please verify the files yourself before writing to a card you can end up
bricking your cards.</p>
<script src="./script.js"></script>
<script src="./scripts/smartair.js"></script>
<script>
let cardSize = 1024 //1k card
let blocks = 64 // 1k card
let filename = Date.now()
function updateCardSize(size) {
cardSize = size
blocks = size / 16
}
document.addEventListener("DOMContentLoaded", function (event) {
const nfc = document.getElementById("nfc");
document.getElementById("file-selector").addEventListener("change", (event) => {
console.log(event.target.files[0])
if (event.target.files[0].name.endsWith(".bin")) {
getBinaryFromFile(event.target.files[0]).then((data) => {
filename = event.target.files[0].name.replace(".bin", "")
const hexStr = generateNfcFromBinary(data);
nfc.value = hexStr;
updateCardSize(data.length)
})
} else if (event.target.files[0].name.endsWith(".nfc")) {
getTextFromFile(event.target.files[0]).then((data) => {
filename = event.target.files[0].name.replace(".nfc", "")
nfc.value = data;
const re = /Mifare Classic type: (1K|4K)/
const dec = re.exec(data)
console.log(dec)
if (dec) {
if (dec[1] == "1K") {
updateCardSize(1024)
} else if (dec[1] == "4K") {
updateCardSize(4096)
}
}
})
} else {
alert("Invalid file type");
return
}
});
});
function bin() {
let array = new Array(blocks)
const nfc = document.getElementById("nfc");
var text = nfc.value.split("\n");
const re = /Block (\d+): (([0-9a-fA-F]+ *)+)/gm
for (let i = 0; i < text.length; i++) {
const data = re.exec(text)
console.log(data)
if (data) {
const block = parseInt(data[1])
const bytes = data[2].replace(/ /g, '')
console.log(block, bytes)
if (block < blocks) {
console.log('block', block, bytes)
array[block] = bytes
}
}
}
let textHex = ""
console.log("number of blocks", blocks)
for (let i = 0; i < blocks; i++) {
console.log('block', i, array[i])
if (array[i] !== undefined && array[i]?.length == 32) {
textHex += array[i]
console.log("Writing block", i, array[i], "to text")
} else {
console.log('block', i, 'is empty')
//Filling with 0 if block is empty
textHex += '00000000000000000000000000000000'
}
}
downloadBinFile(textHex, filename + ".bin")
}
function nfc() {
downloadTextFile(document.getElementById("nfc").value, filename + ".nfc")
}
function smartAir() {
const nfc = document.getElementById("nfc");
const startSector = Number(document.getElementById("startSector").value)
const keyA = document.getElementById("keyA").value
const data = generateSmartAirCard(startSector, keyA)
console.log(data)
const hexStr = generateNfcFromBinary(data);
nfc.value = hexStr;
}
</script>
<button type="button" onclick="bin()">
Download .bin
</button>
<button type="button" onclick="nfc()">
Download .nfc
</button>
<p>.nfc file content here</p>
<br />
<input type="file" id="file-selector" accept=".bin,.nfc">
<br />
<textarea id="nfc" rows="20" cols="90"></textarea>
<br />
<p>Custom generation</p>
<p>What is this?</p>
<p>This is when someone fucked up big time and let us generate good credentials with little to no knowledge
All props goes to Miana and Micsen for their incredible research on Smartair. https://smartair.wtf</p>
<div>
<p>Key A</p><input type="text" id="keyA" />
<p>StartSector</p><input type="text" id="startSector" />
<button type="button" onclick="smartAir()">
Make smartAirDump
</button>
</div>
</body>
</html>