当前位置:   article > 正文

mysql 5 可执行漏洞_MySQL暴身份认证漏洞 需升级到5.5.24可修正

mysql 5.0.24a 漏洞

/*

Check that scrambled message corresponds to the password; the function

is used by server to check that recieved reply is authentic.

This function does not check lengths of given strings: message must be

null-terminated, reply and hash_stage2 must be at least SHA1_HASH_SIZE

long (if not, something fishy is going on).

SYNOPSIS

check_scramble()

scramble clients' reply, presumably produced by scramble()

message original random string, previously sent to client

(presumably second argument of scramble()), must be

exactly SCRAMBLE_LENGTH long and NULL-terminated.

hash_stage2 hex2octet-decoded database entry

All params are IN.

RETURN VALUE

0 password is correct

!0 password is invalid

*/

my_bool

check_scramble(const uchar *scramble_arg, const char *message,

const uint8 *hash_stage2)

{

SHA1_CONTEXT sha1_context;

uint8 buf[SHA1_HASH_SIZE];

uint8 hash_stage2_reassured[SHA1_HASH_SIZE];

mysql_sha1_reset(&sha1_context);

/* create key to encrypt scramble */

mysql_sha1_input(&sha1_context, (const uint8 *) message, SCRAMBLE_LENGTH);

mysql_sha1_input(&sha1_context, hash_stage2, SHA1_HASH_SIZE);

mysql_sha1_result(&sha1_context, buf);

/* encrypt scramble */

my_crypt((char *) buf, buf, scramble_arg, SCRAMBLE_LENGTH);

/* now buf supposedly contains hash_stage1: so we can get hash_stage2 */

mysql_sha1_reset(&sha1_context);

mysql_sha1_input(&sha1_context, buf, SHA1_HASH_SIZE);

mysql_sha1_result(&sha1_context, hash_stage2_reassured);

return memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE);

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/987318
推荐阅读
相关标签
  

闽ICP备14008679号