new_contents: #!/usr/bin/env python
  # -*- coding:utf-8 -*-
  
  import socket
  import urlparse
  from bmplugin import *
  
  info={'desc':"redis unauth vulns and get a shell",
        'cve':'',
        'link':"https://www.sebug.net/vuldb/ssvid-89715"} 
  
  def init_plugin(main):
      active=main.maintive
      active.regcommand('redis',redis_act,"redis vuln use",__file__)    
  
  class  redis:
      def __init__(self,host=None,port=6379):
          if host:
              self.host=host
          self.port=port
      
      
      def setaddress(self,host=None,port=None):
          if host:
              self.host=host
          if port:
              self.port=port
          
          
      def verify_unauth(self):
          result = {}
          payload = '\x2a\x31\x0d\x0a\x24\x34\x0d\x0a\x69\x6e\x66\x6f\x0d\x0a'
          s = socket.socket()
          socket.setdefaulttimeout(10)
          try:
              if not lib_func.isip(self.host):
                  self.host = urlparse.urlparse(self.host).netloc
              s.connect((self.host, self.port))
              s.send(payload)
              recvdata = s.recv(1024)
              if recvdata and 'redis_version' in recvdata:
                  result['vulns']="unauth vuln"
                  result['VerifyInfo'] = {}
                  result['VerifyInfo']['URL'] = self.host
                  result['VerifyInfo']['Port'] = self.port
          except:
              pass
          s.close()
          return result
  
   
   
  red=redis()
  
  def redis_act(paras):
      """redis [-h host] [-p port] [-v]"""
      try:
          pd=lib_func.getparasdict(paras,"vh:p:")
          if (not pd):
              lib_func.printstr("You should input the vaild parameters",1)
              lib_func.printstr(redis_act.__doc__)
              return
      except Exception:
          lib_func.printstr(redis_act.__doc__,1)
          return        
      if pd.has_key('h'):
          red.setaddress(host=pd['h'])
      if pd.has_key('p'):
          red.setaddress(port=int(pd['p']))
      if pd.has_key('v'):
          rs=red.verify_unauth()
          print rs
subject: add plugins_redis