Newer
Older
#include "myorca_uart.h"
#define __OPTION_ATTACK_ENABLE__ 1
#define __OPTION_VICTIM_ENABLE__ 1
// Attack and Victim code
#if __OPTION_ATTACK_ENABLE__ == 1
#include "attack.h"
#endif
#if __OPTION_VICTIM_ENABLE__ == 1
#include "victim.h"
#endif
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
#define HEAP_SIZE_BYTE 1024
char myorca_heap[HEAP_SIZE_BYTE];
int victim_data_address[16];
// ----------------------------------------------------------------------------
// Main
// ----------------------------------------------------------------------------
// Prepare heap
orca_init_malloc(myorca_heap, HEAP_SIZE_BYTE, 4);
#if __OPTION_ATTACK_ENABLE__ == 1
attack_prepare(victim_data_address);
uart_printf("\r\nATTACK_ENABLE");
#if __OPTION_VICTIM_ENABLE__ == 1
unsigned int uart_read_fifo_count = 0;
while (1) {
wait(1000);
uart_read_fifo_count = uart_get_read_fifo_count();
if (uart_read_fifo_count > 0) {
char read_value = uart_read_char();
uart_printf("\r\nReceived value from Uart: (");
uart_printc(read_value);
uart_printf(").");
#if __OPTION_ATTACK_ENABLE__ == 1
victim_1(victim_data_address);
uart_printf("--");
attack_1(res);
if (res[0] < 3) {
uart_printc('A');
}
#else
}
}
return 0;
}
// ----------------------------------------------------------------------------
// Exception handling
// ----------------------------------------------------------------------------
uart_printf("Exception\r\n");
while (1) {
}
// ----------------------------------------------------------------------------
// Victim code
// victim_1 provide simple memory access
// ----------------------------------------------------------------------------
void victim_1(int* val_addr) {
uart_printc('V');
uart_printi(val_addr[0]);
val_addr[0] = val_addr[0] + 1;