Created
September 30, 2025 01:47
-
-
Save zhanglianxin/b59b88cbf8d8ceb853b7a3669536c420 to your computer and use it in GitHub Desktop.
Open a temporary SSH port on the HiWiFi/Gee router (tested and effective on HiWiFi/Gee HC5861)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| ## Open a temporary SSH port on the HiWiFi/Gee router | |
| ## Tested and effective on HiWiFi/Gee HC5861 (aka HiWiFi 3) | |
| // http://www.4006024680.com/local-ssh/ | |
| $contents = file_get_contents('http://192.168.199.1/local-ssh/api?method=get'); | |
| $result = json_decode($contents, true); | |
| $local_token = $result['data']; | |
| // http://www.4006024680.com/cgi-bin/turbo/proxy/router_info | |
| $contents = file_get_contents('http://192.168.199.1/cgi-bin/turbo/proxy/router_info'); | |
| $result = json_decode($contents, true); | |
| $uuid = $result['data']['uuid']; | |
| // decode local_token | |
| $decoded = explode(",", base64_decode($local_token), 4); | |
| $mac = $decoded[0]; | |
| $t = $decoded[2]; | |
| // build message | |
| $message = $mac . ",ssh," . (intval($t) + 1); | |
| // generate key | |
| $key = sha1($uuid, true); | |
| // generate cloud_token | |
| function get_hmac_sha1($message, $key) | |
| { | |
| $result = hash_hmac('sha1', $message, $key, true); | |
| return base64_encode($result); | |
| } | |
| $cloud_token = get_hmac_sha1($message, $key); | |
| echo 'cloud_token: ' . $cloud_token . PHP_EOL; | |
| $queryStr = http_build_query([ | |
| 'method' => 'valid', | |
| 'data' => $cloud_token, | |
| ]); | |
| $contents = file_get_contents('http://192.168.199.1/local-ssh/api?' . $queryStr); | |
| $result = json_decode($contents, true); | |
| // It should be "Success: ssh port is 22" | |
| echo $result['data'] . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment