nfc-relay: Capture ctrl-c for quitting cleanly the relay attack application.

This commit is contained in:
Romuald Conty 2009-11-20 16:06:51 +00:00
parent e5d685a23d
commit d4d5c5495e

View file

@ -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))