Re: Sample code for sending raw packets?
Re: Sample code for sending raw packets?
- Subject: Re: Sample code for sending raw packets?
- From: Dave Camp <email@hidden>
- Date: Fri, 13 Oct 2006 11:37:29 -0700
On Oct 13, 2006, at 11:26 AM, Justin C. Walker wrote:
On Oct 13, 2006, at 11:03 , Dave Camp wrote:
- Add a static entry to the ARP table for x.x.x.x -> Printer MAC
Address, where x.x.x.x is the new IP address they want to set the
printer to and the Printer MAC address is the MAC address of the
printer.
- Send an ICMP ping to the printer.
- Remove the ARP entry
Yes, they set the IP address of the printer by pinging it. I'll
wait here for a bit while you cry.
Sounds ready-made for DOS attacks...
I'm going to guess that fiddling with the local ARP table is
probably not such a swell idea and that I'd be better off hand
rolling my own raw ICMP ping packet at the ethernet level to get
the job done. I think it would have to be at the ethernet level as
I need to specify the IP address and destination MAC address
myself. I know I will have to have a SUID root helper tool to do
this.
Assuming that is the case, I was wondering if someone could point
me to some sample code illustrating how to build a raw ethernet
packet. I've looked in the Unix Programming Book, but it only
covers raw IPv4/6 packets, not raw ethernet packets. Most of the
sample code I've found on the net is for Linux which appears to
use different AF_ and protocol constants than BSD.
If you really want ICMP 'Echo' packets, check the source for
'ping' (or, just use 'ping' in a shell script :-}). It's on the
darwin site (<http://developer.apple.com/darwin>).
Why do you want to use "raw ethernet" if you want to send ICMP
packets?
I'm not well versed in the lower levels of ethernet, but it's my
understanding that to form a packet where the MAC address does not
match the destination IP address in the IP layer, I'd have to roll my
own ethernet packet. The printer is going to listen to the packet
because the MAC address matches and then change it's internal IP
address to match what is in the packet.
Or am I misunderstanding something?
Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden