hackertyper.py 文件源码

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

项目:xf 作者: red-green 项目源码 文件源码
def hackertyper():
    @contextmanager
    def cbreak():
        old_attrs = termios.tcgetattr(sys.stdin)
        tty.setcbreak(sys.stdin)
        try:
            yield
        finally:
            termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_attrs)
    def uinput():
        reader = codecs.getreader(sys.stdin.encoding)(sys.stdin)
        with cbreak():
            while True:
                yield reader.read(1)
    def is_interrupt(c):
        return c == '\x04'

    data = open(os.path.join(os.path.dirname(__file__),'data/hack.txt')).read()
    strs = re.split(r'(\s+)',data)
    it = iter(strs)

    try:
        for c in uinput():
                if is_interrupt(c):
                    break
                else:
                    try:
                        sys.stdout.write(it.next())
                        sys.stdout.flush()
                    except StopIteration:
                        it = iter(strs)
    except:
        print
        print
        time.sleep(0.1)
        print '======================'
        time.sleep(0.1)
        print "====ACCESS GRANTED===="
        time.sleep(0.1)
        print '======================'
        time.sleep(0.1)
        print
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号