Determine OS of remote machine using pings
I am trying to figure out how to find which operating system a remote machine
is running using the ping method.
I don't know how to get the TTL number and look at a list to find what OS it uses.
ping 19.217.64.1
Pinging 19.217.64.1 with 32 bytes of data:
Reply from 19.217.64.1: bytes=32 time=3ms TTL=254
Reply from 19.217.64.1: bytes=32 time=3ms TTL=254
Reply from 19.217.64.1: bytes=32 time=5ms TTL=254
Reply from 19.217.64.1: bytes=32 time=4ms TTL=254
Ping statistics for 19.217.64.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 3ms, Maximum = 5ms, Average = 3ms
python python-3.x sockets operating-system ping
add a comment |
I am trying to figure out how to find which operating system a remote machine
is running using the ping method.
I don't know how to get the TTL number and look at a list to find what OS it uses.
ping 19.217.64.1
Pinging 19.217.64.1 with 32 bytes of data:
Reply from 19.217.64.1: bytes=32 time=3ms TTL=254
Reply from 19.217.64.1: bytes=32 time=3ms TTL=254
Reply from 19.217.64.1: bytes=32 time=5ms TTL=254
Reply from 19.217.64.1: bytes=32 time=4ms TTL=254
Ping statistics for 19.217.64.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 3ms, Maximum = 5ms, Average = 3ms
python python-3.x sockets operating-system ping
add a comment |
I am trying to figure out how to find which operating system a remote machine
is running using the ping method.
I don't know how to get the TTL number and look at a list to find what OS it uses.
ping 19.217.64.1
Pinging 19.217.64.1 with 32 bytes of data:
Reply from 19.217.64.1: bytes=32 time=3ms TTL=254
Reply from 19.217.64.1: bytes=32 time=3ms TTL=254
Reply from 19.217.64.1: bytes=32 time=5ms TTL=254
Reply from 19.217.64.1: bytes=32 time=4ms TTL=254
Ping statistics for 19.217.64.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 3ms, Maximum = 5ms, Average = 3ms
python python-3.x sockets operating-system ping
I am trying to figure out how to find which operating system a remote machine
is running using the ping method.
I don't know how to get the TTL number and look at a list to find what OS it uses.
ping 19.217.64.1
Pinging 19.217.64.1 with 32 bytes of data:
Reply from 19.217.64.1: bytes=32 time=3ms TTL=254
Reply from 19.217.64.1: bytes=32 time=3ms TTL=254
Reply from 19.217.64.1: bytes=32 time=5ms TTL=254
Reply from 19.217.64.1: bytes=32 time=4ms TTL=254
Ping statistics for 19.217.64.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 3ms, Maximum = 5ms, Average = 3ms
python python-3.x sockets operating-system ping
python python-3.x sockets operating-system ping
edited Dec 1 '18 at 10:29
bilalq
3,39321628
3,39321628
asked Nov 21 '18 at 6:58
xxx_mineshaftboy69noscoper_xxxxxx_mineshaftboy69noscoper_xxx
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Here there is an implementation of the ping in python:
https://gist.github.com/chidea/955cea841e5c76a7e5ee8aa02234409d
Look at the receive_ping function. The TTL is the 9th byte of the received packet (index 8). So I print the TTL in that function:
def receive_ping(my_socket, packet_id, time_sent, timeout):
# Receive the ping from the socket.
time_left = timeout
while True:
started_select = time.time()
ready = select.select([my_socket], , , time_left)
how_long_in_select = time.time() - started_select
if ready[0] == : # Timeout
return
time_received = time.time()
rec_packet, addr = my_socket.recvfrom(1024)
print ("TTL:", rec_packet[8]) # IT PRINT THE TTL! HAVE A NICE DAY :)
icmp_header = rec_packet[20:28]
type, code, checksum, p_id, sequence = struct.unpack(
'bbHHh', icmp_header)
if p_id == packet_id:
return time_received - time_sent
time_left -= time_received - time_sent
if time_left <= 0:
return
it works for most of it but it gets trouble ready = select.select([my_socket], , , time_left) and says it must be a int or have a fileno() method
– xxx_mineshaftboy69noscoper_xxx
Nov 22 '18 at 2:57
Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
– Miklos Horvath
Nov 22 '18 at 20:36
yes sadly how would one fix this?
– xxx_mineshaftboy69noscoper_xxx
Nov 23 '18 at 2:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53406753%2fdetermine-os-of-remote-machine-using-pings%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here there is an implementation of the ping in python:
https://gist.github.com/chidea/955cea841e5c76a7e5ee8aa02234409d
Look at the receive_ping function. The TTL is the 9th byte of the received packet (index 8). So I print the TTL in that function:
def receive_ping(my_socket, packet_id, time_sent, timeout):
# Receive the ping from the socket.
time_left = timeout
while True:
started_select = time.time()
ready = select.select([my_socket], , , time_left)
how_long_in_select = time.time() - started_select
if ready[0] == : # Timeout
return
time_received = time.time()
rec_packet, addr = my_socket.recvfrom(1024)
print ("TTL:", rec_packet[8]) # IT PRINT THE TTL! HAVE A NICE DAY :)
icmp_header = rec_packet[20:28]
type, code, checksum, p_id, sequence = struct.unpack(
'bbHHh', icmp_header)
if p_id == packet_id:
return time_received - time_sent
time_left -= time_received - time_sent
if time_left <= 0:
return
it works for most of it but it gets trouble ready = select.select([my_socket], , , time_left) and says it must be a int or have a fileno() method
– xxx_mineshaftboy69noscoper_xxx
Nov 22 '18 at 2:57
Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
– Miklos Horvath
Nov 22 '18 at 20:36
yes sadly how would one fix this?
– xxx_mineshaftboy69noscoper_xxx
Nov 23 '18 at 2:44
add a comment |
Here there is an implementation of the ping in python:
https://gist.github.com/chidea/955cea841e5c76a7e5ee8aa02234409d
Look at the receive_ping function. The TTL is the 9th byte of the received packet (index 8). So I print the TTL in that function:
def receive_ping(my_socket, packet_id, time_sent, timeout):
# Receive the ping from the socket.
time_left = timeout
while True:
started_select = time.time()
ready = select.select([my_socket], , , time_left)
how_long_in_select = time.time() - started_select
if ready[0] == : # Timeout
return
time_received = time.time()
rec_packet, addr = my_socket.recvfrom(1024)
print ("TTL:", rec_packet[8]) # IT PRINT THE TTL! HAVE A NICE DAY :)
icmp_header = rec_packet[20:28]
type, code, checksum, p_id, sequence = struct.unpack(
'bbHHh', icmp_header)
if p_id == packet_id:
return time_received - time_sent
time_left -= time_received - time_sent
if time_left <= 0:
return
it works for most of it but it gets trouble ready = select.select([my_socket], , , time_left) and says it must be a int or have a fileno() method
– xxx_mineshaftboy69noscoper_xxx
Nov 22 '18 at 2:57
Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
– Miklos Horvath
Nov 22 '18 at 20:36
yes sadly how would one fix this?
– xxx_mineshaftboy69noscoper_xxx
Nov 23 '18 at 2:44
add a comment |
Here there is an implementation of the ping in python:
https://gist.github.com/chidea/955cea841e5c76a7e5ee8aa02234409d
Look at the receive_ping function. The TTL is the 9th byte of the received packet (index 8). So I print the TTL in that function:
def receive_ping(my_socket, packet_id, time_sent, timeout):
# Receive the ping from the socket.
time_left = timeout
while True:
started_select = time.time()
ready = select.select([my_socket], , , time_left)
how_long_in_select = time.time() - started_select
if ready[0] == : # Timeout
return
time_received = time.time()
rec_packet, addr = my_socket.recvfrom(1024)
print ("TTL:", rec_packet[8]) # IT PRINT THE TTL! HAVE A NICE DAY :)
icmp_header = rec_packet[20:28]
type, code, checksum, p_id, sequence = struct.unpack(
'bbHHh', icmp_header)
if p_id == packet_id:
return time_received - time_sent
time_left -= time_received - time_sent
if time_left <= 0:
return
Here there is an implementation of the ping in python:
https://gist.github.com/chidea/955cea841e5c76a7e5ee8aa02234409d
Look at the receive_ping function. The TTL is the 9th byte of the received packet (index 8). So I print the TTL in that function:
def receive_ping(my_socket, packet_id, time_sent, timeout):
# Receive the ping from the socket.
time_left = timeout
while True:
started_select = time.time()
ready = select.select([my_socket], , , time_left)
how_long_in_select = time.time() - started_select
if ready[0] == : # Timeout
return
time_received = time.time()
rec_packet, addr = my_socket.recvfrom(1024)
print ("TTL:", rec_packet[8]) # IT PRINT THE TTL! HAVE A NICE DAY :)
icmp_header = rec_packet[20:28]
type, code, checksum, p_id, sequence = struct.unpack(
'bbHHh', icmp_header)
if p_id == packet_id:
return time_received - time_sent
time_left -= time_received - time_sent
if time_left <= 0:
return
answered Nov 21 '18 at 7:58
Miklos HorvathMiklos Horvath
300212
300212
it works for most of it but it gets trouble ready = select.select([my_socket], , , time_left) and says it must be a int or have a fileno() method
– xxx_mineshaftboy69noscoper_xxx
Nov 22 '18 at 2:57
Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
– Miklos Horvath
Nov 22 '18 at 20:36
yes sadly how would one fix this?
– xxx_mineshaftboy69noscoper_xxx
Nov 23 '18 at 2:44
add a comment |
it works for most of it but it gets trouble ready = select.select([my_socket], , , time_left) and says it must be a int or have a fileno() method
– xxx_mineshaftboy69noscoper_xxx
Nov 22 '18 at 2:57
Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
– Miklos Horvath
Nov 22 '18 at 20:36
yes sadly how would one fix this?
– xxx_mineshaftboy69noscoper_xxx
Nov 23 '18 at 2:44
it works for most of it but it gets trouble ready = select.select([my_socket], , , time_left) and says it must be a int or have a fileno() method
– xxx_mineshaftboy69noscoper_xxx
Nov 22 '18 at 2:57
it works for most of it but it gets trouble ready = select.select([my_socket], , , time_left) and says it must be a int or have a fileno() method
– xxx_mineshaftboy69noscoper_xxx
Nov 22 '18 at 2:57
Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
– Miklos Horvath
Nov 22 '18 at 20:36
Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
– Miklos Horvath
Nov 22 '18 at 20:36
yes sadly how would one fix this?
– xxx_mineshaftboy69noscoper_xxx
Nov 23 '18 at 2:44
yes sadly how would one fix this?
– xxx_mineshaftboy69noscoper_xxx
Nov 23 '18 at 2:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53406753%2fdetermine-os-of-remote-machine-using-pings%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown