0
我試圖對第三方項目使用的base64編碼的應用程序進行逆向工程,所以我可以創建一個自定義用戶界面。我的方法在一個例子中取得了成功,但在其他例子中似乎並未達到標準(少數字符不太正確)。數據庫中base64解碼/編碼不一致
AQAAAAAAGQBec2lwOigwMjAxMjM0NTZbMC05XSspQC4qFwBzaXA6MDIwMTIyMTEzQDEyNy4wLjAuMQAA
^^實際base64編碼
AQAAAAAAEABec2lwOigwMjAxMjM0NTZbMC05XSspQC4qEwBzaXA6MDIwMTIyMTEzQDEyNy4wLjAuMQoA
,以配合PHP方法
由於控制字符^^最好的嘗試,我實現了一些JSON編碼,以使其更容易識別正在用於變量的字符串。該字符串與本例匹配,但base64編碼結果與預期的實際不同。
$actualfour = 'AQAAAAAAGQBec2lwOigwMjAxMjM0NTZbMC05XSspQC4qFwBzaXA6MDIwMTIyMTEzQDEyNy4wLjAuMQAA';
echo "".$actualfour;
echo "<br />";
$four = chr(01);
$four .= chr(00);
$four .= chr(00);
$four .= chr(00);
$four .= chr(00);
$four .= chr(00);
$four .= chr(16);
$four .= chr(00);
$four .= '^sip:(02[0-9]+)@.*';
$four .= chr(19);
$four .= chr(00);
$four .= 'sip:[email protected]
'.chr(00);
$jsonfour = json_encode($four);
echo "unencoded: ".$jsonfour;
echo "<br />";
$encodefour = base64_encode($four);
echo "".$encodefour;
echo "<br />";
$jsonencodefour = json_encode(base64_decode($encodefour));
echo "encoded: ".$jsonencodefour;
echo "<br />";
if ($encodefour != $actualfour) { echo "FAIL"; } else { echo "PASS"; }
^^代碼方法
AQAAAAAAGQBec2lwOigwMjAxMjM0NTZbMC05XSspQC4qFwBzaXA6MDIwMTIyMTEzQDEyNy4wLjAuMQAA
unencoded: "\u0001\u0000\u0000\u0000\u0000\u0000\u0010\u0000^sip:(02[0-9]+)@.*\u0013\u0000sip:[email protected]\n\u0000"
AQAAAAAAEABec2lwOigwMjAxMjM0NTZbMC05XSspQC4qEwBzaXA6MDIwMTIyMTEzQDEyNy4wLjAuMQoA
encoded: "\u0001\u0000\u0000\u0000\u0000\u0000\u0010\u0000^sip:(02[0-9]+)@.*\u0013\u0000sip:[email protected]\n\u0000"
FAIL
^^輸出