@@ -97,12 +97,6 @@ enum EMisc
|
||||
*/
|
||||
};
|
||||
|
||||
enum EMatrixCard
|
||||
{
|
||||
MATRIX_CODE_MAX_LEN = 192,
|
||||
MATRIX_ANSWER_MAX_LEN = 8,
|
||||
};
|
||||
|
||||
enum EWearPositions
|
||||
{
|
||||
WEAR_BODY, // 0
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "item.h"
|
||||
#include "item_manager.h"
|
||||
#include "p2p.h"
|
||||
#include "matrix_card.h"
|
||||
#include "log.h"
|
||||
#include "login_data.h"
|
||||
#include "locale_service.h"
|
||||
@@ -225,34 +224,6 @@ void DBManager::LoginPrepare(LPDESC d, uint32_t * pdwClientKey, int * paiPremium
|
||||
|
||||
InsertLoginData(pkLD);
|
||||
|
||||
if (*d->GetMatrixCode())
|
||||
{
|
||||
unsigned long rows = 0, cols = 0;
|
||||
MatrixCardRndCoordinate(rows, cols);
|
||||
|
||||
d->SetMatrixCardRowsAndColumns(rows, cols);
|
||||
|
||||
TPacketGCMatrixCard pm;
|
||||
|
||||
pm.bHeader = HEADER_GC_MATRIX_CARD;
|
||||
pm.dwRows = rows;
|
||||
pm.dwCols = cols;
|
||||
|
||||
d->Packet(&pm, sizeof(TPacketGCMatrixCard));
|
||||
|
||||
sys_log(0, "MATRIX_QUERY: %s %c%d %c%d %c%d %c%d %s",
|
||||
r.login,
|
||||
MATRIX_CARD_ROW(rows, 0) + 'A',
|
||||
MATRIX_CARD_COL(cols, 0) + 1,
|
||||
MATRIX_CARD_ROW(rows, 1) + 'A',
|
||||
MATRIX_CARD_COL(cols, 1) + 1,
|
||||
MATRIX_CARD_ROW(rows, 2) + 'A',
|
||||
MATRIX_CARD_COL(cols, 2) + 1,
|
||||
MATRIX_CARD_ROW(rows, 3) + 'A',
|
||||
MATRIX_CARD_COL(cols, 3) + 1,
|
||||
d->GetMatrixCode());
|
||||
}
|
||||
|
||||
SendAuthLogin(d);
|
||||
}
|
||||
|
||||
@@ -291,7 +262,6 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
|
||||
// PASSWORD('%s'), password, securitycode, social_id, id, status
|
||||
char szEncrytPassword[45 + 1];
|
||||
char szPassword[45 + 1];
|
||||
char szMatrixCode[MATRIX_CODE_MAX_LEN + 1];
|
||||
char szSocialID[SOCIAL_ID_MAX_LEN + 1];
|
||||
char szStatus[ACCOUNT_STATUS_MAX_LEN + 1];
|
||||
DWORD dwID = 0;
|
||||
@@ -314,16 +284,6 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
|
||||
|
||||
strlcpy(szPassword, row[col++], sizeof(szPassword));
|
||||
|
||||
if (!row[col])
|
||||
{
|
||||
*szMatrixCode = '\0';
|
||||
col++;
|
||||
}
|
||||
else
|
||||
{
|
||||
strlcpy(szMatrixCode, row[col++], sizeof(szMatrixCode));
|
||||
}
|
||||
|
||||
if (!row[col])
|
||||
{
|
||||
sys_err("error column %d", col);
|
||||
@@ -451,8 +411,6 @@ void DBManager::AnalyzeReturnQuery(SQLMsg * pMsg)
|
||||
strlcpy(r.social_id, szSocialID, sizeof(r.social_id));
|
||||
DESC_MANAGER::instance().ConnectAccount(r.login, d);
|
||||
|
||||
d->SetMatrixCode(szMatrixCode);
|
||||
|
||||
LoginPrepare(d, pinfo->adwClientKey, aiPremiumTimes);
|
||||
M2_DELETE(pinfo);
|
||||
|
||||
|
||||
@@ -78,9 +78,6 @@ void DESC::Initialize()
|
||||
|
||||
m_SequenceGenerator.seed(SEQUENCE_SEED);
|
||||
|
||||
m_dwMatrixRows = m_dwMatrixCols = 0;
|
||||
m_bMatrixTryCount = 0;
|
||||
|
||||
m_pkLoginKey = NULL;
|
||||
m_dwLoginKey = 0;
|
||||
m_dwPanamaKey = 0;
|
||||
@@ -975,30 +972,6 @@ void DESC::SendLoginSuccessPacket()
|
||||
// //printf("STATE_CHECK PACKET PROCESSED.\n");
|
||||
//}
|
||||
|
||||
void DESC::SetMatrixCardRowsAndColumns(unsigned long rows, unsigned long cols)
|
||||
{
|
||||
m_dwMatrixRows = rows;
|
||||
m_dwMatrixCols = cols;
|
||||
}
|
||||
|
||||
unsigned long DESC::GetMatrixRows()
|
||||
{
|
||||
return m_dwMatrixRows;
|
||||
}
|
||||
|
||||
unsigned long DESC::GetMatrixCols()
|
||||
{
|
||||
return m_dwMatrixCols;
|
||||
}
|
||||
|
||||
bool DESC::CheckMatrixTryCount()
|
||||
{
|
||||
if (++m_bMatrixTryCount >= 3)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DESC::SetLoginKey(DWORD dwKey)
|
||||
{
|
||||
m_dwLoginKey = dwKey;
|
||||
|
||||
@@ -159,14 +159,6 @@ class DESC
|
||||
void SendLoginSuccessPacket();
|
||||
//void SendServerStatePacket(int nIndex);
|
||||
|
||||
void SetMatrixCode(const char * c_psz) { m_stMatrixCode = c_psz; }
|
||||
const char * GetMatrixCode() { return m_stMatrixCode.c_str(); }
|
||||
|
||||
void SetMatrixCardRowsAndColumns(unsigned long rows, unsigned long cols);
|
||||
unsigned long GetMatrixRows();
|
||||
unsigned long GetMatrixCols();
|
||||
bool CheckMatrixTryCount();
|
||||
|
||||
void SetPanamaKey(DWORD dwKey) {m_dwPanamaKey = dwKey;}
|
||||
DWORD GetPanamaKey() const { return m_dwPanamaKey; }
|
||||
|
||||
@@ -235,10 +227,6 @@ class DESC
|
||||
|
||||
pcg32 m_SequenceGenerator;
|
||||
|
||||
DWORD m_dwMatrixRows;
|
||||
DWORD m_dwMatrixCols;
|
||||
BYTE m_bMatrixTryCount;
|
||||
|
||||
CLoginKey * m_pkLoginKey;
|
||||
DWORD m_dwLoginKey;
|
||||
DWORD m_dwPanamaKey;
|
||||
@@ -249,7 +237,6 @@ class DESC
|
||||
bool m_bHackCRCQuery;
|
||||
|
||||
std::string m_stClientVersion;
|
||||
std::string m_stMatrixCode;
|
||||
|
||||
std::string m_Login;
|
||||
int m_outtime;
|
||||
@@ -271,16 +258,7 @@ class DESC
|
||||
public:
|
||||
LPEVENT m_pkDisconnectEvent;
|
||||
|
||||
protected:
|
||||
std::string m_stMatrixCardID;
|
||||
std::string m_stMatrixQuiz;
|
||||
|
||||
public:
|
||||
void SetMatrixCardID( const char * szCardID ) { m_stMatrixCardID = szCardID;}
|
||||
const char * GetMatrixCardID() { return m_stMatrixCardID.c_str();}
|
||||
void SetMatrixQuiz( const char * szCode ) { m_stMatrixCode = szCode; }
|
||||
const char * GetMatrixQuiz() { return m_stMatrixCode.c_str(); }
|
||||
|
||||
void SetLogin( const std::string & login ) { m_Login = login; }
|
||||
void SetLogin( const char * login ) { m_Login = login; }
|
||||
const std::string& GetLogin() { return m_Login; }
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "desc_client.h"
|
||||
#include "desc_manager.h"
|
||||
#include "protocol.h"
|
||||
#include "matrix_card.h"
|
||||
#include "locale_service.h"
|
||||
#include "db.h"
|
||||
|
||||
@@ -169,7 +168,7 @@ void CInputAuth::Login(LPDESC d, const char * c_pData)
|
||||
sys_log(0, "ChannelServiceLogin [%s]", szLogin);
|
||||
|
||||
DBManager::instance().ReturnQuery(QID_AUTH_LOGIN, dwKey, p,
|
||||
"SELECT '%s',password,securitycode,social_id,id,status,availDt - NOW() > 0,"
|
||||
"SELECT '%s',password,social_id,id,status,availDt - NOW() > 0,"
|
||||
"UNIX_TIMESTAMP(silver_expire),"
|
||||
"UNIX_TIMESTAMP(gold_expire),"
|
||||
"UNIX_TIMESTAMP(safebox_expire),"
|
||||
@@ -186,7 +185,7 @@ void CInputAuth::Login(LPDESC d, const char * c_pData)
|
||||
else
|
||||
{
|
||||
DBManager::instance().ReturnQuery(QID_AUTH_LOGIN, dwKey, p,
|
||||
"SELECT PASSWORD('%s'),password,securitycode,social_id,id,status,availDt - NOW() > 0,"
|
||||
"SELECT PASSWORD('%s'),password,social_id,id,status,availDt - NOW() > 0,"
|
||||
"UNIX_TIMESTAMP(silver_expire),"
|
||||
"UNIX_TIMESTAMP(gold_expire),"
|
||||
"UNIX_TIMESTAMP(safebox_expire),"
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
//#define __MATRIX_MAIN_ENABLE__ // define 되어 있으면 main 함수가 포함된다. Unit test 시에 사용
|
||||
#ifndef __MATRIX_MAIN_ENABLE__
|
||||
#include "stdafx.h"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define thecore_random random
|
||||
#define sys_err printf
|
||||
#define sys_log printf
|
||||
|
||||
#endif
|
||||
|
||||
#include "matrix_card.h"
|
||||
|
||||
#define ROW(rows, i) ((rows >> ((4 - i - 1) * 8)) & 0x000000FF)
|
||||
#define COL(cols, i) ((cols >> ((4 - i - 1) * 8)) & 0x000000FF)
|
||||
|
||||
const static int MAX_ROWS = 6;
|
||||
const static int MAX_COLS = 8;
|
||||
const static unsigned int MAX_LENS = (MAX_ROWS * MAX_COLS * 2);
|
||||
const static unsigned int MAX_LENE = (MAX_LENS * 2);
|
||||
const static int ASLENGTH = 8;
|
||||
|
||||
bool EncodeMatrix(const char* szsrc, const char* szpwd, char* lpdes, const unsigned int usize)
|
||||
{
|
||||
int nlen = strlen(szsrc);
|
||||
int i;
|
||||
|
||||
if (strlen(szsrc) != MAX_LENS || strlen(szpwd) != MAX_LENS || lpdes == NULL || usize < (MAX_LENE + 1))
|
||||
return false;
|
||||
|
||||
memset(lpdes, 0, usize);
|
||||
|
||||
for (i = 0; i < nlen; i++)
|
||||
{
|
||||
char sc = szsrc[i];
|
||||
char pc = szpwd[i];
|
||||
char dc = sc ^ pc;
|
||||
char szhex[3];
|
||||
snprintf(szhex, sizeof(szhex), "%02X", dc);
|
||||
strlcat(lpdes, szhex, usize);
|
||||
}
|
||||
|
||||
return (i == nlen) ? true : false;
|
||||
}
|
||||
|
||||
bool DecodeMatrix(const char* szsrc, const char* szpwd, char* lpdes, const unsigned int usize)
|
||||
{
|
||||
int nlen = strlen(szpwd);
|
||||
int i;
|
||||
|
||||
if (strlen(szsrc) != MAX_LENE || strlen(szpwd) != MAX_LENS || lpdes == NULL || usize < (MAX_LENS + 1))
|
||||
return false;
|
||||
|
||||
memset(lpdes, 0, usize);
|
||||
|
||||
char szhex[] = { "0123456789ABCDEF" };
|
||||
|
||||
for (i = 0; i < nlen; i++)
|
||||
{
|
||||
char sc1 = szsrc[i*2];
|
||||
char sc2 = szsrc[i*2+1];
|
||||
char pc = szpwd[i];
|
||||
char sn1 = (char)(strchr(szhex, sc1) - szhex);
|
||||
char sn2 = (char)(strchr(szhex, sc2) - szhex);
|
||||
char dc = (sn1 * 16 + sn2) ^ pc;
|
||||
lpdes[i] = dc;
|
||||
}
|
||||
|
||||
return (i == nlen) ? true : false;
|
||||
}
|
||||
|
||||
void MatrixCardRndCoordinate(unsigned long & rows, unsigned long & cols)
|
||||
{
|
||||
for (unsigned long i = 0; i < (ASLENGTH >> 1); i++)
|
||||
{
|
||||
rows |= ((thecore_random() % MAX_ROWS) & 0x000000FF) << ((4 - i - 1) * 8);
|
||||
cols |= ((thecore_random() % MAX_COLS) & 0x000000FF) << ((4 - i - 1) * 8);
|
||||
}
|
||||
}
|
||||
|
||||
bool ChkCoordinate(const unsigned long rows, const unsigned long cols, const char* matrix, const char* answer)
|
||||
{
|
||||
unsigned int max_lens = strlen(matrix);
|
||||
int answer_lens = strlen(answer);
|
||||
|
||||
if (max_lens != MAX_LENS || answer_lens != ASLENGTH)
|
||||
{
|
||||
sys_err("MATRIX_CARD: length error matrix %d answer %d", max_lens, answer_lens);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool fResult = true;
|
||||
|
||||
unsigned short * pmatrix = (unsigned short *)matrix;
|
||||
unsigned short * panswer = (unsigned short *)answer;
|
||||
|
||||
for (unsigned long i = 0; i < (ASLENGTH >> 1); i++)
|
||||
{
|
||||
if (*(pmatrix + (ROW(rows, i) * MAX_COLS + COL(cols, i))) != *(panswer + i))
|
||||
{
|
||||
fResult = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return fResult;
|
||||
}
|
||||
|
||||
bool MatrixCardCheck(const char * src, const char * answer, unsigned long rows, unsigned cols)
|
||||
{
|
||||
const char * szpasswd = "xEwx3Lb5fH2mnPaMh215cHTbCrFCSmh9yQ3FrybwPnD89QkNX4UTA8UdH41LnU4P94UnaeXDTk17dY5DLaSDPAwvEpMUNTxV";
|
||||
|
||||
char decode_result[MAX_LENS+1];
|
||||
DecodeMatrix(src, szpasswd, decode_result, sizeof(decode_result));
|
||||
|
||||
sys_log(0, "MatrixCardCheck %c%d %c%d %c%d %c%d answer %s",
|
||||
MATRIX_CARD_ROW(rows, 0) + 'A',
|
||||
MATRIX_CARD_COL(cols, 0) + 1,
|
||||
MATRIX_CARD_ROW(rows, 1) + 'A',
|
||||
MATRIX_CARD_COL(cols, 1) + 1,
|
||||
MATRIX_CARD_ROW(rows, 2) + 'A',
|
||||
MATRIX_CARD_COL(cols, 2) + 1,
|
||||
MATRIX_CARD_ROW(rows, 3) + 'A',
|
||||
MATRIX_CARD_COL(cols, 3) + 1,
|
||||
answer);
|
||||
|
||||
return ChkCoordinate(rows, cols, decode_result, answer);
|
||||
}
|
||||
|
||||
#ifdef __MATRIX_MAIN_ENABLE__
|
||||
|
||||
void GetRightAnswer(const unsigned long rows, const unsigned long cols, const char* matrix, char* answer, const unsigned int nsize)
|
||||
{
|
||||
if (strlen(matrix) != MAX_LENS || answer == NULL || nsize < (ASLENGTH + 1))
|
||||
return;
|
||||
|
||||
unsigned short * pmatrix = (unsigned short *)matrix;
|
||||
unsigned short * panswer = (unsigned short *)answer;
|
||||
|
||||
memset(answer, 0, nsize);
|
||||
|
||||
for (unsigned long i = 0; i < (ASLENGTH >> 1); i++)
|
||||
{
|
||||
char sztemp[3] = { 0, 0, 0 };
|
||||
memcpy(sztemp, (char*)(pmatrix + (ROW(rows, i) * MAX_COLS + COL(cols, i))), 2);
|
||||
strlcat(answer, sztemp, nsize);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
srandomdev();
|
||||
|
||||
char* szmatrix = "9Vnppuvv6D8uDmKV9Lbn3ntav6Y86tbMLre7w3DmFc4mTNYEm2UtrppuC9LX6yhYShYTSTCLNC1GwCEV717hTaVYCftMK2xS";
|
||||
char* szpasswd = "xEwx3Lb5fH2mnPaMh215cHTbCrFCSmh9yQ3FrybwPnD89QkNX4UTA8UdH41LnU4P94UnaeXDTk17dY5DLaSDPAwvEpMUNTxV";
|
||||
|
||||
// matrix encode and decode test
|
||||
char encode_result[MAX_LENE + 1], decode_result[MAX_LENS+1];
|
||||
EncodeMatrix(szmatrix, szpasswd, encode_result, sizeof(encode_result));
|
||||
printf("Encode result: %s\r\n", encode_result);
|
||||
|
||||
DecodeMatrix(encode_result, szpasswd, decode_result, sizeof(decode_result));
|
||||
printf("Decode result: %s\r\n", decode_result);
|
||||
|
||||
// matrix rand password test
|
||||
unsigned long rand_rows = 0, rand_cols = 0;
|
||||
MatrixCardRndCoordinate(rand_rows, rand_cols); // get rand position of matrix
|
||||
|
||||
// display rand position
|
||||
printf("%c%d %c%d %c%d %c%d\r\n",
|
||||
ROW(rand_rows, 0) + 'A', COL(rand_cols, 0) + 1, \
|
||||
ROW(rand_rows, 1) + 'A', COL(rand_cols, 1) + 1, \
|
||||
ROW(rand_rows, 2) + 'A', COL(rand_cols, 2) + 1, \
|
||||
ROW(rand_rows, 3) + 'A', COL(rand_cols, 3) + 1);
|
||||
|
||||
char answer[9];
|
||||
GetRightAnswer(rand_rows, rand_cols, szmatrix, answer, sizeof(answer)); // get right answer for test, release not need.
|
||||
printf("Answer: %s\r\n", answer);
|
||||
|
||||
bool f = ChkCoordinate(rand_rows, rand_cols, szmatrix, answer); // check answer
|
||||
printf("Result: %s\n", (f) ? "true" : "false");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,10 +0,0 @@
|
||||
#ifndef __INC_DB_MATRIXCARD_H__
|
||||
#define __INC_DB_MATRIXCARD_H__
|
||||
|
||||
extern bool MatrixCardCheck(const char * src, const char * answer, unsigned long rows, unsigned cols);
|
||||
extern void MatrixCardRndCoordinate(unsigned long & rows, unsigned long & cols);
|
||||
|
||||
#define MATRIX_CARD_ROW(rows, i) ((rows >> ((4 - i - 1) * 8)) & 0x000000FF)
|
||||
#define MATRIX_CARD_COL(cols, i) ((cols >> ((4 - i - 1) * 8)) & 0x000000FF)
|
||||
|
||||
#endif
|
||||
@@ -92,7 +92,6 @@ enum
|
||||
// END_OF_SCRIPT_SELECT_ITEM
|
||||
|
||||
// HEADER_CG_ROULETTE = 200,
|
||||
// HEADER_CG_RUNUP_MATRIX_ANSWER = 201,
|
||||
|
||||
//NOTE : 이런 개XXX 정말 이거 Packet설계한 사람은 누구냐. 이렇게 코딩하고 밥이 넘어가나.
|
||||
//enum을 별도로 구별을 하던가. 아님 namepsace로 구별을 하던가..
|
||||
@@ -227,7 +226,6 @@ enum
|
||||
|
||||
HEADER_GC_NPC_POSITION = 115,
|
||||
|
||||
HEADER_GC_MATRIX_CARD = 116,
|
||||
HEADER_GC_LOGIN_KEY = 118,
|
||||
HEADER_GC_REFINE_INFORMATION = 119,
|
||||
HEADER_GC_CHANNEL = 121,
|
||||
@@ -536,19 +534,6 @@ typedef struct command_login3
|
||||
uint32_t adwClientKey[4];
|
||||
} TPacketCGLogin3;
|
||||
|
||||
typedef struct command_matrix_card
|
||||
{
|
||||
uint8_t bHeader;
|
||||
char szAnswer[MATRIX_ANSWER_MAX_LEN + 1];
|
||||
} TPacketCGMatrixCard;
|
||||
|
||||
typedef struct packet_matrix_card
|
||||
{
|
||||
uint8_t bHeader;
|
||||
uint32_t dwRows;
|
||||
uint32_t dwCols;
|
||||
} TPacketGCMatrixCard;
|
||||
|
||||
typedef struct packet_login_key
|
||||
{
|
||||
uint8_t bHeader;
|
||||
@@ -2100,25 +2085,6 @@ typedef struct packet_damage_info
|
||||
int32_t damage;
|
||||
} TPacketGCDamageInfo;
|
||||
|
||||
enum
|
||||
{
|
||||
RUNUP_MATRIX_ANSWER_MAX_LEN = 4,
|
||||
RUNUP_MATRIX_QUIZ_MAX_LEN = 8 ,
|
||||
|
||||
};
|
||||
|
||||
typedef struct packet_runup_matrix_quiz
|
||||
{
|
||||
uint8_t bHeader;
|
||||
char szQuiz[RUNUP_MATRIX_QUIZ_MAX_LEN + 1];
|
||||
} TPacketGCRunupMatrixQuiz;
|
||||
|
||||
typedef struct command_runup_matrix_answer
|
||||
{
|
||||
uint8_t bHeader;
|
||||
char szAnswer[RUNUP_MATRIX_ANSWER_MAX_LEN + 1];
|
||||
} TPacketCGRunupMatrixAnswer;
|
||||
|
||||
typedef struct tag_GGSiege
|
||||
{
|
||||
uint8_t bHeader;
|
||||
|
||||
Reference in New Issue
Block a user