def _spider(self, subfolder, depth):
        """
        Abandon all hope ye who enter here.
        You're now probably wondering if I was drunk and/or high when writing this.
        Getting this to work took a toll on my sanity. So yes. a lot.
        """

        # The following is some funky shit that deals with the way impacket treats file paths

        if subfolder in ["", "."]:
            subfolder = "*"

        elif subfolder.startswith("*/"):
            subfolder = subfolder[2:] + "/*"
        else:
            subfolder = subfolder.replace("/*/", "/") + "/*"

        # End of the funky shit... or is it? Surprise! This whole thing is funky

        filelist = None
        try:
            filelist = self.smbconnection.listPath(self.share, subfolder)
            self.dir_list(filelist, subfolder)
            if depth == 0:
                return
        except SessionError as e:
            if not filelist:
                if "STATUS_ACCESS_DENIED" not in str(e):
                    self.logger.debug(f"Failed listing files on share {self.share} in directory {subfolder}: {e}")
                return

        for result in filelist:
            if result.is_directory() and result.get_longname() not in [".", ".."]:
                if subfolder == "*":
                    self._spider(
                        subfolder.replace("*", "") + result.get_longname(),
                        depth - 1 if depth else None,
                    )
                elif subfolder != "*" and (subfolder[:-2].split("/")[-1] not in self.exclude_dirs):
                    self._spider(
                        subfolder.replace("*", "") + result.get_longname(),
                        depth - 1 if depth else None,
                    )
        return

        Abandon all hope ye who enter here.
        You're now probably wondering if I was drunk and/or high when writing this.
        Getting this to work took a toll on my sanity. So yes. a lot.
        
cme/protocols/smb/smbspider.py