Exemplo n.º 1
0
 def __str__(self):
     (s1, s2, s3, s4) = struct.unpack(">BBBB", self.src_ip)
     (sp,) = struct.unpack('>H', self.src_port)
     (d1, d2, d3, d4) = struct.unpack(">BBBB", self.dest_ip)
     (dp,) = struct.unpack('>H', self.dest_port)
     proto = util.prot_name(ord(self.proto))
     if sp == 65535: sp = 'none'
     if dp == 65535: dp = 'none'
     return "%s.%s.%s.%s:%s -> %s.%s.%s.%s:%s (%s)" % \
         (s1, s2, s3, s4, sp, d1, d2, d3, d4, dp, proto)
Exemplo n.º 2
0
 def __str__(self):
     (s1, s2, s3, s4) = struct.unpack(">BBBB", self.src_ip)
     (sp, ) = struct.unpack('>H', self.src_port)
     (d1, d2, d3, d4) = struct.unpack(">BBBB", self.dest_ip)
     (dp, ) = struct.unpack('>H', self.dest_port)
     proto = util.prot_name(ord(self.proto))
     if sp == 65535: sp = 'none'
     if dp == 65535: dp = 'none'
     return "%s.%s.%s.%s:%s -> %s.%s.%s.%s:%s (%s)" % \
         (s1, s2, s3, s4, sp, d1, d2, d3, d4, dp, proto)
Exemplo n.º 3
0
    def prettyprint(self):
        """
    Looks something like this:

CURRENT FLOW TABLE:                            okay  drop mod/frg pend t/rx prot
111.222.233.244:12345 > 244.233.222.211:78901 343004 10000 100001 1000/2331 icmp
(192.168.1.100:54343)   (192.168.33.212:2333) opening_hash: 
                      <                       
    """
        pub_src, pub_dest = map(s.inet_ntoa, self.m_tuple[0:2])
        o_hash = self.m_tuple[2]
        # the other side is the only reliable indicator of each side's
        # public port number
        try:
            pub_src += ":" + ` util.bin2int(self.dest_flow[1]) `
            pub_dest += ":" + ` util.bin2int(self.src_flow[3]) `
        except:
            log.error("Weird error caused by flow %s (%s, %s)" % (`self.flow`, \
                      `self.dest_flow`, `self.src_flow`))
            log.error(traceback.format_exc())

        line1 = pub_src.center(21) + " > " + pub_dest.center(21)

        # 19 = len("192.168.1.100:65535") -- this should be okay unless
        # the private addresses & ports are rather unusual
        priv_src = priv_dest = "not firewalled".center(19)
        if self.src_links[0][0].alice_firewalled:
            priv_src = self.src_links[0][0].peers_private_ip
            priv_src += ":" + ` util.bin2int(self.src_flow[1]) `
        if self.dest_links[0][0].alice_firewalled:  # here, alice means bob :)
            priv_dest = self.dest_links[0][0].peers_private_ip
            priv_dest += ":" + ` util.bin2int(self.dest_flow[3]) `

        line2 = "(%19s)   (%19s)" % (priv_src, priv_dest)

        line1+= " %6g %5g %6g %4g/%4g " % (self.okay_packets, self.dropped_packets,\
          self.forged_packets, len(self.sent_packets), len(self.recd_packets))
        line1 += util.prot_name(util.bin2int(self.flow[4]))
        return line1 + "\n" + line2
Exemplo n.º 4
0
  def prettyprint(self):
    """
    Looks something like this:

CURRENT FLOW TABLE:                            okay  drop mod/frg pend t/rx prot
111.222.233.244:12345 > 244.233.222.211:78901 343004 10000 100001 1000/2331 icmp
(192.168.1.100:54343)   (192.168.33.212:2333) opening_hash: 
                      <                       
    """
    pub_src,pub_dest = map(s.inet_ntoa, self.m_tuple[0:2])
    o_hash = self.m_tuple[2]
    # the other side is the only reliable indicator of each side's
    # public port number
    try:
      pub_src += ":" + `util.bin2int(self.dest_flow[1])`
      pub_dest += ":" + `util.bin2int(self.src_flow[3])`
    except:
      log.error("Weird error caused by flow %s (%s, %s)" % (`self.flow`, \
                `self.dest_flow`, `self.src_flow`))
      log.error(traceback.format_exc())

    line1 = pub_src.center(21) + " > " + pub_dest.center(21)

    # 19 = len("192.168.1.100:65535") -- this should be okay unless
    # the private addresses & ports are rather unusual
    priv_src = priv_dest = "not firewalled".center(19)
    if self.src_links[0][0].alice_firewalled:
      priv_src = self.src_links[0][0].peers_private_ip
      priv_src += ":" + `util.bin2int(self.src_flow[1])`
    if self.dest_links[0][0].alice_firewalled: # here, alice means bob :)
      priv_dest = self.dest_links[0][0].peers_private_ip
      priv_dest += ":" + `util.bin2int(self.dest_flow[3])`

    line2 = "(%19s)   (%19s)" % (priv_src, priv_dest)

    line1+= " %6g %5g %6g %4g/%4g " % (self.okay_packets, self.dropped_packets,\
      self.forged_packets, len(self.sent_packets), len(self.recd_packets))
    line1 += util.prot_name(util.bin2int(self.flow[4]))
    return line1 + "\n" + line2
Exemplo n.º 5
0
def print_flow_tuple(f):
    """Pretty print the raw binary flow."""

    return (s.inet_ntoa(f[0]),bin2int(f[1]), s.inet_ntoa(f[2]), bin2int(f[3]),\
           util.prot_name(bin2int(f[4])))
Exemplo n.º 6
0
def print_flow_tuple(f):
    """Pretty print the raw binary flow."""

    return (s.inet_ntoa(f[0]),bin2int(f[1]), s.inet_ntoa(f[2]), bin2int(f[3]),\
           util.prot_name(bin2int(f[4])))