Neped

Solo disponible en BuenasTareas
  • Páginas : 3 (535 palabras )
  • Descarga(s) : 0
  • Publicado : 20 de febrero de 2012
Leer documento completo
Vista previa del texto
/* -----------------------------------------
Network Promiscuous Ethernet Detector.
Linux 2.0.x / 2.1.x, libc5 & GlibC
-----------------------------------------
(c) 1998savage@apostols.org
-----------------------------------------
Scan your subnet, and detect promiscuous

linuxes. It really works, not a joke.
-----------------------------------------*/
/*
* $Id: neped.c,v 1.4 1998/07/20 22:31:52 savage Exp $
*/

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include#include
#include

#define ETH_P_ARP 0x0806
#define MAX_PACK_LEN 2000
#define ETHER_HEADER_LEN 14
#define ARPREQUEST 1
#define ARPREPLY 2
#define perr(s) fprintf(stderr,s)struct arp_struct
{
u_char dst_mac[6];
u_char src_mac[6];
u_short pkt_type;
u_short hw_type;
u_short pro_type;
u_char hw_len;
u_char pro_len;
u_shortarp_op;
u_char sender_eth[6];
u_char sender_ip[4];
u_char target_eth[6];
u_char target_ip[4];
};

union
{
u_char full_packet[MAX_PACK_LEN];
struct arp_structarp_pkt;
}
a;

#define full_packet a.full_packet
#define arp_pkt a.arp_pkt
char *
inetaddr ( u_int32_t ip )
{
struct in_addr in;
in.s_addr = ip;
return inet_ntoa(in);
}

char *hwaddr (u_char * s)
{
static char buf[30];
sprintf (buf, "%02X:%02X:%02X:%02X:%02X:%02X", s[0], s[1], s[2], s[3], s[4], s[5]);
return buf;
}

void main (int argc, char **argv)
{
int rec;int len, from_len, rsflags;
struct ifreq if_data;
struct sockaddr from;
u_int8_t myMAC[6];
u_int32_t myIP, myNETMASK, myBROADCAST, ip, dip, sip;
if (getuid () != 0)
{perr ("You must be root to run this program!\n");
exit (0);
}
if (argc != 2)
{
fprintf(stderr,"Usage: %s eth0\n", argv[0]);
exit (0);
}

if ((rec = socket...
tracking img