免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 9427 | 回复: 12

发送免费ARP解决IP冲突 [复制链接]

论坛徽章:
0
发表于 2009-12-07 16:28 |显示全部楼层
上周五,公司内网有人占用我的私人IP,搞的我上不了网,很是恼火,
由于公司内网有很多机器,不可能主动查找出事谁

所以想起来发送免费ARP似乎可以解决这个问题,于是就用python libnet库写了一个脚本发送ARP


估计对方发现这个IP冲突了,对方很快就释放了
可能是同事无意占用了我的IP

上传脚本,可能对大家有用,


  1. #!/usr/bin/python

  2. import sys
  3. import libnet
  4. from libnet.constants import *

  5. l = libnet.context(
  6.                   LINK,                        # The injection type
  7.                     'eth0'                       # Device name
  8.                       )
  9. dst_ip = l.name2addr4(
  10.                   '10.0.0.9', # Let's get the network byte ordered representation of this IP
  11.                     DONT_RESOLVE
  12.                       )

  13. dst='ffffffffffff'
  14. dst_mac = dst.decode("hex")
  15. src='001d92e08f26'
  16. src_mac = src.decode("hex")
  17. arp_tag = l.autobuild_arp(
  18.                 1,
  19.                 #l.get_hwaddr(),
  20.                 src_mac,
  21.                 dst_ip,
  22.                 dst_mac,
  23.                 dst_ip,
  24.                 )

  25. eth_tag =  l.autobuild_ethernet(
  26.                 dst_mac,
  27.                 0x0806,
  28.                 )

  29. # Now let's write the packet and check for an error
  30. # tcp syn google.com
  31. import time
  32. while 1:
  33.         time.sleep(10)
  34.         l.write()
  35. #l.write()
复制代码

论坛徽章:
0
发表于 2009-12-07 16:29 |显示全部楼层
其中涉及到本机的IP和MAC地址,直接修改就能用了
也可以帮助其他机器发送免费ARP,只要IP和MAC对应就可以了

论坛徽章:
0
发表于 2009-12-07 18:28 |显示全部楼层
libnet,这个库还可以模拟发送其他包吗?

论坛徽章:
0
发表于 2009-12-08 10:01 |显示全部楼层
ARP,ICMP,BGP,SNMP等,很多种,不知楼上需要模拟哪种包

论坛徽章:
0
发表于 2009-12-09 03:40 |显示全部楼层
不错不错,学习了

论坛徽章:
0
发表于 2009-12-15 18:42 |显示全部楼层
用scapy也可以。

论坛徽章:
0
发表于 2009-12-29 00:58 |显示全部楼层
原帖由 nmweizi 于 2009-12-15 18:42 发表
用scapy也可以。

给一个demo吧

论坛徽章:
0
发表于 2010-11-21 18:08 |显示全部楼层
  1. #!/usr/bin/python
  2. import sys
  3. from scapy.all import ARP,send

  4. a=ARP()
  5. a.hwsrc=sys.argv[1]
  6. a.psrc=sys.argv[2]
  7. a.hwdst=sys.argv[3]
  8. a.pdst=sys.argv[4]

  9. send(a)
复制代码
简单的实现。

论坛徽章:
0
发表于 2010-11-25 19:21 |显示全部楼层
可以发送tcp syn么?

论坛徽章:
0
发表于 2010-11-25 21:26 |显示全部楼层
标记之
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP