Created
July 25, 2012 08:20
-
-
Save mwicat/3175069 to your computer and use it in GitHub Desktop.
Cisco PHP phone push
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 | |
| function push2phone($ip, $port, $uri, $uid, $pwd) | |
| { | |
| $b = rand() % 10; | |
| $k = rand() % 10; | |
| $auth = base64_encode($uid.":".$pwd); | |
| $xml = <<<EOD | |
| <CiscoIPPhoneStatus> | |
| <Text>Kadry: $k Bok: $b</Text> | |
| </CiscoIPPhoneStatus> | |
| EOD; | |
| $xml = "XML=".urlencode($xml); | |
| $post = "POST /CGI/Execute HTTP/1.0\r\n"; | |
| $post .= "Host: $ip\r\n"; | |
| $post .= "Authorization: Basic $auth\r\n"; | |
| $post .= "Connection: close\r\n"; | |
| $post .= "Content-Type: application/x-www-form-urlencoded\r\n"; | |
| $post .= "Content-Length: ".strlen($xml)."\r\n\r\n"; | |
| $fp = fsockopen ( $ip, $port, $errno, $errstr, 30); | |
| if(!$fp){ echo "$errstr ($errno)<br>\n"; } | |
| else | |
| { | |
| fputs($fp, $post.$xml); | |
| flush(); | |
| while (!feof($fp)) | |
| { | |
| $response .= fgets($fp, 128); | |
| flush(); | |
| } | |
| } | |
| return $response; | |
| } | |
| $ip = $argv[1]; | |
| $port = $argv[2]; | |
| $uri = "http://your.web.server.here/hello_world.php"; | |
| $uid = "test"; | |
| $pwd = "test"; | |
| echo push2phone($ip, $port, $uri, $uid, $pwd); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment