!C99Shell v. 1.0 pre-release build #16!

Software: Apache/2.0.54 (Fedora). PHP/5.0.4 

uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 

uid=48(apache) gid=48(apache) groups=48(apache)
context=system_u:system_r:httpd_sys_script_t
 

Safe-mode: OFF (not secure)

/usr/bin/X11/./../../share/doc/python-ldap-2.0.6/Demo/Lib/ldap/res/   drwxr-xr-x
Free 5.15 GB of 27.03 GB (19.05%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     deltree.py (2.5 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
import ldap,ldap.res

class DeleteLeafs(ldap.res.SearchHandler):
  """
  Class for deleting entries which are results of a search.
  
  DNs of Non-leaf entries are collected in DeleteLeafs.nonLeafEntries.
  """
  _entryResultTypes = ldap.res._entryResultTypes

  def __init__(self,l):
    ldap.res.SearchHandler.__init__(self,l)
    self.nonLeafEntries = []
    self.deletedEntries = 0

  def startSearch(self,searchRoot,searchScope):
    if not searchScope in [ldap.SCOPE_ONELEVEL,ldap.SCOPE_SUBTREE]:
      raise ValueError, "Parameter searchScope must be either ldap.SCOPE_ONELEVEL or ldap.SCOPE_SUBTREE."
    self.nonLeafEntries = []
    self.deletedEntries = 0
    ldap.res.SearchHandler.startSearch(
      self,
      searchRoot,
      searchScope,
      filterStr='(objectClass=*)',
      attrList=['hasSubordinates','numSubordinates'],
      attrsOnly=0,
    )

  def _processSingleResult(self,resultType,resultItem):
    if self._entryResultTypes.has_key(resultType):
      # Don't process search references
      dn,entry = resultItem
      hasSubordinates = entry.get(
        'hasSubordinates',
        entry.get('hassubordinates',['FALSE']
        )
      )[0]
      numSubordinates = entry.get(
        'numSubordinates',
        entry.get('numsubordinates',['0'])
      )[0]
      if hasSubordinates=='TRUE' or int(numSubordinates):
        self.nonLeafEntries.append(dn)
      else:
        try:
          self._l.delete_s(dn)
        except ldap.NOT_ALLOWED_ON_NONLEAF,e:
          self.nonLeafEntries.append(dn)
        else:
          self.deletedEntries = self.deletedEntries+1


def DelTree(l,dn,scope=ldap.SCOPE_ONELEVEL):
  """
  Recursively delete entries below or including entry with name dn.
  """
  leafs_deleter = DeleteLeafs(l)
  leafs_deleter.startSearch(dn,scope)
  leafs_deleter.processResults()
  deleted_entries = leafs_deleter.deletedEntries
  non_leaf_entries = leafs_deleter.nonLeafEntries[:]
  while non_leaf_entries:
    dn = non_leaf_entries.pop()
    print deleted_entries,len(non_leaf_entries),dn
    leafs_deleter.startSearch(dn,ldap.SCOPE_SUBTREE)
    leafs_deleter.processResults()
    deleted_entries = deleted_entries+leafs_deleter.deletedEntries
    non_leaf_entries.extend(leafs_deleter.nonLeafEntries)
  return # DelTree()


# Create LDAPObject instance
l = ldap.initialize('ldap://localhost:1390')

# Try a bind to provoke failure if protocol version is not supported
l.bind_s('cn=Directory Manager,dc=IMC,dc=org','controller',ldap.AUTH_SIMPLE)

DelTree(
  l,'dc=Delete,dc=IMC,dc=org',ldap.SCOPE_ONELEVEL
)

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0049 ]--