Error with Scapy scripts
#1
Hope someone can help me here, I’m getting the same TypeError: 'IP' object is not callable error with 2 different scapy scripts

The first script I’m sending packet to my router:

Code:
sr(IP(dst="192.168.1.254")/TCP(dport=[21,22,23,80]))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-50-42d44e8df85e> in <module>()
----> 1 sr(IP(dst="192.168.1.254")/TCP(dport=[21,22,23,80]))
TypeError: 'IP' object is not callable


The second script I’m sending packet to a domain:
a,b =sr(IP(dst="[url=http://www.danscourses.com/]www.danscourses.com[/url]")/TCP(sport=[RandShort()]*10))
---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-60-84b1eab0d90c> in <module>()
----> 1 a,b =sr(IP(dst="[url=http://www.danscourses.com/]www.danscourses.com[/url]")/TCP(sport=[RandShort()]*10))


TypeError: 'IP' object is not callable


Am I getting these errors I’m using a usb live persistence and not an Ethernet  ?
Thanks
Reply
#2
Out of curiosity, what's the output of print(IP)?
Reply
#3
(12-28-2020, 01:38 PM)FancyBear Wrote: Hope someone can help me here, I’m getting the same TypeError: 'IP' object is not callable error with 2 different scapy scripts

The first script I’m sending packet to my router:

Code:
sr(IP(dst="192.168.1.254")/TCP(dport=[21,22,23,80]))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-50-42d44e8df85e> in <module>()
----> 1 sr(IP(dst="192.168.1.254")/TCP(dport=[21,22,23,80]))
TypeError: 'IP' object is not callable


The second script I’m sending packet to a domain:
a,b =sr(IP(dst="[url=http://www.danscourses.com/]www.danscourses.com[/url]")/TCP(sport=[RandShort()]*10))
---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)

<ipython-input-60-84b1eab0d90c> in <module>()
----> 1 a,b =sr(IP(dst="[url=http://www.danscourses.com/]www.danscourses.com[/url]")/TCP(sport=[RandShort()]*10))


TypeError: 'IP' object is not callable


Am I getting these errors I’m using a usb live persistence and not an Ethernet  ?
Thanks

No, I don't think the live usb has anything to do with it. So tbh I have no idea what you did wrong from what info you've given. I did the exact same thing you did on my Debian 10, python 3.7.3. I just did
Code:
from scapy.all import IP, sr, TCP

Then I did the same thing you did with no issue. Make sure you're not importing it right. If there's no issue there, try reinstalling scapy.
Reply
#4
Thanks I’ll give it a try and let you know how I get on
Reply
#5
(12-29-2020, 02:00 AM)DeepLogic Wrote: No, I don't think the live usb has anything to do with it. So tbh I have no idea what you did wrong from what info you've given. I did the exact same thing you did on my Debian 10, python 3.7.3. I just did
Code:
from scapy.all import IP, sr, TCP

Then I did the same thing you did with no issue. Make sure you're not importing it right. If there's no issue there, try reinstalling scapy.

OK I tried from scapy.all import IP, sr, TCP and it worked like a charm Thanks for the suggestion, what’s puzzling me now is I rebooted my pc and I tried it the way I was getting issues with and now this way is working also, I haven’t reinstalled or anything don’t know what happened
Reply
#6
(12-30-2020, 01:02 PM)FancyBear Wrote:
(12-29-2020, 02:00 AM)DeepLogic Wrote: No, I don't think the live usb has anything to do with it. So tbh I have no idea what you did wrong from what info you've given. I did the exact same thing you did on my Debian 10, python 3.7.3. I just did
Code:
from scapy.all import IP, sr, TCP

Then I did the same thing you did with no issue. Make sure you're not importing it right. If there's no issue there, try reinstalling scapy.

OK I tried from scapy.all import IP, sr, TCP and it worked like a charm Thanks for the suggestion, what’s puzzling me now is I rebooted my pc and I tried it the way I was getting issues with and now this way is working also, I haven’t reinstalled or anything don’t know what happened

Scapy is kind of different than other python libraries lol. Glad you got it resolved.
Reply
#7
(12-30-2020, 01:02 PM)FancyBear Wrote: OK I tried from scapy.all import IP, sr, TCP and it worked like a charm Thanks for the suggestion, what’s puzzling me now is I rebooted my pc and I tried it the way I was getting issues with and now this way is working also, I haven’t reinstalled or anything don’t know what happened

Sometimes it's just magic Smile I hear rebooting your PC solves 20% of all IT-problems haha.
Reply
#8
(12-30-2020, 11:08 PM)Insider Wrote:
(12-30-2020, 01:02 PM)FancyBear Wrote: OK I tried from scapy.all import IP, sr, TCP and it worked like a charm Thanks for the suggestion, what’s puzzling me now is I rebooted my pc and I tried it the way I was getting issues with and now this way is working also, I haven’t reinstalled or anything don’t know what happened

Sometimes it's just magic Smile I hear rebooting your PC solves 20% of all IT-problems haha.

Lol that's true
Reply
#9
(12-30-2020, 11:08 PM)Insider Wrote: Sometimes it's just magic Smile I hear rebooting your PC solves 20% of all IT-problems haha.
I remember a place I used to work The IT guys first response to any issue was to ask “Have you tried turning it off and turning it back on again  Big Grin
Reply