1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
/*
Kopete Oscar Protocol
icqlogintask.cpp - Handles logging into to the ICQ service
Copyright (c) 2004 Matt Rogers <[email protected]>
Kopete (c) 2002-2004 by the Kopete developers <[email protected]>
*************************************************************************
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
*************************************************************************
*/
#include "icqlogintask.h"
#include <tqstring.h>
#include <kdebug.h>
#include "transfer.h"
#include "connection.h"
#include "oscarutils.h"
using namespace Oscar;
IcqLoginTask::IcqLoginTask( Task* parent )
: Task( parent )
{
}
IcqLoginTask::~IcqLoginTask()
{
}
bool IcqLoginTask::take( Transfer* transfer )
{
Q_UNUSED( transfer );
return false;
}
bool IcqLoginTask::forMe( Transfer* transfer ) const
{
//there shouldn't be a incoming transfer for this task
Q_UNUSED( transfer );
return false;
}
void IcqLoginTask::onGo()
{
FLAP f = { 0x01, 0, 0 };
DWORD flapVersion = 0x00000001;
Buffer *outbuf = new Buffer();
TQString encodedPassword = encodePassword( client()->password() );
const Oscar::ClientVersion* version = client()->version();
outbuf->addDWord( flapVersion );
outbuf->addTLV( 0x0001, client()->userId().length(), client()->userId().latin1() );
outbuf->addTLV( 0x0002, encodedPassword.length(), encodedPassword.latin1() );
outbuf->addTLV( 0x0003, version->clientString.length(), version->clientString.latin1() );
outbuf->addTLV16( 0x0016, version->clientId );
outbuf->addTLV16( 0x0017, version->major );
outbuf->addTLV16( 0x0018, version->minor );
outbuf->addTLV16( 0x0019, version->point );
outbuf->addTLV16(0x001a, version->build );
outbuf->addDWord( 0x00140004 ); //TLV type 0x0014, length 0x0004
outbuf->addDWord( version->other ); //TLV data for type 0x0014
outbuf->addTLV( 0x000f, version->lang.length(), version->lang.latin1() );
outbuf->addTLV( 0x000e, version->country.length(), version->country.latin1() );
Transfer* ft = createTransfer( f, outbuf );
kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Sending ICQ channel 0x01 login packet" << endl;
send( ft );
emit finished();
}
TQString IcqLoginTask::encodePassword( const TQString& loginPassword )
{
kdDebug(OSCAR_RAW_DEBUG) << k_funcinfo << "Called." << endl;
// TODO: check if latin1 is the right conversion
const char *password = loginPassword.latin1();
unsigned int i = 0;
TQString encodedPassword = TQString();
//encoding table used in ICQ password XOR transformation
unsigned char encoding_table[] =
{
0xf3, 0x26, 0x81, 0xc4,
0x39, 0x86, 0xdb, 0x92,
0x71, 0xa3, 0xb9, 0xe6,
0x53, 0x7a, 0x95, 0x7c
};
for (i = 0; i < 8; i++)
{
if(password[i] == 0)
break; //found a null in the password. don't encode it
encodedPassword.append( password[i] ^ encoding_table[i] );
}
#ifdef OSCAR_PWDEBUG
kdDebug(OSCAR_RAW_DEBUG) << " plaintext pw='" << loginPassword << "', length=" <<
loginPassword.length() << endl;
kdDebug(OSCAR_RAW_DEBUG) << " encoded pw='" << encodedPassword << "', length=" <<
encodedPassword.length() << endl;
#endif
return encodedPassword;
}
#include "icqlogintask.moc"
|