better data housekeeping since we're using the on-device heap now... don't want to leave a mess

This commit is contained in:
2020-02-11 15:34:47 -05:00
parent 8b25a00bd4
commit 823c914e84
4 changed files with 135 additions and 35 deletions

View File

@@ -44,62 +44,55 @@ void checkm8_debug_block(const char *format, ...)
#endif
}
int floppysleep(struct pwned_device *dev)
void floppysleep(struct pwned_device *dev)
{
struct dev_cmd_resp *resp;
if(IS_CHECKM8_FAIL(open_device_session(dev)))
{
printf("failed to open device session\n");
return -1;
return;
}
if(IS_CHECKM8_FAIL(install_payload(dev, PAYLOAD_SYNC, SRAM)))
{
printf("failed to install sync payload\n");
return -1;
return;
}
if(IS_CHECKM8_FAIL(install_payload(dev, PAYLOAD_FLOPPYSLEEP, SRAM)))
{
printf("failed to install task sleep payload\n");
return -1;
return;
}
float init_a = -7.504355E-39f;
unsigned long long init_a_ptr = install_data(dev, SRAM, (unsigned char *) &init_a, sizeof(float));
DEV_PTR_T init_a_ptr = install_data(dev, SRAM, (unsigned char *) &init_a, sizeof(float));
if(init_a_ptr == DEV_PTR_NULL)
{
printf("failed to write initial data\n");
return -1;
return;
}
resp = execute_payload(dev, PAYLOAD_SYNC, 0, 0);
if(IS_CHECKM8_FAIL(resp->ret))
{
printf("failed to execute bootstrap\n");
return -1;
return;
}
free_dev_cmd_resp(resp);
while(1)
resp = execute_payload(dev, PAYLOAD_FLOPPYSLEEP, 0, 1, init_a_ptr);
if(IS_CHECKM8_FAIL(resp->ret))
{
resp = execute_payload(dev, PAYLOAD_FLOPPYSLEEP, 0, 1, init_a_ptr);
if(IS_CHECKM8_FAIL(resp->ret))
{
printf("failed to execute flopsleep payload\n");
return -1;
}
printf("retval is %08lli\n", resp->retval);
free_dev_cmd_resp(resp);
usleep(2000000);
printf("failed to execute flopsleep payload\n");
return;
}
printf("retval is %08lli\n", resp->retval);
free_dev_cmd_resp(resp);
close_device_session(dev);
free_device(dev);
}
void aes_sw(struct pwned_device *dev)
@@ -347,8 +340,10 @@ int main()
}
demote_device(dev);
floppysleep(dev);
aes_sw(dev);
uninstall_all_payloads(dev);
uninstall_all_data(dev);
free_device(dev);
}