-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathdb.py
35 lines (31 loc) · 1.7 KB
/
db.py
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
import pandas as pd
import pandasql
def get_display_ttl():
df = pd.read_csv('TTL.csv')
q = "SELECT * FROM df"
items = pandasql.sqldf(q, locals())
return items
def get_display_main():
Main = pd.read_csv('Main.csv')
q ="SELECT Name, Port, Description from Main GROUP BY Name ORDER By CASE WHEN Port LIKE '[0-9]%' THEN 2 ELSE 1 END, abs(Port)"
#q ="SELECT Name, Port, Description from Main GROUP BY Name ORDER By ABS(Port)"
items = pandasql.sqldf(q, locals())
items = items.values.tolist()
return items
def get_display_sub(proto, metasploit):
Main = pd.read_csv('Main.csv')
# q = "SELECT Cmd_Name, SUBSTRING(Cmd_Description, 1, 50), SUBSTRING(replace(Cmd_Command, X'0A', ' '), 1, 50) AS Cmd_Command from Main WHERE Name = '{}'".format(proto)
# q = "SELECT Cmd_Name FROM Main WHERE Name = '{}'".format(proto)
if metasploit == "True":
q = "SELECT Cmd_Name, SUBSTRING(Cmd_Description, 1, 50), SUBSTRING(replace(Cmd_Command, X'0A', ' '), 1, 50) AS Cmd_Command from Main WHERE Name='{}' ORDER By SubDisplayOrder".format(proto)
else:
q = "SELECT Cmd_Name, SUBSTRING(Cmd_Description, 1, 50), SUBSTRING(replace(Cmd_Command, X'0A', ' '), 1, 50) AS Cmd_Command from Main WHERE Name='{}' AND Cmd_Command NOT LIKE 'msfconsole%' ORDER By SubDisplayOrder".format(proto)
items = pandasql.sqldf(q, locals())
items = items.values.tolist()
return items
def get_fullcommand(proto):
Main = pd.read_csv('Main.csv')
q = "SELECT Cmd_Command from Main WHERE Name = '{}' ORDER By SubDisplayOrder".format(proto)
items = pandasql.sqldf(q, locals())
items = items.values.tolist()
return items