From d2d734ce0983fbed72e69f555f57f29de04f30b3 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sat, 9 Mar 2013 00:04:28 -0300 Subject: Hercules Renewal'd Pin Code Feature is not, I repeat, NOT complete. the decryption is not fully functional which leads to dial values different from the ones the player used. Credits: lemongrass3110 for the base yommy for the packets LightFighter for the decrypt function (altho its not stable :P) Signed-off-by: shennetsind --- src/login/login.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'src/login/login.c') diff --git a/src/login/login.c b/src/login/login.c index e174672cc..c16cce342 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -559,6 +559,7 @@ int parse_fromchar(int fd) int group_id = 0; uint8 char_slots = 0; char birthdate[10+1] = ""; + char pincode[4+1] = "\0\0\0\0\0"; int account_id = RFIFOL(fd,2); RFIFOSKIP(fd,6); @@ -570,10 +571,13 @@ int parse_fromchar(int fd) expiration_time = acc.expiration_time; group_id = acc.group_id; char_slots = acc.char_slots; + safestrncpy(pincode, acc.pincode, sizeof(pincode)); safestrncpy(birthdate, acc.birthdate, sizeof(birthdate)); + if( strlen(pincode) == 0 ) + memset(pincode,'\0',sizeof(pincode)); } - WFIFOHEAD(fd,63); + WFIFOHEAD(fd,72); WFIFOW(fd,0) = 0x2717; WFIFOL(fd,2) = account_id; safestrncpy((char*)WFIFOP(fd,6), email, 40); @@ -581,7 +585,9 @@ int parse_fromchar(int fd) WFIFOB(fd,50) = (unsigned char)group_id; WFIFOB(fd,51) = char_slots; safestrncpy((char*)WFIFOP(fd,52), birthdate, 10+1); - WFIFOSET(fd,63); + safestrncpy((char*)WFIFOP(fd,63), pincode, 4+1 ); + WFIFOL(fd,68) = acc.pincode_change; + WFIFOSET(fd,72); } break; @@ -907,6 +913,41 @@ int parse_fromchar(int fd) RFIFOSKIP(fd,2); break; + case 0x2738: //Change PIN Code for a account + if( RFIFOREST(fd) < 11 ) + return 0; + else { + struct mmo_account acc; + + if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) { + strncpy( acc.pincode, (char*)RFIFOP(fd,6), 5 ); + acc.pincode_change = time( NULL ); + accounts->save(accounts, &acc); + } + RFIFOSKIP(fd,11); + } + break; + + case 0x2739: // PIN Code was entered wrong too often + if( RFIFOREST(fd) < 6 ) + return 0; + else { + struct mmo_account acc; + + if( accounts->load_num(accounts, &acc, RFIFOL(fd,2) ) ) { + struct online_login_data* ld; + + if( ( ld = (struct online_login_data*)idb_get(online_db,acc.account_id) ) == NULL ) + return 0; + + login_log( host2ip(acc.last_ip), acc.userid, 100, "PIN Code check failed" ); + } + + remove_online_user(acc.account_id); + RFIFOSKIP(fd,6); + } + break; + default: ShowError("parse_fromchar: Unknown packet 0x%x from a char-server! Disconnecting!\n", command); set_eof(fd); @@ -958,6 +999,8 @@ int mmo_auth_new(const char* userid, const char* pass, const char sex, const cha safestrncpy(acc.lastlogin, "0000-00-00 00:00:00", sizeof(acc.lastlogin)); safestrncpy(acc.last_ip, last_ip, sizeof(acc.last_ip)); safestrncpy(acc.birthdate, "0000-00-00", sizeof(acc.birthdate)); + safestrncpy(acc.pincode, "\0", sizeof(acc.pincode)); + acc.pincode_change = 0; acc.char_slots = 0; if( !accounts->create(accounts, &acc) ) -- cgit v1.2.3-60-g2f50