/usr/lib/python2.7/dist-packages/gplugs/banner.py is in gozerbot 0.99.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # gozerplugs/banner.py
#
# Description: check is host:port is open, and supply the first line or 'banner'
# Author: Wijnand 'tehmaze' Modderman
# Licsense: BSD
""" show banner of <host> <port> """
__author__ = "Wijnand 'tehmaze' Modderman"
__license__ = "BSD"
from gozerbot.commands import cmnds
from gozerbot.plughelp import plughelp
from gozerbot.examples import examples
from gozerbot.tests import tests
import socket
plughelp.add('banner', 'show if host:port is open')
def handle_banner(bot, ievent):
""" banner <host> <port> .. check if host:port is open """
try:
(host, port) = ievent.args
port = int(port)
except ValueError:
ievent.missing('<host> <port>')
return
banner = None
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(2)
sock.connect((host, port))
except socket.timeout:
ievent.reply('%s:%s is not up' % (host, port))
return
except Exception, ex:
ievent.reply('%s:%s is not up ==> %s' % (host, port, str(ex)))
return
try:
msock = sock.makefile()
banner = msock.readline()
except:
pass
try:
sock.close()
except socket.error:
pass
if banner:
ievent.reply('%s:%s is up: %s' % (host, port, banner))
else:
ievent.reply('%s:%s is up' % (host, port))
cmnds.add('banner', handle_banner, 'USER')
examples.add('banner', 'banner <host> <port> // show if host:port is open', \
'banner gozerbot.org 25')
tests.add('banner gozerbot.org 25', 'up')
|