Skip to content

Commit

Permalink
Release 1.0.8 - Improved Magstripe Decoding
Browse files Browse the repository at this point in the history
 of ABA Track 2
  • Loading branch information
exploitagency committed Feb 12, 2018
1 parent 9854059 commit e4531f6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 52 deletions.
33 changes: 33 additions & 0 deletions Source Code/esprfidtool/aba2str.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
String aba2str (String magstripe, int magStart, int magEnd, String swipeDirection) {
//f.println(String()+"Start pos:"+magStart);
//f.println(String()+"Start pos:"+magEnd);
String ABA="";
String aba2str="";
int magCount=abs(magEnd-magStart);
//f.println(String()+"magCount:"+magCount);
aba2str=(String()+"\"Cleaned\" Binary:"+magstripe.substring(magStart,magEnd)+"\n");
aba2str+=(String()+" * Possible "+swipeDirection+" Card Data\(ASCII\):");
while (magCount>0) {
ABA=magstripe.substring(magStart,magStart+4);
if (ABA=="1101") {aba2str+=(";");}
else if (ABA=="0000") {aba2str+=("0");}
else if (ABA=="1000") {aba2str+=("1");}
else if (ABA=="0100") {aba2str+=("2");}
else if (ABA=="1100") {aba2str+=("3");}
else if (ABA=="0010") {aba2str+=("4");}
else if (ABA=="1010") {aba2str+=("5");}
else if (ABA=="0110") {aba2str+=("6");}
else if (ABA=="1110") {aba2str+=("7");}
else if (ABA=="0001") {aba2str+=("8");}
else if (ABA=="1001") {aba2str+=("9");}
else if (ABA=="0011") {aba2str+=("<");}
else if (ABA=="0111") {aba2str+=(">");}
else if (ABA=="0101") {aba2str+=(":");}
else if (ABA=="1011") {aba2str+=("=");}
else if (ABA=="1111") {aba2str+=("?");}
else {aba2str+=("_UNKNOWN-CHARACTER_");}
magStart=magStart+5;
magCount=magCount-5;
}
return aba2str;
}
66 changes: 19 additions & 47 deletions Source Code/esprfidtool/esprfidtool.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "License.h"
#include "version.h"
#include "strrev.h"
#include "aba2str.h"
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
Expand Down Expand Up @@ -524,56 +525,27 @@ void LogWiegand(WiegandNG tempwg) {
}

if (countedBits==248) {

int startSentinel=magstripe.indexOf("11010");
int endSentinel=(magstripe.lastIndexOf("11111")+4);
int magStart=0;
int magEnd=1;
if (endSentinel>startSentinel) {
f.print(" * \"Forward\" Swipe Detected,");
//f.println(String()+"Normal: "+magstripe);
magStart=startSentinel;
magEnd=endSentinel;
}
else if (endSentinel<startSentinel){
f.print(" * \"Reverse\" Swipe Detected,");
char magchar[249];
magstripe.toCharArray(magchar,249);
magstripe=String(strrev(magchar));
//f.println(String()+"Reverse: "+magstripe);
magStart=magstripe.indexOf("11010");
magEnd=(magstripe.lastIndexOf("11111")+4);
}
//f.println(String()+"Start pos:"+magStart);
//f.println(String()+"Start pos:"+magEnd);
String ABA="";
int magCount=abs(magEnd-magStart);
//f.println(String()+"magCount:"+magCount);
f.println(String()+"\"Cleaned\" Binary:"+magstripe.substring(magStart,magEnd));
f.print(" * Possible Card Data\(ASCII\):<b>");
while (magCount>0) {
ABA=magstripe.substring(magStart,magStart+4);
if (ABA=="1101") {f.print(";");}
else if (ABA=="0000") {f.print("0");}
else if (ABA=="1000") {f.print("1");}
else if (ABA=="0100") {f.print("2");}
else if (ABA=="1100") {f.print("3");}
else if (ABA=="0010") {f.print("4");}
else if (ABA=="1010") {f.print("5");}
else if (ABA=="0110") {f.print("6");}
else if (ABA=="1110") {f.print("7");}
else if (ABA=="0001") {f.print("8");}
else if (ABA=="1001") {f.print("9");}
else if (ABA=="0011") {f.print("<");}
else if (ABA=="0111") {f.print(">");}
else if (ABA=="0101") {f.print(":");}
else if (ABA=="1011") {f.print("=");}
else if (ABA=="1111") {f.print("?");}
else {f.print("_UNKNOWN-CHARACTER_");}
magStart=magStart+5;
magCount=magCount-5;
}
f.println("</b>");
//f.print("<pre>");

f.print(" * Trying \"Forward\" Swipe,");
magStart=startSentinel;
magEnd=endSentinel;
f.println(aba2str(magstripe,magStart,magEnd,"\"Forward\" Swipe"));

f.print(" * Trying \"Reverse\" Swipe,");
char magchar[249];
magstripe.toCharArray(magchar,249);
magstripe=String(strrev(magchar));
//f.println(String()+"Reverse: "+magstripe);
magStart=magstripe.indexOf("11010");
magEnd=(magstripe.lastIndexOf("11111")+4);
f.println(aba2str(magstripe,magStart,magEnd,"\"Reverse\" Swipe"));

//f.print("</pre>");
f.println(String()+F(" * You can verify the data at the following URL: <a target=\"_blank\" href=\"https://www.legacysecuritygroup.com/aba-decode.php?binary=")+magstripe+F("\">https://www.legacysecuritygroup.com/aba-decode.php?binary=")+magstripe+F("</a>"));
}

Expand Down Expand Up @@ -959,7 +931,7 @@ void ViewLog(){
File f = SPIFFS.open(payload, "r");
String webString = f.readString();
f.close();
ShowPL = String()+F("<a href=\"/\"><- BACK TO INDEX</a><br><br><a href=\"/logs\">List Exfiltrated Data</a><br><br><a href=\"")+payload+"\"><button>Download File</button><a> - <a href=\"/deletelog?payload="+payload+"\"><button>Delete File</button></a><br><br><small>Note: Preambles shown are only a guess based on card length and may not be accurate for every card format.</small><br><pre>"+payload+"\n-----\n"+webString+"</pre>";
ShowPL = String()+F("<html><head></head><body><a href=\"/\"><- BACK TO INDEX</a><br><br><a href=\"/logs\">List Exfiltrated Data</a><br><br><a href=\"")+payload+"\"><button>Download File</button><a> - <a href=\"/deletelog?payload="+payload+"\"><button>Delete File</button></a><br><br><small>Note: Preambles shown are only a guess based on card length and may not be accurate for every card format.</small><br><pre>"+payload+"\n-----\n"+webString+"</pre></body></html>";
webString="";
server.send(200, "text/html", ShowPL);
}
Expand Down
8 changes: 4 additions & 4 deletions Source Code/esprfidtool/strrev.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ char * strrev (char *s)
for (p2 = s; *p2; ) p2++;
p1 = s;
while (p1 < p2) {
char c1 = *p1;
char c2 = *--p2;
*p1++ = c2;
*p2 = c1;
char c1 = *p1;
char c2 = *--p2;
*p1++ = c2;
*p2 = c1;
}
return s;
}
2 changes: 1 addition & 1 deletion Source Code/esprfidtool/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
String version = "1.0.7";
String version = "1.0.8";

0 comments on commit e4531f6

Please sign in to comment.