Permalink
Browse files

HydraNFC sniff added sub command trace-uart1 (to trace in realtime sn…

…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...
1 parent 8c2f0a3 commit 3ee41cc9070d74d229d7950afbe5479ed6cc0b8f @bvernoux bvernoux committed Oct 4, 2016
Showing with 221 additions and 96 deletions.
  1. +19 −11 hydrabus/commands.c
  2. +1 −2 hydrabus/commands.h
  3. +31 −13 hydranfc/hydranfc.c
  4. +3 −3 hydranfc/hydranfc.h
  5. +167 −67 hydranfc/hydranfc_cmd_sniff.c
View
@@ -95,8 +95,7 @@ t_token_dict tl_dict[] = {
{ T_EMUL_MF_ULTRALIGHT, "emul-mf-ul" },
{ T_CLONE_MF_ULTRALIGHT, "clone-mf-ul" },
{ T_SNIFF, "sniff" },
- { T_SNIFF_DBG, "sniff-dbg" },
- { T_SNIFF_RAW, "sniff-raw" },
+ { T_TRACE_UART1, "trace-uart1" },
{ T_DIRECT_MODE_0, "dm0" },
{ T_DIRECT_MODE_1, "dm1" },
{ T_GPIO, "gpio" },
@@ -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 \
{\
T_TYPEA,\
@@ -302,15 +317,8 @@ t_token tokens_mode_nfc_emul_mf_ul[] = {
},\
{\
T_SNIFF,\
- .help = "Sniff (ISO14443A only)"\
- },\
- {\
- T_SNIFF_DBG,\
- .help = "Sniff debug (ISO14443A only)"\
- },\
- {\
- T_SNIFF_RAW,\
- .help = "Sniff raw (ISO14443A/B)"\
+ .subtokens = tokens_mode_nfc_sniff,\
+ .help = "Sniff (default ISO14443A see options for more details)"\
},\
{\
T_EMUL_MIFARE,\
View
@@ -88,8 +88,7 @@ enum {
T_EMUL_MF_ULTRALIGHT,
T_CLONE_MF_ULTRALIGHT,
T_SNIFF,
- T_SNIFF_DBG,
- T_SNIFF_RAW,
+ T_TRACE_UART1,
T_DIRECT_MODE_0,
T_DIRECT_MODE_1,
T_GPIO,
View
@@ -314,7 +314,7 @@ THD_FUNCTION(key_sniff, arg)
}
D2_ON;
- hydranfc_sniff_14443A(NULL);
+ hydranfc_sniff_14443A(NULL, FALSE);
D2_OFF;
}
@@ -856,10 +856,14 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
{
int dev_func;
mode_config_proto_t* proto = &con->mode->proto;
- int action, period, continuous, t;
+ int action, period, t;
+ bool continuous;
unsigned int mifare_uid = 0;
filename_t sd_file;
int str_offset;
+ bool sniff_trace_uart1;
+ bool sniff_debug;
+ bool sniff_raw;
if(p->tokens[token_pos] == T_SD)
{
@@ -872,6 +876,9 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
trf7970a_irq_fn = NULL;
extStart(&EXTD1, &extcfg);
+ sniff_trace_uart1 = FALSE;
+ sniff_debug = FALSE;
+ sniff_raw = FALSE;
action = 0;
period = 1000;
continuous = FALSE;
@@ -922,9 +929,19 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
action = p->tokens[t];
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_DBG:
- case T_SNIFF_RAW:
action = p->tokens[t];
break;
@@ -981,15 +998,16 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
break;
case T_SNIFF:
- hydranfc_sniff_14443A(con);
- break;
-
- case T_SNIFF_DBG:
- hydranfc_sniff_14443A_dbg(con);
- break;
-
- case T_SNIFF_RAW:
- hydranfc_sniff_14443AB_raw(con);
+ if(sniff_debug)
+ {
+ hydranfc_sniff_14443A_dbg(con, sniff_trace_uart1);
+ }else if(sniff_raw)
+ {
+ hydranfc_sniff_14443AB_raw(con, sniff_trace_uart1);
+ }else
+ {
+ hydranfc_sniff_14443A(con, sniff_trace_uart1);
+ }
break;
case T_EMUL_MIFARE:
View
@@ -71,9 +71,9 @@ void hydranfc_scan_iso14443A(t_hydranfc_scan_iso14443A *data);
void hydranfc_scan_mifare(t_hydra_console *con);
void hydranfc_scan_vicinity(t_hydra_console *con);
-void hydranfc_sniff_14443A(t_hydra_console *con);
-void hydranfc_sniff_14443A_dbg(t_hydra_console *con);
-void hydranfc_sniff_14443AB_raw(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, bool sniff_trace_uart1);
+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);
Oops, something went wrong.

0 comments on commit 3ee41cc

Please sign in to comment.