Skip to content

Instantly share code, notes, and snippets.

@powerexploit
Created October 9, 2019 17:19
Show Gist options
  • Save powerexploit/158606d8c60827abbeca86880d2e020c to your computer and use it in GitHub Desktop.
Save powerexploit/158606d8c60827abbeca86880d2e020c to your computer and use it in GitHub Desktop.
pingscanner using python
#!/usr/bin/python3
#pingscanner.py
import sys
from scapy.all import *
ip = sys.argv[1] # command line argument
icmp = IP(dst=ip)/ICMP()
#icmp = IP(dst=ip)/TCP()
#IP defines the protocol for IP addresses
#dst is the destination IP address
#TCP defines the protocol for the ports
resp = sr1(icmp,timeout=10)
if resp == None:
print("This host is down")
else:
print("This host is up")
@powerexploit
Copy link
Author

Hello! Why do I get this error on running?
PermissionError: [Errno 1] Operation not permitted

How do I resolve it?

run script as root.
if you are using Ubuntu run it as :
sudo python3 pingscanner.py 192.168.x.x.

@rharix19
Copy link

How to run this script without root/sudo permission?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment