mirror of
https://github.com/autistic-symposium/shell-whiz-toolkit.git
synced 2025-05-14 12:42:14 -04:00
add scripts from old box
This commit is contained in:
parent
b05e40158b
commit
df6379f72d
11 changed files with 471 additions and 6 deletions
48
elasticsearch/grabbing_es_data.py
Normal file
48
elasticsearch/grabbing_es_data.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
import elasticsearch
|
||||
import whois
|
||||
import json
|
||||
|
||||
from elasticsearch import Elasticsearch
|
||||
|
||||
es = Elasticsearch([{ 'host': "HOST NAME"}])
|
||||
|
||||
query = {
|
||||
'size': 100,
|
||||
'query': {
|
||||
'filtered': {
|
||||
'query': {
|
||||
'query_string': {
|
||||
'query': 'type:named_query_log',
|
||||
'analyze_wildcard': True
|
||||
}
|
||||
},
|
||||
'filter': {
|
||||
'bool': {
|
||||
'must_not': {
|
||||
'query_string': {
|
||||
'query': '*HOST.com OR *otherhost.com',
|
||||
'analyze_wildcard': True
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}}}
|
||||
|
||||
# Make the search
|
||||
res = es.search(index="LOG-NAME", body=query)
|
||||
|
||||
results = []
|
||||
counter = 0
|
||||
# Print out our results
|
||||
for hit in res['hits']['hits']:
|
||||
if "dns_dest" in hit['_source'].keys():
|
||||
try:
|
||||
results.append(json.dumps(whois.whois(hit['_source']['dns_dest'])))
|
||||
except Exception as e:
|
||||
pass
|
||||
counter += 1
|
||||
print "Scanning {0}/{1} domains, {2} succeeded..".format(counter, len(res['hits']['hits']), len(results))
|
||||
|
||||
with open('processed_domains.txt', 'w') as outfile:
|
||||
json.dump(results, outfile)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue