Example #1
0
static  bool
transmit_bits(const uint8_t *pbtTx, const size_t szTxBits)
{
  // Show transmitted command
  printf("Sent bits:     ");
  print_hex_bits(pbtTx, szTxBits);
  // Transmit the bit frame command, we don't use the arbitrary parity feature
  if ((szRxBits = nfc_initiator_transceive_bits(pnd, pbtTx, szTxBits, NULL, abtRx, sizeof(abtRx), NULL)) < 0)
    return false;

  // Show received answer
  printf("Received bits: ");
  print_hex_bits(abtRx, szRxBits);
  // Succesful transfer
  return true;
}
static  bool
transmit_bits (const byte_t * pbtTx, const size_t szTxBits)
{
  // Show transmitted command
  if (!quiet_output) {
    printf ("Sent bits:     ");
    print_hex_bits (pbtTx, szTxBits);
  }
  // Transmit the bit frame command, we don't use the arbitrary parity feature
  if (!nfc_initiator_transceive_bits (pnd, pbtTx, szTxBits, NULL, abtRx, &szRxBits, NULL))
    return false;

  // Show received answer
  if (!quiet_output) {
    printf ("Received bits: ");
    print_hex_bits (abtRx, szRxBits);
  }
  // Succesful transfer
  return true;
}
Example #3
0
bool transmit_bits(const uint8_t *pbtTx, const size_t szTxBits)
{
    //! Show transmitted command
    #ifdef DEBUG_PRINTF
    fprintf(stderr,"Sent bits:     ");
    #endif
    print_hex_bits(pbtTx, szTxBits);
    //! Transmit the bit frame command, we don't use the arbitrary parity feature
    if ((szRxBits = nfc_initiator_transceive_bits(pnd, pbtTx, szTxBits, NULL, abtRx, sizeof(abtRx), NULL)) < 0)
    {
        return false;
    }
    //! Show received answer
    #ifdef DEBUG_PRINTF
    fprintf(stderr,"Received bits: ");
    #endif
    print_hex_bits(abtRx, szRxBits);
    //! Succesful transfer
    return true;
}
Example #4
0
int main(int argc, const char* argv[])
{
    byte* pbtTx = null;
    ui32 uiTxBits;

    // Try to open the NFC reader
    pdi = nfc_connect();

    if (pdi == INVALID_DEVICE_INFO)
    {
        printf("Error connecting NFC second reader\n");
        return 1;
    }

    printf("\n");
    printf("[+] Connected to NFC reader: %s\n",pdi->acName);
    printf("[+] Try to break out the auto-simulation, this requires a second reader!\n");
    printf("[+] To do this, please send any command after the anti-collision\n");
    printf("[+] For example, send a RATS command or use the \"anticol\" tool\n");
    if (!nfc_target_init(pdi,abtRecv,&uiRecvBits))
    {
        printf("Error: Could not come out of auto-simulation, no command was received\n");
        return 1;
    }
    printf("[+] Received initiator command: ");
    print_hex_bits(abtRecv,uiRecvBits);
    printf("[+] Configuring communication\n");
    nfc_configure(pdi,DCO_HANDLE_CRC,false);
    nfc_configure(pdi,DCO_HANDLE_PARITY,true);
    printf("[+] Done, the simulated tag is initialized\n\n");

    while(true)
    {
        // Test if we received a frame
        if (nfc_target_receive_bits(pdi,abtRecv,&uiRecvBits,null))
        {
            // Prepare the command to send back for the anti-collision request
            switch(uiRecvBits)
            {
            case 7: // Request or Wakeup
                pbtTx = abtAtqa;
                uiTxBits = 16;
                // New anti-collsion session started
                printf("\n");
                break;

            case 16: // Select All
                pbtTx = abtUidBcc;
                uiTxBits = 40;
                break;

            case 72: // Select Tag
                pbtTx = abtSak;
                uiTxBits = 24;
                break;

            default: // unknown length?
                uiTxBits = 0;
                break;
            }

            printf("R: ");
            print_hex_bits(abtRecv,uiRecvBits);

            // Test if we know how to respond
            if(uiTxBits)
            {
                // Send and print the command to the screen
                nfc_target_send_bits(pdi,pbtTx,uiTxBits,null);
                printf("T: ");
                print_hex_bits(pbtTx,uiTxBits);
            }
        }
    }

    nfc_disconnect(pdi);
}