readline.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:pwndemo 作者: zh-explorer 项目源码 文件源码
def init():
    # defer imports until initialization
    import sys, __builtin__
    from ..util import safeeval

    class Wrapper:
        def __init__(self, fd):
            self._fd = fd
        def readline(self, size = None):
            return readline(size)
        def __getattr__(self, k):
            return self._fd.__getattribute__(k)
    sys.stdin = Wrapper(sys.stdin)

    def raw_input(prompt = '', float = True):
        """raw_input(prompt = '', float = True)

        Replacement for the built-in `raw_input` using ``pwnlib``s readline
        implementation.

        Arguments:
            prompt(str): The prompt to show to the user.
            float(bool): If set to `True`, prompt and input will float to the
                         bottom of the screen when `term.term_mode` is enabled.
        """
        return readline(None, prompt, float)
    __builtin__.raw_input = raw_input

    def input(prompt = '', float = True):
        """input(prompt = '', float = True)

        Replacement for the built-in `input` using ``pwnlib``s readline
        implementation, and `pwnlib.util.safeeval.expr` instead of `eval` (!).

        Arguments:
            prompt(str): The prompt to show to the user.
            float(bool): If set to `True`, prompt and input will float to the
                         bottom of the screen when `term.term_mode` is enabled.
        """
        return safeeval.const(readline(None, prompt, float))
    __builtin__.input = input
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号