[GH-ISSUE #1] дешифровщик строки впн под пхп #1

Open
opened 2026-10-13 21:08:22 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @zak20090 on GitHub (Oct 23, 2024).
Original GitHub issue: https://github.com/amnezia-vpn/config-decoder/issues/1

как переписать дешифровщик строки впн под пхп?
`
// Step 1: Remove the "vpn://" prefix
$data = str_replace("vpn://", "", $input);
echo "Step 1: Data after removing 'vpn://':\n";
echo $data . "\n\n";

// Step 2: Base64 decode the data (convert URL-safe Base64 to standard Base64)
$data = str_replace(['-', '_'], ['+', '/'], $data); // Convert Base64 URL encoding to standard Base64

//$data = str_replace(['-', '_'], ['+', '/'], $input);

// Step 2: Add padding if necessary
$mod4 = strlen($data) % 4;
if ($mod4) {
$data .= str_repeat('=', 4 - $mod4);
}
$decodedData = base64_decode($data, true);

if ($decodedData === false) {
echo "Step 2: Error - Base64 decoding failed.\n";
exit;
} else {
echo "Step 2: Base64 decoded data:\n";
echo $decodedData . "\n\n"; // Output as hex to visualize raw data
}

// Step 3: Attempt to uncompress the decoded data
$uncompressedData = @gzdeflate($decodedData);`
на step 3 выдает false

Originally created by @zak20090 on GitHub (Oct 23, 2024). Original GitHub issue: https://github.com/amnezia-vpn/config-decoder/issues/1 как переписать дешифровщик строки впн под пхп? ` // Step 1: Remove the "vpn://" prefix $data = str_replace("vpn://", "", $input); echo "Step 1: Data after removing 'vpn://':\n"; echo $data . "\n\n"; // Step 2: Base64 decode the data (convert URL-safe Base64 to standard Base64) $data = str_replace(['-', '_'], ['+', '/'], $data); // Convert Base64 URL encoding to standard Base64 //$data = str_replace(['-', '_'], ['+', '/'], $input); // Step 2: Add padding if necessary $mod4 = strlen($data) % 4; if ($mod4) { $data .= str_repeat('=', 4 - $mod4); } $decodedData = base64_decode($data, true); if ($decodedData === false) { echo "Step 2: Error - Base64 decoding failed.\n"; exit; } else { echo "Step 2: Base64 decoded data:\n"; echo $decodedData . "\n\n"; // Output as hex to visualize raw data } // Step 3: Attempt to uncompress the decoded data $uncompressedData = @gzdeflate($decodedData);` на step 3 выдает false
Author
Owner

@Darlez commented on GitHub (Nov 2, 2024):

Нужно удалить первые четыре байта $decodedData https://forum.qt.io/topic/123304/uncompressing-data-python-which-is-compressed-using-qt-quncompress-function/2

На питоне код выглядит так:

import base64
import zlib
coded_string = "xxx"
data = base64.urlsafe_b64decode(coded_string.encode('utf-8'))
data = data[4:]
r = zlib.decompress(data, 15 + 32) 
print(r)
<!-- gh-comment-id:2452782085 --> @Darlez commented on GitHub (Nov 2, 2024): Нужно удалить первые четыре байта $decodedData https://forum.qt.io/topic/123304/uncompressing-data-python-which-is-compressed-using-qt-quncompress-function/2 На питоне код выглядит так: ``` import base64 import zlib coded_string = "xxx" data = base64.urlsafe_b64decode(coded_string.encode('utf-8')) data = data[4:] r = zlib.decompress(data, 15 + 32) print(r) ```
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/config-decoder#1
No description provided.