-
Notifications
You must be signed in to change notification settings - Fork 13
/
eagle-eye.py
95 lines (74 loc) · 2.07 KB
/
eagle-eye.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
#!/usr/bin/env python
## Eagle Eye :: By Viss, with a lot of help from @achillean and others!
## To run this you'll need the shodan module as well as gevent.
# First things first, let's monkey patch Python to support greenthreads
from gevent import monkey
monkey.patch_all()
# Non-standard libraries that are being used
from gevent import joinall, sleep, spawn
from gevent.queue import Queue
from shodan import WebAPI
# Standard python stuff
import re
import socket
import sys
import time
import os
# Constants
API_KEY = '<git yer own, theyre free!'
NUM_WORKERS = 25
#del sys.argv[0]
#for arg in sys.argv:
# filter = " ".join(arg," ")
#filter = "org:amazon port:80"
filter = 'port:80 org:"Sony North America"'
def checkCam(ip):
print 'Checking %s...' % ip
ipandport = ip.split()
#port = ipandport[1]
cmd = 'wkhtmltoimage-i386 --width 600 --load-error-handling ignore http://%s %s.png &' % (ip,ip)
sleep(1)
os.system(cmd)
def worker(queue):
while 1:
if queue.empty():
sleep(5)
continue
ip = queue.get()
checkCam(ip)
def main(queue):
# Connect to Shodan
api = WebAPI(API_KEY)
# get the first page of results
res = api.search(filter)
#keep track of how many results we have left
#total_results = res['total']
total_results = res.get('total', 0)
# Start looping through results now
page = 1
try:
while(page * 100 <= total_results):
#check the matches to see if they fit what we are looking for
for host in res['matches']:
queue.put_nowait(host['ip'])
page +=1
res = api.search(filter,page)
except Exception, e:
print e
# Done querying Shodan, now wait for the queue to finish
while not queue.empty():
sleep(10)
# Exit the program
#sys.exit(0)
# Run the script if it's being executed
if __name__ == '__main__':
print "You're searching for: %s" % filter
# Create the worker queue that holds the potential webcams
queue = Queue()
# Spawn the main thread
threads = [ spawn(main, queue) ]
# Spawn the workers
for i in range(NUM_WORKERS):
threads.append(spawn(worker, queue))
# Wait for the greenthreads to finish
joinall(threads)