Esempio n. 1
0
def read(filename):
    try:
        setStdVars(filename)
        setOverrideVars()
        buildModulesList()
        loadModule('common')
        loadModule(config.format)
        processFile(filename)
        checkTagDefinitions()
        finalize.finalize()
        return 1
    except errors.ErrorBase, e:
        if config.debug:
            reraise()
        sys.stderr.write(str(e))
        return 0
Esempio n. 2
0
def read(filename):
    try:
        setStdVars(filename)
        setOverrideVars()
        buildModulesList()
        loadModule('common')
        loadModule(config.format)
        processFile(filename)
        checkTagDefinitions()
        finalize.finalize()
        return 1
    except errors.ErrorBase, e:
        if config.debug:
            reraise()
        sys.stderr.write(str(e))
        return 0
Esempio n. 3
0
def execGameCommonFinalizeScript(channelName, platformId, appVersion, resVersion, checkBox_isChecked, checkBox_4_isChecked, checkBox_5_isChecked):
    if (os.path.exists(file_operate.getGameCommonScriptPath())):
        
        gameCommonFinalizeScriptBat = file_operate.getGameCommonScriptPath() + "/finalize.bat"
        if (os.path.exists(gameCommonFinalizeScriptBat)):
            cmd = '"%s" "%s" "%s" "%s" "%s"' % (gameCommonFinalizeScriptBat, platformId, channelName, appVersion, resVersion)
            ret = file_operate.execFormatCmd(cmd)
            if ret:
                print "execute finalize.bat error"
                return 1
        gameCommonFinalizeScriptExe = file_operate.getGameCommonScriptPath() + "/finalize.exe"
        if (os.path.exists(gameCommonFinalizeScriptExe)):
            cmd = '"%s" "%s" "%s" "%s" "%s"' % (gameCommonFinalizeScriptExe, platformId, channelName, appVersion, resVersion)
            ret = file_operate.execFormatCmd(cmd)
            if ret:
                print "execute finalize.exe error"
                return 1
        gameCommonFinalizeScriptPyc = file_operate.getGameCommonScriptPath() + "/finalize.pyc"
        if os.path.exists(gameCommonFinalizeScriptPyc):
            print "gameCommonFinalize" + file_operate.getGameCommonScriptPath() + "/finalize.pyc"
            sys.path.append(file_operate.getGameCommonScriptPath())
            import finalize
            ret = finalize.finalize(platformId, channelName, appVersion, resVersion, checkBox_isChecked, checkBox_4_isChecked, checkBox_5_isChecked)
Esempio n. 4
0
def obfuscate(lua, encoder, globs, debug=False, xor_val=-1):
    """
    Does the complete obfuscation process, returning the result
    :return: Obfuscated Lua, Tokens, Strings, Comments
    """

    # Set the debug_mode global to the debug mode argument passed
    global debug_mode
    debug_mode = debug

    start_time = time.time()

    # Get an XOR to use
    if xor_val == -1:
        xor_val = random.randint(0, 255)
        log("Randomly chose XOR value {0}.".format(xor_val), False)

    # Set the XOR in the decryption code
    decrypt_code = encoder.get_decrypt_code(xor_val)

    # Strip comments and strings
    lua, strings, comments = stringstripper.strip(lua)
    log("Stripped {0} strings and {1} comments.".format(len(strings), len(comments)), False)

    # Tokenize
    tokens = tokenizer.tokenize(lua)
    log("Finished tokenizing {0} tokens.".format(len(tokens)), False)

    # About to begin
    log("Beginning Level {0} obfuscation...".format(encoder.level), False)

    # Make sure all functions are called with ()
    # Ex: print"Hello!" -> print("Hello!")
    tokens = tokenizer.fix_functions(tokens, strings)
    log("Fixed function notation.")

    # Obfuscate
    tokens = rearrange_functions(tokens)
    log("Rearranged functions.")

    tokens = colon_to_dot(tokens)
    tokens, strings = dot_to_index(tokens, strings)
    log("Rewrote table references.")

    tokens, strings = fix_tables(tokens, strings)
    log("Rewrote table keys.")

    tokens = rename_locals(tokens)
    log("Obfuscated locals.")

    tokens = rename_arguments(tokens)
    log("Renamed function arguments.")

    tokens = rename_loops(tokens)
    log("Renamed loop variables.")

    # Copy the old globals
    old_globs = globs[:]
    globs = assume_globals(tokens, globs)
    # Don't print here because the function prints on its own

    assumed = len(globs) - len(old_globs)

    tokens, strings = rename_globals(tokens, strings, globs)
    log("Obfuscated globals (with {0} assumed).".format(assumed))

    strings = encoder.encode_all(strings, xor_val)
    log("Obfuscated strings.")

    tokens = stringstripper.replace(tokens, strings, DECRYPT_FUNC, encoder.get_str_start(), encoder.get_str_end())
    log("Replaced strings.")

    lua = finalize.finalize(tokens, decrypt_code)

    log("Finished in {0:.3f} seconds.".format(time.time() - start_time), False)

    return lua, tokens, strings, comments
Esempio n. 5
0
def obfuscate(lua, encoder, globs, debug=False, xor_val=-1):
    """
    Does the complete obfuscation process, returning the result
    :return: Obfuscated Lua, Tokens, Strings, Comments
    """

    # Set the debug_mode global to the debug mode argument passed
    global debug_mode
    debug_mode = debug

    start_time = time.time()

    # Get an XOR to use
    if xor_val == -1:
        xor_val = random.randint(0, 255)
        log("Randomly chose XOR value {0}.".format(xor_val), False)

    # Set the XOR in the decryption code
    decrypt_code = encoder.get_decrypt_code(xor_val)

    # Strip comments and strings
    lua, strings, comments = stringstripper.strip(lua)
    log("Stripped {0} strings and {1} comments.".format(len(strings), len(comments)), False)

    # Tokenize
    tokens = tokenizer.tokenize(lua)
    log("Finished tokenizing {0} tokens.".format(len(tokens)), False)

    # About to begin
    log("Beginning Level {0} obfuscation...".format(encoder.level), False)

    # Make sure all functions are called with ()
    # Ex: print"Hello!" -> print("Hello!")
    tokens = tokenizer.fix_functions(tokens, strings)
    log("Fixed function notation.")

    # Obfuscate
    tokens = rearrange_functions(tokens)
    log("Rearranged functions.")

    tokens = colon_to_dot(tokens)
    tokens, strings = dot_to_index(tokens, strings)
    log("Rewrote table references.")

    tokens, strings = fix_tables(tokens, strings)
    log("Rewrote table keys.")

    tokens = rename_locals(tokens)
    log("Obfuscated locals.")

    tokens = rename_arguments(tokens)
    log("Renamed function arguments.")

    tokens = rename_loops(tokens)
    log("Renamed loop variables.")

    # Copy the old globals
    old_globs = globs[:]
    globs = assume_globals(tokens, globs)
    # Don't print here because the function prints on its own

    assumed = len(globs) - len(old_globs)

    tokens, strings = rename_globals(tokens, strings, globs)
    log("Obfuscated globals (with {0} assumed).".format(assumed))

    strings = encoder.encode_all(strings, xor_val)
    log("Obfuscated strings.")

    tokens = stringstripper.replace(tokens, strings, DECRYPT_FUNC, encoder.get_str_start(), encoder.get_str_end())
    log("Replaced strings.")

    lua = finalize.finalize(tokens, decrypt_code)

    log("Finished in {0:.3f} seconds.".format(time.time() - start_time), False)

    return lua, tokens, strings, comments
Esempio n. 6
0
# populate the list of product objects
for product, price in price_value_dict.items():
    # Printing for testing purposes
    print(product, price)

    # Creating product objects from product names and prices
    DefProduct = Product(product, price)
    product_list.append(DefProduct)

# Requesting user for number of people to split check between
number_of_people = input("Insert number of people to split check: ")

#Initializing empty person list
person_list = []

# Creating the necessary number of people objects
for x in range(0, int(number_of_people)):
    createPerson(person_list)

# Prompting for the tip
enterTip()

# Generating a check window for each person created
for person in person_list:
    handleGUI(product_list, person)

# Finalizing program and displaying results
finalize(person_list, product_list)

# Continue application...
Esempio n. 7
0
    
host = yaml_file['nodes']['nodeA']['host']
port = yaml_file['nodes']['nodeA']['ports']['api']

api = Iota('http://{}:{}'.format(host, port))

txn = ProposedTransaction(
address = Address('KSAFREMKHHYHSXNLGZPFVHANVHVMKWSGEAHGTXZCSQMXTCZXOGBLVPCWFKVAEQYDJMQALKZRKOTWLGBSC'),
value = 0
)

bundle = ProposedBundle()
bundle.add_transaction(txn)
bundle.add_transaction(txn)

index_trytes = str(int_to_trytes(index, 9))

bundle[0]._legacy_tag = Tag(index_trytes)
    
finalize.finalize(bundle)
bundle_trytes = bundle.as_tryte_strings()

tips = api.get_transactions_to_approve(depth=3)
branch = tips['branchTransaction']
trunk = tips['trunkTransaction']


milestone_bundle = api.attach_to_tangle(trunk,branch, bundle_trytes,3)
api.broadcast_and_store(milestone_bundle.get('trytes'))
print("Milestone {} attached and stored: {}".format(index, milestone_bundle))