Python Forum
run scapy from python script ..
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
run scapy from python script ..
#1
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%") )
Reply
#2
Have you done the download and installation?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
(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
Reply
#4
Well, the next section on that web page is usage. Full disclosure: I don't know anything about scapy.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
(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]
Reply
#6
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?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#7
(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
Reply
#8
What happens if you just try import scapy.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#9
(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
Reply
#10
it's because your file name is scapy.py. You import your own file, not scapy package. Rename your file.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,274 Jun-29-2023, 11:57 AM
Last Post: gologica
  Permission issue when using scapy jao 3 9,852 Feb-05-2022, 06:14 PM
Last Post: snippsat
  error in scapy attribute 'haslayer' evilcode1 5 6,555 Mar-02-2021, 11:19 AM
Last Post: evilcode1
  How to kill a bash script running as root from a python script? jc_lafleur 4 5,931 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,313 May-28-2020, 05:27 PM
Last Post: micseydel
  Package python script which has different libraries as a single executable or script tej7gandhi 1 2,637 May-11-2019, 08:12 PM
Last Post: keames
  Help Importing Protocol Library Into Scapy joedirgy 0 2,069 May-02-2019, 07:31 PM
Last Post: joedirgy
  How to run python script which has dependent python script in another folder? PrateekG 1 3,161 May-23-2018, 04:50 PM
Last Post: snippsat
  How to call one python script and use its output in another python script lravikumarvsp 3 32,434 May-16-2018, 02:08 AM
Last Post: lravikumarvsp
  save the output from scapy to txt file evilcode1 11 10,875 Oct-10-2017, 02:44 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020