Esempio n. 1
0
def parse(path):
    # Read contents of file
    with open(path) as file:
        program_string = file.read()

    # Lex character-by-character
    tokens, lex_errors = tokenise(program_string)

    # Syntax parse
    program, parse_errors = syntax_parser.parse(tokens)

    # Print out classes and method names if there were no errors
    all_errors = lex_errors + parse_errors

    if not all_errors:
        logger.success('No errors found')

        # Iterate through all the classes in the program AST, and collect them
        for class_def in program:
            logger.header(class_def.class_type, end=' - ')

            methods = ', '.join([feature.identifier for feature in class_def])
            logger.info(methods)

    # Otherwise, print out the errors
    else:
        logger.error('Errors found')
        logger.info('\n'.join(all_errors))
Esempio n. 2
0
def deserialize_payload(payload):
    '''
    :param: bytestring payload: encrypted_aes_key, encrypted_message
    '''
    decoded_payload = base64.b64decode(payload)
    logger.log(
        'Decoded Payload (rsa_encrypt(aes_key) + aes_encrypt(payload)):',
        decoded_payload,
        newline=True)
    encrypted_aes_key, encrypted_message = split_bytes(HASH_DELIMITER,
                                                       decoded_payload)
    global DECRYPTED_AES_KEY
    DECRYPTED_AES_KEY = crypt.decrypt_rsa(PRIVATE_KEY, encrypted_aes_key)
    next_ip, message = crypt.decrypt_payload(
        DECRYPTED_AES_KEY,
        encrypted_message)  # decrypted_message = encypted_payload + next_ip
    logger.log('Decrypted AES Key:', DECRYPTED_AES_KEY)
    logger.log('Decrypted Payload:', next_ip, message)
    logger.header('---- END DECRYPTION OF RECEIVED PAYLOD ----', newline=True)
    return next_ip, message
Esempio n. 3
0
def listen():
    try:
        serversocket = network.start_server('localhost', RELAY_PORT)
        next_ip = None
        while True:
            logger.log('CURRENT RELAY NODE: ' + str(RELAY_PORT))
            logger.log('RECIEVING PORT:' + str(RELAY_PORT) +
                       ' FORWARDING PORT:' + str(FORWARDING_PORT))

            clientsocket, address = serversocket.accept()
            payload = network.recv_by_size(clientsocket)
            previous_ip = parse_address(address)
            logger.log('received payload from: ', previous_ip)
            logger.log('Payload (trunc): ', payload[:100], newline=True)
            logger.header('---- BEGIN DECRYPTION OF RECEIVED PAYLOAD ----')
            next_ip, message = deserialize_payload(payload)

            logger.log('begin forwarding payload to next node...')
            response = forward_payload(next_ip, message)
            if response is not None:
                '''
            Case: send to previous_ip
            '''
                # encrypt layer
                logger.log('Response returned from: ' + next_ip, newline=True)
                logger.header('---- BEGIN ENCRYPTION OF RETURN PAYLOAD ----')
                logger.log('Payload being encrypted (trunc):', response[:100])

                logger.log('aes_key used:', DECRYPTED_AES_KEY)
                encrypted_payload = network.prepend_length(
                    serialize_payload(response))

                logger.log('send payload to previous node: ', previous_ip)
                clientsocket.sendall(encrypted_payload)

            clientsocket.close()
    except Exception:
        logger.error("Unable to connect to server")
        logger.error(traceback.format_exc())
    return
Esempio n. 4
0
        |___/                                                               

\033[0m""")

# exit if input file or directory doesn't exist
if not os.path.exists(args.input):
    error('directory or file \'{0}\' does not exist!'.format(args.input))
    sys.exit(0)

# recursively read all files in the input dir to an array
input_files = [f for f in glob.glob('{0}/**/*.py'.format(args.input.rstrip('/')), recursive=True)] \
    if os.path.isdir(args.input) \
    else [args.input]

deobfuscator = next(d for d in deobfuscators if d.name == args.deobfuscator)
header(' using \033[94m{0}\033[0m deobfuscator '.format(deobfuscator.name))
deobfuscator.set_parsed_arguments(args)

# map input files to output files
io = {}
for input_file in input_files:
    output_file = input_file.replace(args.input, args.output)

    # recursively create output directories
    output_dir = os.path.dirname(output_file)
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)

    io[input_file] = output_file

deobfuscator.deobfuscate(io)
Esempio n. 5
0
				except DCERPCException as e:
					if 'transfer_syntaxes_not_supported' in str(e):
						logger.green('\t-\t{}: OK (32 bit)'.format(logger.GREEN(pipe_name)))
					else:
						logger.green('\t-\t{}: OK ({})'.format(logger.GREEN(pipe_name), str(e)))
				dce.disconnect()
			except smb.SessionError as e:
				logger.red('{}: {}'.format(logger.RED(pipe_name), logger.RED(nt_errors.ERROR_MESSAGES[e.error_code][0])))
			except smbconnection.SessionError as e:
				logger.red('{}: {}'.format(logger.RED(pipe_name), logger.RED(nt_errors.ERROR_MESSAGES[e.error][0])))

		conn.disconnect_tree(tid)
		conn.logoff()
		conn.get_socket().close()
	except (KeyboardInterrupt, SystemExit):
		logger.red('Keyboard interrupt received..')
		quit()

def do_scan(targets):
	for target in targets:
		worawit(target)

banner.checker()

logger.header()
t=args.targets
targets=get_targets(t)

do_scan(targets)

Esempio n. 6
0
def main(message):
    logger.header('---- REQUEST RELAY NODES FROM DIRECTORY ----')
    relay_nodes = request_directory()
    logger.log('RELAY NODES: ', relay_nodes, True)
    logger.header('---- GENERATE CIRCUIT FOR ONION ROUTING ----')
    circuit = generate_circuit(relay_nodes)
    logger.log('CIRCUIT IS: ', circuit)
    circuit_copy = list(circuit)
    entry_node = circuit[0][0]
    logger.log('ENTRY NODE IS: ', entry_node, True)
    logger.header('---- BEGIN ENCRYPTION PROCESS TO WRAP ONION ----')
    encrypted_message = encrypt_payload(message, circuit, relay_nodes)
    logger.header('---- END ENCRYPTION PROCESS TO WRAP ONION ----')
    logger.log('ENCRYPTED MESSAGE: ', encrypted_message, True)
    logger.header('---- SEND REQUEST TO ENTRY NODE ----')
    response = send_request(encrypted_message, entry_node)
    logger.log('...onion routing via relay nodes', 3, True)
    logger.log('...received response from destination')
    logger.log('...received response from destination')
    byteStream = decrypt_payload(response, circuit_copy)
    result = byteStream.decode()
    logger.header('---- DECODED RESPONSE FROM DESTINATION ----\n')
    logger.log('', result)
    # write result to html file
    logger.header('---- BEGIN WRITE RESULT TO HTML FILE ----')
    f = open('response.html', 'w')
    f.write(result)
    f.close()
    logger.header('---- END WRITE RESULT TO HTML FILE ----')
    logger.header('---- OPEN ./response.html TO SEE RESPONSE ----')