Created
October 26, 2012 22:54
-
-
Save dweeber/3962033 to your computer and use it in GitHub Desktop.
Phone Home Script
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 | |
###################################################################### | |
# Phonehome script to obtain IP of home router | |
# | |
# Call with wget from your internal machine | |
# with the command: | |
# wget -t 10 http://yourwebsite/phonehome.php?c=1234&cmd=1 -O /dev/null | |
# | |
###################################################################### | |
$SY = array(); | |
$SY['CODE'] = " 1234"; // Change to be your code | |
$SY['IPADDR'] = $_SERVER['REMOTE_ADDR']; | |
$SY['PCODE'] = 0; // Code found | |
$SY['PCMD'] = 0; // Cmd Found 0 = read 1 = (write) | |
$SY['FILE'] = 'phonehome.dat'; | |
###################################################################### | |
// Get the code if passed | |
if ( isset($_GET['c']) ) { | |
$SY['PCODE'] = intval ($_GET['c']); | |
} | |
if ( isset($_GET['cmd']) ) { | |
$SY['PCMD'] = intval($_GET['cmd']); | |
} | |
// Compare code we got with what it should be | |
if ($SY['PCODE'] == $SY['CODE'] ) { | |
// If cmd = 0 write address we found | |
if ($SY['PCMD'] == 0 ) { | |
$readval = file($SY['FILE']); | |
echo 'Recorded IP is: ' . $readval[0] . '<br/>'; | |
} else { | |
$FP = fopen($SY['FILE'], "w"); | |
if ($FP) { | |
fwrite($FP,$SY['IPADDR']); | |
fclose($FP); | |
} | |
echo 'Got it!<br/>'; | |
} | |
} else { | |
echo 'ERROR, Wrong Access Codes<br/>'; | |
} | |
###################################################################### | |
# END OF MODULE | |
###################################################################### |
Corrected wget command with cmd=1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Initial version.