Skip to content

Commit

Permalink
HydraNFC sniff added sub command trace-uart1 (to trace in realtime sn…
Browse files Browse the repository at this point in the history
…iffed data to UART1 PA9 @8.4Mbauds 8N1 validated with FTDI C232HM-DDHSL-0)

HydraNFC cleanup sniff commands (move sniff-dbg/sniff-raw command to sniff sub command debug raw)
  • Loading branch information
bvernoux committed Oct 4, 2016
1 parent 8c2f0a3 commit 3ee41cc
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 96 deletions.
30 changes: 19 additions & 11 deletions hydrabus/commands.c
Expand Up @@ -95,8 +95,7 @@ t_token_dict tl_dict[] = {
{ T_EMUL_MF_ULTRALIGHT, "emul-mf-ul" }, { T_EMUL_MF_ULTRALIGHT, "emul-mf-ul" },
{ T_CLONE_MF_ULTRALIGHT, "clone-mf-ul" }, { T_CLONE_MF_ULTRALIGHT, "clone-mf-ul" },
{ T_SNIFF, "sniff" }, { T_SNIFF, "sniff" },
{ T_SNIFF_DBG, "sniff-dbg" }, { T_TRACE_UART1, "trace-uart1" },
{ T_SNIFF_RAW, "sniff-raw" },
{ T_DIRECT_MODE_0, "dm0" }, { T_DIRECT_MODE_0, "dm0" },
{ T_DIRECT_MODE_1, "dm1" }, { T_DIRECT_MODE_1, "dm1" },
{ T_GPIO, "gpio" }, { T_GPIO, "gpio" },
Expand Down Expand Up @@ -272,6 +271,22 @@ t_token tokens_mode_nfc_emul_mf_ul[] = {
{ } { }
}; };


t_token tokens_mode_nfc_sniff[] = {
{
T_TRACE_UART1,
.help = "Output realtime sniff trace on UART1(PA9@8.4Mbauds 8N1)"
},
{
T_DEBUG,
.help = "Enable debug sniff trace (ISO14443A)"
},
{
T_RAW,
.help = "Enable raw sniff trace (ISO14443A/B)"
},
{ }
};

#define NFC_PARAMETERS \ #define NFC_PARAMETERS \
{\ {\
T_TYPEA,\ T_TYPEA,\
Expand Down Expand Up @@ -302,15 +317,8 @@ t_token tokens_mode_nfc_emul_mf_ul[] = {
},\ },\
{\ {\
T_SNIFF,\ T_SNIFF,\
.help = "Sniff (ISO14443A only)"\ .subtokens = tokens_mode_nfc_sniff,\
},\ .help = "Sniff (default ISO14443A see options for more details)"\
{\
T_SNIFF_DBG,\
.help = "Sniff debug (ISO14443A only)"\
},\
{\
T_SNIFF_RAW,\
.help = "Sniff raw (ISO14443A/B)"\
},\ },\
{\ {\
T_EMUL_MIFARE,\ T_EMUL_MIFARE,\
Expand Down
3 changes: 1 addition & 2 deletions hydrabus/commands.h
Expand Up @@ -88,8 +88,7 @@ enum {
T_EMUL_MF_ULTRALIGHT, T_EMUL_MF_ULTRALIGHT,
T_CLONE_MF_ULTRALIGHT, T_CLONE_MF_ULTRALIGHT,
T_SNIFF, T_SNIFF,
T_SNIFF_DBG, T_TRACE_UART1,
T_SNIFF_RAW,
T_DIRECT_MODE_0, T_DIRECT_MODE_0,
T_DIRECT_MODE_1, T_DIRECT_MODE_1,
T_GPIO, T_GPIO,
Expand Down
44 changes: 31 additions & 13 deletions hydranfc/hydranfc.c
Expand Up @@ -314,7 +314,7 @@ THD_FUNCTION(key_sniff, arg)
} }


D2_ON; D2_ON;
hydranfc_sniff_14443A(NULL); hydranfc_sniff_14443A(NULL, FALSE);
D2_OFF; D2_OFF;
} }


Expand Down Expand Up @@ -856,10 +856,14 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
{ {
int dev_func; int dev_func;
mode_config_proto_t* proto = &con->mode->proto; mode_config_proto_t* proto = &con->mode->proto;
int action, period, continuous, t; int action, period, t;
bool continuous;
unsigned int mifare_uid = 0; unsigned int mifare_uid = 0;
filename_t sd_file; filename_t sd_file;
int str_offset; int str_offset;
bool sniff_trace_uart1;
bool sniff_debug;
bool sniff_raw;


if(p->tokens[token_pos] == T_SD) if(p->tokens[token_pos] == T_SD)
{ {
Expand All @@ -872,6 +876,9 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
trf7970a_irq_fn = NULL; trf7970a_irq_fn = NULL;
extStart(&EXTD1, &extcfg); extStart(&EXTD1, &extcfg);


sniff_trace_uart1 = FALSE;
sniff_debug = FALSE;
sniff_raw = FALSE;
action = 0; action = 0;
period = 1000; period = 1000;
continuous = FALSE; continuous = FALSE;
Expand Down Expand Up @@ -922,9 +929,19 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
action = p->tokens[t]; action = p->tokens[t];
break; break;


case T_TRACE_UART1:
sniff_trace_uart1 = TRUE;
break;

case T_DEBUG:
sniff_debug = TRUE;
break;

case T_RAW:
sniff_raw = TRUE;
break;

case T_SNIFF: case T_SNIFF:
case T_SNIFF_DBG:
case T_SNIFF_RAW:
action = p->tokens[t]; action = p->tokens[t];
break; break;


Expand Down Expand Up @@ -981,15 +998,16 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
break; break;


case T_SNIFF: case T_SNIFF:
hydranfc_sniff_14443A(con); if(sniff_debug)
break; {

hydranfc_sniff_14443A_dbg(con, sniff_trace_uart1);
case T_SNIFF_DBG: }else if(sniff_raw)
hydranfc_sniff_14443A_dbg(con); {
break; hydranfc_sniff_14443AB_raw(con, sniff_trace_uart1);

}else
case T_SNIFF_RAW: {
hydranfc_sniff_14443AB_raw(con); hydranfc_sniff_14443A(con, sniff_trace_uart1);
}
break; break;


case T_EMUL_MIFARE: case T_EMUL_MIFARE:
Expand Down
6 changes: 3 additions & 3 deletions hydranfc/hydranfc.h
Expand Up @@ -71,9 +71,9 @@ void hydranfc_scan_iso14443A(t_hydranfc_scan_iso14443A *data);
void hydranfc_scan_mifare(t_hydra_console *con); void hydranfc_scan_mifare(t_hydra_console *con);
void hydranfc_scan_vicinity(t_hydra_console *con); void hydranfc_scan_vicinity(t_hydra_console *con);


void hydranfc_sniff_14443A(t_hydra_console *con); void hydranfc_sniff_14443A(t_hydra_console *con, bool sniff_trace_uart1);
void hydranfc_sniff_14443A_dbg(t_hydra_console *con); void hydranfc_sniff_14443A_dbg(t_hydra_console *con, bool sniff_trace_uart1);
void hydranfc_sniff_14443AB_raw(t_hydra_console *con); void hydranfc_sniff_14443AB_raw(t_hydra_console *con, bool sniff_trace_uart1);


void hydranfc_emul_mifare(t_hydra_console *con, uint32_t mifare_uid); void hydranfc_emul_mifare(t_hydra_console *con, uint32_t mifare_uid);


Expand Down

0 comments on commit 3ee41cc

Please sign in to comment.