lcrzo_spoof(3)

NAME
lcrzo_spoof - lcrzo library : spoofing

CONTENTS
/*    Laurent Constantin's network library (lcrzo)
                 lcrzo_spoof module
  Functions herein allow to spoof packets.
*/
/*-------------------------------------------------------------*/
/* definition of a lcrzo_spoof. You should not use its
   fields directly. */
/*-------------------------------------------------------------*/
typedef struct
{ lcrzo_int16 spooftype;
  lcrzo_device device;
  lcrzo_uint16       para_fragoctosize;
  lcrzo_bool         para_printbeforesending;
  lcrzo_printprofile para_printprofile;
  lcrzo_bool         para_useethforip;
  int fd;
  void *plli;
  void *padapter;
} lcrzo_spoof;
/*-------------------------------------------------------------*/
/* Name : lcrzo_spoof_init
   Description :
     Initialize a lcrzo_spoof.
   Input parameter(s) :
   Input/output parameter(s) :
   Output parameter(s) :
     *pspoof : lcrzo_spoof initialized
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_init(lcrzo_spoof *pspoof);
/* Name : lcrzo_spoof_close
   Description :
     Close a lcrzo_spoof.
   Input parameter(s) :
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof to close
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_close(lcrzo_spoof *pspoof);
/*-------------------------------------------------------------*/
/* Name : lcrzo_spoof_eth
   Description :
     Spoof an Ethernet packet.
   Input parameter(s) :
     device : device where to send the packet (ex: "eth0")
     packet : packet to send
     packetsize : size of packet
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_eth(lcrzo_spoof *pspoof,
		    lcrzo_constdevice device,
		    lcrzo_constdata packet,
		    lcrzo_int32 packetsize);
/* Name : lcrzo_spoof_ip
   Description :
     Spoof an IP packet.
   Input parameter(s) :
     packet : packet to send
     packetsize : size of packet
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_ip(lcrzo_spoof *pspoof,
		   lcrzo_constdata packet,
		   lcrzo_int32 packetsize);
/*-------------------------------------------------------------*/
/* Name : lcrzo_spoof_ipoptdata
   Description :
     Spoof an packet with {IP header, IP options, IP data}
   Input parameter(s) :
     hdrlip : IP header
     ipopt : IP options
     ipoptsize : IP options size
     data : IP data
     datasize : IP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_ipoptdata(lcrzo_spoof *pspoof,
			  lcrzo_hdrlip hdrlip,
			  lcrzo_constipopt ipopt,
			  lcrzo_uint8 ipoptsize,
			  lcrzo_constdata data,
			  lcrzo_uint16 datasize);
/* Name : lcrzo_spoof_ipoptudpdata
   Description :
     Spoof an packet with {IP header, IP options,
     UDP header, UDP data}
   Input parameter(s) :
     hdrlip : IP header
     ipopt : IP options
     ipoptsize : IP options size
     hdrludp : UDP header
     data : UDP data
     datasize : UDP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_ipoptudpdata(lcrzo_spoof *pspoof,
			     lcrzo_hdrlip hdrlip,
			     lcrzo_constipopt ipopt,
			     lcrzo_uint8 ipoptsize,
			     lcrzo_hdrludp hdrludp,
			     lcrzo_constdata data,
			     lcrzo_uint16 datasize);
/* Name : lcrzo_spoof_ipopttcpoptdata
   Description :
     Spoof an packet with {IP header, IP options,
     TCP header, TCP options, TCP data}
   Input parameter(s) :
     hdrlip : IP header
     ipopt : IP options
     ipoptsize : IP options size
     hdrltcp : TCP header
     tcpopt : TCP options
     tcpoptsize : TCP options size
     data : TCP data
     datasize : TCP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_ipopttcpoptdata(lcrzo_spoof *pspoof,
				lcrzo_hdrlip hdrlip,
				lcrzo_constipopt ipopt,
				lcrzo_uint8 ipoptsize,
				lcrzo_hdrltcp hdrltcp,
				lcrzo_consttcpopt tcpopt,
				lcrzo_uint8 tcpoptsize,
				lcrzo_constdata data,
				lcrzo_uint16 datasize);
/* Name : lcrzo_spoof_ipopticmpdata
   Description :
     Spoof an packet with {IP header, IP options,
     ICMP header, ICMP data}
   Input parameter(s) :
     hdrlip : IP header
     ipopt : IP options
     ipoptsize : IP options size
     hdrlicmp : ICMP header
     data : ICMP data
     datasize : ICMP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_ipopticmpdata(lcrzo_spoof *pspoof,
			      lcrzo_hdrlip hdrlip,
			      lcrzo_constipopt ipopt,
			      lcrzo_uint8 ipoptsize,
			      lcrzo_hdrlicmp hdrlicmp,
			      lcrzo_constdata data,
			      lcrzo_uint16 datasize);
/* Name : lcrzo_spoof_ethdata
   Description :
     Spoof an packet with {Ethernet header, Ethernet data}
   Input parameter(s) :
     device : device where to send the packet (ex: "eth0")
     hdrleth : Ethernet header
     data : Ethernet data
     datasize : Ethernet data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_ethdata(lcrzo_spoof *pspoof,
			lcrzo_constdevice device,
			lcrzo_hdrleth hdrleth,
			lcrzo_constdata data,
			lcrzo_uint16 datasize);
/* Name : lcrzo_spoof_ethipoptdata
   Description :
     Spoof an packet with {Ethernet header, IP header,
     IP options, IP data }
   Input parameter(s) :
     device : device where to send the packet (ex: "eth0")
     hdrleth : Ethernet header
     hdrlip : IP header
     ipopt : IP options
     ipoptsize : IP options size
     data : IP data
     datasize : IP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_ethipoptdata(lcrzo_spoof *pspoof,
			     lcrzo_constdevice device,
			     lcrzo_hdrleth hdrleth,
			     lcrzo_hdrlip hdrlip,
			     lcrzo_constipopt ipopt,
			     lcrzo_uint8 ipoptsize,
			     lcrzo_constdata data,
			     lcrzo_uint16 datasize);
/* Name : lcrzo_spoof_ethipoptudpdata
   Description :
     Spoof an packet with {Ethernet header, IP header,
     IP options, UDP header, UDP data}
   Input parameter(s) :
     device : device where to send the packet (ex: "eth0")
     hdrleth : Ethernet header
     hdrlip : IP header
     ipopt : IP options
     ipoptsize : IP options size
     hdrludp : UDP header
     data : UDP data
     datasize : UDP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_ethipoptudpdata(lcrzo_spoof *pspoof,
				lcrzo_constdevice device,
				lcrzo_hdrleth hdrleth,
				lcrzo_hdrlip hdrlip,
				lcrzo_constipopt ipopt,
				lcrzo_uint8 ipoptsize,
				lcrzo_hdrludp hdrludp,
				lcrzo_constdata data,
				lcrzo_uint16 datasize);
/* Name : lcrzo_spoof_ethipopttcpoptdata
   Description :
     Spoof an packet with {Ethernet header, IP header,
     IP options, TCP header, TCP options, TCP data}
   Input parameter(s) :
     device : device where to send the packet (ex: "eth0")
     hdrleth : Ethernet header
     hdrlip : IP header
     ipopt : IP options
     ipoptsize : IP options size
     hdrltcp : TCP header
     tcpopt : TCP options
     tcpoptsize : TCP options size
     data : TCP data
     datasize : TCP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_ethipopttcpoptdata(lcrzo_spoof *pspoof,
				   lcrzo_constdevice device,
				   lcrzo_hdrleth hdrleth,
				   lcrzo_hdrlip hdrlip,
				   lcrzo_constipopt ipopt,
				   lcrzo_uint8 ipoptsize,
				   lcrzo_hdrltcp hdrltcp,
				   lcrzo_consttcpopt tcpopt,
				   lcrzo_uint8 tcpoptsize,
				   lcrzo_constdata data,
				   lcrzo_uint16 datasize);
/* Name : lcrzo_spoof_ethipopticmpdata
   Description :
     Spoof an packet with {Ethernet header, IP header,
     IP options, ICMP header, ICMP data}
   Input parameter(s) :
     device : device where to send the packet (ex: "eth0")
     hdrleth : Ethernet header
     hdrlip : IP header
     ipopt : IP options
     ipoptsize : IP options size
     hdrlicmp : ICMP header
     data : ICMP data
     datasize : ICMP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_ethipopticmpdata(lcrzo_spoof *pspoof,
				 lcrzo_constdevice device,
				 lcrzo_hdrleth hdrleth,
				 lcrzo_hdrlip hdrlip,
				 lcrzo_constipopt ipopt,
				 lcrzo_uint8 ipoptsize,
				 lcrzo_hdrlicmp hdrlicmp,
				 lcrzo_constdata data,
				 lcrzo_uint16 datasize);
/* Name : lcrzo_spoof_etharp
   Description :
     Spoof an packet with {Ethernet header, ARP/RARP header}
   Input parameter(s) :
     device : device where to send the packet (ex: "eth0")
     hdrleth : Ethernet header
     hdrlarp : ARP header
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_etharp(lcrzo_spoof *pspoof,
		       lcrzo_constdevice device,
		       lcrzo_hdrleth hdrleth,
		       lcrzo_hdrlarp hdrlarp);
/*-------------------------------------------------------------*/
/* Name : lcrzo_spoof_get_fd
   Description :
     Get the associated file descriptors.
   Input parameter(s) :
     *pspoof : lcrzo_spoof from which obtain fds
   Input/output parameter(s) :
   Output parameter(s) :
     *pwritefd : file descriptor used for writing (-1 if closed)
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoof_get_fd(lcrzo_spoof *pspoof,
		       int *pwritefd);
/*-------------------------------------------------------------*/
/***************************************************************
 * Note about lcrzo_spoofeasy_xxx :                            *
 * These functions send easy packets. Indeed, in most cases,   *
 * we do not need to specify ip.id, tcp.windows, etc.          *
 ***************************************************************/
/* Name : lcrzo_spoofeasy_ipudp
   Description :
     Spoof an packet with {IP header, UDP header, UDP data}
   Input parameter(s) :
     srcipl : IP source address
     dstipl : IP destination address
     srcport : source port
     dstport : destination port
     udpdata : UDP data
     udpdatasize : UDP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoofeasy_ipudp(lcrzo_ipl srcipl,
			  lcrzo_ipl dstipl,
			  lcrzo_uint16 srcport,
			  lcrzo_uint16 dstport,
			  lcrzo_constdata udpdata,
			  lcrzo_uint16 udpdatasize);
/* Name : lcrzo_spoofeasy_iptcp
   Description :
     Spoof an packet with {IP header, TCP header, TCP data}
   Input parameter(s) :
     srcipl : IP source address
     dstipl : IP destination address
     srcport : source port
     dstport : destination port
     seqnum : sequence number
     acknum : acknowledge number
     syn : bit syn
     ack : bit ack
     fin : bit fin
     rst : bit rst
     tcpdata : TCP data
     tcpdatasize : TCP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoofeasy_iptcp(lcrzo_ipl srcipl,
			  lcrzo_ipl dstipl,
			  lcrzo_uint16 srcport,
			  lcrzo_uint16 dstport,
			  lcrzo_uint32 seqnum,
			  lcrzo_uint32 acknum,
			  lcrzo_bool syn,
			  lcrzo_bool ack,
			  lcrzo_bool fin,
			  lcrzo_bool rst,
			  lcrzo_constdata tcpdata,
			  lcrzo_uint16 tcpdatasize);
/* Name : lcrzo_spoofeasy_ipicmp
   Description :
     Spoof an packet with {IP header, ICMP header, ICMP data}
   Input parameter(s) :
     srcipl : IP source address
     dstipl : IP destination address
     type : ICMP type
     code : ICMP code
     icmpdata : ICMP data
     icmpdatasize : ICMP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoofeasy_ipicmp(lcrzo_ipl srcipl,
			   lcrzo_ipl dstipl,
			   lcrzo_uint8 type,
			   lcrzo_uint8 code,
			   lcrzo_constdata icmpdata,
			   lcrzo_uint16 icmpdatasize);
/* Name : lcrzo_spoofeasy_ethipudp
   Description :
     Spoof an packet with {Ethernet header, IP header, UDP header, UDP data}
   Input parameter(s) :
     device : device where the packet has to be sent
     srcetha : Ethernet source address
     dstetha : Ethernet destination address
     srcipl : IP source address
     dstipl : IP destination address
     srcport : source port
     dstport : destination port
     udpdata : UDP data
     udpdatasize : UDP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoofeasy_ethipudp(lcrzo_constdevice device,
			     lcrzo_constetha srcetha,
			     lcrzo_constetha dstetha,
			     lcrzo_ipl srcipl,
			     lcrzo_ipl dstipl,
			     lcrzo_uint16 srcport,
			     lcrzo_uint16 dstport,
			     lcrzo_constdata udpdata,
			     lcrzo_uint16 udpdatasize);
/* Name : lcrzo_spoofeasy_ethiptcp
   Description :
     Spoof an packet with {Ethernet header, IP header, TCP header, TCP data}
   Input parameter(s) :
     device : device where the packet has to be sent
     srcetha : Ethernet source address
     dstetha : Ethernet destination address
     srcipl : IP source address
     dstipl : IP destination address
     srcport : source port
     dstport : destination port
     seqnum : sequence number
     acknum : acknowledge number
     syn : bit syn
     ack : bit ack
     fin : bit fin
     rst : bit rst
     tcpdata : TCP data
     tcpdatasize : TCP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoofeasy_ethiptcp(lcrzo_constdevice device,
			     lcrzo_constetha srcetha,
			     lcrzo_constetha dstetha,
			     lcrzo_ipl srcipl,
			     lcrzo_ipl dstipl,
			     lcrzo_uint16 srcport,
			     lcrzo_uint16 dstport,
			     lcrzo_uint32 seqnum,
			     lcrzo_uint32 acknum,
			     lcrzo_bool syn,
			     lcrzo_bool ack,
			     lcrzo_bool fin,
			     lcrzo_bool rst,
			     lcrzo_constdata tcpdata,
			     lcrzo_uint16 tcpdatasize);
/* Name : lcrzo_spoofeasy_ethipicmp
   Description :
     Spoof an packet with {Ethernet header, IP header, ICMP header, ICMP data}
   Input parameter(s) :
     device : device where the packet has to be sent
     srcetha : Ethernet source address
     dstetha : Ethernet destination address
     srcipl : IP source address
     dstipl : IP destination address
     type : ICMP type
     code : ICMP code
     icmpdata : ICMP data
     icmpdatasize : ICMP data size
   Input/output parameter(s) :
     *pspoof : lcrzo_spoof where to work
   Output parameter(s) :
   Normal return values :
     LCRZO_ERR_OK : ok
*/
int lcrzo_spoofeasy_ethipicmp(lcrzo_constdevice device,
			      lcrzo_constetha srcetha,
			      lcrzo_constetha dstetha,
			      lcrzo_ipl srcipl,
			      lcrzo_ipl dstipl,
			      lcrzo_uint8 type,
			      lcrzo_uint8 code,
			      lcrzo_constdata icmpdata,
			      lcrzo_uint16 icmpdatasize);
/*-------------------------------------------------------------*/
/* if we want to fragment, we can set the fragoctosize of
   a lcrzo_spoof. This value corresponds to
     maximum_IP_data_size / 8
   For example, to send packets with only 24 bytes of data :
     lcrzo_spoof_set_fragoctosize(&spoof, 3);
*/
int lcrzo_spoof_set_fragoctosize(lcrzo_spoof *pspoof,
				 lcrzo_uint16 fragoctosize);
int lcrzo_spoof_get_fragoctosize(lcrzo_spoof *pspoof,
				 lcrzo_uint16 *pfragoctosize);
/*-------------------------------------------------------------*/
/* we can set this value if we want to print every packet
   sent by a lcrzo_spoof. For example :
     lcrzo_spoof_set_printbeforesending(&spoof, 1);
*/
int lcrzo_spoof_set_printbeforesending(lcrzo_spoof *pspoof,
				       lcrzo_bool printbeforesending);
int lcrzo_spoof_get_printbeforesending(lcrzo_spoof *pspoof,
				       lcrzo_bool *pprintbeforesending);
/*-------------------------------------------------------------*/
/* if we print packets before sending them, we can change
   the way they are printed. For example :
     lcrzo_spoof_set_printprofile(&spoof,
                                  LCRZO_PRINTPROFILE_HEXANCHMS);
*/
int lcrzo_spoof_set_printprofile(lcrzo_spoof *pspoof,
				 lcrzo_printprofile printprofile);
int lcrzo_spoof_get_printprofile(lcrzo_spoof *pspoof,
				 lcrzo_printprofile *pprintprofile);
/*-------------------------------------------------------------*/
/* if we spoof ethernet packet when the user wants to only
     spoof IP. This is very useful on systems like Solaris
     which modify IP header values. */
int lcrzo_spoof_set_useethforip(lcrzo_spoof *pspoof,
				lcrzo_bool useethforip);
int lcrzo_spoof_get_useethforip(lcrzo_spoof *pspoof,
				lcrzo_bool *puseethforip);

SEE ALSO
lcrzo(3), lcrzo_types(3), lcrzo_data(3), lcrzo_string(3), lcrzo_time(3), lcrzo_file(3), lcrzo_address(3), lcrzo_device(3), lcrzo_list(3), lcrzo_process(3), lcrzo_ipc(3), lcrzo_header(3), lcrzo_ipopt(3), lcrzo_tcpopt(3), lcrzo_packet(3), lcrzo_icmp(3), lcrzo_print(3), lcrzo_record(3), lcrzo_conf(3), lcrzo_spoof(3), lcrzo_sniff(3), lcrzo_sock(3), lcrzo_wait(3), lcrzo_global(3), lcrzo_error(3) lcrzo_misc(3), lcrzo_obso(3),