summaryrefslogtreecommitdiff
path: root/protocols/Xfire/src/clientloginpacket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Xfire/src/clientloginpacket.cpp')
-rw-r--r--protocols/Xfire/src/clientloginpacket.cpp164
1 files changed, 83 insertions, 81 deletions
diff --git a/protocols/Xfire/src/clientloginpacket.cpp b/protocols/Xfire/src/clientloginpacket.cpp
index 59ac46fcdd..33e9fd9130 100644
--- a/protocols/Xfire/src/clientloginpacket.cpp
+++ b/protocols/Xfire/src/clientloginpacket.cpp
@@ -28,94 +28,96 @@
#include <iostream>
#include "baseProtocol.h"
-namespace xfirelib {
- using namespace std;
-
- int ClientLoginPacket::getPacketContent(char *packet) {
- int index = 0;
- /*Username*/
-
- index = XFireUtils::addAttributName(packet,index, "name");/*add username attribute*/
- packet[index] = 0x01;
- packet[index+1] = (char)name.length();
- packet[index+2] = 0x00;
- index +=3;
- std::copy(name.begin(),name.end(),packet+index);
- index += name.size();
-
- /*Crypted Password*/
- unsigned char pass[41];
- pass[40] = 0x00;
- cryptPassword(pass);
- index = XFireUtils::addAttributName(packet,index, "password");/*add username attribute*/
- packet[index] = 0x01;
- packet[index+1] = (char)40;
- packet[index+2] = 0x00;
- index += 3;
-
- memcpy(packet+index,pass,40);
- index += 40;
-
- VariableValue val;
- val.setName( "flags" );
- index += val.writeName( packet, index );
- packet[index++] = 0x02;
- packet[index++] = 0x00;
- packet[index++] = 0x00;
- packet[index++] = 0x00;
- packet[index++] = 0x00;
-
- val.setName( "sid" );
- index += val.writeName( packet, index );
- packet[index++] = 0x03;
-
- for(int i=0;i<16;i++)
+using namespace std;
+
+namespace xfirelib
+{
+ int ClientLoginPacket::getPacketContent(char *packet)
{
- packet[index++] = 0x0;
+ int index = 0;
+ /*Username*/
+
+ index = XFireUtils::addAttributName(packet, index, "name");/*add username attribute*/
+ packet[index] = 0x01;
+ packet[index + 1] = (char)name.length();
+ packet[index + 2] = 0x00;
+ index += 3;
+ std::copy(name.begin(), name.end(), packet + index);
+ index += name.size();
+
+ /*Crypted Password*/
+ unsigned char pass[41];
+ pass[40] = 0x00;
+ cryptPassword(pass);
+ index = XFireUtils::addAttributName(packet, index, "password");/*add username attribute*/
+ packet[index] = 0x01;
+ packet[index + 1] = (char)40;
+ packet[index + 2] = 0x00;
+ index += 3;
+
+ memcpy(packet + index, pass, 40);
+ index += 40;
+
+ VariableValue val;
+ val.setName("flags");
+ index += val.writeName(packet, index);
+ packet[index++] = 0x02;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+ packet[index++] = 0x00;
+
+ val.setName("sid");
+ index += val.writeName(packet, index);
+ packet[index++] = 0x03;
+
+ for (int i = 0; i < 16; i++) {
+ packet[index++] = 0x0;
+ }
+
+ length = index;
+ return index;
}
- length = index;
- return index;
- }
-
- int ClientLoginPacket::getPacketAttributeCount() {
- return 3;
- }
-
- void ClientLoginPacket::cryptPassword(unsigned char *crypt){
- std::string total;
- char temp[81];
- CSHA1 sha1;
-
- total = name+password+"UltimateArena";
- hashSha1(total.c_str(),crypt);
- memcpy(temp,crypt,40);
- memcpy(temp+40,salt->getValue(),40);
- temp[80] = 0x00;
-
- hashSha1(temp,crypt);
- }
+ int ClientLoginPacket::getPacketAttributeCount()
+ {
+ return 3;
+ }
+ void ClientLoginPacket::cryptPassword(unsigned char *crypt)
+ {
+ std::string total;
+ char temp[81];
+ CSHA1 sha1;
+ total = name + password + "UltimateArena";
+ hashSha1(total.c_str(), crypt);
+ memcpy(temp, crypt, 40);
+ memcpy(temp + 40, salt->getValue(), 40);
+ temp[80] = 0x00;
-/*give string and you will get the hash*/
-void ClientLoginPacket::hashSha1(const char *string, unsigned char *sha){
+ hashSha1(temp, crypt);
+ }
- char result[41];
- unsigned char temp[1024];
- CSHA1 sha1;
- sha1.Reset();
- sha1.Update((UINT_8 *)string, mir_strlen(string));
- sha1.Final();
- sha1.GetHash(temp);
+ /*give string and you will get the hash*/
+ void ClientLoginPacket::hashSha1(const char *string, unsigned char *sha)
+ {
- result[0] = 0;
- char szTemp[16];
- for(int i = 0 ; i < 20 ; i++) {
- mir_snprintf(szTemp, "%02x", temp[i]);
- mir_strcat(result,szTemp);
+ char result[41];
+ unsigned char temp[1024];
+ CSHA1 sha1;
+ sha1.Reset();
+ sha1.Update((UINT_8 *)string, mir_strlen(string));
+ sha1.Final();
+ sha1.GetHash(temp);
+
+ result[0] = 0;
+ char szTemp[16];
+ for (int i = 0; i < 20; i++) {
+ mir_snprintf(szTemp, "%02x", temp[i]);
+ mir_strcat(result, szTemp);
+ }
+ memcpy(sha, result, 40);
+ sha[40] = 0x00;
}
- memcpy(sha,result,40);
- sha[40] = 0x00;
-}
}