title: python - create a socket that shows a custom service name in nmap
body: <p>I have a piece of python code to listen on a port. The end result I want is that when anyone runs nmap against that IP, a custom name shows up in the service name column. To illustrate my requirement, see below screenshot that shows port 666 as the name doom.</p>
  
  <p><a href="https://i.stack.imgur.com/bEF6t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bEF6t.png" alt="enter image description here"></a></p>
  
  <p>I tried searching for solutions without any success.</p>
  
  <p>Below is the python code that I'm using to listen on a port:</p>
  
  <pre><code>import socket
  import sys
  
  HOST = ''   # Symbolic name, meaning all available interfaces
  PORT = 8888 # Arbitrary non-privileged port
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  print 'Socket created'
  
  #Bind socket to local host and port
  try:
      s.bind((HOST, PORT))
  except socket.error as msg:
      print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
      sys.exit()
  
  print 'Socket bind complete'
  
  #Start listening on socket
  s.listen(10)
  print 'Socket now listening'
  
  #now keep talking with the client
  while 1:
       #wait to accept a connection - blocking call
      conn, addr = s.accept()
      print 'Connected with ' + addr[0] + ':' + str(addr[1])
  
  s.close()
  </code></pre>
  
  <p>If someone could point me in the right direction or help me with the modification I should make to this code, I would really appreciate it.</p>