Ejemplo n.º 1
0
    def ping_stratux(self):
        """
        Run a complete ping against the Stratux.
        This keeps the connection alive.
        """
        ping.verbose_ping(configuration.CONFIGURATION.stratux_address())

        if AdsbTrafficClient.INSTANCE is not None:
            AdsbTrafficClient.INSTANCE.keep_alive()
  def run(self):
    while True:
        try:
          instruction = self.Q_in.get(True)
        except Queue.Empty: # Not needed
          pass

        if instruction:
            self.rate = instruction["rate"]
            self.pktsize = instruction["size"]
            self.target = instruction["target"]
            BUCKET = 0

            sleep_delay = float(1) / self.rate # Delay should be (1 - rate * RTT)/rate ????? <--------------------------------------------------
            counter = {}
            counter['ICMP_probe'] = [] # appro
            for i in range(0,self.rate): # Do it for 1 second worth of the attack, equal to the increase of the attack rate
              ping_delay = ping.verbose_ping(self.target,1,1,self.pktsize) #timeout = 1
              ## Sending ("ping_delay")
              if ping_delay == float(1):
                  BUCKET += 1
                  if BUCKET > 2:
                      break
              counter['ICMP_probe'].append(ping_delay)
              time.sleep(sleep_delay)

            print counter
            if BUCKET > 2:
                CONCLUSION = "NO"
            else:
                CONCLUSION = "YES"
            self.Q_out.put(CONCLUSION)
Ejemplo n.º 3
0
 def check_connections(self):
     import ping, socket
     connections_good = True
     try:
         ping.verbose_ping(self.base_page_address, count=1)
         delay = ping.Ping(self.base_page_address, timeout=2000).do()
     except socket.error:
         connections_good = False
         print("ping error when trying to connect to: ", self.base_page_address)
     try:
         ping.verbose_ping(self.video_stream_address, count=1)
         delay = ping.Ping(self.video_stream_address, timeout=2000).do()
     except socket.error:
         connections_good = False
         print("ping error when trying to connect to: ", self.video_stream_address)
     return connections_good
Ejemplo n.º 4
0
 def run(self):
     self._semaphore_ip.acquire()
     counter, dest_addr = ping.verbose_ping(self._ip)
     if counter == 2 or counter == '1':
         counter = '!'
     print "-- %s ---> %s ---> %s\n" % (counter, dest_addr, self.getName())
     self._semaphore_ip.release()
Ejemplo n.º 5
0
def ping_host(host):
    print("pinging ", host, "... ", end="")
    if ping.verbose_ping(host):
        print("reached OK, ", end="")
        return True
    print("not reached, ", end="")
    return False
Ejemplo n.º 6
0
def ping_host(host):
    print ("pinging ", host, "... ", end="")
    if ping.verbose_ping(host):
        print ("reached OK, ", end="")
        return True
    print ("not reached, ", end="")
    return False
Ejemplo n.º 7
0
def ping_baidu():

    if ping.verbose_ping("61.135.169.121", 2, 1):
        log.write("PING_BAIDU_SUCCESS")
        return True

    log.write("PING_BAIDU_FAILED")
    return False
Ejemplo n.º 8
0
def test_school_internet_connection(testcount):
    response = verbose_ping('10.0.0.55', count=testcount)
    if 'get ping' in response:
        print '[1]school internet is OK'
        return True
    else:
        print '[1]school internet is disconnected'
        return False
Ejemplo n.º 9
0
def test_the_internet_connection(testcount):
    response = verbose_ping('www.baidu.com', count=testcount)
    if 'get ping' in response:
        print '[2]the Internet is OK'
        return True
    else:
        print '[2]the Internet is disconnected'
        return False
Ejemplo n.º 10
0
def icmp_check(server):
    s = verbose_ping(server, 1000, 1, 8)
    if not s:
        return False
    if s.fracLoss == 0:
        return True
    else:
        return False
Ejemplo n.º 11
0
 def run(self):
   ## ICMP Response Monitoring ##
   counter = {}
   counter['ICMP'] = {}
   while True:
     ping_delay = ping.verbose_ping(target,0.1,1,1000)
     ## Sending ("ping_delay")
     counter['ICMP'] = ping_delay
     monitoring_q.put(counter)
     if not ping_delay:
         pass
     else:
         sleep(0.1) # Simulate at least a 100 MS RTT (Low_freq)
Ejemplo n.º 12
0
def runTests(display, user):
    if(os.path.exists(r'list.txt')):
        statinfo = os.stat('list.txt')
    else:
        u = urllib2.urlopen('http://sinfrog.metabaron.net/list.php')
        localFile = open('list.txt', 'w')
        localFile.write(u.read())
        localFile.close()
        statinfo = os.stat('list.txt')
    if (datetime.fromtimestamp(time()) - datetime.fromtimestamp(statinfo.st_mtime)) > timedelta (days = 1):
        #Retrieve list of servers to ping
        u = urllib2.urlopen('http://sinfrog.metabaron.net/list.php')
        localFile = open('list.txt', 'w')
        localFile.write(u.read())
        localFile.close()
    #loading file line by line and not at once in memory
    for line in fileinput.input(['list.txt']):
        display.DisplayFrame_statusbar.SetStatusText("\nPinging " + line.strip(' \t\n\r'))
        verbose_ping(line.strip(' \t\n\r'), displayTarget = display, user = user)
    display.DisplayFrame_statusbar.SetStatusText("Pinging done")
    
    speedClass = SpeedClass(display, user)
    speedClass.start()
Ejemplo n.º 13
0
def process_Ping(data):
    print "begin process_Ping"
    #print data;
    #print data[u'ma-instruction'][u'ma-instruction-tasks'][0]
    if data[u'ma-instruction'][u'ma-instruction-tasks'][0][
            u'ma-task-name'].lower() == u'ping':
        i = 0
        parastring = ''
        for i in range(
                len(data[u'ma-instruction'][u'ma-instruction-tasks'][0]
                    [u'ma-task-options'])):
            #print data[u'ma-instruction'][u'ma-instruction-tasks'][0][u'ma-task-options'][i];print parastring
            if data[u'ma-instruction'][u'ma-instruction-tasks'][0][
                    u'ma-task-options'][i][u'name'] != 'destination-ip':
                if i == 0:
                    parastring = str(
                        data[u'ma-instruction'][u'ma-instruction-tasks'][0]
                        [u'ma-task-options'][i][u'value'])
                else:
                    parastring = parastring + ',' + str(
                        data[u'ma-instruction'][u'ma-instruction-tasks'][0]
                        [u'ma-task-options'][i][u'value'])
            else:
                parastring = parastring + ',' + str(
                    data[u'ma-instruction'][u'ma-instruction-tasks'][0]
                    [u'ma-task-options'][i][u'value'][u'ip-address'])
        parastring = parastring.split(',')
        #print parastring
        print 'suppress', suppress
        while suppress == 0:
            testresult = list(ping.verbose_ping(parastring[2]))
            report = paravalues.rep
            report[u'ma-report'][u'ma-report-date'] = str(datetime.now())
            report[u'ma-report'][u'ma-report-tasks'][0][
                u'ma-report-task-config'] = data[u'ma-instruction'][
                    u'ma-instruction-tasks'][0]
            rep_url = data[u'ma-instruction'][u'ma-report-channels'][0][
                u'ma-channel-target']
            report[u'ma-report'][u'ma-report-tasks'][0][
                u'ma-report-task-rows'] = testresult
            report = json.dumps(report)
            #rep_url="http://172.24.20.185:8080/ma/rep"
            req = urllib2.Request(rep_url, report)
            print "reportted here"
            print rep_url
            response = urllib2.urlopen(req)
            thepage = response.read()
            time.sleep(24 * 60 * 60)
            print "end process_Ping"
Ejemplo n.º 14
0
Archivo: main.py Proyecto: tammela/PiE
 def Ping(self):
     global serverList, maxPing
     i = 0
     while i <= len(serverList):
         if self.StopThread:
             self.IsRunning = False
             return
         #infinite ping calls logic
         i += 1
         if i == len(serverList):
             i = 0
         _ms = ping.verbose_ping(serverList[i], maxPing, 1)
         _evt = UpdateMS(value = _ms, server= serverList[i])
         wx.PostEvent(self.win, _evt)
         #stop the thread so we don't have a frozen GUI
         time.sleep(1.5)
Ejemplo n.º 15
0
def ping_gate_way():

    host_name = socket.gethostname()
    log.write("host name: " + host_name)

    local_ip = socket.gethostbyname(host_name)
    log.write("local IP: " + local_ip)

    if local_ip == "127.0.0.1":
        log.write("PC_IP_NOT_CORRECT")
        return False

    dot_pos = local_ip.rfind(".")
    gate_way_ip = local_ip[0:dot_pos+1] + "1"
    log.write("Gate way IP: " + gate_way_ip)

    if ping.verbose_ping(gate_way_ip, 2, 1):
        log.write("PING_GATE_WAY_SUCCESS")
        return True

    log.write("PING_GATE_WAY_FAILED")
    return False
Ejemplo n.º 16
0
 def process_task(self,data):
    global test_on, suppress
    
    if test_on :
      return
    else :
      if suppress==1:
        suppress=0
      test_on=1
    
    #print data[u'ma-instruction'][u'ma-instruction-tasks'][0]
    if data[u'ma-instruction'][u'ma-instruction-tasks'][0][u'ma-task-name'].lower()==u'ping' :
     i=0; parastring=''; 
     for  i in range(len(data[u'ma-instruction'][u'ma-instruction-tasks'][0][u'ma-task-options'])) :
       #print data[u'ma-instruction'][u'ma-instruction-tasks'][0][u'ma-task-options'][i];print parastring
       if data[u'ma-instruction'][u'ma-instruction-tasks'][0][u'ma-task-options'][i][u'name']!='destination-ip' :
         if i==0 :
           parastring=str(data[u'ma-instruction'][u'ma-instruction-tasks'][0][u'ma-task-options'][i][u'value'])
         else :
          parastring=parastring+','+str(data[u'ma-instruction'][u'ma-instruction-tasks'][0][u'ma-task-options'][i][u'value'])
       else :
          parastring=parastring+','+str(data[u'ma-instruction'][u'ma-instruction-tasks'][0][u'ma-task-options'][i][u'value'][u'ip-address'])
     parastring=parastring.split(',');#print parastring
     while suppress==0 :
      testresult=list(ping.verbose_ping(parastring[2]));
      report=paravalues.rep
      report[u'ma-report'][u'ma-report-date']=str(datetime.now())
      report[u'ma-report'][u'ma-report-tasks'][0][u'ma-report-task-config']=data[u'ma-instruction'][u'ma-instruction-tasks'][0]
      rep_url=data[u'ma-instruction'][u'ma-report-channels'][0][u'ma-channel-target'];
      report[u'ma-report'][u'ma-report-tasks'][0][u'ma-report-task-rows']=testresult;
      report=json.dumps(report);
      #rep_url="http://172.24.20.185:8080/ma/rep"
      req=urllib2.Request(rep_url, report);
      response=urllib2.urlopen(req)
      thepage=response.read();
      time.sleep(20)
    suppression=0;
Ejemplo n.º 17
0
import ping, socket

try:
    ping.verbose_ping('www.google.com', count=3)
    delay = ping.Ping('www.wikipedia.org', timeout=2000).do()
except socket.error, e:
    print "Ping Error:", e
Ejemplo n.º 18
0
import socket
import sys
import ping

try:
    ping.verbose_ping('127.0.0.1', count=1000)
except socket.error, e:
    print "Ping Error:", e

total = 0
buffer_size = 1000

if len(sys.argv) > 1:
    portno = int(sys.argv[1])
    # Create a TCP/IP socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    # Connect the socket to the port where the server is listening
    server_address = ("localhost", portno)
    print >> sys.stderr, 'connecting to %s port %s' % server_address
    sock.connect(server_address)

    try:
        # Send data
        message = bytearray([1 for b in range(buffer_size)])
        print >> sys.stderr, 'sending %d bytes' % len(message)
        sock.sendall(message)

        total += len(message)
        print >> sys.stderr, 'sent %d total bytes' % total
Ejemplo n.º 19
0
    if args.timestamp == True:
        print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
#Liberally copied from Ping.py
    if log != -1:
        if args.timestamp == True:
            log.write(time.strftime("%Y-%m-%d %H:%M:%S \n", time.localtime()))
        try:
            delay = ping.do_one(args.destination, 2)
        except socket.gaierror, e:
            log.write("failed. (socket error: '%s')" % e[1])
            print "failed. (socket error: '%s')" % e[1]
            break

        if delay == None:
            log.write("failed. (timeout within %ssec.)" % 2)
            print "failed. (timeout within %ssec.)" % 2
        else:
            delay = delay * 1000
            log.write("get ping in %0.4fms" % delay)
            print "get ping in %0.4fms" % delay
        log.write("\n")
                   
    #Logging will require a reimplementation of ping.verbose_ping or something- looking at that later
    else:
        ping.verbose_ping(args.destination,2,1)
    if count > 0:
        count = count - 1
    if count == 0:
        looping = False

def check_network():
    import ping
    host = get_domain_name()[0]
    ping.verbose_ping(host)
Ejemplo n.º 21
0
if str(cidr) == "16" or str(cidr) == "/16":
     while True:
         ip_set1 = raw_input("\n Please enter the first octet desired ip set within the /16 CIDR, e.g 192: ")
     
         if int(ip_set1) >= 0 and int(ip_set1) <= 255:
              ip_set2 = raw_input("\n Please enter the second octet desired ip set within the /16 CIDR, e.g 168: ")

              if int(ip_set2) >= 0 and int(ip_set2) <= 255:

                  try: 
                      for i in range(255):
                          f = 0
                          while f < 255:
                              ip_string = str(ip_set1) + "." + str(ip_set2) + "." + str(f) + "." + str(i)  
#                              sys.stdout = open('ping_sweep_py.log', 'a')
                              ping.verbose_ping(ip_string, count=1)
                              f += 1

                  except socket.error, e:
                      print "ping error:",e


elif str(cidr) == "24" or cidr == "/24":
     
    ip_set = raw_input("\n Please enter the first three octets desired ip set within the /24 CIDR, e.g 192.168.1: ")

    prog = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}$")

    if prog.match(ip_set):

        try: 
Ejemplo n.º 22
0
#!/usr/bin/env python

'''Very simple pinger written in Python  +  bash
for day-to-day routine
'''

import ping, socket
from datetime import datetime
from datetime import date

try:
    print date.today(),'-',datetime.time(datetime.now())
    ping.verbose_ping('web.centracom.co.za', count=1)
except socket.error, e:
    print "Ping Error:", e

#-------------------------------------------------------

#!/bin/bash

COUNTER=0
while [  $COUNTER -lt 6 ]; do
python pinger.py
let COUNTER=COUNTER+1 
sleep 20m
done

#-------------------------------------------------------

# $ pinger.sh >> pinger.log
# $ pinger.sh | tee -a pinger.log 
Ejemplo n.º 23
0
def check_port(domain, count):
    fl = float(count)
    # open a file descriptor to stdin
    result = verbose_ping(domain, fl)
    return result
Ejemplo n.º 24
0
#!/usr/bin/python3.3

import ping, socket
HOST=172.16.24.199
count=3
try:
    ping.verbose_ping(host, count)
    delay = ping.Ping('www.wikipedia.org', timeout=2000).do()
except socket.error, e:
    print "Ping Error:", e
Ejemplo n.º 25
0
'''
Created on Oct 7, 2014

@author: dlui
'''

import sys
import ping

if __name__ == '__main__':
    blah = [123, 456, "abc"]
    print blah
    print 'Hello World'
    blah.append("999")
    for i in blah:
        print i
    mystr = "hello world"
    blah.reverse()
    print blah
    print mystr.split()
    print sys.api_version
    print sys.path
    print sys.builtin_module_names
    print sys.platform

    ping.verbose_ping('www.google.com', count=3)
Ejemplo n.º 26
0
import socket
import sys
import ping

try:
    ping.verbose_ping('127.0.0.1', count=1000)
except socket.error, e:
    print "Ping Error:", e

total = 0
buffer_size = 1000

if len (sys.argv) > 1:
    portno = int(sys.argv[1])
    # Create a TCP/IP socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

    # Connect the socket to the port where the server is listening
    server_address = ("localhost", portno)
    print >>sys.stderr, 'connecting to %s port %s' % server_address
    sock.connect(server_address)

    try:
        # Send data
        message = bytearray([1 for b in range(buffer_size) ])
        print >>sys.stderr, 'sending %d bytes' % len(message)
        sock.sendall(message)

        total += len(message)
        print >>sys.stderr, 'sent %d total bytes' % total
Ejemplo n.º 27
0
import socket
import sys
import ping

if len(sys.argv) > 3:
    cur_address = sys.argv[1]
    cur_size = int(sys.argv[2])
    cur_count = int(sys.argv[3])
    try:
        ping.verbose_ping(cur_address, count=cur_count, packet_size=cur_size)
    except socket.error, e:
        print "Ping Error:", e
Ejemplo n.º 28
0
def simple_ping(address):
    try:
        ping.verbose_ping(address, count=4)
    except socket.error, e:
        print "Ping Error:", e
ping 192.168.1.1 with ... get ping in 3.0000ms

 """

import os
import sys

try:
    import ping
except ImportError:
    try:
        command_to_execute = "pip install ping || easy_install ping"
        os.system(command_to_execute)
    except OSError:
        print("Can NOT install 'ping', Aborted!")
        sys.exit(1)
    except Exception as e:
        print("Uncaught exception, %s" % e.message)
        sys.exit(1)
    import ping

try:
    ping.verbose_ping("192.168.88.1")
except Exception as e:
    # Note that ICMP messages can only be sent from processes running as root.
    if "10013" in e.message or "as root" in str(e):
        print("socket.SOCK_RAW require super administrator privilege")
    else:
        print(e.args)
    sys.exit(1)
Ejemplo n.º 30
0
passwd='password27'
networkPart='10.6.15'
startHost='140'
endHost='170'
upList=[]
downList=[]
sshHandlers = []
threads = []
count = 1
flag = 0

#os.system("sh generateEvalFiles.sh")

for i in range(int(startHost), int(endHost)):
    host = networkPart + '.' + str(i)
    c = ping.verbose_ping(host)
    if c > 0:
        upList.append(host)
    else:
        downList.append(host)

if len(upList) < 9:
    print 'Not enough hosts alive. Increase the range'
    exit()
for host1 in upList:
    sshConnect = ssh.connect(host1,uname,passwd)
    #sshConnect = sshConnect.get_transport()
    if sshConnect =='':
        print 'skipping', host1
    else:
        sshHandlers.append(sshConnect)
Ejemplo n.º 31
0
#!/usr/bin/env python
#-*- coding:utf-8 -*-

import ping, socket

try:
	ping.verbose_ping('www.google.com')
	delay = ping.Ping('www.wikipedia.org', timeout=2000).do()
except socket.error, e:
	print "Ping Error:", e
Ejemplo n.º 32
0
ping 192.168.1.1 with ... get ping in 3.0000ms

 """

import os
import sys

try:
    import ping
except ImportError:
    try:
        command_to_execute = "pip install ping || easy_install ping"
        os.system(command_to_execute)
    except OSError:
        print("Can NOT install 'ping', Aborted!")
        sys.exit(1)
    except Exception as e:
        print("Uncaught exception, %s" % e.message)
        sys.exit(1)
    import ping

try:
    ping.verbose_ping("192.168.88.1")
except Exception as e:
    # Note that ICMP messages can only be sent from processes running as root.
    if "10013" in e.message or "as root" in str(e):
        print("socket.SOCK_RAW require super administrator privilege")
    else:
        print(e.args)
    sys.exit(1)
Ejemplo n.º 33
0
 def Ping_Pc(self, speech, language):
     Retour_Ping = ping.verbose_ping("192.168.0.29",2,1)
     self.say(Retour_Ping)
     self.complete_request()
Ejemplo n.º 34
0
        return Vm_list
    except Exception, e:
        print type(e)
        print e
        return []


if __name__ == "__main__":
    print "\n----------------------------------------------------------------------------------"
    print "                   Scan APC"
    print "----------------------------------------------------------------------------------"
    Apc_dict = getAllAPC()
    for apc in Apc_dict.keys():
        myPower = POWERSUPPLY(apc)
        print "APC : %s, Connected to %s, Location: %s" % (
            myPower.connection, Apc_dict[apc]['PC'], Apc_dict[apc]['LOC'])

    print "\n----------------------------------------------------------------------------------"
    print "                   Scan Host Machine"
    print "----------------------------------------------------------------------------------"
    for apc in Apc_dict.keys():
        print "%s at %s : " % (Apc_dict[apc]['PC'], Apc_dict[apc]['LOC'])
        result = ping.verbose_ping('%s' % Apc_dict[apc]['PC'], count=3)

    print "\n----------------------------------------------------------------------------------"
    print "                   Scan Virtual Machine"
    print "----------------------------------------------------------------------------------"
    for vm in getAllVM():
        print "%s : " % (vm)
        result = ping.verbose_ping('%s' % vm, count=3)
Ejemplo n.º 35
0
import socket
import sys
import ping

if len (sys.argv) > 3:
    cur_address = sys.argv[1]
    cur_size = int(sys.argv[2])
    cur_count = int(sys.argv[3])
    try:
        ping.verbose_ping(cur_address, count=cur_count, packet_size=cur_size)
    except socket.error, e:
        print "Ping Error:", e

Ejemplo n.º 36
0
def get_ping(hostname):
    try:
        ping.verbose_ping(hostname, count = 3)
        return True
    except socket.error, e:
        return False