Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global name 'IP' is not defined #1

Closed
daniel-infosec opened this issue Jan 16, 2018 · 4 comments
Closed

global name 'IP' is not defined #1

daniel-infosec opened this issue Jan 16, 2018 · 4 comments

Comments

@daniel-infosec
Copy link

After running mitm6 for a while, I begin seeing the following error:

Unhandled Error Traceback (most recent call last): File "mitm6.py", line 286, in <module> main() File "mitm6.py", line 283, in main reactor.run() File "/root/.pyenv/versions/mitm6v2/local/lib/python2.7/site-packages/Twisted-17.9.0-py2.7-linux-x86_64.egg/twisted/internet/base.py", line 1243, in run self.mainLoop() File "/root/.pyenv/versions/mitm6v2/local/lib/python2.7/site-packages/Twisted-17.9.0-py2.7-linux-x86_64.egg/twisted/internet/base.py", line 1252, in mainLoop self.runUntilCurrent() --- <exception caught here> --- File "/root/.pyenv/versions/mitm6v2/local/lib/python2.7/site-packages/Twisted-17.9.0-py2.7-linux-x86_64.egg/twisted/internet/base.py", line 851, in runUntilCurrent f(*a, **kw) File "mitm6.py", line 212, in parsepacket send_dns_reply(p) File "mitm6.py", line 137, in send_dns_reply ip = p[IP] exceptions.NameError: global name 'IP' is not defined

Restarting the application will result in this error reappearing. The only way I could fix it was reinstalling the application, but then the error reappeared.

I installed the application in a pyenv virtualenv, python version 2.7.9.

uname -a

Linux XXXXXX 4.0.0-kali1-amd64 #1 SMP Debian 4.0.4-1+kali2 (2015-06-03) x86_64 GNU/Linux

@dirkjanm
Copy link
Owner

Seems like there is an import missing. Could you try to change line 2:

from scapy.all import sniff, ls, ARP, IPv6, DNS, DNSRR, Ether, conf

to this:

from scapy.all import sniff, ls, ARP, IPv6, DNS, DNSRR, Ether, conf, IP

And see if the error comes up again?

@daniel-infosec
Copy link
Author

That appears to have resolved it. I also didn't get this error in python 3, so I just switched to that.

I'm curious why it would work at first and then fail repeatedly after a period of time.

@dirkjanm
Copy link
Owner

Well that code only is used when someone attempts to use your machine as DNS server over IPv4, which isn't something that should happen a lot

@dirkjanm
Copy link
Owner

Also thanks for confirming, I'll push a fix this weekend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants