__init__.py 文件源码

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

项目:king-phisher-plugins 作者: securestate 项目源码 文件源码
def enrollment_setup(self, _):
        rpc = self.application.rpc
        this_user = rpc.remote_table_row('users', rpc.username)
        if this_user.otp_secret is not None:
            reset = gui_utilities.show_dialog_yes_no(
                'Already Enrolled',
                self.application.get_active_window(),
                'This account is already enrolled in TOTP,\nreset the existing TOTP token?'
            )
            if not reset:
                return
        new_otp = pyotp.TOTP(pyotp.random_base32())
        provisioning_uri = rpc.username + '@' + self.application.config['server'].split(':', 1)[0]
        provisioning_uri = new_otp.provisioning_uri(provisioning_uri) + '&issuer=King%20Phisher'
        bytes_io = io.BytesIO()
        qrcode_ = qrcode.make(provisioning_uri).get_image()
        qrcode_.save(bytes_io, 'PNG')
        pixbuf_loader = GdkPixbuf.PixbufLoader.new()
        pixbuf_loader.write(bytes_io.getvalue())
        pixbuf_loader.close()
        pixbuf = pixbuf_loader.get_pixbuf()

        self.logger.debug('loading gtk builder file from: ' + gtk_builder_file)
        builder = Gtk.Builder()
        builder.add_from_file(gtk_builder_file)
        window = builder.get_object('TOTPEnrollment.window')
        window.set_transient_for(self.application.get_active_window())

        self.application.add_window(window)

        image = builder.get_object('TOTPEnrollment.image_qrcode')
        image.set_from_pixbuf(pixbuf)

        button_check = builder.get_object('TOTPEnrollment.button_check')
        entry_totp = builder.get_object('TOTPEnrollment.entry_totp')
        button_check.connect('clicked', self.check_totp, window, entry_totp, new_otp, this_user)
        entry_totp.connect('activate', self.check_totp, window, entry_totp, new_otp, this_user)

        window.show_all()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号