You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Proxmark3GUI/module/mifare.h

132 lines
3.4 KiB
C

5 years ago
#ifndef MIFARE_H
#define MIFARE_H
#include "common/util.h"
#include "ui_mainwindow.h"
#include "ui/mf_attack_hardnesteddialog.h"
#include "ui/mf_uid_parameterdialog.h"
#include "ui/mf_sim_simdialog.h"
5 years ago
#include <QObject>
#include <QString>
#include <QStringList>
#include <QRegularExpression>
#include <QMessageBox>
5 years ago
class Mifare : public QObject
{
Q_OBJECT
public:
explicit Mifare(Ui::MainWindow *ui, Util *addr, QWidget *parent = nullptr);
5 years ago
QString info(bool isRequiringOutput = false);
void chk();
void nested();
void hardnested();
void sniff();
void snoop();
void list();
void read();
void readAll();
void write();
void writeAll();
void dump();
void restore();
enum KeyType
{
KEY_A = 'A',
KEY_B = 'B',
};
enum DataType
{
DATA_INVALID,
DATA_WITHSPACE,
DATA_NOSPACE,
};
struct CardType
{
int type;
4 years ago
int sector_size;
int block_size;
int blk[40];
int blks[40];
};
4 years ago
enum AccessType
{
4 years ago
ACC_NEVER = 0,
ACC_KEY_A = 1,
ACC_KEY_B = 2,
ACC_KEY_AB = 3,
};
4 years ago
static const CardType card_mini;
static const CardType card_1k;
static const CardType card_2k;
static const CardType card_4k;
static const AccessType dataCondition[8][4];
static const AccessType trailerReadCondition[8][3];
static const AccessType trailerWriteCondition[8][3];
void data_clearData();
void data_clearKey();
static bool data_isKeyValid(const QString& key);
static Mifare::DataType data_isDataValid(const QString& data);
void data_syncWithDataWidget(bool syncAll = true, int block = 0);
void data_syncWithKeyWidget(bool syncAll = true, int sector = 0, KeyType keyType = KEY_A);
CardType cardType;
Mifare::CardType getCardType();
void setCardType(int type);
void writeAllC();
void writeC();
void readAllC();
void readC();
void wipeC();
void setParameterC();
bool data_loadDataFile(const QString& filename);
bool data_loadKeyFile(const QString& filename);
bool data_saveDataFile(const QString& filename, bool isBin);
bool data_saveKeyFile(const QString& filename, bool isBin);
void data_key2Data();
void data_data2Key();
void data_setData(int block, const QString& data);
void data_setKey(int sector, KeyType keyType, const QString& key);
void lockC();
void writeAllE();
void readAllE();
void wipeE();
void simulate();
void loadSniff(const QString& file);
void saveSniff(const QString& file);
4 years ago
void data_fillKeys();
QString _readblk(int blockId, KeyType keyType, const QString &key, int waitTime = 300);
QStringList _readsec(int sectorId, KeyType keyType, const QString &key, int waitTime = 300);
static QList<quint8> data_getACBits(const QString &text);
5 years ago
public slots:
signals:
private:
QWidget* parent;
Ui::MainWindow *ui;
Util* util;
QStringList* keyAList;
QStringList* keyBList;
QStringList* dataList;
QRegularExpression* dataPattern;
QRegularExpression* keyPattern_res;
QRegularExpression* keyPattern;
QString bin2text(const QByteArray& buff, int start, int length);
//QString _readblk(int blockId, KeyType keyType, const QString &key, int waitTime = 300);
//QStringList _readsec(int sectorId, KeyType keyType, const QString &key, int waitTime = 300);
5 years ago
};
#endif // MIFARE_H