Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /var/www/web-klick.de/dsh/10_customer2017/1210__delphi/newitem/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : /var/www/web-klick.de/dsh/10_customer2017/1210__delphi/newitem/APTest.py

#!/usr/bin/python3

import os
import re
import time
import sys
import imp
import pickle
import base64

#vvvvvvv   DO NOT TOUCH THIS CODE. IT IS NEEDED FOR DYNAMIC INHERITANCE!!  vvvvvvv
#                                                                                 #
#pkg = __name__                                                                   #
#print (pkg)
#while (0 == 0):                                                                  #
#   m = re.search(r"^(.*)\.(.*)$",pkg)                                            #
#   if not m:                                                                     #
#      break                                                                      #
#   pkg = m.group(1)                                                              #
#   try:                                                                          #
#      exec("import "+pkg+"\nclass parent ("+pkg+".cls):\n   pass\n")             #
#      break                                                                      #
#   except:                                                                       #
#      __name__.run()
#      break                                                                      #
#                                                                                 #
#AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA


#  This is the central testtree1.py module to perform hierarchical
#  organized tests (tree of test items)


print(__name__)

class cls ():

   def __init__ (self):
      self._result     = "0/0/0/0"
      self._remark     = ""
      self._user       = "xx"
      self._arch       = "NOARCH"
      self._requ       = { 'ALLREQU'  :   100  }
      self._log        = ""
      self._testcase   = ""
      self._testfile   = ""
      self.___jump___  = "run"
      self.___jump1___ = ""

#****************************************************************************

#  The standard result function, should be overloaded

   def result (self):
      return('''
:RESULT:   0/0/0/0
:REMARK:
:USER:   
:ARCH:     NOARCH
:ALLREQU:  10000000000
''')

#****************************************************************************

#  The standard run function, reproduces itself. The crazy masking
#  in the re.sub's enables it not to interpret ''' resp. """
#  as a string.
#  Should be overloaded.
#  The run function is the starting point for the run of a test-item.
#  the sync at its end writes the actual run into a child item.

   def run (self,pars):
   
      o = """
   def run (self,pars):
   
      o = "1"1"1
---LOG---
"1"1"1

      o1 = re.sub('" *1','"'+'2',o)
      o  = re.sub("---LOG---",o1,o,1)
      o  = re.sub('" *1','"'    ,o)
      o  = re.sub('" *2','"'+'1',o)
      
      self._log = o
      
      self.sync(1)
"""
      o1 = re.sub('" *1','"'+'2',o)
      o  = re.sub("---LOG---",o1,o,1)
      o  = re.sub('" *1','"'    ,o)
      o  = re.sub('" *2','"'+'1',o)
            
      self._log = o
      
      self.sync(1)


#****************************************************************************

#  This is the standard function which makes from a testcase (e.g. the filename)
#  the 'next' testcase: If the testcase is t<nnn>, the 'next' is:  t(<nnn>+1)

   def next_test0 (self,filename):
      try:
         filename = int(re.sub(r"^.*?(\d+).*$",r"\1",filename))
      except:
         filename = 0
      filename = "%03u" % (filename+1)
      return("t"+filename)

#****************************************************************************

#  This is the general function which makes from a testcase (e.g. the filename)
#  the 'next' testcase. If it is not overloaded, then it will
#  call the standard 'next' function next_test0

   def next_test (self,filename):
      return(self.next_test0(filename))
      
#****************************************************************************

#  This function dumps the running test run of a test-item as
#  a child item into a file


   def sync (self,p1="___NO_P___",p2="___NO_P___",p3="___NO_P___",p4="___NO_P___",p5="___NO_P___"):
   
      passed = -1
      warn   = -1
      err    = -1
      notp   = -1
      for o in [p1,p2,p3,p4,p5]:
          if o == "___NO_P___":
             break
          if   passed == -1 and type(o) == type(0):
             passed   =  o
          elif warn   == -1 and type(o) == type(0):
             warn     =  o
          elif err    == -1 and type(o) == type(0):
             err      =  o
          elif notp   == -1 and type(o) == type(0):
             notp     =  o
          else:
             self._remark = o
      if not passed+warn+err+notp == -4:
         if (passed == -1):
            passed  =   0
         if (warn   == -1):
            warn    =   0
         if (err    == -1):
            err     =   0
         if (notp   == -1):
            notp    =   0
         self._result = str(passed) + "/" + str(warn) + "/" + str(err) + "/" + str(notp)

      if not self.___jump___ == "":
         self.___jump1___ = self.___jump___
         self.___jump___  = ""
      else:
         for o in dir(self):
            if re.search(r"^(run|r\d+|t\d+)$",o):
               if self.___jump1___ == "":
                  self.___jump1___ = o
                  break
               elif self.___jump1___ == o:
                  self.___jump1___ = ""

      testdir  = re.sub(r"\.",r"/",self.__module__)   #  the name of the actual testitem-file
#      testdir  = re.sub(r"\/(autoitem|item|pytest)$",r"",testdir)
      #previous_testcase = ""
      if self._testcase == "":
         while (0 == 0):   #  Searching for a valid testcase-name
            #if re.search(r"^t\d+$",self._testcase):   #  proposal from sw
               #previous_testcase = self._testcase
            self._testcase = self.next_test(self._testcase)
            if not os.path.isfile(testdir+"/"+self._testcase+"/item.py") or self._testcase == "":               
               break
      if self._testcase == "":  #  Searching for a valid testcase-name
         return("ERROR: No testcase to be done found anymore")
         
      text     = ""
      filename = ""
      if text == "":
         filename = ".pl"
         text     = self.check_perl()
      if text == "":
         filename = ".py"
         text     = self.check_python()
      logname     = "item.log"

      o = self.___jump1___
      if o == "":
         o = "NONE"
      text = re.sub(r" ---JUMP---"," "+o,text)

      # Add previous result (please comment that proposal!)
      """
      if previous_testcase:
         ffile = open(testdir+"/"+previous_testcase+"/"+filename,"r")
         textp = ffile.read()
         ffile.close()
         m = re.search(r"^(.*?)\:RESULT\:(.*?)\n(.*)$",textp,re.DOTALL)
         m1 = re.search(r"^(.*?)(\d+)\/(\d+)\/(\d+)\/(\d+)(.*)$",m.group(2),re.DOTALL)
         m2 = re.search(r"^(.*?)(\d+)\/(\d+)\/(\d+)\/(\d+)(.*)$",self._result,re.DOTALL)
         p = str(int(m1.group(2))+int(m2.group(2)))
         w = str(int(m1.group(3))+int(m2.group(3)))
         e = str(int(m1.group(4))+int(m2.group(4)))
         n = str(int(m1.group(5))+int(m2.group(5)))
         self._result = p + "/" + w + "/" + e + "/" + n
         text = re.sub(r"\:RESULT\: *\d+\/\d+\/\d+\/\d+",":"+"RESULT"+":   "+str(self._result),text)
      """
           
      if not os.path.isdir(testdir):
         os.makedirs(testdir)
         ffile = open(testdir+"/__init__.py","w")
         ffile.write("")
         ffile.close()
         os.chmod(testdir+"/__init__.py",0o774)      
      
#      if not os.path.isdir(testdir+"/"+self._testcase):
#         os.makedirs(testdir+"/"+self._testcase)
      
      f = testdir+"/"+self._testcase+filename
      ffile = open(f,"w")
      ffile.write(text)
      ffile.close()
      os.chmod(f,0o774)
      
#      l = testdir+"/"+self._testcase+"/"+self._testcase+".py" 
#      if os.name == 'nt':    #  proposal from sw
#         os.system("mklink \""+l+"\" "+filename+" > NUL")
#      elif os.name == 'posix':        
#         os.system("ln -s "+filename+" \""+l+"\" > /dev/null")
         
         
#      o = ""
#      m = re.search(r"^SLEEP(\d+)$",self._remark)
#      if m:
#         o = o + "SLEEP: " + str(int(self._sleep + 1 + int(m.group(1)))) + "\n"
#      r = self._requ
#      for o1 in r.keys():
#         o = o + o1 + ": " + str(r[o1]) + "  " + self._result  + "\n"
#      ffile = open(testdir+"/"+self._testcase+"/"+logname,"w")
#      ffile.write(o)
#      ffile.close()
#      os.chmod(testdir+"/"+self._testcase+"/"+logname,0o774)

#      ffile = open(testdir+"/"+self._testcase+"/__init__.py","w")
#      ffile.write("")
#      ffile.close()
#      os.chmod(testdir+"/"+self._testcase+"/__init__.py",0o774)      
      
      o = ""
      if self.___jump1___:
         o = ", next jump: " + self.___jump1___
      print("\nWRITTEN: " + testdir+"/"+self._testcase+o+"\n")
          
      #if (re.search(r"^GENERATED",self._remark)):
         #os.system("y r "+testdir+"/"+self._testcase)
      self._testdir =testdir   
      
      if not self.___jump1___:
         return()

      text1 = ""  
      try:
         if not os.environ['autoedit'] == "":
            os.system(os.environ['autoedit']+" "+testdir+"/"+self._testcase+filename)
            ffile     = open(testdir+"/"+self._testcase+filename)
            for zeile in ffile:
               text1 = text1 + zeile
            ffile.close()
      except:
         pass

      if not text1 == "" and not text == text1:
         text1 = re.sub(r"(:REMARK: +) SLEEP(\d+)","\\1 SLEEP0",text1)
         ffile = open(testdir+"/"+self._testcase+filename,"w")
         ffile.write(text1)
         ffile.close()
         ffile = open(testdir+"/"+self._testcase+filename,"w")
         ffile.write(text1)
         ffile.close()
         o       = re.sub(r"\.item$","."+self._testcase+".item",self.__module__)
         self._o = ""
         time.sleep(0.015)  #  for the reason of race condition with __pycache__ !
         exec("import " + o + "\nimp.reload("+o+")\nself._o = " + o + ".cls()\n")
         self._o.proceed()

#****************************************************************************

   def check_autotest (self):
      return("")
      
#****************************************************************************
      
   def check_perl (self):
      return("")
      
#****************************************************************************

   def check_python (self):


      text = """# -*- coding: utf-8 -*-
import os
import re

#vvvvvvv   DO NOT TOUCH THIS CODE. IT IS NEEDED FOR DYNAMIC INHERITANCE!!  vvvvvvv
                                                                                 #
pkg = __name__                                                                   #
while (0 == 0):                                                                  #
   m = re.search(r"^(.*)\\.(.*)\\.(.*)$",pkg)                                      #
   if not m:                                                                     #
      break                                                                      #
   pkg = m.group(1) + "." + m.group(3)                                           #
   try:                                                                          #
      exec("import "+pkg+"\\nclass parent ("+pkg+".cls):\\n   pass\\n")             #
      break                                                                      #
   except:                                                                       #
      break                                                                      #
                                                                                 #
#AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

class cls (parent):

   def next_test (self,o):
      return(self.next_test0(o))

#------------  EVALUATION: --------------------

   def result (self):
      return('''
---RESULT---
---REMARK---
---USER---
---ARCH---
"""
#      text = re.sub("---EXECUTABLE---",'/usr/bin/python3',      text)
      text = re.sub("---RESULT---",":"+"RESULT"+":   "+str(self._result),text)
      text = re.sub("---REMARK---",":"+"REMARK"+":   "+str(self._remark),text)
      text = re.sub("---ARCH---",  ":"+"ARCH"+":     "+str(self._arch),  text)

      o    = time.localtime()
      r    =      "%02u" % o[0] + "%02u" % o[1] + "%02u" % o[2] + "_"
      o    =  r + "%02u" % o[3] + "%02u" % o[4] + "%02u" % o[5]
      if self.___jump1___ == "run":
         m = re.search(r"\:USER\: +(.*?)\n",self.result())
         if m:
            o = m.group(1) + "," + o
      o    = re.sub("^,","",o+self._user)
      text = re.sub("---USER---",":"+"USER"+":     "+o,text)

      r    = self._requ
      for o in r.keys():
         text = text + ":" + o + ":  " + str(r[o]) + "\n"
      rem = ""

      text = text + ":" + "DUMPTIME" + ": "  + str(time.time()) + "\n"
      text = text + "''')\n\n"
      
      if (re.search(r"^[\n ]*def +run +\(self,pars\) *\:",self._log)):
         rem       = "#"
         self._log = re.sub(r"'(X*)X''",r"'\1''",self._log)
      text = text + "#------------  PROGRAM CODE: (next jump: ---JUMP---) ------\n\n"
      text = text + rem+"   def log       (self):\n"+rem+"      o = '''"
      text = text + self._log + rem + "'''\n" + rem + "      return(o)\n"

      """  proposal from sw
      if (re.search(r"^[\n ]*def +run +\(self,pars\) *\:",self._log)):
         rem       = "#"
         self._log = re.sub(r"'(X*)X''",r"'\1''",self._log)
      text = text + "#------------  PROGRAM CODE: (next jump: ---JUMP---) ------\n\n"
      if not rem:
         text = text + rem+"   def log       (self):\n"+rem+"      o = '''"
         text = text + self._log + rem + "'''\n" + rem + "      return(o)\n"
      else:
         text = text + self._log
      """
      if not self.___jump1___ == "":
         text = text + "\n   def dump_data (self):\n      return('''\n"
         o    = re.sub(r"^b\'(.*)\'$",r"\1",str(base64.b64encode(pickle.dumps(self))))
         while not o == "":
            text = text + o[:80] + "\n";
            o    = o[80:]
         text = text + "''')\n"

      return(text)

#****************************************************************************   

   def proceed (self,pars=""):

#      if (0 == 0):
      try:
         o         = bytes(re.sub(r"\n",r"",self.dump_data()),'utf-8')
         o         = pickle.loads(base64.b64decode(o))
         o1        = self.result() + "\n"
         o._requ   = {}
         
         while (0 == 0):
            m = re.search(r"^(.*?)\:(.*?)\: *(.*?) *\n(.*)$",o1,re.DOTALL)
            if not m:
               print(o1)
               break
            if   (m.group(2) == 'RESULT'):
               o._result   = m.group(3)
            elif (m.group(2) == 'REMARK'):
               o._remark   = m.group(3)
            elif (m.group(2) == 'USER'):
               o._user     = m.group(3)
            elif (m.group(2) == 'ARCH'):
               o._arch     = m.group(3)
            elif (m.group(2) == 'DUMPTIME'):
               o._dumptime = m.group(3)
            else:
               o._requ[m.group(2)] = m.group(3)
            o1 = m.group(4)
         o._log    = self.log()
         self      = o
      except:
         print("Process has no dump data. Seems to be finished.")
         return()


      if self.___jump1___ == "":
         print("Process cannot be proceeded because there is no jump function. Seems to be finished.")
         return()

      m = re.search(r"^(SLEEP|sleep)(\d+)$",self._remark)

      if m:
         o = float(self._dumptime) + float(m.group(2)) - time.time()
         if o > 0:
            print("Awake time not yet reached. " + str(int(o)) + " seconds to wait.")
            return()
            
      o = "self." + self.___jump1___ + "()"
      try:
         exec(o)
         print("Process resumed and proceeded.")
      except BaseException as e:
         o = "Error in function " + o + ". Process could not be proceeded. Error message is:\n"
         o = o + str(e)
         print(o)
         

#****************************************************************************   

   def add_log (self,mode,text):
      self._log = self._log + text + "\n"
      print(text)

#****************************************************************************   

   def add_requ (self,val,req):
      self._requ[req] = val
      #self.add_log(0,"   ---> Requirement " + req + " added with sensitivity " + str(val))
      self.add_log(0,'%20s %-25s %12s %s' % ("   ---> Requirement ",req," added","   sensitivity " + str(val)))

#****************************************************************************   


bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net