mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
WPS NFC: Protect nfcpy pretty print calls against exceptions
nfcpy does not yet support all the new message formats, so some of the pretty() calls can result in exceptions. Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
parent
c209dd1108
commit
12288d848c
@ -92,7 +92,11 @@ class HandoverServer(nfc.handover.HandoverServer):
|
|||||||
|
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
print "HandoverServer - request received"
|
print "HandoverServer - request received"
|
||||||
print "Parsed handover request: " + request.pretty()
|
try:
|
||||||
|
print "Parsed handover request: " + request.pretty()
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
print str(request).encode("hex")
|
||||||
|
|
||||||
sel = nfc.ndef.HandoverSelectMessage(version="1.2")
|
sel = nfc.ndef.HandoverSelectMessage(version="1.2")
|
||||||
|
|
||||||
@ -112,7 +116,10 @@ class HandoverServer(nfc.handover.HandoverServer):
|
|||||||
sel.add_carrier(message[0], "active", message[1:])
|
sel.add_carrier(message[0], "active", message[1:])
|
||||||
|
|
||||||
print "Handover select:"
|
print "Handover select:"
|
||||||
print sel.pretty()
|
try:
|
||||||
|
print sel.pretty()
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
print str(sel).encode("hex")
|
print str(sel).encode("hex")
|
||||||
|
|
||||||
print "Sending handover select"
|
print "Sending handover select"
|
||||||
|
@ -126,7 +126,10 @@ class HandoverServer(nfc.handover.HandoverServer):
|
|||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
self.ho_server_processing = True
|
self.ho_server_processing = True
|
||||||
print "HandoverServer - request received"
|
print "HandoverServer - request received"
|
||||||
print "Parsed handover request: " + request.pretty()
|
try:
|
||||||
|
print "Parsed handover request: " + request.pretty()
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
|
||||||
sel = nfc.ndef.HandoverSelectMessage(version="1.2")
|
sel = nfc.ndef.HandoverSelectMessage(version="1.2")
|
||||||
|
|
||||||
@ -147,7 +150,10 @@ class HandoverServer(nfc.handover.HandoverServer):
|
|||||||
sel.add_carrier(message[0], "active", message[1:])
|
sel.add_carrier(message[0], "active", message[1:])
|
||||||
|
|
||||||
print "Handover select:"
|
print "Handover select:"
|
||||||
print sel.pretty()
|
try:
|
||||||
|
print sel.pretty()
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
print str(sel).encode("hex")
|
print str(sel).encode("hex")
|
||||||
|
|
||||||
print "Sending handover select"
|
print "Sending handover select"
|
||||||
@ -170,7 +176,11 @@ def wps_handover_init(llc):
|
|||||||
message.add_carrier(datamsg[0], "active", datamsg[1:])
|
message.add_carrier(datamsg[0], "active", datamsg[1:])
|
||||||
|
|
||||||
print "Handover request:"
|
print "Handover request:"
|
||||||
print message.pretty()
|
try:
|
||||||
|
print message.pretty()
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
print str(message).encode("hex")
|
||||||
|
|
||||||
client = nfc.handover.HandoverClient(llc)
|
client = nfc.handover.HandoverClient(llc)
|
||||||
try:
|
try:
|
||||||
@ -199,18 +209,26 @@ def wps_handover_init(llc):
|
|||||||
return
|
return
|
||||||
|
|
||||||
print "Received message"
|
print "Received message"
|
||||||
print message.pretty()
|
try:
|
||||||
|
print message.pretty()
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
print str(message).encode("hex")
|
||||||
message = nfc.ndef.HandoverSelectMessage(message)
|
message = nfc.ndef.HandoverSelectMessage(message)
|
||||||
print "Handover select received"
|
print "Handover select received"
|
||||||
print message.pretty()
|
try:
|
||||||
|
print message.pretty()
|
||||||
|
except Exception, e:
|
||||||
|
print e
|
||||||
|
|
||||||
for carrier in message.carriers:
|
for carrier in message.carriers:
|
||||||
print "Remote carrier type: " + carrier.type
|
print "Remote carrier type: " + carrier.type
|
||||||
if carrier.type == "application/vnd.wfa.wsc":
|
if carrier.type == "application/vnd.wfa.wsc":
|
||||||
print "WPS carrier type match - send to wpa_supplicant"
|
print "WPS carrier type match - send to wpa_supplicant"
|
||||||
wpas_report_handover(data, carrier.record, "INIT")
|
wpas_report_handover(data, carrier.record, "INIT")
|
||||||
wifi = nfc.ndef.WifiConfigRecord(carrier.record)
|
# nfcpy does not support the new format..
|
||||||
print wifi.pretty()
|
#wifi = nfc.ndef.WifiConfigRecord(carrier.record)
|
||||||
|
#print wifi.pretty()
|
||||||
|
|
||||||
print "Remove peer"
|
print "Remove peer"
|
||||||
client.close()
|
client.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user