def run(self):
value, user = getword()
for ip in completed:
print "-"*12
print "[+] IP: "+ip
try:
print "User:",user,"Password:",value
smtp = smtplib.SMTP(ip)
smtp.login(user, value)
print "\t\n[!] Login successful:",user, value
logger.write("[!] Found: " + ip + " " + str(user) + ":" + str(value) + "\n")
smtp.quit()
sys.exit(2)
except(socket.gaierror, socket.error, socket.herror, smtplib.SMTPException), msg:
pass
python类herror()的实例源码
def run(self):
value, user = getword()
try:
print "-"*12
print "User:",user,"Password:",value
n = nntplib.NNTP(sys.argv[1],int(sys.argv[2]),user,value)
print "\t\nLogin successful:",value, user
n.quit()
work.join()
sys.exit(2)
except(nntplib.NNTPError, socket.gaierror, socket.error, socket.herror), msg:
print "An error occurred:", msg
pass
def run(self):
value = getword()
try:
print "-"*12
print "User:",user[:-1],"Password:",value
n = nntplib.NNTP(ip,119,user,value)
print "\t\nLogin successful:",user, value
n.quit()
work.join()
sys.exit(2)
except(nntplib.NNTPError, socket.gaierror, socket.error, socket.herror), msg:
print "An error occurred:", msg
pass
def run(self):
value = getword()
try:
print "-"*12
print "User:",user[:-1],"Password:",value
M = imaplib.IMAP4(ipaddr[0])
M = login(user[:-1], value)
print "\t\nLogin successful:",user, value
M.close()
M.logout()
work.join()
sys.exit(2)
except(IMAP4.error, socket.gaierror, socket.error, socket.herror), msg:
print "An error occurred:", msg
pass
def run(self):
value = getword()
try:
print "-"*12
print "User:",user[:-1],"Password:",value
smtp = smtplib.SMTP(ipaddr[0])
smtp.login(user[:-1], value)
print "\t\nLogin successful:",user, value
smtp.quit()
work.join()
sys.exit(2)
except(socket.gaierror, socket.error, socket.herror, smtplib.SMTPException), msg:
#print "An error occurred:", msg
pass
def run(self):
value = getword()
try:
print "-"*12
print "User:",user[:-1],"Password:",value
n = nntplib.NNTP(ipaddr[0],119,user,value)
print "\t\nLogin successful:",user, value
n.quit()
work.join()
sys.exit(2)
except (nntplib.NNTPError, socket.gaierror, socket.error, socket.herror), msg:
#print "An error occurred:", msg
pass
def run(self):
value, user = getword()
try:
print "-"*12
print "User:",user,"Password:",value
M = imaplib.IMAP4(sys.argv[1])
M = login(user, value)
print "\t\nLogin successful:",user, value
M.close()
M.logout()
work.join()
sys.exit(2)
except(IMAP4.error, socket.gaierror, socket.error, socket.herror), msg:
print "An error occurred:", msg
pass
def get_all_names(self):
"""Returns all names found in the Nginx Configuration.
:returns: All ServerNames, ServerAliases, and reverse DNS entries for
virtual host addresses
:rtype: set
"""
all_names = set()
for vhost in self.parser.get_vhosts():
all_names.update(vhost.names)
for addr in vhost.addrs:
host = addr.get_addr()
if common.hostname_regex.match(host):
# If it's a hostname, add it to the names.
all_names.add(host)
elif not common.private_ips_regex.match(host):
# If it isn't a private IP, do a reverse DNS lookup
# TODO: IPv6 support
try:
socket.inet_aton(host)
all_names.add(socket.gethostbyaddr(host)[0])
except (socket.error, socket.herror, socket.timeout):
continue
return util.get_filtered_names(all_names)
def run(self):
"""
Infinite loop fetching email , lauching < 10 threads pushing email
to storage service and worker
"""
try:
self._imap_conn = get_imap_connection(host=HOST, port=PORT, user=USER, passwd=PASS)
except (IMAP4.error, IMAP4.abort, IMAP4.readonly) as ex:
Logger.error(unicode('Error in IMAP connection - %s' % (str(ex))))
return
except (socket.error, socket.gaierror, socket.herror, socket.timeout) as ex:
Logger.error(unicode('Error in IMAP connection - %s' % (str(ex))))
return
pool = ThreadPool(5)
while True:
try:
messages = self.get_messages()
except (socket.error, socket.gaierror, socket.herror,
socket.timeout, ssl.SSLError) as ex:
Logger.debug(unicode('Error in IMAP connection - %s' % (str(ex))))
return
if not messages:
sleep(1)
continue
uids = messages.keys()
args = [(uid, messages) for uid in uids]
pool.map(push_email, args)
pool.wait_completion()
for uid in uids:
if uid not in messages:
self._imap_conn.uid('store', uid, '+FLAGS', r'(\Deleted)')
self._imap_conn.expunge()
sleep(1)
def get_ips_from_fqdn(fqdn):
"""
Retrieve IPs from FQDN
:param str fqdn: The FQDN to resolve
:rtype: list
:return: the list of resolved IP address for given FQDN
"""
try:
socket.setdefaulttimeout(5)
ips = socket.gethostbyname_ex(fqdn)[2]
return ips
except (ValueError, socket.error, socket.gaierror, socket.herror, socket.timeout):
return None
def run():
try:
querly = socket.gethostbyaddr(variables['target'][0])
printSuccess("resolved hostname: "+ querly[0])
return querly[0]
except(socket.herror):
printError("unknown host")
return ModuleError("unknown host")
except(socket.gaierror):
printError("name or service not known")
return ModuleError("name or service not known")
def __init__(self, ip, raw_request, timestamp, parsed_request, is_detected,
hostname):
self.ip = ip
self.raw_request = raw_request
self.timestamp = timestamp
self.path = ""
self.command = ""
self.version = ""
self.ua = ""
self.headers = ""
self.country = ""
self.continent = ""
self.timezone = ""
self.dns_name = ""
self.tracert = "" # TODO
if hasattr(parsed_request, 'path'):
self.path = parsed_request.path
if parsed_request.command is not None:
self.command = parsed_request.command
if hasattr(parsed_request, 'request_version'):
self.version = parsed_request.request_version
if hasattr(parsed_request, 'headers'):
self.headers = parsed_request.headers
if 'user-agent' in parsed_request.headers:
self.ua = parsed_request.headers['user-agent']
self.isDetected = is_detected
self.hostname = hostname
location = geolite2.lookup(ip)
if location is not None:
self.country = location.country
self.continent = location.continent
self.timezone = location.timezone
try:
self.dns_name = socket.gethostbyaddr(ip)[0]
except socket.herror:
pass
def arp_spoof(self, tm):
arp = Arp_Spoof(args.iface)
try:
log.status("{} ({}) is at {}".format(socket.gethostbyaddr(args.target)[0], args.target, tm))
except socket.herror:
log.warn("{} is at {}".format(args.target, tm))
ajobs = []
victim_thread = multiprocessing.Process(target=arp.poison_victim, args=(args.target, args.gateway, int(verbose), args.iface, tm))
ajobs.append(victim_thread)
victim_thread.start()
try:
vname = socket.gethostbyaddr(args.target)[0]
vname = vname.replace('.home', " ")
log.status("Started attack on {}".format(vname))
except socket.herror:
log.warn("Started attack on {}".format(args.target))
target_thread = multiprocessing.Process(target=arp.poison_router, args=(args.gateway, args.target, int(verbose), args.iface, tm))
ajobs.append(victim_thread)
target_thread.start()
try:
rname = socket.gethostbyaddr(args.gateway)[0]
rname = rname.replace('.home', " ")
log.status("Started attack on {}".format(rname))
except socket.herror:
log.warn("Started attack on {}".format(args.target))
def testSocketError(self):
# Testing socket module exceptions
def raise_error(*args, **kwargs):
raise socket.error
def raise_herror(*args, **kwargs):
raise socket.herror
def raise_gaierror(*args, **kwargs):
raise socket.gaierror
self.assertRaises(socket.error, raise_error,
"Error raising socket exception.")
self.assertRaises(socket.error, raise_herror,
"Error raising socket exception.")
self.assertRaises(socket.error, raise_gaierror,
"Error raising socket exception.")
def testExceptionTree(self):
self.assertTrue(issubclass(socket.error, Exception))
self.assertTrue(issubclass(socket.herror, socket.error))
self.assertTrue(issubclass(socket.gaierror, socket.error))
self.assertTrue(issubclass(socket.timeout, socket.error))
torstatus.blutmagie.py 文件源码
项目:attacks-pages-collector
作者: ifreddyrondon
项目源码
文件源码
阅读 27
收藏 0
点赞 0
评论 0
def get_host(ip):
attempts = 5
host = "undefined"
while attempts:
try:
data = socket.gethostbyaddr(ip)
host = data[0]
break
except socket.herror:
attempts -= 1
return host
reputation.alienvault.py 文件源码
项目:attacks-pages-collector
作者: ifreddyrondon
项目源码
文件源码
阅读 27
收藏 0
点赞 0
评论 0
def get_host(ip):
attempts = 5
host = "undefined"
while attempts:
try:
data = socket.gethostbyaddr(ip)
host = data[0]
break
except socket.herror:
attempts -= 1
return host
def get_ip(name):
attempts = 5
ip = "undefined"
while attempts:
try:
data = socket.gethostbyname_ex(name)
ip = data[2][0]
break
except (socket.herror, socket.gaierror):
attempts -= 1
return ip
def get_host(ip):
attempts = 5
host = "undefined"
while attempts:
try:
data = socket.gethostbyaddr(ip)
host = data[0]
break
except socket.herror:
attempts -= 1
return host
def get_host(ip):
attempts = 5
host = "undefined"
while attempts:
try:
data = socket.gethostbyaddr(ip)
host = data[0]
break
except socket.herror:
attempts -= 1
return host