How to query server information of csanti-terrorism elites in python

Source: Internet
Author: User
This article mainly introduces how to query information about cs server in python, and shares the implementation examples of the anti-terrorism Elite version 1.5 and the anti-terrorism Elite version 1.6, if you need it, you can refer to it for reference. let's learn it together. Preface

I was very confused when I learned about servers. I believe that many Python developers have similar experiences with me. This article describes how to query the server information of csanti-terrorism elites in python. For more information, see.

Sample code of csanti-terrorism Pro 1.5

#!/bin/env python import urllib2, base64, sys, getoptimport reimport socket def Usage ():  print "Usage: hlds.py -h 127.0.0.1 -p 27015"  sys.exit(2) def main ():   # Default values  host = "localhost"  port = ""   if len(sys.argv) < 1:    Usage()   try:    opts, args = getopt.getopt(sys.argv[1:], "h:p:a:")  except getopt.GetoptError:    Usage()   # Assign parameters as variables  for opt, arg in opts :    if opt == "-h" :      host = arg    if opt == "-p" :      port = arg   sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  port = int(port)  sock.settimeout(10)  sock.connect((host, port))  sock.send('\xFF\xFF\xFF\xFF\x69\x6E\x66\x6F\x73\x74\x72\x69\x6E\x67\x0A\00')   request=sock.recv(1400)  sock.close()  server_info=request.replace('\xFF', '')   buffer = re.findall(r'\d+', server_info)  print buffer[6] if __name__ == "__main__": main()

Sample code of csanti-terrorism pro 1.6

#!/bin/env python import urllib2, base64, sys, getoptimport reimport socket def Usage ():  print "Usage: hlds.py -h 127.0.0.1 -p 27015"  sys.exit(2) def main ():   # Default values  host = "localhost"  port = ""   if len(sys.argv) < 1:    Usage()   try:    opts, args = getopt.getopt(sys.argv[1:], "h:p:a:")  except getopt.GetoptError:    Usage()   # Assign parameters as variables  for opt, arg in opts :    if opt == "-h" :      host = arg    if opt == "-p" :      port = arg   sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)  port = int(port)  sock.settimeout(10)  sock.connect((host, port))  sock.send('\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00')   request=sock.recv(1400)  sock.close()  #server_info=request.replace('\xFF', '')  print request   #buffer = re.findall(r'\d+', server_info)  #print buffer[6]  #print buffer if __name__ == "__main__": main()

For more information about how to query the server information of csanti-terrorism elites in python, please refer to PHP!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.