Can not decipher BASE64(AES256()) data from web
Posted: Wed Dec 05, 2012 10:19 am
				
				In general there are two pieces of code:
PHP (http://r0.by/crypt.php):
and PB code:
Why I can not get decrypted text?
			PHP (http://r0.by/crypt.php):
Code: Select all
<?php
    $Pass = "password";
    $Clear = "text_text_text_text_text_text_text_text_text_text_text_text";
    $crypted = fnEncrypt($Clear, $Pass);
    echo $crypted;
    function fnEncrypt($sValue, $sSecretKey)
    {
        return trim(
            base64_encode(
                mcrypt_encrypt(
                    MCRYPT_RIJNDAEL_256,
                    $sSecretKey, $sValue, 
                    MCRYPT_MODE_ECB
                    )
                )
            );
    }
    ?>
Code: Select all
Procedure.s do_request(host.s, page.s="", post_data.s="",  cookie.s="", is_secure.b=#False, user_agent.s="", referer.s="", proxy.s="", timeout.l=1000, redirect.b=#True)
  result.s=""
  If Not proxy="" : access_type.i=3 : Else : access_type.i=1 : EndIf
  open_handle = InternetOpen_(user_agent,access_type,proxy,"",0)
  InternetSetOption_(open_handle, 2,timeout,4)
  If is_secure
    port.i=443
    flag.l=$00800000|$00001000|$00002000|$00080000|$00000100|$04000000
  Else
    port.i=80
    flag.l=$00080000|$00000100|$04000000
  EndIf
  If Not redirect : flag|$00200000 : EndIf
  If Not post_data="" : verb.s="POST" : Else : verb.s="GET" : EndIf
  If page="" : page="/" : EndIf
  If user_agent="" : user_agent="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" : EndIf
  connect_handle = InternetConnect_(open_handle,host,port,"","",3,0,0)
  request_handle = HttpOpenRequest_(connect_handle,verb,page,"",referer,0,flag,0)
  If verb="POST"
    headers.s = "Content-Type: application/x-www-form-urlencoded" +Chr(13)+Chr(10)
    HttpAddRequestHeaders_(request_handle,headers,Len(headers), $80000000|$20000000)
  EndIf
  If Not cookie=""
    headers.s = "Cookie: "+cookie+Chr(13)+Chr(10)
    HttpAddRequestHeaders_(request_handle,headers,Len(headers), $80000000|$20000000)
  EndIf
  send_handle = HttpSendRequest_(request_handle,"",0,post_data,Len(post_data))
  buffer.s = Space(1024)
  Repeat
    InternetReadFile_(request_handle,@buffer,1024,@bytes_read.l)
    result.s + Left(buffer,bytes_read)
    buffer = Space(1024)
  Until bytes_read=0
  InternetCloseHandle_(open_handle)
  InternetCloseHandle_(connect_handle)
  InternetCloseHandle_(request_handle)
  InternetCloseHandle_(send_handle)
  ProcedureReturn result
EndProcedure
aes.s=do_request("r0.by","/crypt.php")
Debug aes
InputString.s = aes
InputSize.l = Len(InputString)
*OutputBuffer = AllocateMemory(InputSize.l)
len = Base64Decoder(@InputString.s, InputSize.l, *OutputBuffer, InputSize.l)
Debug len
*out=AllocateMemory(len)
password.s="password"
AESDecoder(*OutputBuffer, *out, len, @password, 256, 0, #PB_Cipher_ECB)
ShowMemoryViewer(*out,len)