/usr/share/pyshared/gplugs/hex2ip.py is in gozerbot 0.99.1-2.
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 | # plugs/hex2ip.py
#
#
from gozerbot.commands import cmnds
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
from gozerbot.tests import tests
import struct, socket
plughelp.add('hex2ip', 'convert a hexadecimal number to an ip addres')
def handle_hex2ip(bot, ievent):
try:
what = ievent.args[0]
except IndexError:
ievent.missing("<hexnr>")
return
try:
ipint = int(what, 16)
ipint = socket.ntohl(ipint)
packed = struct.pack('l', ipint)
ip = socket.inet_ntoa(str(packed))
except Exception, ex:
ievent.reply("can't make ipnr out of %s" % what)
return
ievent.reply('%s is %s' % (what, ip))
try:
hostname = socket.gethostbyaddr(ip)[0]
except:
ievent.reply("can't find hostname of %s" % ip)
return
ievent.reply('hostname is %s' % hostname)
cmnds.add('hex2ip', handle_hex2ip, 'USER')
examples.add('hex2ip', 'convert hexadecimal number to ip addres', 'hex2ip \
54008c8a')
#tests.add('hex2ip 54008c8a')
|