############################################################################ # # # ettercap -- etter.filter.examples -- filter source file # # # # Copyright (C) ALoR & NaGA # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation; either version 2 of the License, or # # (at your option) any later version. # # # ############################################################################ # make sure this filter will not be used... exit(); # display a message if the tcp port is 22 if (ip.proto == TCP) { if (tcp.src == 22 || tcp.dst == 22) { msg("SSH packet\n"); } } # log all IEC 61850 traffic when the destination ip is 192.168.1.2 if (ip.dst == '192.168.1.2' && tcp.src == 102) { log(DATA.data, "./logfile.log"); } # tip: if you get "filter engine: Cannot open file ./logfile.log" error, just chmod -R 777 ./logfile.log and run the filter again. # log all telnet traffic, also execute ./program on every packet if (ip.proto == TCP) { if (tcp.src == 23 || tcp.dst == 23) { log(DATA.data, "./logfile.log"); exec("./program"); } } # log all traffic except http if (ip.proto == TCP && tcp.src != 80 && tcp.dst != 80) { log(DATA.data, "./logfile.log"); } # log all traffic except http if (ip.proto == TCP && tcp.src != 80 && tcp.dst != 80) { log(DATA.data, "./logfile.log"); } # some operation on the payload of the packet if (DATA.data + 20 == 0x4142) { DATA.data + 20 = 0x4243; } else { DATA.data = "modified"; DATA.data + 20 = 0x4445; } # drop any packet containing "ettercap" if (search(DECODED.data, "ettercap")) { msg("some one is talking about us...\n"); drop(); kill(); } # log ssh decrypted packets matching the regexp if (ip.proto == TCP) { if (tcp.src == 22 || tcp.dst == 22) { if (regex(DECODED.data, ".*login.*")) { log(DECODED.data, "./decrypted_log"); } } } # dying packets if (ip.ttl < 5) { msg("The packet will die soon\n"); } # the same for IPv6 but make sure we really see IPv6 packets doing such trivial tests if (eth.proto == IP6 && ipv6.hl < 5) { msg("The IPv6 packet will die soon\n"); } # string comparison at a given offset if (DATA.data + 40 == "ette") { log(DATA.data, "./logfile.log"); } # inject a file after a specific packet if (tcp.src == 21 && search(DATA.data, "root")) { inject("./fake_response"); } # replace the entire packet with another log file if (tcp.src == 23 && search(DATA.data, "microsoft")) { drop(); inject("./logfile.log"); } # Modifying binary data by using external commands if (udp.dst == 53 && pcre_regex(DATA.data, ".*\x03com\x00.*")) { log(DATA.data, "/tmp/payload"); drop(); execinject("/bin/sed 's/\x03com\x00/\x02my\x04page\x02de\x00/g' /tmp/payload"); udp.len += 7; exec("/bin/rm /tmp/payload"); msg("faked"); } if (udp.dst == 53 && pcre_regex(DATA.data, ".*\x03com\x00.*")) { execreplace("/bin/sed 's/\x03com\x00/\x02my\x04page\x02de\x00/g'"); msg("faked"); } # filter only a specific ip address if (ip.src == '192.168.0.2') { drop(); } # do the same for IPv6 if (ipv6.src == '2001:db8::1') { drop(); } # combined both IPv4 and IPv6 if (eth.proto == IP && ip.dst == '192.168.0.2') { msg("drop IPv4"); drop(); } if (eth.proto == IP6 && ipv6.dst == '2001:db8::1') { msg("drop IPv6"); drop(); } # translate the port of the tcp packet from 80 to 81 if (tcp.dst == 80) { tcp.dst -= 1; tcp.dst += 2; } # identify and mangle ESP packets if (ip.proto == ESP) { DATA.data = "DEADDECAF"; } # eof # vim:ts=3:expandtab