How to retrieve essential smart card info - python

I am using a simple smart card reader and am wanting to retrieve information that is stored on an EMV chip using the same reader. Currently, I found a library to do so, called pyscard, and it uses python.
At the moment, I have managed to use the documentation and some command codes to get the ATR of my card, including Applet codes, but have not been able to retrieve any of the data that is actually important, as in CardHolder name, PAN, Expiration date, card type(Visa, MasterCard...) etc.
Does the ATR or AID is somewhat useful? Do I have to process or analyze the ATR and AID to get the command codes?
Is there a possibility to get the data, as there are no command codes anywhere, but a lot of stack overflow articles leading mostly nowhere with thorough explanations that are available in Wikipedia and in overall documentation.
The pyscard documentation also did not seem to provide such information.
Also, is it possible to access the library of purchases the user has made, for instance as a list: 4.5euro, 22euro, 5euro.. etc or rather not, or is such data even logged on the chip?
The closest source I found was this link: https://iso8583.info/lib/EMV/TLVs with a duplicate-like article here Retrieve smart card's PAN with Python and pyscard with some documentation here https://www.openscdp.org/scripts/tutorial/emv/reademv.html
Here is also documentation for the pyscard: https://pyscard.sourceforge.io/index.html
Thanks for answering if not for downvoting, as many similar queries I have found, have received such votes.

SCSH (Smart Card Shell) provided by Card connect can be a useful tool for you. It has some predefined scripts to read EMV cards.
Download link is EMV Credit Card Application

RFIDIOt is an great library to use for this:
https://github.com/AdamLaurie/RFIDIOt
It comes with many examples include ChAP.py which has the code you need to talk to EMV cards.

Related

How to programmatically sync anki flashcard database with local file?

I would like to have a script ran by cron or an anki background job that will automatically read in a file (e.g. csv, tsv) containing all my flashcards and update the flashcard database in anki automatically so that i don't have to manually import my flashcards 1000 times a week.
any have any ideas how this can be achieved ?
Some interesting links I've came across, including from answers, that might provide a lead towards solutions:
https://github.com/langfield/ki
https://github.com/patarapolw/ankisync
https://github.com/towercity/anki-cli
The most robust approach there is so far is to have your collection under git, and use Ki to make Anki behave like a remote repository, so it's very easy to synchronise. The only constraint is the format of your collection. Each card is kept as a single file, and there is no real way around this.
I'm the maintainer of ki, one of the tools you linked! I really appreciate the shout-out #BlackBeans.
It's hard to give you perfect advice without more details about your workflow, but it sounds to me like you've got the source-of-truth for your notes in tabular files, and you import these files into Anki when you've made edits or added new notes.
If this is the case, ki may be what you're looking for. As #BlackBeans mentioned, this tool allows you to convert Anki notes into markdown files, and more generally, handles moving your data from your collection to a git repository, and back.
Basically, if the reason why you've got stuff in tabular files is (1) because you want to version it, (2) because you want to use an external editor, or (3) because your content is generated programmatically, then you might gain some use from using ki.
Feel free to open an issue describing your use case in detail. I'd love to give you some support in figuring out a good workflow if you think it would be helpful. I am in need of more user feedback at the moment, so you'd be helping me out, too!

scraping a subscribed website for video links

I use Kodi with add-ons such as Exodus which allow me to load episodes of my favourite TV programs etc, and I also have a subscription to horse and country to watch equine based shows but there is not a horse and country add-on to allow me to watch these on Kodi.
Is it possible for me to be able to code an add-on for Kodi (presumably in Python?) that would obtain all of the possible video links from www.horseandcountry.tv (catch up and on demand) using my log-in details and list these for me to watch.
I have a fair bit of experience coding (mostly Java, and a little Python), but have never written a Kodi add-on or done anything that scrapes video links from websites etc. I'm a first year computer science student so have a bit of understanding but not much experience!
First off, is what I am looking to do realistic and possible? and secondly, if so, would someone be able to give a very brief overview of how I would go about it and the necessary principles involved?
Your going to write a python addon, in this case probably a plugin is fitted best.
Have a look at https://github.com/Razzeee/generator-kodi for a good quickstart/boilerplate. (Let me know if you spot something wrong)
You might also want to use beautifulsoup to grab the links via python.

Webscraping a page: notification on update stock prices

Question
I am interested in web scraping and data analysis and I would like to develop my skills by writing a program using Python 2.7 that will monitor changes in stock prices. My goal is to be able to compare two stocks (for the time being) at certain points throughout the day, save that info into a document format easily handled by pandas (which I will learn how to use after I get this front end working). In the end I would like to map relationship trends between chosen stocks (when this one goes up by x what effect does that have on the other one). This is just a hobby project so it doesn't matter if the code is production quality.
My Experience
I am a brand new Python programmer (I have a very basic understanding of python and no real experience with any non-included modules) but I do have a technical background so if the answer to my question requires reading and understanding documentation intended for intermediate level programmers that should be OK.
For the basics I am working my way through Learning Python: Powerful Object-Oriented Programming by Mark Lutz if this helps any.
What I'm Looking For
I recognize this is a very broad subject and I am not asking for anyone to write any actual code examples or anything. I just want some direction as to where to go to get information more specific to my interests and goals.
This is actually my first post on this forum so please forgive me if this doesn't follow best practices for posting. I did search for other questions like mine and read the posting tips docs prior to writing this.
So, you want to web-scrape? If you're using Python 2.7, then you'll want to look into the urllib2, requests and BeautifulSoup libraries. If you're using Python 3.x, then you'll want to peek at urllib, urllib.request, and BeautifulSoup, again. Together, these libraries should accomplish everything you're looking to do in terms of web-scraping.
If you're interested in scraping stock data, might I suggest the yahoo_finance package? This is a Python wrapper for the Yahoo Finance API. Whenever I've done things with stock data in the past, this module was invaluable. There's also googlefinance, too. It's much easier to use these already-developed wrappers to extract stock info, rather than scraping hundreds (if not thousands) of web pages to get the data you want.

Total Downloads of Module Missing on PyPi

Up until recently, it was possible to see how many times a python module indexed on https://pypi.python.org/pypi had been downloaded (each module listed downloads for the past 24hrs, week and month). Now that information seems to be missing.
Download numbers are very helpful information when evaluating whether to build code off of one module or another. They also seem to be referenced by sites such as https://img.shields.io/
Does anyone know what happened? And/or, where I can view/retrieve that information?
This email from Donald Stufft (PyPI maintainer) from distutils mailing list says:
Just an FYI, I've disabled download counts on PyPI for the time being. The statistics stack is broken and needs engineering effort to fix it back up to deal with changes to PyPI. It was suggested that hiding the counts would help prevent user confusion when they see things like "downloaded 0 times" making people believe that a library has no users, even if it is a significantly downloaded library.
I'm unlikely to get around to fixing the current stack since, as part of Warehouse, I'm working on a new statistics stack which is much better. The data collection and storage parts of that stack are already done and I just need to get querying done (made more difficult by the fact that the new system queries can take 10+ seconds to complete, but can be queried on any dimension) and a tool to process the historical data and put it into the new storage engine.
Anyways, this is just to let folks know that this isn't a permanent loss of the feature and we won't lose any data.
So i guess we'll have to wait for a new stats stack in PyPI.
I just released http://pepy.tech/ to view the downloads of a package. I use the official data which is stored in BigQuery. I hope you will find it interesting :-)
Also the site is open source https://github.com/psincraian/pepy
Don't know what happened (although it happened before, i.e.) but you might wan't to try the PyPI ranking, or any of the several available modules and recipes to do this. For example:
Vanity
pyStats
random recipe
But consider that a lot of the downloads might be mirrors and not necessarily "real" user downloads. You should that into account in you evaluation. The libs mailing list (or other preferred media) might be a better way to know what version you should install.
PYPI count is disable temporarily as posted by dmand but there are some sites which may tells you python package statistics like pypi-stats.com (they said it shows real time information) and pypi-ranking.info (this might not gives you real time information).
You can also found some pypi packages which can gives you downloads information.

How to programmatically add a new contact to the iOS device from a PC/Mac

I need a way to programmatically add a new contact to iPhone from a computer.
Preferably using Python.
Long story short, I have contacts extracted from my old phone, and I want to transfer them to my new iPhone.
A solution that comes to my mind is to fill an addressbook supported by iTunes and then synchronize it with iOS.
But I would like a clean, easy, direct approach over intermixing this and that to find out that it wouldn't work because of something idiotic popped up.
Is there any protocol specification for doing that, or a way to link to iTunes DLLs or dynlibs?
Or perhaps a tweak using Apple Script on Mac.
I solved my personal problem by constructing vCard file containing all contacts from my old phone, then transfering that file to my iPhone manually who happily offered to import all contacts from it into its contacts App.
VCard specification can be found on Wikipedia. It is one nice file format. I used version 2.1 and it worked.
I was afraid that iPhone would accept only XML vCard version, but it worked with 2.1.
That's what I really meant in my comment. I wasn't sure which vCard version iOS uses.
It was extremely easy as my old phone gave me all contacts as a bunch of individual vCard files. So I only needed a simple little program to combine them into one file.
Thanks to apraetor for a comment that gave me that idea.
But the way I wanted it done (as I explained in the question) is possible by using LibIMobileDevice library available at:
http://www.libimobiledevice.org/
I didn't have time to experiment but it should work. And anyone searching for a way to do what I wanted should know about this excellent library.
I'd like someone's answer with details on how it is done and the code (for other's benefit), as I wouldn't play with this for some time. I am currently very busy.
I suspect it is something like:
Get all contacts from iPhone
Add new ones or delete old ones
Synchronize back
as I didn't see anything
there hinting at direct contact manipulation.

Categories