예제 #1
0
// try to find values that correctly transmit all commands to t55x7
// so that a GET_UID command will return a true value
BOOL t55x7_rwd_test(BYTE *pattern)
{
    BYTE gap, one, zero, i, tmp[T55X7_BLOCKSIZE * 2 + 1];
    BOOL found= FALSE;

    // min/max from datasheets
    for(one= 48 ; one <= 63 ; ++one)
        for(zero= 16; zero <= 31 ; ++zero)
            for(gap=  8 ; gap <= 30 ; ++gap)
            {
                if(get_user_abort())
                    return found;
                RFIDlerConfig.RWD_Gap_Period= gap;
                RFIDlerConfig.RWD_One_Period= one;
                RFIDlerConfig.RWD_Zero_Period= zero;
                if(get_tag_uid(tmp))
                {
                    UserMessageNum(" gap: %d", gap);
                    UserMessageNum(" one: %d", one);
                    UserMessageNum(" zero: %d", zero);
                    UserMessage(" UID: %s\r\n", tmp);
                    found= TRUE;
                }
            }
    UserMessage("%s", "\r\n");
    return found;
}
예제 #2
0
파일: q5.c 프로젝트: natashenka/RFIDler
// try to find values that correctly transmit all commands to q5
// to test this properly, q5 should have invalid data in it's data blocks
// so that only a GET_TRACE_DATA command will return a true value
BOOL q5_rwd_test(BYTE *pattern)
{
    BYTE start_gap, gap, one, zero, i, tmp[Q5_BLOCKSIZE + 1];
    BOOL found= FALSE, blank;

    // min/max from datasheets
    for(one= 48 ; one <= 63 ; ++one)
        for(zero= 16; zero <= 31 ; ++zero)
            for(gap=  10 ; gap <= 50 ; ++gap)
                for(start_gap= 11 ; start_gap <= 50 ; ++start_gap)
                {
                    RFIDlerConfig.Manchester= TRUE;
                    blank= TRUE;
                    if(get_user_abort())
                        return found;
                    RFIDlerConfig.RWD_Gap_Period= gap;
                    RFIDlerConfig.RWD_One_Period= one;
                    RFIDlerConfig.RWD_Zero_Period= zero;
                    // reset tag
                    get_tag_uid(tmp);
                    // try to switch off modulation
                    // send command with start gap: reset with sleep time set to start gap, and wake time set to 0 as we transmit the 1st bit immediately
                    // note that we must also subtract standard gap period as it will be added to the front of the first bit by default.
                    rwd_send(Q5_MODULATION_DEFEAT, strlen(Q5_MODULATION_DEFEAT), NO_RESET, BLOCK, RWD_STATE_START_SEND, RFIDlerConfig.FrameClock, start_gap - RFIDlerConfig.RWD_Gap_Period, 0, RFIDlerConfig.RWD_Zero_Period, RFIDlerConfig.RWD_One_Period, RFIDlerConfig.RWD_Gap_Period, RFIDlerConfig.RWD_Wait_Switch_TX_RX);
                    // read a block with no sync & no manchester - will be all '0' if not modulating
                    RFIDlerConfig.Manchester= FALSE;
                    if(read_ask_data(RFIDlerConfig.FrameClock, RFIDlerConfig.DataRate, tmp, RFIDlerConfig.DataBits, RFIDlerConfig.Sync, 0, RFIDlerConfig.Timeout, NO_ONESHOT_READ, HEX) == RFIDlerConfig.DataBits)
                    {
                        for(i= 0 ; i < HEXDIGITS(RFIDlerConfig.DataBits) ; ++i)
                            if(tmp[i] != '0')
                                blank= FALSE;
                        RFIDlerConfig.Manchester= TRUE;
                        if(blank && get_tag_uid(tmp) && q5_read_block(tmp, 0))
                        {
                            UserMessageNum("\r\nFound tag with start_gap %d", start_gap);
                            UserMessageNum(" gap %d", gap);
                            UserMessageNum(" one %d", one);
                            UserMessageNum(" zero %d", zero);
                            found= TRUE;
                        }
                    }
                }
    UserMessage("%s", "\r\n");
    return found;
}
예제 #3
0
파일: uid.c 프로젝트: hhcalder92/RFIDler
BOOL get_interpreted_tag_uid(BYTE *response, BYTE tagtype)
{
        BYTE tmp[MAXUID + 1];

        if(get_tag_uid(tmp))
        {
            if(interpret_uid(response, tmp, tagtype))
                return write_wiegand_uid(response);
        }
        return FALSE;
}
예제 #4
0
파일: q5.c 프로젝트: rgooler/RFIDler
// try to find values that correctly transmit all commands to q5
// to test this properly, q5 should have invalid data in it's data blocks
// so that only a GET_TRACE_DATA command will return a true value
BOOL q5_rwd_test(BYTE *pattern)
{
    BYTE gap, one, zero, tmp[Q5_BLOCKSIZE + 1];
    BOOL found= FALSE, blank;

    // min/max from datasheets
    for(one= 48 ; one <= 63 ; ++one)
        for(zero= 16; zero <= 31 ; ++zero)
            for(gap=  10 ; gap <= 50 ; ++gap)
            {
                RFIDlerConfig.Manchester= TRUE;
                blank= TRUE;
                if(get_user_abort())
                    return found;
                RFIDlerConfig.RWD_Gap_Period= gap;
                RFIDlerConfig.RWD_One_Period= one;
                RFIDlerConfig.RWD_Zero_Period= zero;
                // reset tag
                get_tag_uid(tmp);
                // try to switch off modulation
                rwd_send(Q5_MODULATION_DEFEAT, strlen(Q5_MODULATION_DEFEAT), NO_RESET, BLOCK, RWD_STATE_START_SEND, RFIDlerConfig.FrameClock, RFIDlerConfig.RWD_Gap_Period, 0, RFIDlerConfig.RWD_Zero_Period, RFIDlerConfig.RWD_One_Period, RFIDlerConfig.RWD_Gap_Period, RFIDlerConfig.RWD_Wait_Switch_TX_RX);
                // read a block with no sync & no manchester - will be all '0' if not modulating
                RFIDlerConfig.Manchester= FALSE;
                if(read_ask_data(RFIDlerConfig.FrameClock, RFIDlerConfig.DataRate, tmp, RFIDlerConfig.DataBits, RFIDlerConfig.Sync, 0, RFIDlerConfig.Timeout, NO_ONESHOT_READ, HEX) == RFIDlerConfig.DataBits)
                {
                    if(strcmp(tmp, "0000000000000000") != 0)
                            blank= FALSE;
                    RFIDlerConfig.Manchester= TRUE;
                    if(blank && get_tag_uid(tmp) && q5_read_block(tmp, 0))
                    {
                        UserMessageNum("\r\nFound tag with gap %d", gap);
                        UserMessageNum(" one %d", one);
                        UserMessageNum(" zero %d", zero);
                        found= TRUE;
                    }
                }
            }
    UserMessage("%s", "\r\n");
    return found;
}
예제 #5
0
파일: select.c 프로젝트: coolacid/RFIDler
// select specific tag for read/write operations
BOOL select_tag(BYTE *response, BYTE *uid)
{
    BYTE tmp[MAXUID + 1];

    if(strlen(uid) == 0)
    {
        if(!get_tag_uid(tmp))
            return FALSE;
        uid= tmp;
    }

    switch(RFIDlerConfig.TagType)
    {
        case TAG_TYPE_HITAG1:
                return hitag1_select(response, uid);
            break;

        default:
            return FALSE;
    }
}
예제 #6
0
파일: vtag.c 프로젝트: androdev4u/RFIDler
BOOL vtag_write_to_tag(BYTE *pass)
{
    unsigned int block, config_block_no;
    BYTE tmp[MAXBLOCKSIZE + 1];
    BOOL auth= FALSE;
    StoredConfig tmptag;

    // preserve tag type
    memcpy(&tmptag, &RFIDlerConfig, sizeof(RFIDlerConfig));

    // set real tag to vtag type if not already the same
    if(RFIDlerConfig.TagType != RFIDlerVTag.TagType)
        if(!tag_set(RFIDlerVTag.TagType))
        {
            memcpy(&RFIDlerConfig, &tmptag, sizeof(RFIDlerConfig));
            return FALSE;
        }

    // reset target tag, but don't care if we get UID as it may not be in a valid mode
    get_tag_uid(tmp);

    // re-auth
    if(!tag_login(block, tmp, pass))
        tag_auth(block, tmp, pass);

    // initialise target in default mode
    // get config block number
    if(!config_block_number(&config_block_no, RFIDlerConfig.TagType))
        return FALSE;

    // get default config block data
    tmp[HEXDIGITS(RFIDlerVTag.BlockSize)]= '\0';
    if (!config_block(tmp, RFIDlerConfig.TagType, RFIDlerConfig.TagType))
    {
        memcpy(&RFIDlerConfig, &tmptag, sizeof(RFIDlerConfig));
        return FALSE;
    }

    // write default config
    if(!write_tag(config_block_no, tmp, VERIFY))
    {
        memcpy(&RFIDlerConfig, &tmptag, sizeof(RFIDlerConfig));
        return FALSE;
     }
    
    // reset tag again
    get_tag_uid(tmp);

    // write all VTAG blocks with valid data in them
    // but avoid writing config block until last as tag may stop responding
    tmp[HEXDIGITS(RFIDlerVTag.BlockSize)]= '\0';
    for(block= 0 ; block < RFIDlerVTag.DataBlocks ; ++block)
        if(block != config_block_no && RFIDlerVTag.Data[HEXDIGITS(RFIDlerVTag.BlockSize * block)])
        {
            // try to login/auth in case target tag requires it
            // don't care if we fail
            if(!(auth= tag_login(block, tmp, pass)))
                auth= tag_auth(block, tmp, pass);
            
            memcpy(tmp, &RFIDlerVTag.Data[HEXDIGITS(RFIDlerVTag.BlockSize * block)], HEXDIGITS(RFIDlerVTag.BlockSize));
            UserMessageNum("\r\n%d: ", block);
            UserMessage("%s", tmp);
            // failure allowed as we may be trying to write locked blocks
            if(!write_tag(block, tmp, VERIFY))
            {
                UserMessage("%s", " Failed!");
                if(!auth)
                    UserMessage("%s", " (Auth/Login)");
            }
        }

    // write config block (no verify as some tags stop talking after config change)

    if(!tag_login(block, tmp, pass))
        tag_auth(block, tmp, pass);

    tmp[HEXDIGITS(RFIDlerVTag.BlockSize)]= '\0';
    memcpy(tmp, &RFIDlerVTag.Data[HEXDIGITS(RFIDlerVTag.BlockSize * config_block_no)], HEXDIGITS(RFIDlerVTag.BlockSize));
    UserMessageNum("\r\n\r\n%d: ", config_block_no);
    UserMessage("%s", tmp);
    if(!write_tag(config_block_no, tmp, NO_VERIFY))
    {
        memcpy(&RFIDlerConfig, &tmptag, sizeof(RFIDlerConfig));
        return FALSE;
    }

    memcpy(&RFIDlerConfig, &tmptag, sizeof(RFIDlerConfig));
    return TRUE;
}
예제 #7
0
파일: vtag.c 프로젝트: androdev4u/RFIDler
// copy real tag to vtag or set up emulation
BOOL vtag_copy_from_tag(BYTE *tagtype, BYTE *pass)
{
    BYTE tmp[MAXUID + 1], tag, copy= FALSE, i;
    unsigned int config_block_no, user_block_no;

    // set target tag type
    if (strlen(tagtype) == 0)
    {
        if(RFIDlerVTag.TagType == TAG_TYPE_NONE)
            tag= RFIDlerConfig.TagType;
        else
            tag= RFIDlerVTag.TagType;
    }
    else
        if(!(tag= tag_get_type(tagtype)))
            return FALSE;
    
    // check we've got a tag to copy
    if(!get_tag_uid(tmp))
        return FALSE;

    // set vtag to desired type
    vtag_set_tag_from_type(tag);

    // if tag & vtag are the same, just copy
    if(RFIDlerConfig.TagType == tag)
    {
        RFIDlerVTag.EmulatedTagType= TAG_TYPE_NONE;
        // auth
        if(!tag_login(0, TmpBits, pass))
            tag_auth(0, TmpBits, pass);

        // copy UID
        strcpy(RFIDlerVTag.UID, tmp);
        
        // if no data to copy, we're done.
        if(RFIDlerVTag.DataBlocks == 0)
            return TRUE;

        // copy data blocks
        for(i= 0 ; i < RFIDlerVTag.DataBlocks ; ++i)
        {
            if (!read_tag(RFIDlerVTag.Data + HEXDIGITS(i * RFIDlerVTag.BlockSize), i, i))
                UserMessageNum("%d: (fail)\r\n", i);
            else
                copy= TRUE;
        }
        return copy;
    }

    // otherwise, set up emulation
    RFIDlerVTag.EmulatedTagType= RFIDlerConfig.TagType;
    strcpy(RFIDlerVTag.UID, tmp);

    // get config & user data block numbers
    if(!config_block_number(&config_block_no, tag) || !config_user_block(&user_block_no, tag))
        return FALSE;

    // get & store config block
    if (!config_block(&RFIDlerVTag.Data[HEXDIGITS(RFIDlerVTag.BlockSize * config_block_no)], RFIDlerConfig.TagType, tag))
        return FALSE;

    // copy raw hex UID to data blocks
    memcpy(&RFIDlerVTag.Data[HEXDIGITS(RFIDlerVTag.BlockSize * user_block_no)], RFIDlerVTag.UID, strlen(RFIDlerVTag.UID));

    return TRUE;
}