3
<title>Cool Things You Can do With Endpoint</title>
6
<h1>Endpoint: Tips and Tricks</h1>
8
<h2>Send/Receive Normal TCP/UDP Traffic</h2>
11
// Choose one of these. It'll return once a connection is established.
12
Endpoint ep(TCP | CLIENT, "example.com:80"); // Active open
13
Endpoint ep(TCP | SERVER, ":80"); // Passive open
14
Endpoint ep(UDP | CLIENT, "example.com:41170"); // Send
15
Endpoint ep(UDP | SERVER, ":41170"); // Receive
17
if (!ep) // If couldn't open socket
18
std::cout << "failed: " << std::endl;
20
// Print out the local and remote address
21
std::cout << "New socket: " << ep << std::endl;
23
// Find out who we're connected to (note that this is shown above also)
24
std::cout << "Connected to: " << string(ep.m_remote) << std::endl;
31
<p>If your host supports it, IPv6 will be automatically enabled. DNS names
32
will resolve to 128-bit IPv6 addresses. To <i>specifically</i> use IPv6:
34
EndpointAddrlist::g_default_family = AF_INET6;
36
<p>Now all DNS names will resolve to IPv6 addresses. (See also: RES_USE_INET6)
38
<p>To connect to an IPv6 host without DNS, simply write the address. Use
39
square brackets around the IPv6 address if you're also specifying a port.
40
For example, to connect to a local web server you're running on IPv6:
42
Endpoint ep(TCP | CLIENT, "[::1]:80");
46
<p>If you have IPv6 support but don't want it to get in the way, use:
48
EndpointAddrlist::g_default_family = AF_INET;
51
<h2>Use Raw Sockets</h2>
52
<p>Endpoint now supports raw sockets with IPv4 (IPv6 doesn't have raw sockets;
53
you have to use datalink access for that, which Endpoint doesn't currently
54
support). If you want to write your own IP header, use RAW.
56
<p>A number of transport-layer protocols that sit on top of IPv4 are available
57
to Endpoint. To write IGMP packets, for example, use RAW_ICMP. This will make
58
the IP header for you, but you have to write the IGMP header.
60
<p>RAW_UDP and RAW_ICMP automatically create the UDP or ICMP header for you.
61
See the next topic for using ICMP.
64
<h2>Send ICMP Messages</h2>
65
<p>Simply create a RAW_ICMP | CLIENT socket with your destined address,
66
specifying a port number of <i>type</i>,<i>code</i>. For example, to send a
67
"host unreachable" ICMP message to 10.3.2.1:
70
Endpoint ep(RAW_ICMP | CLIENT, "10.3.2.1:3,1");
75
<p>To send a "ping" (ICMP echo request), replace "3,1" with "8,0". See the
76
official <a href="http://www.iana.org/assignments/icmp-parameters">IANA ICMP
77
parameters</a> for more information.
79
<p>ICMP can be used as a covert channel. See
80
<a href="http://www.phrack.org/phrack/49/P49-06">Project Loki: ICMP
81
Tunnelling</a> in Phrack 49, by Alhambra and daemon9 for an article about this
82
steganographic process.