as indicated, you have basic quotes. but more fundamentally:
- Pythonesque
,
. , , , funner ( ) .
- -,
- : (
-)
-.
- 10.1.1. * - "" . RFC 1918 ,
"" : 10.0.0.0 - 10.255.255.255, 172.16.0.0 - 172.31.255.255
192.168.0.0 - 192.168.255.255.
"" .
- - (
) ,
80 ( 8000, 8001 8080).
- -, DNS ..
-
( ).
, , ,
, (5), ()
.
btw -,
"" . IP- Yahoo
.
import urllib
import threading
import socket
def t_run(thread_list, chunks):
t_count = len(thread_list)
print "Running %s jobs in groups of %s threads" % (t_count, chunks)
for x in range(t_count / chunks + 1):
i = x * chunks
i_c = min(i + chunks, t_count)
c = len([t.start() for t in thread_list[i:i_c]])
print "Started %s threads for jobs %s...%s" % (c, i, i_c - 1)
c = len([t.join() for t in thread_list[i:i_c]])
print "Finished %s threads for job index %s" % (c, i)
def url_scan(ip_base, timeout=5):
socket.setdefaulttimeout(timeout)
def f(url):
try:
r = urllib.urlopen(url)
if r:
print "## (%s) got %s bytes" % (url, len(r.read()))
else:
print "## (%s) failed to connect" % url
except IOError, msg:
if str(msg)=="[Errno socket error] timed out":
return
if str(msg)=="[Errno socket error] (10061, 'Connection refused')":
return
print "## (%s) got error '%s'" % (url, msg)
return [threading.Thread(target=f,
args=("http://" + ip_base + str(x) + ":" + str(p),))
for x in range(255) for p in [80, 8080]]
t_run(url_scan("209.131.36."), 100)
t_run(url_scan("209.131.36.", 30), 100)