diff --git a/polictf/asms/decrypt.pstc b/polictf/asms/decrypt.pstc index 59e8af0..e95afbb 100644 --- a/polictf/asms/decrypt.pstc +++ b/polictf/asms/decrypt.pstc @@ -104,8 +104,4 @@ poop s0 addi s0, 4 cmpr s0, r2 jpbi decrypt -lodi r0, 0 -lodi r1, 2 -lodi r2, 4 -lodi r3, 6 shit \ No newline at end of file diff --git a/polictf/res/decrypteddatasection.txt b/polictf/res/decrypteddatasection.txt index 9d6cea0..159e2c2 100644 --- a/polictf/res/decrypteddatasection.txt +++ b/polictf/res/decrypteddatasection.txt @@ -1 +1 @@ -TheDataSectionHasBeenEncrypted!WhoAreYouGonnaCall?TheRuNasss! \ No newline at end of file +TheDataSectionHasBeenEncrypted...WhoAreYouGonnaCall...TheRuNasOfCourse.. \ No newline at end of file diff --git a/polictf/res/encrypteddatasection b/polictf/res/encrypteddatasection index 6b06b68..6d6f093 100644 --- a/polictf/res/encrypteddatasection +++ b/polictf/res/encrypteddatasection @@ -1 +1 @@ -꾪kR%z~*g2E$LdYxѼ:n\RXFUXE! \ No newline at end of file +꾪kR%z~*g2<wB )K4gKɟ [rd\RXF6v]BG \ No newline at end of file diff --git a/polictf/server/pasticciotto_server.cpp b/polictf/server/pasticciotto_server.cpp index 5431e5e..d9bd9c1 100644 --- a/polictf/server/pasticciotto_server.cpp +++ b/polictf/server/pasticciotto_server.cpp @@ -1,5 +1,5 @@ -#include "../../vm/vm.h" #include "../../vm/debug.h" +#include "../../vm/vm.h" #include #include #include @@ -8,9 +8,19 @@ #include #include -#define KEYLEN 15 +#define OPCODES_KEYLEN 15 #define CODESIZE 0x300 -#define DATAKEYLEN 30 +#define FLAG_LEN 30 + +unsigned char EN_DATASECTION[] = { + 0x8c, 0xea, 0xbe, 0xaa, 0xed, 0xa0, 0xd0, 0x6b, 0x99, 0x1c, 0x52, 0x25, + 0xb9, 0xe6, 0xd8, 0xff, 0xf9, 0xe9, 0x92, 0x7a, 0x1c, 0xc5, 0xc4, 0x7e, + 0x2a, 0xec, 0x67, 0x32, 0x86, 0xca, 0xff, 0xf8, 0x3c, 0x1c, 0x77, 0x42, + 0xe3, 0x20, 0x29, 0x4b, 0x34, 0x67, 0x4b, 0xc9, 0x9f, 0xa9, 0xf9, 0x0c, + 0x0f, 0x9b, 0x8a, 0x5b, 0x72, 0x64, 0xe5, 0xd8, 0x5c, 0x52, 0x58, 0x46, + 0xef, 0x36, 0x76, 0x87, 0xec, 0x1e, 0xfb, 0x5d, 0x42, 0x8e, 0xb7, 0x47}; + +unsigned int DATASECTIONLEN = 72; void gen_random(uint8_t *s, const int len) { srand(time(NULL)); @@ -24,28 +34,17 @@ void gen_random(uint8_t *s, const int len) { s[len] = 0; } -unsigned char encrypted_data[] = { - 0x8c, 0xea, 0xbe, 0xaa, 0xed, 0xa0, 0xd0, 0x6b, 0x99, 0x1c, 0x52, 0x25, - 0xb9, 0xe6, 0xd8, 0xff, 0xf9, 0xe9, 0x92, 0x7a, 0x1c, 0xc5, 0xc4, 0x7e, - 0x2a, 0xec, 0x67, 0x32, 0x1f, 0x45, 0x24, 0xd0, 0x4c, 0x7f, 0x15, 0x64, - 0x59, 0xed, 0xa6, 0x78, 0xfe, 0xad, 0xd1, 0xbc, 0xe0, 0xd8, 0x3a, 0xf9, - 0xfb, 0xf9, 0xf9, 0x6e, 0x5c, 0x52, 0x58, 0x46, 0x8d, 0x55, 0x58, 0x45, - 0x21 -}; -unsigned int encrypted_data_len = 61; - - int main(int argc, char *argv[]) { - uint8_t *key = new uint8_t[KEYLEN], *decdatasec = new uint8_t[encrypted_data_len], - *flag = new uint8_t[DATAKEYLEN]; + uint8_t *opcodes_key = new uint8_t[OPCODES_KEYLEN], + *decdatasec = new uint8_t[DATASECTIONLEN], + *flag = new uint8_t[FLAG_LEN]; uint8_t *clientcode; uint8_t i; uint32_t clientcodesize, bytesread; FILE *datap, *flagp; - gen_random(key, KEYLEN); - printf("Use this: \"%s\"\n", key); - fflush(stdout); + gen_random(opcodes_key, OPCODES_KEYLEN); + printf("Use this: \"%s\"\n", opcodes_key); printf("How much data are you sending me?\n"); fflush(stdout); scanf("%d", &clientcodesize); @@ -58,30 +57,22 @@ int main(int argc, char *argv[]) { fflush(stdout); exit(1); } - VM vm(key, clientcode, clientcodesize); - vm.as.insData(encrypted_data, encrypted_data_len); - printf("BEFORE:\n"); - for (i = 0; i < DATAKEYLEN; i++) { - fprintf(stdout, "buf[%d] = 0x%02x\n", i, vm.as.data[i]); - } + VM vm(opcodes_key, clientcode, clientcodesize); + vm.as.insData(EN_DATASECTION, DATASECTIONLEN); vm.run(); datap = fopen("../res/decrypteddatasection.txt", "r"); if (datap == NULL) { - printf("Couldn't open decrypteddatasection.txt!\n"); - fflush(stdout); - exit(1); + printf("Couldn't open decrypteddatasection.txt!\n"); + fflush(stdout); + exit(1); } fscanf(datap, "%s", decdatasec); fclose(datap); - for (i = 0; i < DATAKEYLEN; i++) { - fprintf(stdout, "buf[%d] = 0x%02x\n", i, vm.as.data[i]); - } - for (i = 0; i < DATAKEYLEN; i++) { + for (i = 0; i < DATASECTIONLEN; i++) { + DBG_INFO(("Checking data[%d]..\n", i)); if (vm.as.data[i] != decdatasec[i]) { - printf("Checking data[%d]..\n", i); - fflush(stdout); printf("Nope!\n"); fflush(stdout); exit(1); @@ -90,9 +81,9 @@ int main(int argc, char *argv[]) { flagp = fopen("../res/flag.txt", "r"); if (flagp == NULL) { - printf("Couldn't open flag.txt!\n"); - fflush(stdout); - exit(1); + printf("Couldn't open flag.txt!\n"); + fflush(stdout); + exit(1); } fscanf(flagp, "%s", flag); fclose(flagp);