net.clackrouter.component.extension
Class DNSHijacker
java.lang.Object
net.clackrouter.component.base.ClackComponent
net.clackrouter.component.extension.DNSHijacker
- All Implemented Interfaces:
- Alarm
public class DNSHijacker
- extends ClackComponent
A fun little component that hijacks DNS requests being forwarded
by the IP layer and sends back false replies.
Fields inherited from class net.clackrouter.component.base.ClackComponent |
componentCell, m_has_error, m_log, m_name, m_num_ports, m_packetcount_in, m_packetcount_out, m_ports, mListeners, mRouter, pendingError, SIGNAL_ERROR_LEN_MSEC, UNIQUE_COUNT, view |
Method Summary |
void |
acceptPacket(VNSPacket packet,
int port_number)
Extract the packet and see if its UDP, and then DNS. |
boolean |
isModifying()
Reports whether this component modifies packets passed through it
This value is used by the static checking algorithm used to make sure port
connections are valid. |
void |
setHijackPair(java.lang.String toHijack,
java.net.InetAddress toReply)
Sets a new address to hijack, and false IP |
protected void |
setupPorts(int numPorts)
Allocates an array of ClackPort objects to be used by this component |
Methods inherited from class net.clackrouter.component.base.ClackComponent |
createCopy, createInputPullPort, createInputPushPort, createOutputPullPort, createOutputPushPort, error, fireListeners, getColor, getComponentCell, getHierarchicalView, getLog, getName, getNumPorts, getPacketCountIn, getPacketCountOut, getPendingError, getPort, getPropertiesView, getRouter, getSerializableProperties, getTime, getTypeName, getUniqueCount, getView, handlePullRequest, hasError, initializeProperties, isHierarchical, log, notifyAlarm, poll, registerListener, sendOutPort, setAlarm, setComponentCell, setName, setPendingError, setView, showErrorDialog, signalError, try_repaint, unregisterListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PORT_IN
public static int PORT_IN
PORT_OUT
public static int PORT_OUT
NUM_PORTS
public static int NUM_PORTS
DEFAULT_TARGET
public static java.lang.String DEFAULT_TARGET
DEFAULT_FALSE_ADDRESS
public static java.lang.String DEFAULT_FALSE_ADDRESS
DNSHijacker
public DNSHijacker(Router r,
java.lang.String name)
DNSHijacker
public DNSHijacker(Router r,
java.lang.String name,
java.lang.String target,
java.lang.String falseAddress)
setHijackPair
public void setHijackPair(java.lang.String toHijack,
java.net.InetAddress toReply)
- Sets a new address to hijack, and false IP
- Parameters:
toHijack
- the domain name to hijacktoReply
- the false IP address with which to reply
setupPorts
protected void setupPorts(int numPorts)
- Description copied from class:
ClackComponent
- Allocates an array of ClackPort objects to be used by this component
- Overrides:
setupPorts
in class ClackComponent
- Parameters:
numPorts
- the number of ports to create
acceptPacket
public void acceptPacket(VNSPacket packet,
int port_number)
- Extract the packet and see if its UDP, and then DNS. If it is, check if their is a query
for the target DNS name we are trying to hijack. If there is, we create a DNS answer and
add it to the original packet, modify the flags, flip the IP addresses and pass it on to
be forwarded.
- Overrides:
acceptPacket
in class ClackComponent
- Parameters:
packet
- The pushed packetport_number
- The number of the port that this packet is arriving on
isModifying
public boolean isModifying()
- Description copied from class:
ClackComponent
- Reports whether this component modifies packets passed through it
This value is used by the static checking algorithm used to make sure port
connections are valid. Sub-classes that do not modify packets should override
this method
- Overrides:
isModifying
in class ClackComponent
- Returns:
- by default, we assume the component modifies packets