Initial commit
This commit is contained in:
commit
660e9d9961
15
LICENSE
Normal file
15
LICENSE
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
ISC License
|
||||||
|
|
||||||
|
Copyright (c) 2024, acidvegas <acid.vegas@acid.vegas>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
12
README.md
Normal file
12
README.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# MSR90
|
||||||
|
> A journey into learning about magnetic strip data in modern day cards
|
||||||
|
|
||||||
|
#### WORK IN PROGRESS
|
||||||
|
**Hardware:** [Deftun MSR90 3 Track Reader](https://www.amazon.com/MSR90-Magnetic-Credit-Reader-Deftun/dp/B01DUB4GVO/)
|
||||||
|
|
||||||
|
I will be documenting all my research on magnetic strip data aswell at writing code for it.
|
||||||
|
For some reason it seems hard to find code or any valid documentation on working with magnetic strip data on Linux, so this will attempt to be a deep dive into understanding the capabilities.
|
||||||
|
|
||||||
|
___
|
||||||
|
|
||||||
|
###### Mirrors for this repository: [acid.vegas](https://git.acid.vegas/msr90) • [SuperNETs](https://git.supernets.org/acidvegas/msr90) • [GitHub](https://github.com/acidvegas/msr90) • [GitLab](https://gitlab.com/acidvegas/msr90) • [Codeberg](https://codeberg.org/acidvegas/msr90)
|
76
msr90.py
Normal file
76
msr90.py
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# MSR90 Card Reader - Developed by acidvegas in Python (https://acid.vegas/msr90)
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
# ANSI Escape Codes
|
||||||
|
YELLOW = '\033[93m'
|
||||||
|
RESET = '\033[0m'
|
||||||
|
|
||||||
|
# Numeric values for the service code
|
||||||
|
service_code_values = {
|
||||||
|
'0': 'No restrictions and PIN required.',
|
||||||
|
'1': 'No restrictions.',
|
||||||
|
'2': 'Goods and services only (no cash).',
|
||||||
|
'3': 'ATM only and PIN required.',
|
||||||
|
'4': 'Cash only.',
|
||||||
|
'5': 'Goods and services only (no cash), PIN required.',
|
||||||
|
'6': 'No restrictions, use of PIN depends on issuers requirements.',
|
||||||
|
'7': 'Goods and services only, use of PIN depends on issuers requirements.'
|
||||||
|
}
|
||||||
|
|
||||||
|
# Description of the format code
|
||||||
|
format_code_values = {
|
||||||
|
'A': 'Reserved for proprietary use of the card issuer.',
|
||||||
|
'B': 'Used by financial and credit card systems.'
|
||||||
|
}
|
||||||
|
|
||||||
|
def parse_magnetic_stripe(data: str):
|
||||||
|
'''
|
||||||
|
Parse the raw data from the magnetic stripe of a card.
|
||||||
|
|
||||||
|
:param data: Raw data from the magnetic stripe of a card.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# Regex to match the track 1 and track 2 data
|
||||||
|
track1 = re.search(r'%([AB])(\d+)\^([^?^]+)\^(\d{4})(\d{3}).*?\?', data)
|
||||||
|
track2 = re.search(r';(\d+)=(\d{4})(\d{3}).*?\?', data)
|
||||||
|
|
||||||
|
# Check if the data is valid
|
||||||
|
if not track1 or not track2:
|
||||||
|
raise ValueError('Invalid data format')
|
||||||
|
|
||||||
|
# Parse the data from the track 1 and track 2
|
||||||
|
format_code = track1.group(1)
|
||||||
|
account_number = track1.group(2)
|
||||||
|
name = track1.group(3).strip()
|
||||||
|
expiry_date = track1.group(4)
|
||||||
|
expiry_date = f'{expiry_date[2:4]}/{expiry_date[0:2]}'
|
||||||
|
service_code = track1.group(5)
|
||||||
|
|
||||||
|
service_code_description = [
|
||||||
|
f'{service_code[0]} - {service_code_values.get(service_code[0], 'Unknown')}',
|
||||||
|
f'{service_code[1]} - {service_code_values.get(service_code[1], 'Unknown')}',
|
||||||
|
f'{service_code[2]} - {service_code_values.get(service_code[2], 'Unknown')}'
|
||||||
|
]
|
||||||
|
|
||||||
|
format_code_description = format_code_values.get(format_code, 'Unknown')
|
||||||
|
|
||||||
|
# Print the parsed data
|
||||||
|
print(f'{YELLOW}Name :{RESET} {name}')
|
||||||
|
print(f'{YELLOW}Account Number :{RESET} {account_number}')
|
||||||
|
print(f'{YELLOW}Expiration Date :{RESET} {expiry_date}')
|
||||||
|
print(f'{YELLOW}Service Code :{RESET} {service_code}')
|
||||||
|
for item in service_code_description:
|
||||||
|
print(' '*18 + item)
|
||||||
|
print(f'{YELLOW}Format Code :{RESET} {format_code} ({format_code_description})')
|
||||||
|
print(f'{YELLOW}Track 1 :{RESET} {track1.group(0)}')
|
||||||
|
print(f'{YELLOW}Track 2 :{RESET} {track2.group(0)}')
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print('Please swipe the card...')
|
||||||
|
data = input()
|
||||||
|
parse_magnetic_stripe(data)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user