-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyMyAdmin.py
executable file
·171 lines (148 loc) · 7.49 KB
/
PyMyAdmin.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
from datetime import datetime
import sqlite3
class Database:
def __init__(self,group_id,group_title,userid):
self.conn = sqlite3.connect('Scrutin.db')
self.cursor = self.conn.cursor()
self.group_id = group_id
self.group_title = group_title
self.userid = userid
def add_groups(self):
try:
self.cursor.execute("""INSERT INTO Groups VALUES (?,?,?);""",(self.group_title,self.group_id,self.userid))
self.conn.commit()
except Exception as e:
print(e)
def remove_groups(self):
try:
self.cursor.execute("""DELETE FROM Groups where group_id={}""".format(self.group_id))
self.conn.commit()
except Exception as e:
print(e)
# def create_table(self):
# self.cursor.execute("""create table Scanners (type_scan varchar(5), data_exec timestamp, user varchar(255) DEFAULT 'anonymous',id int,site text);""")
# self.cursor.execute("""create table Crawler (crawler_name varchar(5), data_exec timestamp, user varchar(255) DEFAULT 'anonymous', id int, dork text);""")
# self.cursor.execute("""create table Users (data timestamp, user varchar(255), id int, primary key(id));""")
# self.cursor.execute("""create table Groups (name_group varchar(255),group_id int,who_add int,primary key(group_id));""")
# self.cursor.execute("""create table Generators (gen varchar(5), data_exec timestamp, user varchar(255) DEFAULT 'anonymous', id int, generated text);""")
# self.cursor.execute("""create table Cryptography (algorithm varchar(10), data_exec timestamp, user varchar(255) DEFAULT 'anonymous', id int, strings text);""")
# self.conn.commit()
# self.cursor.close()
# pass
def get_admin(self):
adms = []
self.cursor.execute("""SELECT * FROM Admin;""")
for admin in self.cursor.fetchall():
adms.append(admin[2])
return adms
def return_users(self):
_users = []
sql_querys = {'users':'SELECT id from Users;','groups':'SELECT group_id from Groups;'}
for x in self.cursor.execute(sql_querys['users']).fetchall():
_users.append(''.join(str(x[0])))
for x in self.cursor.execute(sql_querys['groups']).fetchall():
_users.append(''.join(str(x[0])))
return _users
def update(self):
try:
with open("groups.txt","r",encoding='utf-8') as file:
for line in file.readlines():
z = line.strip()
print(z)
x = z.split(',')[0]
s = z.split(',')[1]
ss = z.split(',')[2]
try:
self.cursor.execute("""insert into Groups values (?,?,?);""",(x,s,ss))
self.conn.commit()
except Exception as e:
print(e)
except Exception as e:
print(e)
def get_statistic(self):
now = datetime.now().strftime('%Y-%m-%d')
month = datetime.now().strftime('%Y-%m')
sql_querys = {
'scanners': "SELECT count(type_scan) from Scanners;",
'sqli': "SELECT count(type_scan) from Scanners where type_scan='SQL';",
'xss': "SELECT count(type_scan) from Scanners where type_scan='XSS';",
'lfi': "SELECT count(type_scan) from Scanners where type_scan='LFI';",
'targets': "SELECT count(DISTINCT site) from Scanners;",
'users': "SELECT count(id) from Users;",
'dorks': "SELECT count(gen) from Generators;",
'crawler': "SELECT count(crawler_name) from Crawler;",
'U_today': "SELECT count(data) from Users WHERE DATA LIKE \"%"+str(now)+"%\";",
'U_month': "SELECT count(data) from Users WHERE DATA LIKE \"%"+str(month)+"%\";",
'all_Groups': "SELECT count(group_id) from Groups;",
}
statistic ={
"all_scan":''.join(str(x[0]) for x in self.cursor.execute(sql_querys['scanners']).fetchall()),
"sqli":''.join(str(x[0]) for x in self.cursor.execute(sql_querys['sqli']).fetchall()),
"xss":''.join(str(x[0]) for x in self.cursor.execute(sql_querys['xss']).fetchall()),
"lfi":''.join(str(x[0]) for x in self.cursor.execute(sql_querys['lfi']).fetchall()),
"targets":''.join(str(x[0]) for x in self.cursor.execute(sql_querys['targets']).fetchall()),
"users":''.join(str(x[0]) for x in self.cursor.execute(sql_querys['users']).fetchall()),
"dorks":''.join(str(int(x[0])*42) for x in self.cursor.execute(sql_querys['dorks']).fetchall()),
"crawler":''.join(str(int(x[0])*10) for x in self.cursor.execute(sql_querys['crawler']).fetchall()),
"U_today":''.join(str(x[0]) for x in self.cursor.execute(sql_querys['U_today']).fetchall()),
"U_month":''.join(str(x[0]) for x in self.cursor.execute(sql_querys['U_month']).fetchall()),
"all_Groups":''.join(str(x[0]) for x in self.cursor.execute(sql_querys['all_Groups']).fetchall()),
}
return statistic
class LogManager:
def __init__(self,text,idd,nick,gid,gtt):
self.text = text.get('text')
self.textS = self.text.split(' ')
self.id = idd
self.nick = nick
self.idG = gid
self.ttG = gtt
self.cmd = self.text.split(' ')[0].replace('/','')
self.now = str(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
self.conn = sqlite3.connect('Scrutin.db')
self.cursor = self.conn.cursor()
def scanners(self):
site = self.text.split(' ')[1]
try:
self.cursor.execute("""INSERT INTO Scanners VALUES (?,?,?,?,?);""",(self.cmd.upper(),self.now,self.nick,self.id,site))
self.conn.commit()
self.cursor.close()
except Exception as e:
print(e)
def crawler(self):
search = self.text.replace("/bing ", "")
try:
self.cursor.execute("""INSERT INTO Crawler VALUES (?,?,?,?,?);""",(self.cmd.upper(),self.now,self.nick,self.id,search))
self.conn.commit()
except Exception as e:
print(e)
def generators(self):
generated = self.text.replace(self.cmd,'')
try:
self.cursor.execute("""INSERT INTO Generators VALUES (?,?,?,?,?);""", (self.cmd.upper(),self.now,self.nick,self.id,generated.replace('/ ','')))
self.conn.commit()
except Exception as e:
print(e)
def encrypt(self):
algorithm = self.textS[1]+'_encode'
string = self.text.replace('/encrypt {} '.format(self.textS[1]),'')
try:
self.cursor.execute("""INSERT INTO Cryptography VALUES (?,?,?,?,?);""",(algorithm,self.now,self.nick,self.id,string))
self.conn.commit()
except Exception as e:
print(e)
def decrypt(self):
algorithm = self.textS[1]+'_decode'
string = self.text.replace('/decrypt {} '.format(self.textS[1]),'')
try:
self.cursor.execute("""INSERT INTO Cryptography VALUES (?,?,?,?,?);""",(algorithm,self.now,self.nick,self.id,string))
self.conn.commit()
except Exception as e:
print(e)
def users(self):
try:
self.cursor.execute("""INSERT INTO Users VALUES (?,?,?);""", (self.now,self.nick,self.id))
self.conn.commit()
except Exception as e:
print(e)
#Database().update()