Exemple #1
0
void prot_login_send_info( struct qqclient* qq )
{
    static uchar unknown5[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,
                               0x00,0x00,0x00
                              };
    static uchar unknown6[] = {0xE9,0xC4,0xD6,0x5C,0x4D,0x9D,
                               0xA0,0x17,0xE5,0x24,0x6B,0x55,0x57,0xD3,0xAB,0xF1
                              };
    static uchar unknown7[] = {0xCB,0x8D,0xA4,0xE2,0x61,0xC2,
                               0xDD,0x27,0x39,0xEC,0x8A,0xCA,0xA6,0x98,0xF8,0x9B
                              };

    qqpacket* p = packetmgr_new_send( qq, QQ_CMD_LOGIN_SEND_INFO );
    if( !p ) return;
    bytebuffer *buf = p->buf;
    //prepare sth.
    randkey( unknown6 );
    randkey( unknown7 );

    put_word( buf, 0x0001 );
    put_data( buf, qq->data.version_spec, sizeof(qq->data.version_spec) );
    put_int( buf, qq->data.login_info_unknown2 );
    put_int( buf, qq->server_time );
    put_int( buf, qq->client_ip );
    put_int( buf, 00000000 );
    put_word( buf, qq->data.login_info_large.len );
    put_data( buf, qq->data.login_info_large.data, qq->data.login_info_large.len );
    buf->pos += 35;
    put_data( buf, qq->data.exe_hash, sizeof(qq->data.exe_hash) );
    put_byte( buf, rand2() );	//unknown important byte
    put_byte( buf, qq->mode );
    put_data( buf, unknown5, sizeof(unknown5) );
    put_data( buf, qq->data.server_data, sizeof(qq->data.server_data) );
    put_data( buf, qq->data.locale, sizeof(qq->data.locale) );
    buf->pos += 16; //16 zeros
    put_word( buf, qq->data.token_c.len );
    put_data( buf, qq->data.token_c.data, qq->data.token_c.len );
    put_int( buf, 0x00000007 );
    put_int( buf, 0x00000000 );
    put_int( buf, 0x08041801 );
    put_byte( buf, 0x40 );	//length of the following
    put_byte( buf, 0x01 );
    put_int( buf, rand2()  );
//	put_int( buf, 0x0741E9748  );
    put_word( buf, sizeof(unknown6) );
    put_data( buf, unknown6, sizeof(unknown6) );
    put_data( buf, unknown5, sizeof(unknown5) );
    put_data( buf, qq->data.server_data, sizeof(qq->data.server_data) );
    put_byte( buf, 0x02 );
    put_int( buf, rand2()  );
//	put_int( buf, 0x8BED382E  );
    put_word( buf, sizeof(unknown7) );
    put_data( buf, unknown7, sizeof(unknown7) );
    buf->pos += 249;	//all zeros
    memcpy( p->key, qq->data.login_info_key1, sizeof(qq->data.login_info_key1) );
    post_packet( qq, p, RANDOM_KEY );
}
Exemple #2
0
void test_db(int n)
{
    char *dir = Option.dir;
    struct db db;
    u64 key;
    struct lump val;
    u64 i;
    int rc;

    if (1) set_cleanup(cleanup);
    create_db(dir);
    db = open_db(dir);
    for (i = 0; i < n; i++) {
        key = randkey();
        if (0) val = randlump();
        if (1) val = key2lump(key);
        //printf("%lld %*s %zd\n", key, val.size, (char *)val.d, strlen(val.d));
        insert_db(&db, key, val);
    }
    if (1)
        for (i = 0; i < n + 1; i++) {
            rc = next_log(db.r);
            if (rc == DONE)
                break;
            //printf("%lld %s\n", key_log(db.r), (char *)val_log(db.r).d);
        }
    if (1) merge_db(&db);
    close_db(&db);
    destroy_db(dir);
}
Exemple #3
0
int main(void)
{
    size_t max = 100;
    size_t n = 20;
    char buf[strsiz];
    size_t i;
    st_t st = st_init(max);

    for (i = 0; i < n; i++) {
        item_t t = newitem(randkey(), randstr(buf, strsiz));
        st_insert(st, t);
    }

    st_sort(st, print);
    printf("\nThe item with key 11 is: ");
    print(st_search(st, 11));
    printf("\nThe 4th smallest key is: ");
    print(st_select(st, 4));
    st_delete(st, st_search(st, 11));
    printf("\n delete the item with key 11.\n");
    st_sort(st, print);

    /* delete all item */
    while (!st_empty(st)) {
        item_t x = st_select(st, 0);
        printf("delete item: ");
        print(x);
        st_delete(st, st_select(st, 0));
    }

    st_finalize(&st);
    return 0;
}
Exemple #4
0
void prot_login_touch_with_info( struct qqclient* qq, uchar* server_data, uchar len )
{
    qqpacket* p = packetmgr_new_send( qq, QQ_CMD_TOUCH );
    if( !p ) return;
    bytebuffer *buf = p->buf;
    restore_version_data( qq );
    randkey( p->key );
    memcpy( qq->data.server_data, server_data, MIN(len,sizeof(qq->data.server_data)) );
    put_word( buf, 0x0001 );
    put_data( buf, qq->data.locale, sizeof(qq->data.locale) );
    put_data( buf, qq->data.version_spec, sizeof(qq->data.version_spec) );
    put_data( buf, server_data, sizeof(qq->data.server_data) );
    post_packet( qq, p, RANDOM_KEY );
}
Exemple #5
0
void test_bag(int num_recs)
{
    u64 key;
    struct lump val;
    struct bag *bag;
    u64 i;

    bag = new_bag(10);
    for (i = 0; i < num_recs; i++) {
        key = randkey();
        if (0) val = randlump();
        if (1) val = key2lump(key);
        //printf("%lld %*s\n", key, val.size, (char *)val.d);
        stuff_bag(bag, key, val);
    }
    sort_bag(bag);
    pr_bag(bag);
    free_bag(bag);
}
Exemple #6
0
void prot_login_verify( struct qqclient* qq )
{
    qqpacket* p = packetmgr_new_send( qq, QQ_CMD_LOGIN_VERIFY );
    if( !p ) return;
    bytebuffer *buf = p->buf;
    bytebuffer *verify_data;
    NEW( verify_data, sizeof(bytebuffer) );
    if( !verify_data ) {
        packetmgr_del_packet( &qq->packetmgr, p );
        return;
    }
    verify_data->size = PACKET_SIZE;
    put_int( verify_data, rand2() );	//random??
    put_word( verify_data, 0x0001 );
    put_int( verify_data, qq->number );
    put_data( verify_data, qq->data.version_spec, sizeof(qq->data.version_spec) );
    put_byte( verify_data, 00 );
    put_word( verify_data, 00 );	//0x0001 什么来的?
    put_data( verify_data, qq->md5_pass1, 16 );
    put_int( verify_data, qq->server_time );
    verify_data->pos += 13;
    put_int( verify_data, qq->server_ip );
    put_int( verify_data, 0 );
    put_int( verify_data, 0 );
    put_word( verify_data, 0x0010 );
    put_data( verify_data, qq->data.verify_key1, 0x10 );
    put_data( verify_data, qq->data.verify_key2, 0x10 );
    //
    put_word( buf, 0x00CA );	//sub cmd??
    put_word( buf, 0x0001 );
    put_data( buf, qq->data.locale, sizeof(qq->data.locale) );
    put_data( buf, qq->data.version_spec, sizeof(qq->data.version_spec) );
    put_word( buf, qq->data.token_c.len );
    put_data( buf, qq->data.token_c.data, qq->data.token_c.len );
    if( verify_data->pos != 104 ) {
        DBG("wrong pos!!!");
    }

    int out_len = 120;
    uchar encrypted[120+10];
    qqencrypt( verify_data->data, verify_data->pos, qq->md5_pass2, encrypted, &out_len );
    put_word( buf, out_len );
    put_data( buf, encrypted, out_len );

    put_word( buf, 0x0000 );
    put_word( buf, 0x018B );
    put_byte( buf, 0x2E );	//length of the following info
    static uchar unknown6[] = {0xE9,0xC4,0xD6,0x5C,0x4D,0x9D,
                               0xA0,0x17,0xE5,0x24,0x6B,0x55,0x57,0xD3,0xAB,0xF1
                              };
    static uchar unknown7[] = {0xCB,0x8D,0xA4,0xE2,0x61,0xC2,
                               0xDD,0x27,0x39,0xEC,0x8A,0xCA,0xA6,0x98,0xF8,0x9B
                              };
    randkey( unknown6 );
    randkey( unknown7 );
    put_byte( buf, 0x01 );
    put_int( buf, rand2()  );
//	put_int( buf, 0x0741E9748  );
    put_word( buf, sizeof(unknown6) );
    put_data( buf, unknown6, sizeof(unknown6) );
    put_byte( buf, 0x02 );
    put_int( buf, rand2()  );
//	put_int( buf, 0x8BED382E  );
    put_word( buf, sizeof(unknown7) );
    put_data( buf, unknown7, sizeof(unknown7) );
    buf->pos += 0x015C;	//395 zeros?  348

    DEL( verify_data );
    post_packet( qq, p, RANDOM_KEY );
}