|
@@ -8,7 +8,6 @@
|
8
|
8
|
#include <Business/FreeFareDeviceBusiness.h>
|
9
|
9
|
#include "DBO/Result.h"
|
10
|
10
|
#include "Business/LibNfcBusiness.h"
|
11
|
|
-#include "Business/FreeFareDeviceBusiness.h"
|
12
|
11
|
#include "CommandLineParser.h"
|
13
|
12
|
#include "MainClass.h"
|
14
|
13
|
|
|
@@ -64,27 +63,62 @@ int MainClass::main()
|
64
|
63
|
auto tag = tags.getData()[i];
|
65
|
64
|
std::cout << "UID: " << tag->getUid() << std::endl;
|
66
|
65
|
std::cout << "Type: " << tag->getType() << std::endl;
|
67
|
|
- for(int s = 0; s < 16; ++s) {
|
68
|
|
- std::cout << "+Sector: " << s << std::endl;
|
69
|
|
- auto sectorResult = tag->readSector(s, StringUtils::humanToRaw("8829da9daf76").getData(), MFC_KEY_A);
|
70
|
|
- if (!sectorResult) {
|
71
|
|
- sectorResult.print();
|
72
|
|
- }
|
73
|
|
- else {
|
74
|
|
- auto sector = sectorResult.getData();
|
75
|
|
- for (int b = 0; b < 3; ++b) {
|
76
|
|
- std::cout << StringUtils::rawToHuman(sector.getBlock(b)) << std::endl;
|
77
|
|
- }
|
78
|
|
- std::cout << StringUtils::rawToHuman(sector.getKeyA()) << " "
|
79
|
|
- << StringUtils::rawToHuman(sector.getAccessBits()) << " "
|
80
|
|
- << StringUtils::rawToHuman(sector.getKeyB()) << std::endl;
|
81
|
|
- }
|
82
|
|
- }
|
|
66
|
+ mapKeys(tag);
|
83
|
67
|
}
|
84
|
68
|
|
85
|
69
|
device->close();
|
86
|
|
-
|
87
|
70
|
libNfc.clean();
|
88
|
71
|
|
89
|
72
|
return 0;
|
90
|
73
|
}
|
|
74
|
+
|
|
75
|
+int MainClass::mapKeys(std::shared_ptr<FreeFareTagBusiness> tag)
|
|
76
|
+{
|
|
77
|
+ std::vector<std::string> keys;
|
|
78
|
+ keys.push_back(StringUtils::humanToRaw("8829da9daf76").getData());
|
|
79
|
+ auto mappedKeysResult = tag->mapKeys(keys);
|
|
80
|
+ if (!mappedKeysResult) {
|
|
81
|
+ mappedKeysResult.print();
|
|
82
|
+ }
|
|
83
|
+ else {
|
|
84
|
+ auto mappedKeys = mappedKeysResult.getData();
|
|
85
|
+ for (int s = 0; s < mappedKeys.size(); ++s) {
|
|
86
|
+ auto sectorKeys = mappedKeys[s];
|
|
87
|
+ std::cout << "+Sector: " << s << std::endl;
|
|
88
|
+ for (int b = 0; b < sectorKeys.size(); ++b) {
|
|
89
|
+ auto blockKeys = sectorKeys[b];
|
|
90
|
+ std::cout << "+Block: " << b << std::endl;
|
|
91
|
+ std::cout << "Key A: " << StringUtils::rawToHuman(blockKeys.first) << std::endl;
|
|
92
|
+ std::cout << "Key B: " << StringUtils::rawToHuman(blockKeys.second) << std::endl;
|
|
93
|
+ }
|
|
94
|
+ }
|
|
95
|
+ }
|
|
96
|
+ return 0;
|
|
97
|
+}
|
|
98
|
+
|
|
99
|
+int MainClass::dump(std::shared_ptr<FreeFareTagBusiness> tag)
|
|
100
|
+{
|
|
101
|
+ for(int s = 0; s < 16; ++s)
|
|
102
|
+ {
|
|
103
|
+ std::cout << "+Sector: " << s << std::endl;
|
|
104
|
+ auto sectorResult = tag->readSector(s, StringUtils::humanToRaw("8829da9daf76").getData(), MFC_KEY_A);
|
|
105
|
+ if (!sectorResult)
|
|
106
|
+ {
|
|
107
|
+ sectorResult.print();
|
|
108
|
+ }
|
|
109
|
+ else
|
|
110
|
+ {
|
|
111
|
+ auto sector = sectorResult.getData();
|
|
112
|
+ for (int b = 0; b < 3; ++b)
|
|
113
|
+ {
|
|
114
|
+ std::cout << StringUtils::rawToHuman(sector.getBlock(b)) << std::endl;
|
|
115
|
+ }
|
|
116
|
+ std::cout << StringUtils::rawToHuman(sector.getKeyA()) << " "
|
|
117
|
+ << StringUtils::rawToHuman(sector.getAccessBits()) << " "
|
|
118
|
+ << StringUtils::rawToHuman(sector.getKeyB()) << std::endl;
|
|
119
|
+ }
|
|
120
|
+ }
|
|
121
|
+ return 0;
|
|
122
|
+}
|
|
123
|
+
|
|
124
|
+
|