From 988157fb68d4e6453cb032f449cd5f22eb3a8cc9 Mon Sep 17 00:00:00 2001 From: skyg4mb Date: Tue, 17 Dec 2019 08:30:27 -0500 Subject: [PATCH] Actualizacion de a libreria de dionaea hpfeeds.py En caso de despliegue de sensor en un ambiente sin acceso a internet la funcion retorna error y no reporta ataques, se modifica el codigo para capturar una interfaz de red --- server/mhn/static/hpfeeds.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/mhn/static/hpfeeds.py b/server/mhn/static/hpfeeds.py index 9d7d97d7..149b652f 100644 --- a/server/mhn/static/hpfeeds.py +++ b/server/mhn/static/hpfeeds.py @@ -28,6 +28,9 @@ from dionaea.core import ihandler, incident, g_dionaea, connection from dionaea.util import sha512file + +import socket +import fcntl import os import logging import struct @@ -71,6 +74,10 @@ UNIQUECHAN = 'mwbinary.dionaea.sensorunique' +def get_ip_address(ifname): + buscarip = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + return socket.inet_ntoa(fcntl.ioctl(buscarip.fileno(),0x8915,struct.pack('256s', bytes(ifname[:15], 'utf-8')))[20:24]) + class BadClient(Exception): pass @@ -266,6 +273,7 @@ def _ownip(self, icd): if self.ownip: return self.ownip else: + return (get_ip_address('eth0')) #En caso de no resolver IP retorna la ip de la interfaz ETH0 raise Exception('Own IP not yet resolved!') return icd.con.local.host