├── README.md ├── cmd-inputs.py ├── labtrack2.py └── labtrack1.py /README.md: -------------------------------------------------------------------------------- 1 | # credit-card-reader 2 | This Python script takes a hexadecimal string of digital binary data (from the a debit card barcode) and obtains serial, account number, expiration, CVV, and other discretionary data. 3 | -------------------------------------------------------------------------------- /cmd-inputs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding: utf-8 3 | 4 | # In[13]: 5 | 6 | 7 | get_ipython().run_line_magic('run', 'labtrack1.py 01 45 1D 44 AD 12 A5 A9 52 60 DC 89 46 95 68 56 63 EC EB E9 32 A4 9B CA A8 7A EB A3 03 6C 08 10 20 40 81 02 04 08 10 2F A2 8D 08 36 28 48 A1 02 04 08 10 22 51 B5 22 84 08 10 20 40 83 42 34 F9 D8') 8 | 9 | 10 | # In[22]: 11 | 12 | 13 | get_ipython().run_line_magic('run', 'labtrack2.py 03 55 43 50 8A D6 62 CA 04 46 92 76 80 82 28 06 10 24 02 10 88 2D 08 42 1F 90') 14 | 15 | 16 | # In[ ]: 17 | 18 | 19 | 20 | 21 | 22 | # In[ ]: 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /labtrack2.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import re 3 | import math 4 | hexnum = " ".join(sys.argv[1:]) 5 | hexnum = hexnum.split() 6 | 7 | binary = list() 8 | noParityList = list() 9 | decoded = list() 10 | 11 | for i in range(len(hexnum)): 12 | binaryString = "" 13 | ini_string=hexnum[i] 14 | res = bin(int(ini_string, 16))[2:].zfill(8) 15 | binaryString = res 16 | binary.append(binaryString) 17 | 18 | binary = ''.join(map(str, binary)) 19 | 20 | binary = [binary[i:i+5] for i in range(6, len(binary), 5)] 21 | 22 | for i in range(len(binary)): 23 | noParityString = binary[i][0:4] 24 | if i > 0: 25 | MSB = ''.join(reversed(noParityString)) 26 | noParityList.append(MSB) 27 | else: 28 | noParityList.append(noParityString) 29 | 30 | for i in range(len(noParityList)): 31 | if i==0: 32 | decoded.append("[SS]") 33 | if noParityList[i]=="1101": 34 | decoded.append("[FS]") 35 | if noParityList[i]=="1111": 36 | decoded.append("[ES]") 37 | if i!=0 and len(noParityList[i])==4: 38 | integer=int(noParityList[i],2) 39 | decoded.append(str(integer)) 40 | decodedString = ''.join(map(str, decoded)) 41 | print(decodedString) -------------------------------------------------------------------------------- /labtrack1.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import re 3 | import math 4 | hexnum = " ".join(sys.argv[1:]) 5 | hexnum = hexnum.split() 6 | 7 | binary = list() 8 | noParityList = list() 9 | decoded = list() 10 | 11 | #makes a binary list 12 | 13 | for i in range(len(hexnum)): 14 | binaryString = "" 15 | ini_string=hexnum[i] 16 | res = bin(int(ini_string, 16))[2:].zfill(8) 17 | binaryString = res 18 | binary.append(binaryString) 19 | #converts each hex # into binary and appends to the binary list of strings 20 | 21 | binary = ''.join(map(str, binary)) 22 | #concatentates the entire list of strings into one string 23 | 24 | binary = [binary[i:i+7] for i in range(0, len(binary), 7)] 25 | #divides the binary into 7 bit blocks and makes a list of 7-bits strings 26 | 27 | decoder = { 28 | "111110":"[ES][LRC]", 29 | "011111":"[FS]", 30 | "100100":"[LRC]", 31 | "100000":"a", 32 | "010000":"a", 33 | "110000":"c", 34 | "011000":"a", 35 | "111000":"a", 36 | "001000":"$", 37 | "000100":"(", 38 | "100100":")", 39 | "101100":"--", 40 | "011100":".", 41 | "111100":"/", 42 | "000010":"0", 43 | "100010":"1", 44 | "010010":"2", 45 | "110010":"3", 46 | "001010":"4", 47 | "101010":"5", 48 | "011010":"6", 49 | "111010":"7", 50 | "000110":"8", 51 | "100110":"9", 52 | "100001":'A', 53 | "010001":'B', 54 | "110001":'C', 55 | "001001":'D', 56 | "101001":'E', 57 | "011001":'F', 58 | "111001":'G', 59 | "000101":'H', 60 | "100101":'I', 61 | "010101":'J', 62 | "110101":'K', 63 | "001101":'L', 64 | "101101":'M', 65 | "011101":'N', 66 | "111101":'O', 67 | "000011":"P", 68 | "100011":"Q", 69 | "010011":"R", 70 | "110011":"S", 71 | "001011":"T", 72 | "101011":"U", 73 | "011011":"V", 74 | "111011":"W", 75 | "000111":"X", 76 | "100111":"Y", 77 | "010111":"Z" 78 | } 79 | 80 | 81 | for i in range(len(binary)): 82 | noParityString = binary[i][0:6] 83 | noParityList.append(noParityString) 84 | #creates list of binary 6-bits without parity attached to end 85 | 86 | for i in range(len(noParityList)): 87 | if noParityList[i]=="000000" and i==0: 88 | decoded.append("[SS]") 89 | if noParityList[i] in decoder and i!=0: 90 | character = decoder[noParityList[i]] 91 | decoded.append(character) 92 | decodedString = ''.join(map(str, decoded)) 93 | print(decodedString) 94 | 95 | #and noParityList[i]!="000000" 96 | #don't forget the parity bit! that's why none of it matches the keys 97 | --------------------------------------------------------------------------------