This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM1PwdClear.c
91 lines (90 loc) · 1.63 KB
/
M1PwdClear.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* @file M1PwdClear.c
* @author wvv ([email protected])
* @brief
* @version 0.1
* @date 2021-02-15
*
* @copyright Copyright (c) 2021
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define CARD_SZ 1024
typedef unsigned char Card[CARD_SZ];
void card_load(char *p, Card *c)
{
FILE *fin = fopen(p, "rb");
if (!fin)
{
puts("file not exist.");
return;
}
fread(c, CARD_SZ, 1, fin);
}
void card_print(Card cd)
{
puts("M1 CARD");
for (int c = 0; c < CARD_SZ; c++)
{
printf("%02X", cd[c]);
if (c % 64 == 63)
{
printf("\n");
}
}
}
void card_clear_pwd(Card c)
{
for (int i = 0; i < 16; i++)
{
for (int j = 0; j < 6; j++)
{
c[i * 64 + 48 + j] = 0xff;
c[i * 64 + 58 + j] = 0xff;
}
}
}
void card_save(char *p, Card c)
{
FILE *fout = fopen(p, "wb");
if (!fout)
{
puts("file already exist.");
return;
}
fwrite(c, CARD_SZ, 1, fout);
}
void test()
{
puts("DEMO TEST");
Card c = {0};
// card_load("1.dump", &c);
card_print(c);
card_clear_pwd(c);
card_print(c);
}
int main(int n, char **args)
{
if (n < 2)
{
puts("USAGE: M1PwdClear.exe xx.dump");
test();
return 0;
}
puts(args[0]);
puts(args[1]);
Card c = {0};
card_load(args[1], &c);
card_print(c);
card_clear_pwd(c);
card_print(c);
char cn[200];
memcpy(cn,args[1],strlen(args[1]));
strcat(cn, ".dump");
puts("PASSWORD CLEARED.");
printf("SAVE TO THE FILE %s.",cn);
card_save(cn,c);
return 0;
}