Skip to content

Commit

Permalink
HydraNFC add sniff sub commands bin, frame-time and parity (remove de…
Browse files Browse the repository at this point in the history
…bug sub command)
  • Loading branch information
bvernoux committed Oct 13, 2016
1 parent e716907 commit 9e1f30a
Show file tree
Hide file tree
Showing 5 changed files with 350 additions and 161 deletions.
16 changes: 13 additions & 3 deletions hydrabus/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ t_token_dict tl_dict[] = {
{ T_CLONE_MF_ULTRALIGHT, "clone-mf-ul" },
{ T_SNIFF, "sniff" },
{ T_TRACE_UART1, "trace-uart1" },
{ T_FRAME_TIME, "frame-time" },
{ T_BIN, "bin" },
{ T_DIRECT_MODE_0, "dm0" },
{ T_DIRECT_MODE_1, "dm1" },
{ T_GPIO, "gpio" },
Expand Down Expand Up @@ -277,12 +279,20 @@ t_token tokens_mode_nfc_sniff[] = {
.help = "Output realtime sniff trace on UART1([email protected] 8N1)"
},
{
T_DEBUG,
.help = "Enable debug sniff trace (ISO14443A)"
T_BIN,
.help = "Force binary sniff trace(UART1 only)"
},
{
T_RAW,
.help = "Enable raw sniff trace (ISO14443A/B)"
.help = "Enable binary raw sniff trace(ISO14443A/B)(UART1 only)"
},
{
T_PARITY,
.help = "Add parity bit information in binary sniff trace(UART1 only)"
},
{
T_FRAME_TIME,
.help = "Add start/end frame timestamp(in CPU cycles)"
},
{ }
};
Expand Down
2 changes: 2 additions & 0 deletions hydrabus/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ enum {
T_CLONE_MF_ULTRALIGHT,
T_SNIFF,
T_TRACE_UART1,
T_FRAME_TIME,
T_BIN,
T_DIRECT_MODE_0,
T_DIRECT_MODE_1,
T_GPIO,
Expand Down
55 changes: 44 additions & 11 deletions hydranfc/hydranfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ THD_FUNCTION(key_sniff, arg)
}

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

Expand Down Expand Up @@ -862,8 +862,10 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
filename_t sd_file;
int str_offset;
bool sniff_trace_uart1;
bool sniff_debug;
bool sniff_raw;
bool sniff_bin;
bool sniff_frame_time;
bool sniff_parity;

if(p->tokens[token_pos] == T_SD)
{
Expand All @@ -877,8 +879,10 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
extStart(&EXTD1, &extcfg);

sniff_trace_uart1 = FALSE;
sniff_debug = FALSE;
sniff_raw = FALSE;
sniff_bin = FALSE;
sniff_frame_time = FALSE;
sniff_parity = FALSE;
action = 0;
period = 1000;
continuous = FALSE;
Expand Down Expand Up @@ -933,8 +937,16 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
sniff_trace_uart1 = TRUE;
break;

case T_DEBUG:
sniff_debug = TRUE;
case T_FRAME_TIME:
sniff_frame_time = TRUE;
break;

case T_BIN:
sniff_bin = TRUE;
break;

case T_PARITY:
sniff_parity = TRUE;
break;

case T_RAW:
Expand Down Expand Up @@ -998,15 +1010,36 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
break;

case T_SNIFF:
if(sniff_debug)
if(sniff_bin)
{
hydranfc_sniff_14443A_dbg(con, sniff_trace_uart1);
}else if(sniff_raw)
{
hydranfc_sniff_14443AB_raw(con, sniff_trace_uart1);
if(sniff_raw)
{
/* Sniffer Binary RAW UART1 only */
hydranfc_sniff_14443AB_bin_raw(con, sniff_frame_time, sniff_frame_time);
}else
{
/* Sniffer Binary UART1 only */
hydranfc_sniff_14443A_bin(con, sniff_frame_time, sniff_frame_time, sniff_parity);
}
}else
{
hydranfc_sniff_14443A(con, sniff_trace_uart1);
if(sniff_raw)
{
/* Sniffer Binary RAW UART1 only */
hydranfc_sniff_14443AB_bin_raw(con, sniff_frame_time, sniff_frame_time);
}else
{
/* Sniffer ASCII */
if(sniff_trace_uart1)
{
if(sniff_frame_time)
cprintf(con, "frame-time disabled for trace-uart1 in ASCII\r\n");
hydranfc_sniff_14443A(con, FALSE, FALSE, TRUE);
}else
{
hydranfc_sniff_14443A(con, sniff_frame_time, sniff_frame_time, FALSE);
}
}
}
break;

Expand Down
6 changes: 3 additions & 3 deletions hydranfc/hydranfc.h
Original file line number Diff line number Diff line change
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_vicinity(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_sniff_14443A(t_hydra_console *con, bool start_of_frame, bool end_of_frame, bool sniff_trace_uart1);
void hydranfc_sniff_14443A_bin(t_hydra_console *con, bool start_of_frame, bool end_of_frame, bool parity);
void hydranfc_sniff_14443AB_bin_raw(t_hydra_console *con, bool start_of_frame, bool end_of_frame);

void hydranfc_emul_mifare(t_hydra_console *con, uint32_t mifare_uid);

Expand Down
Loading

0 comments on commit 9e1f30a

Please sign in to comment.