Sign in to follow this  
Followers 0
Alek

Need help to decrypt something.

2 posts in this topic

#1 ·  Posted (edited)

i have bin trying to create some MySQL udfs using TCP only, it turned out to be somewhat easy but if server has a password the client needs to send it

encrypted, the username and everything else is not encrypted (thats why it was somewhat easy :D ).

so i need help creating the correct encrypt UDF for the password.

when you connect to the server you get a message, im guessing this is where the encrypt/decrypt key is because 1 part of the packet is different every time i connect.

first time i connect

35 00 00 00 0A 35 2E 30 2E 35 31 61 00 A9 00 00 00 2F 72 73 6D 46 55 57 37 00 2C A2 08 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 4B 52 3B 6F 3E 26 41 56 6A 37 6F 4C 00

second time i connect

35 00 00 00 0A 35 2E 30 2E 35 31 61 00 AA 00 00 00 59 21 36 2C 76 34 3D 76 00 2C A2 08 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5D 4F 53 31 3D 7B 76 5F 57 76 6C 3A 00

35 is the size of the packet

00 00 00 i think its where i should split the packet

35 2E 30 2E 35 61 (5.0.51 here) is the version of the server)

the rest i don't know :s

Im guessing the last numbers after all the 00 00 is the key but im not 100% sure

here is the passwords i get from the first connection

70 F5 38 B8 CD BA 68 57 5D A7 EA 8F 7D E7 BD 1E CE 09 5D 59

the password on the second connection.

2A 90 D4 C1 D0 A1 BE 8A 3B 28 A1 A5 CE 28 A1 C5 70 1A 08 15

they should both say "test".

my script for looking at the connection between server and client (HeidiSQL).

#include <GUIConstants.au3>

TCPStartup()

Global $Listen_Socket   ;This is the input/Output form wow client socket
Global $Connect_Socket  ;This is the Input/Output from wow server socket
Global $Recv_Socket = -1
Global $Send_Socket = -1
Global $Old_Socket = 0

;make the client use port 3305 insted of the default 3306
;this will make the client connect to this script insted.
;this script will then redirect the stream to the real server
;and log the data from the server to the client
;and data from the client to the server
Do
    $Listen_Socket = TCPListen('127.0.0.1',3305)
Until $Listen_Socket > 0


;connect to the server
Do
    $Connect_Socket = TCPConnect('127.0.0.1',3306)
Until $Connect_Socket > 0

ConsoleWrite('Server is up' & @CRLF)

$Form1 = GUICreate("", 625, 328, 193, 125)
$Tab1 = GUICtrlCreateTab(5, 5, 614, 313)
$TabSheet1 = GUICtrlCreateTabItem("Input")
$Edit1 = GUICtrlCreateEdit("", 10, 35, 601, 276)
$TabSheet2 = GUICtrlCreateTabItem("Output")
$Edit2 = GUICtrlCreateEdit("", 10, 35, 601, 276)

ConsoleWrite('Sending Data to server' & @CRLF)

Do
    $Recv_Socket = TCPAccept($Listen_Socket)
Until $Recv_Socket <> -1
ConsoleWrite('Connection to Client Sucssesfull' & @CRLF)


GUISetState(@SW_SHOW)

While 1
    $Recv = TCPRecv($Recv_Socket,2048)
    If $Recv <> '' Then
        TCPSend($Connect_Socket,$Recv)
        ConsoleWrite('Geting Data from Client' & @CRLF)
        FileWrite(@ScriptDir & '\Data_Log.txt','To Server:' & @TAB & @TAB & $Recv & @CRLF & @TAB & @TAB & @TAB & @TAB & _Decrypt($Recv) & @CRLF)
        GUICtrlSetData($Edit1,String($Recv) & @CRLF,1)
    EndIf
    
    $Recv2 = TCPRecv($Connect_Socket,2048)
    If $Recv2 <> '' Then
        TCPSend($Recv_Socket,$Recv2)
        ConsoleWrite('Geting Data from Server' & @CRLF)
        FileWrite(@ScriptDir & '\Data_Log.txt','From Server:' & @TAB & $Recv2 & @CRLF & @TAB & @TAB & @TAB & @TAB & _Decrypt($Recv2) & @CRLF)
        GUICtrlSetData($Edit2,String($Recv2) & @CRLF,1)
    EndIf
WEnd

Func OnAutoitExit()
    TCPCloseSocket($Listen_Socket)
    TCPCloseSocket($Connect_Socket)
    TCPShutdown()
    Exit
EndFunc

Func _Decrypt($s_String)
    Return StringReplace(BinaryToString($s_String),Chr(0),'00')
EndFunc
Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You should start with this: http://www.redferni.uklinux.net/mysql/MySQL-Protocol.html, It's a bit old, but should help at the Beginning.

Look here too: http://forge.mysql.com/wiki/MySQL_Internal...Server_Protocol

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0