How to use the ciphey.iface.SearchLevel function in ciphey

To help you get started, weโ€™ve selected a few ciphey examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brandonskerritt / Ciphey / ciphey / basemods / Searchers / ausearch.py View on Github external
decoders = []

        for decoder_type, decoder_class in registry[Decoder][type(target)].items():
            for decoder in decoder_class:
                decoders.append(DecoderComparer(decoder))
        # Fun fact:
        #     with Python's glorious lists, inserting n elements into the right position (with bisect) is O(n^2)
        decoders.sort(reverse=True)

        for decoder_cmp in decoders:
            logger.trace(f"Inspecting {decoder_cmp}")
            res = self._config()(decoder_cmp.value).decode(target)

            if res is None:
                continue
            level = SearchLevel(
                name=decoder_cmp.value.__name__.lower(),
                result=CrackResult(value=res),
            )
            if type(res) == self._final_type:
                check_res = self._checker(res)
                if check_res is not None:
                    return True, (level, check_res)
            ret.append(level)
        return False, ret
github brandonskerritt / Ciphey / ciphey / basemods / Searchers / ausearch.py View on Github external
def evaluate(self, node: Node) -> (bool, Union[List[SearchLevel], List[Node]]):
        # logger.debug(f"Evaluating {node}")

        res = node.cracker.attemptCrack(node.parents[-1].result.value)
        # Detect if we succeeded, and if deduplication is needed
        logger.trace(f"Got {len(res)} results")

        ret = []
        for i in res:
            success, res = self.expand(
                node.parents
                + [SearchLevel(name=type(node.cracker).__name__.lower(), result=i)]
            )
            if success:
                return True, res
            ret.extend(res)

        return False, ret
github brandonskerritt / Ciphey / ciphey / basemods / Searchers / ausearch.py View on Github external
ParamSpec,
    CrackInfo,
    registry,
    SearchLevel,
    CrackResult,
    SearchResult,
    Decoder,
    DecoderComparer,
)
from datetime import datetime
from loguru import logger


class Node(Generic[T], NamedTuple):
    cracker: Cracker
    parents: List[SearchLevel]
    crack_info: CrackInfo
    check_info: float

    def __hash__(self):
        return hash((type(self.cracker).__name__, len(self.parents)))


class AuSearch(Searcher, ABC):
    @abstractmethod
    def findBestNode(self, nodes: List[Node]) -> Node:
        pass

    def handleDecodings(
        self, target: Any
    ) -> (bool, Union[Tuple[SearchLevel, str], List[SearchLevel]]):
        """