Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
surykatka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
surykatka
Commits
0b516822
Commit
0b516822
authored
Feb 17, 2020
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bot: Correctly group IPs per URLs and DOMAINs
parent
72bcbb48
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
38 deletions
+43
-38
src/surykatka/bot.py
src/surykatka/bot.py
+43
-38
No files found.
src/surykatka/bot.py
View file @
0b516822
...
...
@@ -249,31 +249,31 @@ class WebBot:
url_dict
[
url
].
append
(
network_change
[
"ip"
])
# Report the SSL status
query
=
reportSslCertificate
(
self
.
_db
,
ip
=
[
x
for
x
in
server_ip_dict
.
keys
()],
port
=
443
,
hostname
=
domain_list
,
)
result_dict
[
"ssl_certificate"
]
=
[]
for
ssl_certificate
in
query
.
dicts
().
iterator
():
result_dict
[
"ssl_certificate"
].
append
(
{
"hostname"
:
ssl_certificate
[
"hostname"
],
"ip"
:
ssl_certificate
[
"ip"
],
"port"
:
ssl_certificate
[
"port"
],
"sha1_fingerprint"
:
ssl_certificate
[
"sha1_fingerprint"
],
"subject"
:
ssl_certificate
[
"subject"
],
"issuer"
:
ssl_certificate
[
"issuer"
],
"not_before"
:
rfc822
(
ssl_certificate
[
"not_before"
])
if
(
ssl_certificate
[
"not_before"
]
is
not
None
)
else
None
,
"not_after"
:
rfc822
(
ssl_certificate
[
"not_after"
])
if
(
ssl_certificate
[
"not_after"
]
is
not
None
)
else
None
,
"date"
:
rfc822
(
ssl_certificate
[
"status"
]),
}
for
ip_
,
domain_list_
in
server_ip_dict
.
items
():
query
=
reportSslCertificate
(
self
.
_db
,
ip
=
ip_
,
port
=
443
,
hostname
=
domain_list_
,
)
for
ssl_certificate
in
query
.
dicts
().
iterator
():
result_dict
[
"ssl_certificate"
].
append
(
{
"hostname"
:
ssl_certificate
[
"hostname"
],
"ip"
:
ssl_certificate
[
"ip"
],
"port"
:
ssl_certificate
[
"port"
],
"sha1_fingerprint"
:
ssl_certificate
[
"sha1_fingerprint"
],
"subject"
:
ssl_certificate
[
"subject"
],
"issuer"
:
ssl_certificate
[
"issuer"
],
"not_before"
:
rfc822
(
ssl_certificate
[
"not_before"
])
if
(
ssl_certificate
[
"not_before"
]
is
not
None
)
else
None
,
"not_after"
:
rfc822
(
ssl_certificate
[
"not_after"
])
if
(
ssl_certificate
[
"not_after"
]
is
not
None
)
else
None
,
"date"
:
rfc822
(
ssl_certificate
[
"status"
]),
}
)
# XXX put back orignal url list
for
url
in
self
.
calculateUrlList
():
...
...
@@ -282,23 +282,28 @@ class WebBot:
if
root_url
in
url_dict
:
url_dict
[
url
]
=
url_dict
[
root_url
]
# map IP to URLs for less queries during fetching results
ip_to_url_dict
=
{}
for
url
,
ip_list
in
url_dict
.
items
():
for
ip
in
ip_list
:
ip_to_url_dict
.
setdefault
(
ip
,
[])
if
url
not
in
ip_to_url_dict
[
ip
]:
ip_to_url_dict
[
ip
].
append
(
url
)
# Get the list of HTTP servers to check
query
=
reportHttp
(
self
.
_db
,
ip
=
[
x
for
x
in
server_ip_dict
.
keys
()],
url
=
[
x
for
x
in
url_dict
.
keys
()],
)
result_dict
[
"http_query"
]
=
[]
for
network_change
in
query
.
dicts
().
iterator
():
result_dict
[
"http_query"
].
append
(
{
"status_code"
:
network_change
[
"status_code"
],
"total_seconds"
:
network_change
[
"total_seconds"
],
"url"
:
network_change
[
"url"
],
"ip"
:
network_change
[
"ip"
],
"date"
:
rfc822
(
network_change
[
"status"
]),
}
)
for
ip
,
url_list
in
ip_to_url_dict
.
items
():
query
=
reportHttp
(
self
.
_db
,
ip
=
ip
,
url
=
url_list
)
for
network_change
in
query
.
dicts
().
iterator
():
result_dict
[
"http_query"
].
append
(
{
"status_code"
:
network_change
[
"status_code"
],
"total_seconds"
:
network_change
[
"total_seconds"
],
"url"
:
network_change
[
"url"
],
"ip"
:
network_change
[
"ip"
],
"date"
:
rfc822
(
network_change
[
"status"
]),
}
)
return
result_dict
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment