|
I am new to tgt_host = "ipcalf.com"
class OverrideDNS:
def dns_request(self, flow: mitmproxy.dns.DNSFlow):
if any(q.name == tgt_host for q in flow.request.questions):
flow.response = flow.request.succeed(
[
dns.ResourceRecord.A(
tgt_host, IPv4Address("10.0.2.2"), ttl=10
)
]
)
logging.info("Overwrite DNS response")
flow.comment = "Overwrote by OverrideAP"
flow.marked = ":black_nib:"
addons = [OverrideDNS()]Tucked into https://docs.mitmproxy.org/stable/addons/overview/ I see there is a but when I follow that up with Going into the container via I see that it does have the new ordering merged via #7685 ( |
Replies: 2 comments
|
Aaaaah, was so close! The script itself was simply incomplete/buggy. Found in the logs (via
And proceeded from there. Basically the example I found was missing a whole bunch of imports. The official example https://docs.mitmproxy.org/stable/addons/examples/#dns-simple which I've now found would have been a better starting point. Combining what I'd started with, with what it needed to be as: from ipaddress import ip_address
from mitmproxy import dns
import logging
target_domain = "ipcalf.com"
fake_record = "10.0.0.42"
def dns_request(flow: dns.DNSFlow) -> None:
q = flow.request.question
if q.name == target_domain and q.type == dns.types.A:
logging.info(f"Spoofing record for {q.name}...")
flow.response = flow.request.succeed([
dns.ResourceRecord.A(
name=q.name,
ip=ip_address(fake_record),
)
])and it's working! 🎊 I guess I'll close this since I have my answer, but hopefully a more completely worked example (which should largely work with |
|
Hello good morning.... I am Lidia by my name, I could like to help if you need any assistant. |
Aaaaah, was so close! The script itself was simply incomplete/buggy.
Found in the logs (via
http://${mitmIp}:8081/#/flows?e=true) a Python error like:And proceeded from there. Basically the example I found was missing a whole bunch of imports. The official example https://docs.mitmproxy.org/stable/addons/examples/#dns-simple which I've now found would have been a better starting point. Combining what I'd started with, with what it needed to be as: