Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long awaited mifare UL card emulator #17

Merged
merged 7 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Merge branch 'master' into sandbox
  • Loading branch information
AAsyunkin-se committed Aug 17, 2020
commit 5e48f44cf3d9b07b66780040f429391eabe2cd23
163 changes: 155 additions & 8 deletions src/hydrabus/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ t_token_dict tl_dict[] = {
{ T_FRAME_TIME, "frame-time" },
{ T_PCAP, "pcap" },
{ T_BIN, "bin" },
{ T_DIRECT_MODE_0, "dm0" },
{ T_DIRECT_MODE_1, "dm1" },
{ T_SET_EMUL_TAG_PROPERTIES, "ce" },
{ T_EMUL_TAG_PROPERTY_UID, "uid" },
{ T_EMUL_TAG_PROPERTY_SAK, "sak" },
{ T_EMUL_TAG_PROPERTY_URI, "uri" },
{ T_EMUL_T4T, "emul-t4t" },
{ T_SET_NFC_MODE, "set-nfc-mode"},
{ T_GET_NFC_MODE, "get-nfc-mode"},
{ T_NFC_MODE, "nfc-mode"},
{ T_NFC_MODE_TX_BITRATE, "nfc-mode-tx_br"},
{ T_NFC_MODE_RX_BITRATE, "nfc-mode-rx_br"},
{ T_NFC_TRANSPARENT, "nfc-transp" },
{ T_NFC_STREAM, "nfc-stream" },
#endif
{ T_SNIFF, "sniff" },
{ T_GPIO, "gpio" },
Expand Down Expand Up @@ -517,7 +517,154 @@ t_token tokens_nfc[] = {
{ }
};

#endif /* ifdef HYDRANFC or HYDRANFC_V2 */
t_token tokens_mode_dnfc_show[] = {
{
T_PINS,
.help = "Show pins used in this mode"
},
{
T_REGISTERS,
.help = "Show NFC registers"
},
{ }
};

t_token tokens_set_nfc_mode[] = {
{
T_NFC_MODE,
.arg_type = T_ARG_UINT,
.help = "Set NFC Mode\r\n\tNONE=0, POLL_NFCA=1, POLL_NFCA_T1T=2, POLL_NFCB=3, POLL_B_PRIME=4, POLL_B_CTS=5, POLL_NFCF=6\r\n\tPOLL_NFCV=7, POLL_PICOPASS=8, POLL_ACTIVE_P2P=9, LISTEN_NFCA=10, LISTEN_NFCB=11=, LISTEN_NFCF=12, LISTEN_ACTIVE_P2P=13"
},
{
T_NFC_MODE_TX_BITRATE,
.arg_type = T_ARG_UINT,
.help = "Set TX BitRate\r\n\tBR_106=0, BR_212=1, BR_424=2, BR_848=3, BR_52p97=235, BR_26p48=236, BR_1p66=237, BR_KEEP=255"
},
{
T_NFC_MODE_RX_BITRATE,
.arg_type = T_ARG_UINT,
.help = "Set RX BitRate\r\n\tBR_106=0, BR_212=1, BR_424=2, BR_848=3, BR_52p97=235, BR_26p48=236, BR_1p66=237, BR_KEEP=255"
},
{ }
};

#define DNFC_PARAMETERS \
{ T_FREQUENCY, \
.arg_type = T_ARG_FLOAT, \
.help = "Set SPI Bus frequency" },

t_token tokens_mode_dnfc[] = {
{
T_SHOW,
.subtokens = tokens_mode_dnfc_show,
.help = "Show DNFCv2 parameters"
},
DNFC_PARAMETERS
{
T_TRIGGER,
.subtokens = tokens_mode_trigger,
.help = "Setup DNFCv2 SPI2 trigger"
},
{
T_SET_NFC_MODE,
.subtokens = tokens_set_nfc_mode,
.help = "Set NFC Mode and TX/RX BitRate in kbit/s"
},
{
T_GET_NFC_MODE,
.help = "Get NFC Mode"
},
{
T_NFC_TRANSPARENT,
.help = "Enter NFC Transparent Mode"
},
{
T_NFC_STREAM,
.help = "Enter NFC Stream Mode"
},

/* SPI-specific commands */
{
T_READ,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "SPI Read byte (repeat with :<num>)"
},
{
T_HD,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "SPI Read byte (repeat with :<num>) and print hexdump"
},
{
T_WRITE,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "SPI Write byte (repeat with :<num>)"
},
{
T_ARG_UINT,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "SPI Write byte (repeat with :<num>)"
},
{
T_ARG_STRING,
.help = "SPI Write string"
},
{
T_CS_ON,
.help = "SPI Alias for \"chip-select on\""
},
{
T_CS_OFF,
.help = "SPI Alias for \"chip-select off\""
},
/* BP commands */
{
T_LEFT_SQ,
.help = "SPI Alias for \"chip-select on\""
},
{
T_RIGHT_SQ,
.help = "SPI Alias for \"chip-select off\""
},
{
T_AMPERSAND,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Delay 1 usec (repeat with :<num>)"
},
{
T_PERCENT,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "Delay 1 msec (repeat with :<num>)"
},
{
T_TILDE,
.flags = T_FLAG_SUFFIX_TOKEN_DELIM_INT,
.help = "SPI Write a random byte (repeat with :<num>)"
},
{
T_AUX_ON,
.help = "Toggle AUX[0](PC4) high"
},
{
T_AUX_OFF,
.help = "Toggle AUX[0](PC4) low"
},
{
T_AUX_READ,
.help = "Read AUX[0](PC4)"
},
{
T_EXIT,
.help = "Exit DNFCv2 mode"
},
{ }
};

t_token tokens_dnfc[] = {
DNFC_PARAMETERS
{ }
};

#endif /* ifdef HYDRANFC_V2 */

t_token tokens_parity[] = {
{ T_NONE },
Expand Down
14 changes: 7 additions & 7 deletions src/hydrabus/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ enum {
T_FRAME_TIME,
T_PCAP,
T_BIN,
T_DIRECT_MODE_0,
T_DIRECT_MODE_1,
T_SET_EMUL_TAG_PROPERTIES,
T_EMUL_TAG_PROPERTY_UID,
T_EMUL_TAG_PROPERTY_SAK,
T_EMUL_TAG_PROPERTY_URI,
T_EMUL_T4T,
T_SET_NFC_MODE,
T_GET_NFC_MODE,
T_NFC_MODE,
T_NFC_MODE_TX_BITRATE,
T_NFC_MODE_RX_BITRATE,
T_NFC_TRANSPARENT,
T_NFC_STREAM,
#endif
T_SNIFF,
T_GPIO,
Expand Down
38 changes: 0 additions & 38 deletions src/hydranfc_v2/hydranfc_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,20 +1037,6 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
break;

case T_EMUL_ISO14443A:
case T_SET_EMUL_TAG_PROPERTIES:
action = p->tokens[t];
break;

case T_EMUL_T4T:
action = p->tokens[t];
if (p->tokens[t+1] == 0 || p->tokens[t+2] != 0) {
cprintf(con, "Invalid parameter(s).\r\n");
return t;
}
break;

case T_DIRECT_MODE_0:
case T_DIRECT_MODE_1:
action = p->tokens[t];
break;

Expand Down Expand Up @@ -1207,30 +1193,6 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
user_tag_properties.level4_enabled = false;
break;

case T_DIRECT_MODE_0:
/*
TODO Test Transparent mode
TX encoding:
In Transparent mode, the framing and FIFO are bypassed, and the MOSI pin directly drives
the modulation of the transmitter.
RX decoding:
In Transparent mode the framing and FIFO are bypassed. The digitized subcarrier signal
directly drives the MISO pin
*/
break;

case T_DIRECT_MODE_1:
/*
TODO Test Stream mode
TX encoding:
In Stream mode the framing is bypassed. The FIFO data directly defines the modulation
data sent to the transmitter.
RX decoding:
In Stream mode the framing is bypassed. The digitized subcarrier signal is directly stored in
the FIFO.
*/
break;

default:
break;
}
Expand Down
5 changes: 2 additions & 3 deletions src/hydranfc_v2/hydranfc_v2.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# List of all the hydranfc related files.
HYDRANFC_V2_SRC = hydranfc_v2/hydranfc_v2.c \
hydranfc_v2/hydranfc_v2_ce.c \
hydranfc_v2/ce.c \
hydranfc_v2/rfal_poller.c
hydranfc_v2/rfal_poller.c \
hydranfc_v2/hydrabus_mode_dnfc.c

# Required include directories
HYDRANFC_V2_INC = ./hydranfc_v2
You are viewing a condensed version of this merge commit. You can view the full changes here.