Пример #1
0
function start($aspid = false)
{
    $unix = new unix();
    $sock = new sockets();
    $Masterbin = $unix->find_program("ufdbgclient");
    if (!is_file($Masterbin)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, ufdbgclient not installed\n";
        }
        return false;
    }
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return true;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $sock = new sockets();
    $EnableUfdbGuard = intval($sock->EnableUfdbGuard());
    $SquidUFDBUrgency = intval($sock->GET_INFO("SquidUFDBUrgency"));
    if ($SquidUFDBUrgency == 1) {
        $EnableUfdbGuard = 0;
    }
    if ($EnableUfdbGuard == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Not Enabled\n";
        }
        return false;
    }
    $pids = GetAllPids();
    if (count($pids) > 0) {
        while (list($pid, $none) = each($pids)) {
            $ttl = $unix->PROCESS_TTL($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, already running PID {$pid} since {$ttl}Mn\n";
            }
        }
        return true;
    }
    if (IsInSquid()) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Hooked chock proxy\n";
        }
        squid_admin_mysql(1, "Reload proxy service to run Web filtering clients.", null, __FILE__, __LINE__);
        $squidbin = $unix->LOCATE_SQUID_BIN();
        system("{$squidbin} -f /etc/squid3/squid.conf -k reconfigure");
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Not Hooked! Hook proxy\n";
        }
        EnableClient();
    }
    for ($i = 1; $i < 8; $i++) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Waiting {$i}/5\n";
        }
        sleep(1);
        $pids = GetAllPids();
        if (count($pids) > 0) {
            break;
        }
    }
    $pids = GetAllPids();
    if (count($pids) > 0) {
        while (list($pid, $none) = each($pids)) {
            $ttl = $unix->PROCESS_TTL($pid);
            $fty[] = "Success PID {$pid} since {$ttl}Mn";
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid} since {$ttl}Mn\n";
            }
        }
        squid_admin_mysql(2, "Succes {starting_web_filtering} Client service from the proxy{$GLOBALS["ADPLUS"]}", @implode("\n", $fty), __FILE__, __LINE__);
        return true;
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Failed\n";
        }
    }
}
Пример #2
0
function start($aspid = false)
{
    $unix = new unix();
    $sock = new sockets();
    $Masterbin = $unix->find_program("ufdbgclient");
    if (!is_file($Masterbin)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, ufdbgclient not installed\n";
        }
        return false;
    }
    if (!$aspid) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return true;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $sock = new sockets();
    $EnableUfdbGuard = $sock->EnableUfdbGuard();
    if ($EnableUfdbGuard == 0) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Not Enabled\n";
        }
        return false;
    }
    $pids = GetAllPids();
    if (count($pids) > 0) {
        while (list($pid, $none) = each($pids)) {
            $ttl = $unix->PROCESS_TTL($pid);
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, already running PID {$pid} since {$ttl}Mn\n";
            }
        }
        return true;
    }
    if (IsInSquid()) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Hooked chock proxy\n";
        }
        shell_exec("/etc/init.d/squid reload --script=" . basename(__FILE__));
    } else {
        EnableClient();
    }
    for ($i = 1; $i < 8; $i++) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Waiting {$i}/5\n";
        }
        sleep(1);
        $pids = GetAllPids();
        if (count($pids) > 0) {
            break;
        }
    }
    $pids = GetAllPids();
    if (count($pids) > 0) {
        while (list($pid, $none) = each($pids)) {
            $ttl = $unix->PROCESS_TTL($pid);
            $fty[] = "Success PID {$pid} since {$ttl}Mn";
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Success PID {$pid} since {$ttl}Mn\n";
            }
        }
        squid_admin_mysql(2, "Succes starting Web Filtering Client service from the proxy{$GLOBALS["ADPLUS"]}", @implode("\n", $fty), __FILE__, __LINE__);
        return true;
    } else {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Failed\n";
        }
    }
}
Пример #3
0
function stop($nopid = false)
{
    $users = new usersMenus();
    $unix = new unix();
    if (!$users->ETTERCAP_INSTALLED) {
        echo "ArpSpoofing.........: [STOP]: Ettercap, not installed...\n";
        return;
    }
    $kill = $unix->find_program("kill");
    if (!$nopid) {
        $me = basename(__FILE__);
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
        $pid = $unix->get_pid_from_file($pidfile);
        if ($unix->process_exists($pid, $me)) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            echo "ArpSpoofing.........: [START]: Ettercap, Already start instance executed PID {$pid} since {$time}Mn...\n";
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    $pids = GetAllPids();
    if (count($pids) == 0) {
        echo "ArpSpoofing.........: [STOP]: Ettercap, no instance in memory\n";
        return;
    }
    while (list($pid, $ruleid) = each($pids)) {
        echo "ArpSpoofing.........: [STOP]: stopping smoothly pid {$pid} for rule {$ruleid}\n";
        unix_system_HUP($pid);
        unix_system_kill($pid);
    }
    for ($i = 0; $i < 10; $i++) {
        $pids = GetAllPids();
        while (list($pid, $ruleid) = each($pids)) {
            if (!$unix->process_exists($pid)) {
                echo "ArpSpoofing.........: [STOP]: pid {$pid} for rule {$ruleid} stopped...\n";
                unset($pids[$pid]);
                continue;
            }
            echo "ArpSpoofing.........: [STOP]: pid {$pid} for rule {$ruleid} still alive...\n";
        }
        if (count($pids) == 0) {
            break;
        }
        sleep(1);
    }
    $pids = GetAllPids();
    if (count($pids) > 0) {
        reset($pids);
        while (list($pid, $ruleid) = each($pids)) {
            echo "ArpSpoofing.........: [STOP]: pid {$pid} for rule {$ruleid} force stopping...\n";
            unix_system_kill_force($pid);
        }
    }
    $pids = GetAllPids();
    if (count($pids) > 0) {
        reset($pids);
        while (list($pid, $ruleid) = each($pids)) {
            echo "ArpSpoofing.........: [STOP]: pid {$pid} for rule {$ruleid} failed stopping...\n";
        }
    }
    echo "ArpSpoofing.........: [STOP]: DONE...\n";
}