• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

perl or python

onlyspfc

Weaksauce
Joined
Nov 1, 2006
Messages
86
Does anyone have any suggestions as to where I could find a simple Linux Perl or Python script that would ping and display the IP addresses from a web page?
I wasn't very lucky with Google.


Basically, I need something that can be used in the very crude example below:

>./(ipscan).pl (or .py) http[dot]www.aol[dot]com
XXX.XXX.XXX.XXX
XXX.XXX.XXX.XXX
XXX.XXX.XXX.XXX
XXX.XXX.XXX.XXX
XXX.XXX.XXX.XXX
XXX.XXX.XXX.XXX
XXX.XXX.XXX.XXX
XXX.XXX.XXX.XXX
 
googling "ping with perl" I ran across Net::ping (in FreeBSD it is
/usr/ports/ net? /p5-Net-Ping ) installable from...
............
no time today about how to get the IP from the .htm. Post maybe
if that Htm is local or on the remote web and/or you could
similarly google the remainder.
OTOH there are other huge-ish Perl (LWP) stuff that might include
already working code.
 
Any particular reason why you need this done with perl/python when you could use tools like nslookup, dig, or host?
 
The indentation of a couple of those lines is incorrect & indentation in Python is critical.

Try this:


Code:
#!/usr/bin/python
import os
import re
import time
import sys
from threading import Thread

class ping(Thread):
    def __init__ (self,ip):
        Thread.__init__(self)
        self.ip = ip
        self.status = -1
    def run(self):
        pingseq = os.popen("ping -q -c2 "+self.ip,"r")
        while 1:
            line = pingseq.readline()
            if not line: break
            result = re.findall(ping.getstatus,line)
            if result:
                self.status = int(result[0])
ping.getstatus = re.compile(r"(\d) received")
output = ("Not responding","Partial Response","Responding")

print time.ctime()

pinglist = []

for host in range(60,70):
    ip = "200.172.171."+str(host)
    current = ping(ip)
    pinglist.append(current)
    current.start()

for pingle in pinglist:
    pingle.join()
    print "Status from ",pingle.ip,"is",output[pingle.status]

print time.ctime()
 
Wow, Thank you sir! It does run fine now.
I do have another problem though. the script can't seem to make the addresses that don't respond to pings have the output "Not responding"..as to differ them from the ones that to respond.
Anything you type in the "ip=" and anything you specify in the "for host in range(1,255):" outputs "is responding".
IE:
pinglist = []

for host in range(1,4):
ip = "123.123.123."+str(host)
current = ping(ip)
pinglist.append(current)
current.start()

XXXXXXXXXXXXXXXXXXXXXXXXXX

OUTPUT:
Thu Dec 11 10:56:44 2008
Status from 123.123.123.1 is Responding
Status from 123.123.123.2 is Responding
Status from 123.123.123.3 is Responding
Thu Dec 11 10:56:45 2008
 
Back
Top