-
Notifications
You must be signed in to change notification settings - Fork 0
/
NFClogin.ino
62 lines (48 loc) · 1.42 KB
/
NFClogin.ino
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
/**************************************************************************
*
* @title NFClogin
* @author Dr Aaron McConville
* @email a.mcconville@ulster.ac.uk
* @date 2019/11/30
* @license GPL v3.0
*
**************************************************************************/
#include <AESLib.h>
#include <Base64.h>
#include "base64.hpp"
#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>
#include <Keyboard.h>
PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
String uid = "0";
void setup() {
nfc.begin();
}
void loop() {
if (nfc.tagPresent())
{
NfcTag tag = nfc.read();
uid = tag.getUidString();
uid.replace(" ", "");
String uid2 = uid + uid;
char key[uid2.length()];
uid2.toCharArray(key, uid2.length());
char pass[] = "O+2lNKO6JF98+L+3+ZBmhQ=="; // <--------------- Base64 Encoded Password
int passLen = sizeof(pass);
int decodedLen = base64_dec_len(pass, passLen);
char decoded[decodedLen];
base64_decode(decoded, pass, passLen);
aes128_dec_single(key, decoded);
char * p = strchr(decoded, ' ');
if (p){
*p = 0;
}
Keyboard.write(KEY_RETURN);
delay(200);
Keyboard.print(decoded);
delay(2000);
}
}