Debian Codegraph @

share/etter.filter.examples

raw
1 ############################################################################
2 # #
3 # ettercap -- etter.filter.examples -- filter source file #
4 # #
5 # Copyright (C) ALoR & NaGA #
6 # #
7 # This program is free software; you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation; either version 2 of the License, or #
10 # (at your option) any later version. #
11 # #
12 ############################################################################
13
14 # make sure this filter will not be used...
15 exit();
16
17
18 # display a message if the tcp port is 22
19 if (ip.proto == TCP) {
20 if (tcp.src == 22 || tcp.dst == 22) {
21 msg("SSH packet\n");
22 }
23 }
24
25
26 # log all IEC 61850 traffic when the destination ip is 192.168.1.2
27 if (ip.dst == '192.168.1.2' && tcp.src == 102) {
28 log(DATA.data, "./logfile.log");
29 }
30 # tip: if you get "filter engine: Cannot open file ./logfile.log" error, just chmod -R 777 ./logfile.log and run the filter again.
31
32
33 # log all telnet traffic, also execute ./program on every packet
34 if (ip.proto == TCP) {
35 if (tcp.src == 23 || tcp.dst == 23) {
36 log(DATA.data, "./logfile.log");
37 exec("./program");
38 }
39 }
40
41
42 # log all traffic except http
43 if (ip.proto == TCP && tcp.src != 80 && tcp.dst != 80) {
44 log(DATA.data, "./logfile.log");
45 }
46
47
48 # log all traffic except http
49 if (ip.proto == TCP && tcp.src != 80 && tcp.dst != 80) {
50 log(DATA.data, "./logfile.log");
51 }
52
53
54 # some operation on the payload of the packet
55 if (DATA.data + 20 == 0x4142) {
56 DATA.data + 20 = 0x4243;
57 } else {
58 DATA.data = "modified";
59 DATA.data + 20 = 0x4445;
60 }
61
62
63 # drop any packet containing "ettercap"
64 if (search(DECODED.data, "ettercap")) {
65 msg("some one is talking about us...\n");
66 drop();
67 kill();
68 }
69
70
71 # log ssh decrypted packets matching the regexp
72 if (ip.proto == TCP) {
73 if (tcp.src == 22 || tcp.dst == 22) {
74 if (regex(DECODED.data, ".*login.*")) {
75 log(DECODED.data, "./decrypted_log");
76 }
77 }
78 }
79
80 # dying packets
81 if (ip.ttl < 5) {
82 msg("The packet will die soon\n");
83 }
84
85 # the same for IPv6 but make sure we really see IPv6 packets doing such trivial tests
86 if (eth.proto == IP6 && ipv6.hl < 5) {
87 msg("The IPv6 packet will die soon\n");
88 }
89
90 # string comparison at a given offset
91 if (DATA.data + 40 == "ette") {
92 log(DATA.data, "./logfile.log");
93 }
94
95 # inject a file after a specific packet
96 if (tcp.src == 21 && search(DATA.data, "root")) {
97 inject("./fake_response");
98 }
99
100 # replace the entire packet with another log file
101 if (tcp.src == 23 && search(DATA.data, "microsoft")) {
102 drop();
103 inject("./logfile.log");
104 }
105
106 # Modifying binary data by using external commands
107 if (udp.dst == 53 && pcre_regex(DATA.data, ".*\x03com\x00.*")) {
108 log(DATA.data, "/tmp/payload");
109 drop();
110 execinject("/bin/sed 's/\x03com\x00/\x02my\x04page\x02de\x00/g' /tmp/payload");
111 udp.len += 7;
112 exec("/bin/rm /tmp/payload");
113 msg("faked");
114 }
115
116 if (udp.dst == 53 && pcre_regex(DATA.data, ".*\x03com\x00.*")) {
117 execreplace("/bin/sed 's/\x03com\x00/\x02my\x04page\x02de\x00/g'");
118 msg("faked");
119 }
120
121 # filter only a specific ip address
122 if (ip.src == '192.168.0.2') {
123 drop();
124 }
125
126 # do the same for IPv6
127 if (ipv6.src == '2001:db8::1') {
128 drop();
129 }
130
131 # combined both IPv4 and IPv6
132 if (eth.proto == IP && ip.dst == '192.168.0.2') {
133 msg("drop IPv4");
134 drop();
135 }
136 if (eth.proto == IP6 && ipv6.dst == '2001:db8::1') {
137 msg("drop IPv6");
138 drop();
139 }
140
141 # translate the port of the tcp packet from 80 to 81
142 if (tcp.dst == 80) {
143 tcp.dst -= 1;
144 tcp.dst += 2;
145 }
146
147 # identify and mangle ESP packets
148 if (ip.proto == ESP) {
149 DATA.data = "DEADDECAF";
150 }
151
152 # eof
153
154 # vim:ts=3:expandtab