-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathping.py
37 lines (35 loc) · 826 Bytes
/
ping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
"""Program to ping the google server and use RTT values to generate a hash"""
os.system('ping -c 10 google.com > google.txt')
fo = open("google.txt", "r")
s = fo.readline()
st = s.split(' ')
if not st[1]=='unknown':
fo.readline()
fo.readline()
fo.readline()
fo.readline()
fo.readline()
fo.readline()
fo.readline()
fo.readline()
fo.readline()
fo.readline()
fo.readline()
fo.readline()
s1 = fo.readline()
s2 = fo.readline()
fo.close()
st1 = s1.split(' ')
s1 = st1[9][:-3]
st2 = s2.split(' ')
st3 = st2[3].split('/')
n=0
"""Add all the rtt logged to generate a hash"""
for sa in st3:
n+=int(float(sa)*1000)
n*=(int(s1))
fo = open("hashed.txt", "a")
fo.write(str(n));
fo.close()
os.system('rm google.txt')