Exemplo n.º 1
0
function main_save_root()
{
    if ($_POST["root_password"] == null) {
        return null;
    }
    $group = new groups();
    $group->BuildOrdinarySambaGroups();
    $tpl = new templates();
    $user = new user();
    if (!$user->CreateModifyRootUSer($_POST["root_password"])) {
        echo $user->ldap_error;
    } else {
        echo $tpl->_ENGINE_parse_body('{success}');
    }
}
Exemplo n.º 2
0
function parseContent($file)
{
    if (!is_file($file)) {
        exit;
    }
    $gp = new groups(null);
    $gp->BuildOrdinarySambaGroups();
    $datas = file_get_contents($file);
    $tbl = explode("\n", $datas);
    while (list($num, $line) = each($tbl)) {
        if (trim($line) == null) {
            continue;
        }
        $computer_name = null;
        $ip = null;
        $line = trim($line);
        if (preg_match("#^Interesting ports on (.+?)\\s+\\((.+?)\\)#", $line, $re)) {
            if (preg_match('#([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)#', $re[2])) {
                $ip = $re[2];
                $computer_name = $re[1];
                compevents("found computer: {$computer_name}/{$ip} (line {$num})");
                $arr[$computer_name]["IP"] = $ip;
                continue;
            }
        }
        if (preg_match("#^Interesting ports on ([0-9\\.]+):#", $line, $re)) {
            $ip = $re[1];
            $computer_name = "{$ip}";
            compevents("found {$computer_name}/{$ip} (line {$num})");
            $arr[$computer_name]["IP"] = $ip;
            continue;
        }
        if (preg_match("#^Nmap scan report for\\s+(.+?)\\s+\\((.+?)\\)#", $line, $re)) {
            $ip = $re[2];
            $computer_name = $re[1];
            compevents("found computer: {$computer_name}/{$ip} (line {$num})");
            $arr[$computer_name]["IP"] = $ip;
            continue;
        }
        if (preg_match("#^Nmap scan report for\\s+(.+?)\$#", trim($line), $re)) {
            $ip = $re[1];
            $computer_name = $ip;
            compevents("found computer: just {$ip} (line {$num})");
            $arr[$computer_name]["IP"] = $ip;
            continue;
        }
        if (preg_match("#^MAC Address.+?\\((.+?)\\)#", $line, $re)) {
            if ($_GET["VERBOSE"]) {
                echo "{$computer_name}:: Found type={$re[1]}\n";
            }
            compevents("{$computer_name}: found type={$re[1]} (line {$num})");
            $arr[$computer_name]["TYPE"] = $re[1];
            continue;
        }
        if (preg_match('#^MAC Address:\\s+(.+?)\\s+#', $line, $re)) {
            compevents("{$computer_name}: found MAC={$re[1]} (line {$num})");
            if ($_GET["VERBOSE"]) {
                echo "{$computer_name}:: Found MAC={$re[1]}\n";
            }
            $arr[$computer_name]["MAC"] = $re[1];
            continue;
        }
        if (preg_match('#Running:\\s+(.+)#', $line, $re)) {
            compevents("{$computer_name}: found OS={$re[1]} (line {$num})");
            if ($_GET["VERBOSE"]) {
                echo "{$computer_name}:: Found OS={$re[1]}\n";
            }
            $arr[$computer_name]["OS"] = $re[1];
            continue;
        }
    }
    if (!is_array($arr)) {
        return null;
    }
    while (list($num, $line) = each($arr)) {
        if (trim($num) == null) {
            continue;
        }
        compevents("Add entry: " . $num . '$');
        $cp = new computers($num . '$');
        $cp->ComputerIP = $line["IP"];
        $cp->ComputerOS = $line["OS"];
        $cp->ComputerMacAddress = $line["MAC"];
        if ($line["TYPE"] != null) {
            $cp->ComputerMachineType = $line["TYPE"];
        }
        if (!$cp->Add()) {
            compevents($cp->ldap_error . " for {$num}\$");
        }
    }
    @unlink($file);
}