Well DOTNOT finnaly put a fork in my MySQL server saying that they no longer support the old Authenication of Mysql323... So for the last three day's I've been trying to recreate the protocol. Anyone know what the hell I'm doing wrong here???
(Wireshark Pictures of Test Box posted)
The password going in is "password" salted with a string of "^^>X%I%w"
then the outcome that get's sent to the server is "f8d3172d3ca4b7e92b103fd20cb711527b4ed6f1"
I just can't for the life of me get it to work :(
I think this is the correct OpenSource code. http://i7.askmonty.org/lcov/5.3-test...rd.c.gcov.html
The difference between how the server sends and stores the password is separated by this line.. where it does the SHA_Input twice in a row with the first result as a seed maybe?.... What is the C# equivalent?
Any help will be GREATLY appreciated! (Code attached)
SRC:http://i7.askmonty.org/lcov/5.3-test...rd.c.gcov.html
(Wireshark Pictures of Test Box posted)
The password going in is "password" salted with a string of "^^>X%I%w"
then the outcome that get's sent to the server is "f8d3172d3ca4b7e92b103fd20cb711527b4ed6f1"
I just can't for the life of me get it to work :(
I think this is the correct OpenSource code. http://i7.askmonty.org/lcov/5.3-test...rd.c.gcov.html
The difference between how the server sends and stores the password is separated by this line.. where it does the SHA_Input twice in a row with the first result as a seed maybe?.... What is the C# equivalent?
Any help will be GREATLY appreciated! (Code attached)
SRC:http://i7.askmonty.org/lcov/5.3-test...rd.c.gcov.html
Code:
void
439 : scramble(char *to, const char *message, const char *password)
440 0 : {
441 : SHA1_CONTEXT sha1_context;
442 : uint8 hash_stage1[SHA1_HASH_SIZE];
443 : uint8 hash_stage2[SHA1_HASH_SIZE];
444 :
445 0 : mysql_sha1_reset(&sha1_context);
446 : /* stage 1: hash password */
447 0 : mysql_sha1_input(&sha1_context, (uint8 *) password, (uint) strlen(password));
448 0 : mysql_sha1_result(&sha1_context, hash_stage1);
449 : /* stage 2: hash stage 1; note that hash_stage2 is stored in the database */
450 0 : mysql_sha1_reset(&sha1_context);
451 0 : mysql_sha1_input(&sha1_context, hash_stage1, SHA1_HASH_SIZE);
452 0 : mysql_sha1_result(&sha1_context, hash_stage2);
453 : /* create crypt string as sha1(message, hash_stage2) */;
454 0 : mysql_sha1_reset(&sha1_context);
455 0 : mysql_sha1_input(&sha1_context, (const uint8 *) message, SCRAMBLE_LENGTH);
456 0 : mysql_sha1_input(&sha1_context, hash_stage2, SHA1_HASH_SIZE);
457 : /* xor allows 'from' and 'to' overlap: lets take advantage of it */
458 0 : mysql_sha1_result(&sha1_context, (uint8 *) to);
459 0 : my_crypt(to, (const uchar *) to, hash_stage1, SCRAMBLE_LENGTH);
460 0 : }
461 :
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text;
using System.Security.Cryptography;
using System.Diagnostics;
using System.Globalization;
namespace CSharpeMySQL
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
handshake();
Debug.WriteLine(GenerateMySQLHash("password"));
Debug.WriteLine(mysql_old_password("password"));
Debug.WriteLine(EncryptPassword("password", "^^>X%I%w", false));
Debug.WriteLine(EncryptPassword("password", "^^>X%I%w", true));
Debug.WriteLine(EncryptPassword(mysql_old_password("password"), "^^>X%I%w", true));
Debug.WriteLine(EncryptPassword(mysql_old_password("password"), "^^>X%I%w", false));
Debug.WriteLine(EncryptPassword(mysql_old_password("password"), "^^>X%I%wLT@%7%RMm\\c^", true));
Debug.WriteLine(EncryptPassword(mysql_old_password("password"), "^^>X%I%wLT@%7%RMm\\c^", false));
Debug.WriteLine(EncryptPassword(GenerateMySQLHash("password"), "^^>X%I%w", true));
Debug.WriteLine(EncryptPassword(GenerateMySQLHash("password"), "^^>X%I%w", false));
Debug.WriteLine(EncryptPassword(GenerateMySQLHash("password"), "^^>X%I%wLT@%7%RMm\\c^", true));
Debug.WriteLine(EncryptPassword(GenerateMySQLHash("password"), "^^>X%I%wLT@%7%RMm\\c^", false));
SHATwice("password");
SHATwice(GenerateMySQLHash("password"));
SHATwice(mysql_old_password("password"));
int[] Salt = getSaltFromPassword("f8d3172d3ca4b7e92b103fd20cb711527b4ed6f1");
Debug.WriteLine(Get410Password(SHATwice("password"), System.Text.ASCIIEncoding.ASCII.GetBytes("^^>X%I%w")));
Debug.WriteLine(Get410Password(SHATwice("password"), System.Text.ASCIIEncoding.ASCII.GetBytes("^^>X%I%wLT@%7%RMm\\c^")));
}
/*
SERVER: scramble_buffer=create_random_string()
send(scramble_buffer)
CLIENT: recv(scramble_buffer)
hash_stage1=sha1("password")
hash_stage2=sha1(hash_stage1)
scrambled_password=xor(hash_stage1, sha1(scramble_buffer, hash_stage2)
send(scrambled_password)
SERVER: recv(scrambled_password)
hash_stage1=xor(scrambled_password, sha1(scramble_buffer,hash_stage2))
candidate_hash2=sha1(hash_stage1)
check(candidate_hash2==hash_stage2)
*/
private static string handshake()
{
byte[] Stage1 = SHAOnceByte(mysql_old_password("password"));
string Stage2 = SHATwice(mysql_old_password("password"));
string Seed = "^^>X%I%wLT@%7%RMm\\c^";
byte[] BSeed = System.Text.ASCIIEncoding.ASCII.GetBytes("^^>X%I%wLT@%7%RMm\\c^");
//byte[] shake1 = Get411Password(Stage2, Seed);
//byte[] shake2 = Get410Password(Stage2, BSeed);
byte[] shake3 = GetOld410Password(Stage2, BSeed);
byte[] scrambled_password = new byte[20];
//XorScramble(Stage1, 0, scrambled_password, 0, shake2, 20);
//byte[] buffer2 = new byte[20];
//XorScramble(shake2, 0, buffer2, 0, Stage1, 20);
return Seed;
}
....