This repository has been archived by the owner on Apr 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgetdatabase.py
72 lines (60 loc) · 2.98 KB
/
getdatabase.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
import requests
import json
import datetime
import logging
logger = logging.getLogger(__name__)
class Dictlist(dict):
def __setitem__(self, key, value):
try:
self[key]
except KeyError:
super(Dictlist, self).__setitem__(key, [])
self[key].append(value)
def main():
s = requests.session()
database = s.get("https://vhack.olympiccode.ga/database/getdata.php")
database = json.loads(database.text)
# sort = max(database['data'], key=lambda ev: ev[i][3])
# lines = sorted(database['data'], key=lambda k=database: k['data'][0][2], reverse=True)
# print sort
results = [x for x in database['data']]
data = sorted(results, key=lambda x: x[2])
logger.info("{:>2} {:>2} {:>2} {:>2} {:>2} {:>2} {:>2}".format("IP".rjust(15),
"Username".rjust(15),
"Money".rjust(15),
"IPSP".rjust(15),
"Firewall".rjust(15),
"Antivirus".rjust(15),
"Add Date".rjust(15)))
# list_argent = []
# list_ip = []
list_total = {}
list_total = Dictlist()
d = datetime.date.today()
day = '{:02d}'.format(d.day)
month = '{:02d}'.format(d.month)
year = d.year
for i, data2 in enumerate(data):
if "unknown" not in data2[1] and str(year) + "-" + str(month) + "-" + str(day) in data2[6]:
"""print ("{:>2} {:>2} {:>2} {:>2} {:>2} {:>2} {:>2}".format(
str(data2[0]).rjust(15),
str(data2[1]).rjust(15),
str(data2[2]).rjust(15),
str(data2[3]).rjust(15),
str(data2[4]).rjust(15),
str(data2[5]).rjust(15),
str(data2[6]).rjust(15)))"""
list_total["ip"] = data2[0], data2[1], data2[2], data2[3], data2[4], data2[5], data2[6]
results = [x for x in list_total["ip"]]
data = sorted(results, key=lambda x: int(x[2]), reverse=True)
for i, data2 in enumerate(data):
logger.info("{:>2} {:>2} {:>2} {:>2} {:>2} {:>2} {:>2}".format(
str(data2[0]).rjust(15),
str(data2[1]).rjust(15),
str(data2[2]).rjust(15),
str(data2[3]).rjust(15),
str(data2[4]).rjust(15),
str(data2[5]).rjust(15),
str(data2[6]).rjust(15)))
if __name__ == "__main__":
main()