Ejemplo n.º 1
0
Archivo: mitm.py Proyecto: nfcgate/mitm
    def onNfcData(self, srcname, srcpeer, otherpeer, data, bytes):
        def relay():
            otherpeer.sendNfcData(srcname, bytes)

        relay()
        if srcname == NFCData.READER:
            print "lastRequestAPDU -> " + strhex(bytes)
            self.lastRequestAPDU = bytes
        else:
            cmd = self.lastRequestAPDU[0]
            reply = bytes[0]
            cmdOk = reply == desfire.RESPONSE_OK

            if cmd == desfire.CMD_SELECT and cmdOk:
                print "cmd: CMD_SELECT"
                self.selectedAID = self.lastRequestAPDU[1:]
                self.onAidSelected(self.lastRequestAPDU[1:])
            elif cmd == desfire.CMD_AUTH and reply == desfire.CMD_AUTHPHASE:
                print "cmd: CMD_AUTH"
                self.inAuthPhase = True
                self.onAuthStart()
            elif cmd == desfire.CMD_AUTHPHASE and reply == desfire.RESPONSE_OK:
                print "cmd: CMD_AUTHPHASE"
                self.inAuthPhase = False
                self.onAuthenticated()

        return
Ejemplo n.º 2
0
    def onNfcData(self, srcname, srcpeer, otherpeer, data, bytes):
        def relay():
            otherpeer.sendNfcData(srcname, bytes)

        relay()
        if srcname == NFCData.READER:
            print "lastRequestAPDU -> " + strhex(bytes)
            self.lastRequestAPDU = bytes
        else:
            cmd = self.lastRequestAPDU[0]
            reply = bytes[0]
            cmdOk = reply == desfire.RESPONSE_OK

            if cmd == desfire.CMD_SELECT and cmdOk:
                print "cmd: CMD_SELECT"
                self.selectedAID = self.lastRequestAPDU[1:]
                self.onAidSelected(self.lastRequestAPDU[1:])
            elif cmd == desfire.CMD_AUTH and reply == desfire.CMD_AUTHPHASE:
                print "cmd: CMD_AUTH"
                self.inAuthPhase = True
                self.onAuthStart()
            elif cmd == desfire.CMD_AUTHPHASE and reply == desfire.RESPONSE_OK:
                print "cmd: CMD_AUTHPHASE"
                self.inAuthPhase = False
                self.onAuthenticated()

        return
Ejemplo n.º 3
0
 def printFile(self, fid):
     reply = self.readFile(fid)
     print "File " + strhex(fid) + ": " + strhex(reply)
Ejemplo n.º 4
0
 def printFile(self, fid):
     reply = self.readFile(fid)
     print "File " + strhex(fid) + ": " + strhex(reply)