iroteta

characters_and_vehicles.js

May 6th, 2022
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var readline = require('readline');
  2. var fs = require('fs');
  3.  
  4. var ld = require('..');
  5. var CharCrypto = ld.CharCrypto;
  6. var PWDGen = ld.PWDGen;
  7. var pad = require('pad');
  8.  
  9. process.stdout.write('\u001B[2J\u001B[0;0f');
  10.  
  11. const rl = readline.createInterface({
  12.     input: process.stdin,
  13.     output: process.stdout
  14. });
  15.  
  16. rl.question("Enter NFC's UID: ", (uid) => {
  17.     rl.question("Enter character or vehicle ID ( [Character or Vehicle ID] or [C] for all Characters or [V] for all Vehicles ): ", (cvid) => {
  18.         if (uid == "") {
  19.             console.log("");
  20.             console.log("No valid NFC's UID");
  21.         }
  22.         else if (cvid == "") {
  23.             console.log("");
  24.             console.log("No valid character or vehicle ID");
  25.         }
  26.         else {
  27.             var cc = new CharCrypto();
  28.             var pwd = pad(8, PWDGen(uid).toString(16), '0');
  29.            
  30.             var characters = JSON.parse(fs.readFileSync('../data/list_of_characters.json.txt', 'utf8'));
  31.             var vehicles = JSON.parse(fs.readFileSync('../data/list_of_vehicles.json.txt', 'utf8'));
  32.            
  33.             var vehicle_page38 = '00010000';
  34.            
  35.             console.log("");
  36.             console.log("");
  37.            
  38.             if (cvid == "C") {
  39.                 console.log("... [Page  36] [Page  37] ... [Page  43]");
  40.                 console.log("... [    0x24] [    0x25] ... [    0x2B]");
  41.                
  42.                 for (character in characters) {
  43.                     var characterCode = pad(16, cc.encrypt(uid, characters[character].id).toString("hex"), '0');
  44.                    
  45.                     console.log(
  46.                         "... [" + characterCode.substring(0, 8).toUpperCase()  + "] [" + characterCode.substring(8, 16).toUpperCase()  + "] ... [" + pwd.toUpperCase() + "] " + characters[character].name);
  47.                 }
  48.             }
  49.             else if (cvid == "V") {
  50.                 console.log("... [Page  36] [Page  38] ... [Page  43]");
  51.                 console.log("... [    0x24] [    0x26] ... [    0x2B]");
  52.                
  53.                 for (vehicle in vehicles) {
  54.                     var vehicleCode = vehicles[vehicle].line36.toString("hex");
  55.                    
  56.                     console.log(
  57.                         "... [" + vehicleCode  + "] [" + vehicle_page38 + "] ... [" + pwd.toUpperCase() + "] " + vehicles[vehicle].name);
  58.                 }
  59.             }
  60.             else {
  61.                 var characterCode = pad(16, cc.encrypt(uid, cvid).toString("hex"), '0');
  62.                
  63.                 if (cvid.length == 4) {
  64.                     console.log("... [Page  36] [Page  38] ... [Page  43]");
  65.                     console.log("... [    0x24] [    0x26] ... [    0x2B]");
  66.                    
  67.                     for (vehicle in vehicles) {
  68.                         var vehicleId = vehicles[vehicle].id;
  69.                         var vehicleCode = vehicles[vehicle].line36.toString("hex");
  70.                        
  71.                         if (vehicleId == cvid) {
  72.                             console.log(
  73.                                 "... [" + vehicleCode  + "] [" + vehicle_page38 + "] ... [" + pwd.toUpperCase() + "] " + vehicles[vehicle].name);
  74.                         }
  75.                     }
  76.                 }
  77.                 else {
  78.                     console.log("... [Page  36] [Page  37] ... [Page  43]");
  79.                     console.log("... [    0x24] [    0x25] ... [    0x2B]");
  80.                    
  81.                     console.log(
  82.                         "... [" + characterCode.substring(0, 8).toUpperCase()  + "] [" + characterCode.substring(8, 16).toUpperCase()  + "] ... [" + pwd.toUpperCase() + "] ");
  83.                 }
  84.             }
  85.            
  86.             console.log("");
  87.             console.log("");
  88.         }
  89.        
  90.         rl.close();
  91.     });
  92. });
Advertisement
Add Comment
Please, Sign In to add comment