enviar un mensaje a una ip determinada...

(1/1)

ceibe:
Hola existe algun comando o script para mandar un mensaje a una ip fuera de tu red

animanegra:
¿Que quieres decir con mensaje? Si te refieres a envío de datos hacia una dirección IP el propio navegador ya lo hace. si en la URL pones http://IP/loquesea en realidad la otra IP esta recibiendo:

Código:

GET /loquesea HTTP/1.1
Host: IP
User-Agent: Mozilla/5.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1


Eso si, tiene que haber alguien escuchando, si no el handshake no se finaliza y no se envia nada.

Por ejemplo, con el programa nc (netcat) puedes poner un servidor en otro lado, y un cliente en tu ordenador, y puedes usarlo como si fuese un chat entre los dos ordenadores.

ceibe:
me refiero como en windows cuando utilizas el cmd  por terminal para enviar un mensaje a una ip determinada  de tu red ,ya que creo que fuera de tu dominio no va..

y este si se modifica ....

import os

def Menu():
   os.system("clear")
   print "---NetSend---"
   print "[1] Send message to a single computer"
   print "[2] Send message to multiple computers"
   print "[3] Send spam to a single computer"
   print "[4] Send spam to multiple computers"
   print "[5] view computers on network"
   
   try:
      option = int(raw_input("Option: "))

      if option == 1:
         get_mach("single", "one", "single_msg_one_mach")

      elif option == 2:
         get_mach("single", "multi", "single_msg_multi_mach")

      elif option == 3:
         get_mach("spam", "one", "spam_msg_one_mach")

      elif option == 4:
         get_mach("spam", "multi", "spam_msg_multi_mach")

      elif option == 5:
         view_comps_on_network()

      else:
         print "error testing..."
         pause = raw_input()
         exit()
         errors("menu_option_err")

   except ValueError:
      print "error testing..."
      pause = raw_input()
      exit()
      errors("menu_option_err")

def get_mach(msg_type, mach_type, net_send_type):
   if mach_type == "one":
      computer_name = raw_input("computer name or ip: ")

      if len(computer_name) == 0:
         #call error
         print "error testing..."
         pause = raw_input()
         exit()

      else:
         get_msg(msg_type, mach_type, net_send_type, computer_name)

   elif mach_type == "multi":
      computer_names = []

      try:
         print "enter the name or ip of the computes with a space between each one"
         print "for example: computer1 computer2 computer3\n"
         computer_names_str = raw_input("computer names: ")

         if len(computer_names_str) < 1:
            #calls errors
            print "error testing..."
            pause = raw_input()
            exit()

         else:
            computer_names = computer_names_str.split()
            get_msg(msg_type, mach_type, net_send_type, computer_names)

      except ValueError:
         #call errors
         print "error testing..."
         pause = raw_input()
         exit()

def get_msg(msg_type, mach_type, net_send_type, computerNames):
   message = raw_input("message: ")

   if len(message) == 0:
      #calls errors
      print "error testing..."
      pause = raw_input()
      exit()

   else:
      if msg_type == "single":
         net_send(net_send_type, computerNames, message, "NA")

      else:
         try:
            spam_count = int(raw_input("number of times to spam: "))

            if spam_count == 0:
               #calls errors
               print "error testing..."
               pause = raw_input()
               exit()

            else:
               net_send(net_send_type, computerNames, message, spam_count)

         except ValueError:
            #calls errors
            print "error testing..."
            pause = raw_input()
            exit()


def net_send(net_send_type, computerNames, message, spamCount):
   if net_send_type == "single_msg_one_mach":
      #send message to single machine
      #os.system("net send %s %s" % (computerNames, message))
      #os.system("PAUSE")
      #Menu()
      print "net send %s %s" % (computerNames, message)
      print "message sent to %s" % computerNames
      pause = raw_input("Press any key to continue...")
      Menu()

   elif net_send_type == "single_msg_multi_mach":
      numb_of_computers = len(computerNames)
      i = 0

      while i < numb_of_computers:
         #os.system("net send %s %s" % (computerNames, message))
         print "net send %s %s" % (computerNames, message)
         print "message sent to %s" % computerNames
         i += 1

      pause = raw_input("Press any key to continue...")
      Menu()

   elif net_send_type == "spam_msg_one_mach":
      print net_send_type
      print computerNames
      print message
      print spamCount

   elif net_send_type == "spam_msg_multi_mach":
      print net_send_type
      print computerNames
      print message
      print spamCount

   else:
      pass

def view_comps_on_network():
   #os.system("net view")
   #os.system("PAUSE")
   print "will use the 'net view' command to list computers on network"
   pause = raw_input()
   Menu()

def errors(error_type):
   print "test1"
   print "error testing..."

Menu()

WHK:
Para eso existe el comando "wall". Dale un vistazo acá:

https://www.tecmint.com/send-a-message-to-logged-users-in-linux-terminal/

Para enviar mensajes remotamente existe el servicio de correos, en linux cada usuario tiene por defecto un directorio para el recibimiento de correos por parte de la red local.

Saludos.

Navegación

[0] Índice de Mensajes