| 1 |
#!/bin/sh |
| 2 |
########################################################################### |
| 3 |
# |
| 4 |
# |
| 5 |
# This is free software. You can redistribute it and/or modify under |
| 6 |
# the terms of the GNU General Public License version 2. |
| 7 |
# |
| 8 |
# Copyright (C) 1999 by kra |
| 9 |
# |
| 10 |
########################################################################### |
| 11 |
# |
| 12 |
# |
| 13 |
# First Generation Transproxy support |
| 14 |
# |
| 15 |
# the MAC address of the gateway on the client have to be ARP spoofed |
| 16 |
# to MAC address of host running hunt. Then the transproxy in the |
| 17 |
# kernel can pick up the packets sent by client as if they will be |
| 18 |
# sent to the gateway |
| 19 |
# |
| 20 |
|
| 21 |
# |
| 22 |
# which port to redirect |
| 23 |
# |
| 24 |
DST_PORT=7000 |
| 25 |
#DST_PORT=80 |
| 26 |
|
| 27 |
# |
| 28 |
# port with transproxy module |
| 29 |
# |
| 30 |
DST_PORT_PROXY=7044 |
| 31 |
|
| 32 |
# |
| 33 |
# forward by kernel |
| 34 |
# |
| 35 |
# when is used kernel forwarding do not start ARP relayer daemon, |
| 36 |
# the kernel will forward such a pakcets itself and thous destined |
| 37 |
# to DST_PORT will redirect to DST_PORT_PROXY |
| 38 |
# |
| 39 |
# when the kernel forwarding is not used start ARP relayer daemon |
| 40 |
# to relay packets and to relayer database enter not to forward |
| 41 |
# traffic which is aimed for transproxy |
| 42 |
KERNEL_FORWARD=1 |
| 43 |
|
| 44 |
################################################################## |
| 45 |
|
| 46 |
# |
| 47 |
# turn forwarding on - needed for kernel transproxy to work |
| 48 |
# |
| 49 |
echo 1 >/proc/sys/net/ipv4/ip_forward |
| 50 |
|
| 51 |
# |
| 52 |
# set the default policy for the chains to accept |
| 53 |
# |
| 54 |
|
| 55 |
|
| 56 |
# |
| 57 |
# flush the chains |
| 58 |
# |
| 59 |
ipchains -F input |
| 60 |
ipchains -F forward |
| 61 |
ipchains -F output |
| 62 |
|
| 63 |
# |
| 64 |
# set transproxy from DST_PORT to DST_PORT_PROXY |
| 65 |
# |
| 66 |
ipchains -A input -p TCP -s 0.0.0.0/0 -d 0.0.0.0/0 $DST_PORT -j REDIRECT $DST_PORT_PROXY |
| 67 |
|
| 68 |
# ipfwadm untested |
| 69 |
#ipfwadm -I -a accept -P tcp -S 0.0.0.0/0 -D 0.0.0.0/0 $DST_PORT -r $DST_PORT_PROXY |
| 70 |
|
| 71 |
# |
| 72 |
# turn off ip forwarding for other traffic than transproxy |
| 73 |
# - otherwise every packet forwarded by kernel will trigger sending |
| 74 |
# the ICMP redirect message to tell the host that he should use |
| 75 |
# real gateway |
| 76 |
# |
| 77 |
# anyway it does not matter because the ARP address of gateway is ARP spoofed |
| 78 |
# on client so the client will not change anything. |
| 79 |
# |
| 80 |
# there are two approaches: |
| 81 |
# 1) forward packets with hunt relayer daemon - then start the relayer daemon |
| 82 |
# and deny forwarding in the kernel |
| 83 |
# 2) let the kernel forward them but it will also send ICMP redirect, |
| 84 |
# Linux kernel 2.2 allows as to block these redirects. |
| 85 |
# |
| 86 |
|
| 87 |
# |
| 88 |
# forwarded by kernel ? |
| 89 |
# |
| 90 |
if [ "$KERNEL_FORWARD" = 1 ]; then |
| 91 |
# |
| 92 |
# block ICMP redirects, that are send by default when we use kernel forwarding |
| 93 |
# |
| 94 |
ipchains -A output -p icmp -s 0.0.0.0/0 redirect -d 0.0.0.0/0 -j DENY |
| 95 |
|
| 96 |
ipchains -A forward -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT |
| 97 |
else |
| 98 |
ipchains -A forward -s 0.0.0.0/0 -d 0.0.0.0/0 -j DENY |
| 99 |
fi |
| 100 |
|
| 101 |
# ipfwadm untested |
| 102 |
#ipfwadm -F -a deny -S 0.0.0.0/0 -D 0.0.0.0/0 |
| 103 |
|