Python Forum
run scapy from python script .. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: run scapy from python script .. (/thread-12715.html)

Pages: 1 2


run scapy from python script .. - evilcode1 - Sep-09-2018

hello all ...

im try to learn scapy ... i need to run this commands from python how i can do it : ?

Quote:ARP Ping

The fastest way to discover hosts on a local ethernet network is to use the ARP Ping method:

>>> ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.1.0/24"),timeout=2)

Answers can be reviewed with the following command:

>>> ans.summary(lambda (s,r): r.sprintf("%Ether.src% %ARP.psrc%") )



RE: run scapy from python script .. - ichabod801 - Sep-09-2018

Have you done the download and installation?


RE: run scapy from python script .. - evilcode1 - Sep-10-2018

(Sep-09-2018, 12:42 PM)ichabod801 Wrote: Have you done the download and installation?

yes i already did what is the next step ?
note : i use python 2.7


RE: run scapy from python script .. - ichabod801 - Sep-10-2018

Well, the next section on that web page is usage. Full disclosure: I don't know anything about scapy.


RE: run scapy from python script .. - evilcode1 - Sep-10-2018

(Sep-10-2018, 01:08 PM)ichabod801 Wrote: Well, the next section on that web page is usage. Full disclosure: I don't know anything about scapy.

im not asking about usage i know how to use it ...
but i need to know how to run it from python .... when i try to import
Quote:from scapy.all import *
via visual studio code i got this error :

Error:
Traceback (most recent call last): File "/root/Desktop/scapy.py", line 1, in <module> from scapy.all import * File "/root/Desktop/scapy.py", line 1, in <module> from scapy.all import * ImportError: No module named all
and the same for pycharm .... run it from python terminal it does not give me any error :
[Image: Screenshot_from_2018-09-10_11-36-49.png]


RE: run scapy from python script .. - ichabod801 - Sep-10-2018

Then it sounds like there is something wrong with your installation. Do you have two versions of Python? Could you have installed it for the one you're not importing from?


RE: run scapy from python script .. - evilcode1 - Sep-11-2018

(Sep-10-2018, 05:28 PM)ichabod801 Wrote: Then it sounds like there is something wrong with your installation. Do you have two versions of Python? Could you have installed it for the one you're not importing from?

i already remove python 3 and still the same problem :

this is my code :
from scapy.all import srp,Ether,ARP,conf
conf.verb=0
ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.20.0/24"),timeout=2)
for snd,rcv in ans:

    #print(rcv.sprintf("%Ether.src% - %ARP.psrc%"))
    print(rcv.sprintf("%ARP.psrc%"))
this is the error :

Error:
Traceback (most recent call last): File "/root/Desktop/scapy.py", line 1, in <module> from scapy.all import srp,Ether,ARP,conf File "/root/Desktop/scapy.py", line 1, in <module> from scapy.all import srp,Ether,ARP,conf ImportError: No module named all



RE: run scapy from python script .. - ichabod801 - Sep-11-2018

What happens if you just try import scapy.


RE: run scapy from python script .. - evilcode1 - Sep-12-2018

(Sep-11-2018, 12:23 PM)ichabod801 Wrote: What happens if you just try import scapy.

got this error :
Error:
Traceback (most recent call last): File "/root/Desktop/scapy.py", line 1, in <module> import scapy File "/root/Desktop/scapy.py", line 4, in <module> ans, unans = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst="192.168.20.0/24"),timeout=2) NameError: name 'srp' is not defined



RE: run scapy from python script .. - buran - Sep-12-2018

it's because your file name is scapy.py. You import your own file, not scapy package. Rename your file.