-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
58 lines (45 loc) · 1.17 KB
/
Copy pathdb.py
File metadata and controls
58 lines (45 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sqlite3
import os
DB_PATH = "kast.db"
def init_db():
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS victims (
vic_id TEXT PRIMARY KEY,
hostname TEXT,
ip_priv TEXT,
ip_pub TEXT,
plat TEXT,
system TEXT,
machine TEXT,
first_seen DATETIME DEFAULT CURRENT_TIMESTAMP
)
""")
conn.commit()
conn.close()
def insert_victim(info: dict):
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
cursor.execute("""
INSERT OR IGNORE INTO victims
(vic_id, hostname, ip_priv, ip_pub, plat, system, machine)
VALUES (?, ?, ?, ?, ?, ?, ?)
""", (
info["vic_id"],
info["hostname"],
info["ip_priv"],
info["ip_pub"],
info["plat"],
info["system"],
info["machine"]
))
conn.commit()
conn.close()
def get_victims():
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
cursor.execute("SELECT * FROM victims")
rows = cursor.fetchall()
conn.close()
return rows