Esempio n. 1
0
def jiemi_des(line):
    # print(decode())
    c = desdecode(line, '0f1571c947')
    print("DES解密后的值", c)
    # c = '1' + '1'.join(c.split('1')[1:])
    # print("去掉额外补位的零之后的值", c)
    # print("解码后的值", decode(c))
    return decode(c)
    def run(self):

        # view = sublime.active_window().active_view()
        filename = self.pars['file']
        
        if not exists(filename):
            print ("File \'{0}\' is not exist.".format(filename))
            return


        code = open(filename, "r").read()

        if sys.version_info[0] < 3:
            encoding = 'UTF-8'
            try:
                decoded = code.decode('UTF-8')
            except UnicodeDecodeError:
                encoding = 'ascii'
            else:
                for ch in decoded:
                    if 0xD800 <= ord(ch) <= 0xDFFF:
                        encoding = 'ascii'
                # encoding = 'UTF-8'
        else:
            encoding = 'UTF-8'
        # if encoding == 'Undefined':
        #     encoding = 'UTF-8'

        try:
            password, host, port, origin = self.pars['password'],self.pars['host'],self.pars['port'],self.pars['origin']
        except ValueError as exc:
            print('Invalid credentials.')
            return

        try:
            error = send_code(filename, code, encoding, password, host, port, str(origin))
        # except ConnectionRefusedError as exc:
        #     print('Could not connect to {0}:{1}'.format(host, port))
        #     return
        except socket.error as exc:
            print('socket.error occured, see console')
            # show_console()
            traceback.print_exc()
            return
        except UnicodeDecodeError:
            print('UnicodeDecodeError occured, see console')
            traceback.print_exc()
            return

        if error == 'invalid-password':
            print('Password was not accepted by the Remote Code Executor Server at {0}:{1}'.format(host, port))
        elif error == 'invalid-request':
            print('Request was invalid, maybe this plugin is outdated?')
        elif error is not None:
            print('error (unexpected): {0}'.format(error))
        else:
            print('Code sent to {0}:{1}'.format(host, port))
Esempio n. 3
0
def test():
    assert xor([1, 1, 0, 1], [1, 0, 0, 1]) == [0, 1, 0, 0]
    assert get_residue([0, 1, 1, 1, 0, 0, 0], [1, 0, 1, 1]) == [0, 0, 1, 0]

    data = [0, 1, 1, 1]
    encoded = encode(data)

    assert encoded == [0, 1, 1, 1, 0, 1, 0]
    assert encode([1, 1, 1]) == [0, 1, 1, 1, 0, 1, 0]

    decoded, err = decode(encoded)
    assert (decoded, err) == (data, False)
Esempio n. 4
0
def check(account):
    """Fetch the username and password by the input target"""    
    if account == 'all':
        for name in box.keys():
            print name,
            print "\t\t\t",
            print decode(box[name])
    elif box.has_key(account) == False:
        for name in box.keys():
            if name.find(account) == -1:
                pass
            else:
                candidate.append(name)
        if len(candidate):
            print "Do you mean:"
            for n in candidate:
                print "\t\t",
                print n
            account = raw_input(">")    
            if len(account):
                print decode(box[account])
            else:
                exit(1)
        else:
            print "Can't find the account '%s', try the correct name." % account
            exit(1)
    else:
        print decode(box[account])
Esempio n. 5
0
def check(account):
    """Fetch the username and password by the input target"""
    if account == 'all':
        for name in box.keys():
            print name,
            print "\t\t\t",
            print decode(box[name])
    elif box.has_key(account) == False:
        for name in box.keys():
            if name.find(account) == -1:
                pass
            else:
                candidate.append(name)
        if len(candidate):
            print "Do you mean:"
            for n in candidate:
                print "\t\t",
                print n
            account = raw_input(">")
            if len(account):
                print decode(box[account])
            else:
                exit(1)
        else:
            print "Can't find the account '%s', try the correct name." % account
            exit(1)
    else:
        print decode(box[account])
Esempio n. 6
0
 def test_steven(self):
     self.assertEqual(code.decode("19 20 5 22 5 14"), "steven")
Esempio n. 7
0
 def test_alphabet(self):
     self.assertEqual(ascii_lowercase, code.decode(alphabet_numbers))
Esempio n. 8
0
def cli():
	loadPreferences()
	parser = argparse.ArgumentParser(description="input file with no options builds in debug mode and runs game")
	parser.add_argument("filein", metavar="FILE.GMK", type=str, nargs="?",help="read file (gmk gm81 egm gmx gmz formats)")
	parser.add_argument("-o", dest="writefile", help="convert to output file and exit (gmk ggg formats)")
	parser.add_argument("-c", dest="code", help="empty game with object create event code")
	parser.add_argument("-r", dest="run", action="store_true", help="run game emode (debug is default)")
	parser.add_argument("-d", dest="dontrun", action="store_true", help="compile but don't run game")
	parser.add_argument("-t", dest="test", action="store_true", help="don't compile with enigma")
	parser.add_argument("-s", dest="stats", action="store_true", help="stats")
	parser.add_argument("-p", dest="python", help="run python line")
	parser.add_argument("-i", dest="interactive", action="store_true", help="interactive")
	parser.add_argument("-j", dest="dejavu", action="store_true", help="print dejavu AST for scripts")
	parser.add_argument("--mingw", dest="mingw", action="store_true", help="compile for Windows with mingw")
	parser.add_argument("--audio", dest="audio", help="OpenAL, SFML, DirectSound, FMOD")
	parser.add_argument("--collision", dest="collision", help="Precise, BBox")
	parser.add_argument("--graphics", dest="graphics", help="OpenGL1, OpenGL3, Direct3D9")
	if len(sys.argv)==1:
		args = parser.parse_args(["--help"])
	else:
		args = parser.parse_args()
	try:
		app = QtGui.QApplication(["python"])
	except:
		print_warning("pyqt4 is not installed")
		app = None
	if args.filein:
		p=args.filein
		if p[-1] in ["/","\\"]:
			p=p[:-1]
		ext=os.path.splitext(p)[1]
		gameFile=GameFile()
		print_notice("loading "+p)
		gameFile.Read(p)
	if args.code:
		gameFile=newGame(args.code)
	if args.stats:
		gameFile.printBasicStats()
		sys.exit(0)
	if args.python:
		import code
		t=code.InteractiveConsole(locals())
		t.runsource(args.python)
	if args.interactive:
		gameFile.resourceTree.PrintRecursive()
		import code
		t=code.InteractiveConsole(locals())
		t.interact()
	if args.dejavu:
		import dejavu.parser
		for s in gameFile.scripts:
			print_notice("AST for script "+s.getMember("name"))
			code=s.getMember("value")
			#print code
			print(dejavu.parser.parseGML(s.getMember("name"), code.decode()))
		for o in gameFile.objects:
			for ec in o.events:
				name = o.getMember("name") + "_" + str(ec.eventNumber) + "_" + str(ec.getMember("eventKind"))
				print_notice("AST for "+name)
				code = getActionsCode(ec.actions)#.encode()
				#print code
				print(dejavu.parser.parseGML(name, code))
		sys.exit(0)
	if args.writefile:
		if args.writefile=="-":
			ext=".ggg"
			gameFile.SaveExt(ext,tmpDir+"crap",wfile=sys.stdout)
		else:
			ext=os.path.splitext(os.path.split(args.writefile)[1])[1]
			if ext not in [".gmk",".gm81",".egm",".gmx",".ggg"]:
				print_error("unsupported output type "+ext)
			print_notice("saving "+args.writefile)
			gameFile.SaveExt(ext,args.writefile)
		sys.exit(0)
	gameFile.app=app
	if args.test:
		sys.exit(0)
	emode=emode_compile#make turns compile into debug
	if args.run:
		emode=emode_run
	#if os.name!="nt":
	#	redirectStdout()
		#realStdout=sys.stdout
	#	setRealStdout(realStdout)
	if args.audio:
		gameFile.EnigmaTargetAudio=args.audio#"OpenAL"
	if args.collision:
		gameFile.EnigmaTargetCollision=args.collision
	if args.graphics:
		gameFile.EnigmaTargetGraphics=args.graphics#"OpenGL3"
	if args.mingw:
		gameFile.EnigmaTargetWindowing="Win32"
		gameFile.EnigmaTargetCompiler="MinGW32"
		#gameFile.EnigmaTargetWidget="Win32"
	LoadPluginLib()
	print_notice("ENIGMA compile")
	error=gameFile.compileRunEnigma(testGameFile,emode)
	if error:
		print_notice("returned error")
		sys.exit(1)
	restoreStdout()
	if emode==emode_compile:
		if args.dontrun:
			print_notice("not running game")
		else:
			print_notice("run game")
			print_notice(subprocess.check_output([testGameFile]))
Esempio n. 9
0
#!usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'LotteWong'

import code
import easygui

key = '23333333'
cipher = easygui.enterbox('请输入您的密文:', '解密中...')
plain = code.decode(cipher, key)

easygui.msgbox('被您抽到的幸运儿是:%s' % plain, '已解密!')