Determine OS of remote machine using pings












-1














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









share|improve this question





























    -1














    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









    share|improve this question



























      -1












      -1








      -1







      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









      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 1 at 10:29









      bilalq

      3,20821528




      3,20821528










      asked Nov 21 at 6:58









      xxx_mineshaftboy69noscoper_xxx

      1




      1
























          1 Answer
          1






          active

          oldest

          votes


















          1














          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





          share|improve this answer





















          • 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 at 2:57












          • Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
            – Miklos Horvath
            Nov 22 at 20:36










          • yes sadly how would one fix this?
            – xxx_mineshaftboy69noscoper_xxx
            Nov 23 at 2:44











          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          1














          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





          share|improve this answer





















          • 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 at 2:57












          • Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
            – Miklos Horvath
            Nov 22 at 20:36










          • yes sadly how would one fix this?
            – xxx_mineshaftboy69noscoper_xxx
            Nov 23 at 2:44
















          1














          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





          share|improve this answer





















          • 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 at 2:57












          • Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
            – Miklos Horvath
            Nov 22 at 20:36










          • yes sadly how would one fix this?
            – xxx_mineshaftboy69noscoper_xxx
            Nov 23 at 2:44














          1












          1








          1






          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





          share|improve this answer












          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






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 at 7:58









          Miklos Horvath

          172112




          172112












          • 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 at 2:57












          • Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
            – Miklos Horvath
            Nov 22 at 20:36










          • yes sadly how would one fix this?
            – xxx_mineshaftboy69noscoper_xxx
            Nov 23 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 at 2:57












          • Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
            – Miklos Horvath
            Nov 22 at 20:36










          • yes sadly how would one fix this?
            – xxx_mineshaftboy69noscoper_xxx
            Nov 23 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 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 at 2:57














          Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
          – Miklos Horvath
          Nov 22 at 20:36




          Do you use Windows? If yes read this: stackoverflow.com/questions/33777308/…
          – Miklos Horvath
          Nov 22 at 20:36












          yes sadly how would one fix this?
          – xxx_mineshaftboy69noscoper_xxx
          Nov 23 at 2:44




          yes sadly how would one fix this?
          – xxx_mineshaftboy69noscoper_xxx
          Nov 23 at 2:44


















          draft saved

          draft discarded




















































          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          Refactoring coordinates for Minecraft Pi buildings written in Python