Use simple pythonic syntax to compose TCPDump expressions


Ping requests coming from blacklisted ip spaces

    net1 = Expr(NET_SRC, '')
    net2 = Expr(NET_SRC, '')
    proto = Expr(ICMP) and not Expr(ICMP.ECHO) and not Expr(ICMP.ECHO_REPLY)

    final = proto and (net1 or net2)


All outbound SSH, RDP, TELNET, or FTP initiations coming from suspected compromised host, HTTP POST requests to suspicious networkors from suspected compromised host, and all inbound traffic from not-well-known source port to compromised host

    host = ''
    propogation_ports = Expr(PORT, 20) or Expr(PORT, 21)  or Expr(PORT, 3389)
    propogation = Expr(HOST_SRC, host) and propogation_ports

    net1 = Expr(NET_DST, '')
    net2 = Expr(NET_DST, '')
    http_post = Expr(HOST_SRC, host) and (net1 or net2) and Expr(HTTP.POST)

    approved_ports = Expr(PORT, 21) or Expr(PORT, 53) or Expr(PORT, 135) or Expr(PORT, 443)
    inbound = Expr(HOST_DST, host) and not approved_ports

    final = propogation or http_post or inbound


All DNS traffic not bound for internal DNS server on UDP and all inbound UDP traffic to suspected compromised host on known suspicious ports

    host = ''

    # indicator 1 - exfil via DNS
    dns_proto = Expr(TCP)
    dns_server = Expr(HOST_DST, '')
    dns_approved = dns_server and dns_proto

    bad_dns = Expr(HOST_SRC, host) and Expr(PORT_DST, 53) and not dns_approved

    # indicator 2 - UDP traffic
    port1 = Expr(PORT_DST, 54321)	# known suspicious port1
    port2 = Expr(PORT_DST, 30003)	# known suspicious port2

    bad_udp = Expr(HOST_DST, host) and Expr(UDP) and (port1 or port2)

    Compile(bad_dns or bad_udp)

All non-SSH, TELNET, RDP, and ICMP traffic coming from

    src_host_1 = Expr(HOST_SRC, '')
    ports = Expr(PORT, 22) and Expr(PORT, 20) and Expr(PORT, 3389)

    final_expr = src_host_1 and not (ports and Expr(ICMP))


All attempts to change cipher suites within a TLS connection with local database server

    tls_port = Expr(PORT, 1433)
    tls_v1_2 = Expr(TLS)
    sql_server_ip = Expr(HOST, '')
    tls_change_cipher = Expr(TLS.CHANGE_CIPHER)

    final = tls_port and tls_v1_2 and sql_server_ip and tls_change_cipher