if (!$statement->execute()) {
    throw new PDOException();
}
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $item) {
    foreach ($types as $type) {
        switch ($type) {
            case 'hostname':
                $founds = common_host($conf, $item['item'], $vocables);
                $type = 'hostname';
                break;
            case 'network':
                $founds = common_network($conf, $item['item'], $vocables);
                $type = 'network';
                break;
            case 'routeur':
                $founds = common_routeur($conf, $item['item'], $vocables);
                $type = 'routeur';
                break;
            default:
                $results = 0;
                break;
        }
        foreach ($founds as $found) {
            if (count($found['factors']) > 0) {
                $results[] = array('type' => $type, 'factors' => $found['factors'], 'type_of_checker' => $found['type_of_checker']);
            }
        }
    }
    send_alert($conf, $item['item'], $results, $vocables, $pdo);
}
示例#2
0
require_once dirname(__FILE__) . "/../includes/init.php";
$email_alert = factory::create('email_alert');
$sql = "SELECT * FROM email_alert \n        WHERE HOUR(TIMEDIFF(NOW(), last_sent)) >= frequency_hours AND activated = 1 ";
$email_alerts = $email_alert->execute($sql);
if (ALERT_DEBUG > 0) {
    print "{$sql} \n";
    print count($email_alerts) . " alerts to process\n";
}
foreach ($email_alerts as $email_alert) {
    //send email
    $leaflets = get_leaflets($email_alert);
    if (ALERT_DEBUG > 0) {
        print count($leaflets) . " leaflets\n";
    }
    if (count($leaflets) > 0) {
        send_alert($email_alert, $leaflets);
    }
    //update last_sent
    $email_alert->last_sent = mysql_date(time());
    if (!ALERT_DEBUG_LASTSENT_NO_UPDATE) {
        $email_alert->update();
    }
}
// retrieve array of leaflets which match the alert type and time period
function get_leaflets($email_alert)
{
    if (ALERT_DEBUG > 0) {
        print $email_alert->type . "\n";
        print "frequency : " . $email_alert->frequency_hours . "\n";
    }
    $results = array();
示例#3
0
function add_crash($time, $node, $target, $hash_quick, $hash_full, $type, $fuzzer, $log_data, $crash_data, $verified)
{
    global $verified_interesting, $verified_exploitable;
    $success = false;
    $hash = $hash_quick . "." . $hash_full;
    $unique_crash = false;
    $unique_before = 0;
    $unique_after = 0;
    $sql = "SELECT hash_quick FROM crashes GROUP BY hash_quick;";
    $result = mysql_query($sql);
    if ($result) {
        $unique_before = mysql_num_rows($result);
        mysql_free_result($result);
    }
    $sql = "INSERT INTO crashes ( time, node, target, hash, hash_quick, hash_full, type, fuzzer, count, log_data, crash_data, verified ) VALUES ";
    $sql .= "( '" . $time . "', '" . $node . "', '" . $target . "', '" . $hash . "', '" . $hash_quick . "', '" . $hash_full . "', '" . $type . "', '" . $fuzzer . "', '1', '" . $log_data . "', '" . $crash_data . "', '" . $verified . "' );";
    $result = mysql_query($sql);
    if ($result) {
        $success = true;
        mysql_free_result($result);
        $sql = "SELECT hash_quick FROM crashes GROUP BY hash_quick;";
        $result = mysql_query($sql);
        if ($result) {
            $unique_after = mysql_num_rows($result);
            mysql_free_result($result);
        }
        if ($unique_after > $unique_before) {
            $unique_crash = true;
        }
        $sql = "SELECT alerts.field, alerts.value, alerts.id, users.email FROM alerts INNER JOIN users ON alerts.id=users.id WHERE alerts.disabled='0';";
        $result = mysql_query($sql);
        if ($result) {
            $count = 0;
            $fields = array('Node', 'Target', 'Fuzzer', 'Type', 'Hash', 'Quick Hash', 'Full Hash', 'Unique', 'Verified');
            $user_ids = array();
            while ($row = mysql_fetch_array($result)) {
                $alert_sent = false;
                $field = $row['field'];
                // we only want to send one email per new crash that matches an alert, even if the new crash would match more then one of the alerts.
                // currently we dont prioritize the alert types.
                if (in_array($user_ids, $row['id'])) {
                    continue;
                }
                //array( 'node', 'target', 'fuzzer', 'type', 'hash', 'hash_quick', 'hash_full', 'unique', 'verified' );
                switch ($field) {
                    case 0:
                        if ($node == $row['value']) {
                            $alert_sent = send_alert($row['email'], $fields[$field], $row['value']);
                        }
                        break;
                    case 1:
                        if ($target == $row['value']) {
                            $alert_sent = send_alert($row['email'], $fields[$field], $row['value']);
                        }
                        break;
                    case 2:
                        if ($fuzzer == $row['value']) {
                            $alert_sent = send_alert($row['email'], $fields[$field], $row['value']);
                        }
                        break;
                    case 3:
                        if ($type == $row['value']) {
                            $alert_sent = send_alert($row['email'], $fields[$field], $row['value']);
                        }
                        break;
                    case 4:
                        if ($hash == $row['value']) {
                            $alert_sent = send_alert($row['email'], $fields[$field], $row['value']);
                        }
                        break;
                    case 5:
                        if ($hash_quick == $row['value']) {
                            $alert_sent = send_alert($row['email'], $fields[$field], $row['value']);
                        }
                        break;
                    case 6:
                        if ($hash_full == $row['value']) {
                            $alert_sent = send_alert($row['email'], $fields[$field], $row['value']);
                        }
                        break;
                    case 7:
                        if ($unique_crash) {
                            $alert_sent = send_alert($row['email'], 'New Unique Crash', $hash);
                        }
                        break;
                    case 8:
                        if ($verified == $verified_interesting) {
                            $alert_sent = send_alert($row['email'], 'New Verified Interesting Crash', $hash);
                        } else {
                            if ($verified == $verified_exploitable) {
                                $alert_sent = send_alert($row['email'], 'New Verified Exploitable Crash', $hash);
                            }
                        }
                        break;
                    default:
                        break;
                }
                if ($alert_sent) {
                    array_push($user_ids, $row['id']);
                }
            }
            mysql_free_result($result);
        }
    }
    if ($success) {
        $success = update_node_crash_status($node, $time);
    }
    return $success;
}
示例#4
0
 protected function _search_with_upc($upc, $api, $search_url)
 {
     $ret = array();
     try {
         $ret = $this->sticky_api->searchUpc($upc, $search_url);
     } catch (Exception $e) {
         send_alert($e->getMessage(), 'Sticky "' . $api . '" spider exception searching by UPC: ' . $upc);
     }
     return $ret;
 }
<?php

/*
    send email alerts
    select * from email_alert where hour(timediff(now(), last_sent)) >= frequency_hours
*/
require_once dirname(__FILE__) . "/include_path.php";
require_once dirname(__FILE__) . "/../includes/init.php";
$email_alert = factory::create('leaflet');
$email_alerts = $email_alert->execute("\n        Select * from email_alert \n        where hour(timediff(now(), last_sent)) >= frequency_hours and activated = 1\n    ");
foreach ($email_alerts as $email_alert) {
    //send email
    $leaflets = get_leaflets($email_alert);
    if (count($leaflets) > 0) {
        send_alert($email_alert);
    }
    //update last_sent
    $email_alert->last_sent = $this->last_sent = mysql_date(time());
    $email_alert->update();
}
function get_leaflets($email_alert)
{
    $results = array();
    $search = factory::create('search');
    $time = time() - 60 * 60 * $email_alert->frequency_hours;
    $time = mysql_date($time);
    //do we have any matching leaflets?
    if ($email_alert->type = 'attack') {
        $search->search('leaflet', array(array('leaflet_party_attack.party_id', '=', $email_alert->parent_id), array('leaflet.date_uploaded', '>=', $time)), 'AND', array(array('leaflet_party_attack', 'inner')));
    } else {
        if ($email_alert->type = 'party') {