0

我有这三个表(我附上预览)。列表末尾是“virustotalscans”表中的数据示例。有一列名为“virustotal”。每个唯一样本都有编号,例如 165,下一个样本编号为 166 等。

病毒

CREATE TABLE virustotals (
                            virustotal INTEGER PRIMARY KEY,
                            virustotal_md5_hash TEXT NOT NULL,
                            virustotal_timestamp INTEGER NOT NULL,
                            virustotal_permalink TEXT NOT NULL
                    );
CREATE INDEX virustotals_md5_hash_idx
                    ON virustotals (virustotal_md5_hash);

表格虚拟扫描

CREATE TABLE virustotalscans (
                    virustotalscan INTEGER PRIMARY KEY,
                    virustotal INTEGER NOT NULL,
                    virustotalscan_scanner TEXT NOT NULL,
                    virustotalscan_result TEXT
            );
CREATE INDEX virustotalscans_result_idx
                    ON virustotalscans (virustotalscan_result);
CREATE INDEX virustotalscans_scanner_idx
                    ON virustotalscans (virustotalscan_scanner);
CREATE INDEX virustotalscans_virustotal_idx
                    ON virustotalscans (virustotal);

表格下载

CREATE TABLE downloads (
                            download INTEGER PRIMARY KEY,
                            connection INTEGER,
                            download_url TEXT,
                            download_md5_hash TEXT
                            -- CONSTRAINT downloads_connection_fkey FOREIGN KEY (connection) REFERENCES connections (connection)
                    );
CREATE INDEX downloads_connection_idx   ON downloads (connection);
CREATE INDEX downloads_md5_hash_idx
                    ON downloads (download_md5_hash);
CREATE INDEX downloads_url_idx
                    ON downloads (download_url);

“virustotalscans”表中的数据示例:http: //pastebin.com/7E7McZwT

现在,我需要选择所有样本,这些样本在“virustotalscan_result”列中的所有行为空。所以我需要选择所有样本,这些样本不会用任何防病毒软件检测到 VirusTotal。我试过这个选择:

select distinct downloads.download_md5_hash from virustotalscans, virustotals, 
   downloads 
where downloads.download_md5_hash = virustotals.virustotal_md5_hash and 
   virustotals.virustotal = virustotalscans.virustotal and 
   virustotalscans.virustotalscan_result IS NULL;

但是我得到了所有样本的 MD5 哈希值......可能的原因是所有样本都至少包含一行,它是空的。这是合乎逻辑的,因为某些防病毒软件始终无法检测到某些样本。

更好的例子: http: //pastebin.com/y81DPpmQ。现在我需要选择样本 - 编号(列 virustotal),其中列 virustotalscan_result 中的所有行都是空的。例如,它只能是 2 号。

你能帮我吗?

非常感谢您的回复。

4

1 回答 1

0
SELECT download_md5_hash
FROM downloads
JOIN virustotals ON download_md5_hash = virustotal_md5_hash
WHERE virustotal IN (SELECT virustotal
                     FROM virustotalscans
                     GROUP BY virustotal
                     HAVING COUNT(virustotalscan_result) = 0)
于 2013-08-15T20:00:19.637 回答