Skip to forum content

You are not logged in. Please login or register.


forums.pvpgn.pro → [EN] The Source Code → [HELP] modify the command /chpass

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 9

1

Topic: [HELP] modify the command /chpass

please help me to modify the command /chpass
I like to modify /chpass be <command> <current password> <new password>

I've tried to copy my _handle_chpass_command be _handle_pass_command and setting up the command with /pass

and as this is the setting that I created,

download my attachment (handle_pass.txt)

but always fails and the source of failure is here,

if (!std::strcmp(command,account_get_pass(account))) {

so, I really expect help from experts to correct and justify my modifications

--
sorry my bad speak and
THX A LOT

2

Re: [HELP] modify the command /chpass

account_get_pass() returns a passhash string, but you're comparing it with a raw password.

// to lower input pass
for (i=0; i<std::strlen(command); i++)
    if (std::isupper((int)command[i])) command[i] = std::tolower((int)command[i]);

// get passhash from input pass     
t_hash inputpasshash;
bnet_hash(&inputpasshash, std::strlen(command), command);

// compare (input and user's) passhash strings
if (!std::strcmp( hash_get_str(inputpasshash), account_get_pass(account) )) 
{
...
Do not ask for support in PM.

3 (edited by kucc 18.08.2011 11:12)

Re: [HELP] modify the command /chpass

GanyoyGen wrote:

please help me to modify the command /chpass
I like to modify /chpass be <command> <current password> <new password>

I've tried to copy my _handle_chpass_command be _handle_pass_command and setting up the command with /pass

and as this is the setting that I created,

download my attachment (handle_pass.txt)

but always fails and the source of failure is here,

if (!std::strcmp(command,account_get_pass(account))) {

so, I really expect help from experts to correct and justify my modifications

--
sorry my bad speak and
THX A LOT

Лови, пару проверок  на левые символы в новом пароле добавь по любасику.

4

Re: [HELP] modify the command /chpass

cool, finally I've successfully modified chpass alone.  cool  cool

concepts that I apply is, save one argument that has been hashed into the temporary data in the user file, and will compare with the old password ..

nah its this detail ..

static int _handle_chpass_command(t_connection * c, char const *text)
{
  unsigned int i,j;
  t_account  * account;
  t_account  * temp;
  t_hash       passhash;
  char *command;
  char         arg1[256];
  char         arg2[256];
  char const * username;
  char *       pass;
  
  for (i=0; text[i]!=' ' && text[i]!='\0'; i++);
  for (; text[i]==' '; i++);

  for (j=0; text[i]!=' ' && text[i]!='\0'; i++) /* get username/pass */
    if (j<sizeof(arg1)-1) arg1[j++] = text[i];
  arg1[j] = '\0';

  for (; text[i]==' '; i++); /* skip spaces */
  for (j=0; text[i]!=' ' && text[i]!='\0'; i++)
    if (j<sizeof(arg2)-1) arg2[j++] = text[i];
  arg2[j] = '\0';

  account  = conn_get_account(c);
  username = conn_get_username(c);
  command  = arg1;
  pass     = arg2;

  if (arg2[0]=='\0') {
      message_send_text(c,message_type_info,c,"Change your password.");
      message_send_text(c,message_type_info,c,"Type: /chpass <currentpassword> <newpassword>");
      return 0;
  }
  else {

      for (i=0; i<std::strlen(command); i++)
          if (std::isupper((int)command[i])) command[i] = std::tolower((int)command[i]);
      
      bnet_hash(&passhash,std::strlen(command),command);

      account_set_strattr(account,"TEMP\\Curpass",hash_get_str(passhash));
  }

  snprintf(msgtemp, sizeof(msgtemp), "Trying to change password for account \"%.64s\" to \"%.128s\"",username,pass);
  message_send_text(c,message_type_info,c,msgtemp);

  if (!std::strcmp(account_get_strattr(account,"TEMP\\Curpass"),account_get_pass(account))) {
      if (std::strlen(pass) > MAX_USERPASS_LEN) {
          snprintf(msgtemp, sizeof(msgtemp), "Maximum password length allowed is %d",MAX_USERPASS_LEN);
          message_send_text(c,message_type_error,c,msgtemp);
          return 0;
      }
  
      for (i=0; i<std::strlen(pass); i++)
          if (std::isupper((int)pass[i])) pass[i] = std::tolower((int)pass[i]);
      
      bnet_hash(&passhash,std::strlen(pass),pass);
      
      if (account_set_pass(account,hash_get_str(passhash))<0) {
          message_send_text(c,message_type_error,c,"Unable to set password.");
          return 0;
      }
  
      if (account_get_auth_admin(account,NULL) == 1 || account_get_auth_operator(account,NULL) == 1) {
          snprintf(msgtemp, sizeof(msgtemp), "Success. Password for account "UID_FORMAT" updated.",account_get_uid(account));
          message_send_text(c,message_type_info,c,msgtemp);
          snprintf(msgtemp, sizeof(msgtemp), "Hash is: %.128s",hash_get_str(passhash));
          message_send_text(c,message_type_info,c,msgtemp);
      } else {
          snprintf(msgtemp, sizeof(msgtemp), "Success. Password for account %.64s updated.",username);
          message_send_text(c,message_type_info,c,msgtemp);
      }
      return 0;
  } else {
      message_send_text(c,message_type_error,c,"Unable to change password. Wrong current password!");
      return 0;
  }

}

and I also had to overcome a mistake if,
/chpass aa bb cc

then the password will be changed only into bb, cc does not include, of course if aa is the old password
cool  cool

I hope this information can be useful and applicable if there is a need  wink  wink

thx...

17 minutes and 58 seconds after:

and this is of screen shoot  cool  cool

http://a1.sphotos.ak.fbcdn.net/hphotos-ak-snc7/308171_1794223550244_1679342460_1306123_1329102_n.jpg

5

Re: [HELP] modify the command /chpass

хз вариант предложенный kucc'ом тоже норм, проверок больше)

6 (edited by Jimmy_Aquarius 20.11.2012 19:00)

Re: [HELP] modify the command /chpass

my #1 question :
if i am admin of the server
how can i change another user's password?

my #2 question :
if i am admin
someone request new password because he forgot his password,
how can i change his password ?
because <current password> <new password>

Please Ganyoygen or HarpyWar or everybody
if can answer this smile

7

Re: [HELP] modify the command /chpass

#1 afair

/chpass username newpass

#2 see #1

8

Re: [HELP] modify the command /chpass

xpeh wrote:

#1 afair

/chpass username newpass

#2 see #1

it doesn't work..
because i use command chpass <old password> <new password>
ex :
My nick : Jimmy_Aquarius
i want to change another user's password, his nick is : Windows
so i type /chpass <Windows> <123456>
PvPGN says : trying to change account Jimmy_Aquarius to 123456
Your current password is wrong.

because pvpgn read that "Windows" is the old password and "123456" is the new password

9

Re: [HELP] modify the command /chpass

It seems, you are using not original PvPGN.

Do not ask for support in PM.

Posts: 9

Pages 1

You must login or register to post a reply

Who now at forum

Currently view post: 0 guests, 0 registered users

forums.pvpgn.pro → [EN] The Source Code → [HELP] modify the command /chpass