nfc-relay: Capture ctrl-c for quitting cleanly the relay attack application.
This commit is contained in:
parent
e5d685a23d
commit
d4d5c5495e
1 changed files with 16 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <nfc.h>
|
||||
|
||||
|
@ -39,6 +40,14 @@ static byte_t abtTagRxPar[MAX_FRAME_LEN];
|
|||
static size_t szTagRxBits;
|
||||
static dev_info* pdiReader;
|
||||
static dev_info* pdiTag;
|
||||
static bool quitting=false;
|
||||
|
||||
void intr_hdlr(void)
|
||||
{
|
||||
printf("\nQuitting...\n");
|
||||
quitting=true;
|
||||
return;
|
||||
}
|
||||
|
||||
void print_usage(char* argv[])
|
||||
{
|
||||
|
@ -68,6 +77,12 @@ int main(int argc,char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
signal(SIGINT, (void (__cdecl*)(int)) intr_hdlr);
|
||||
#else
|
||||
signal(SIGINT, (void (*)()) intr_hdlr);
|
||||
#endif
|
||||
|
||||
// Try to open the NFC emulator device
|
||||
pdiTag = nfc_connect(NULL);
|
||||
if (pdiTag == INVALID_DEVICE_INFO)
|
||||
|
@ -102,7 +117,7 @@ int main(int argc,char* argv[])
|
|||
nfc_configure(pdiReader,DCO_ACCEPT_INVALID_FRAMES,true);
|
||||
printf("[+] Done, relaying frames now!\n\n");
|
||||
|
||||
while(true)
|
||||
while(!quitting)
|
||||
{
|
||||
// Test if we received a frame from the reader
|
||||
if (nfc_target_receive_bits(pdiTag,abtReaderRx,&szReaderRxBits,abtReaderRxPar))
|
||||
|
|
Loading…
Add table
Reference in a new issue