From a0128d323b9d3bd985973b2db3c2c328a9189e51 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Mon, 29 May 2017 17:55:36 +0200 Subject: [PATCH] PoliCTF challenge testata e funzionante. Polishing --- .gitignore | 1 + {vm => emulator}/emulator.cpp | 4 ++-- polictf/asms/decrypt.pstc | 10 ---------- polictf/res/compiled.pstc | Bin 266 -> 0 bytes polictf/res/decrypteddatasection.txt | 2 +- polictf/res/encrypteddatasection | 1 + polictf/server/pasticciotto_server.cpp | 24 ++++++++++++++++++------ polictf/server/test.py | 16 ++++++++++++++++ polictf/tea_cversion/decrypt_test | 1 - polictf/tea_cversion/encrypted | 1 - polictf/tea_cversion/tea-decrypt.c | 8 ++------ polictf/tea_cversion/tea-encrypt.c | 8 +------- polictf/tea_cversion/test.py | 12 ------------ 13 files changed, 42 insertions(+), 46 deletions(-) rename {vm => emulator}/emulator.cpp (93%) delete mode 100644 polictf/res/compiled.pstc create mode 100644 polictf/res/encrypteddatasection create mode 100644 polictf/server/test.py delete mode 100644 polictf/tea_cversion/decrypt_test delete mode 100644 polictf/tea_cversion/encrypted delete mode 100644 polictf/tea_cversion/test.py diff --git a/.gitignore b/.gitignore index cec544a..81214c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.gipu *.out *.elf +*.pasticciotto .vscode/ diff --git a/vm/emulator.cpp b/emulator/emulator.cpp similarity index 93% rename from vm/emulator.cpp rename to emulator/emulator.cpp index c70fa2e..5ab072f 100644 --- a/vm/emulator.cpp +++ b/emulator/emulator.cpp @@ -1,5 +1,5 @@ -#include "debug.h" -#include "vm.h" +#include "../vm/debug.h" +#include "../vm/vm.h" #include #include #include diff --git a/polictf/asms/decrypt.pstc b/polictf/asms/decrypt.pstc index 3f5d96e..59e8af0 100644 --- a/polictf/asms/decrypt.pstc +++ b/polictf/asms/decrypt.pstc @@ -89,14 +89,6 @@ poop r1 retn def main: -movi r0, 0x93af -movi r1, 0x9ea9 -stri 0, r0 -stri 2, r1 -movi r0, 0x2008 -movi r1, 0xc917 -stri 0x4, r0 -stri 0x6, r1 movi r0, 0 call datastrlen movr r2, r0 @@ -110,12 +102,10 @@ addr r1, s0 call round poop s0 addi s0, 4 -debg cmpr s0, r2 jpbi decrypt lodi r0, 0 lodi r1, 2 lodi r2, 4 lodi r3, 6 -debg shit \ No newline at end of file diff --git a/polictf/res/compiled.pstc b/polictf/res/compiled.pstc deleted file mode 100644 index 8500d120749b918d578a0215f091cfc01163d225..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 266 zcmYk0J&FQB6ol*bydFVelHCIsxRDqLo?t{Xp|OJvOk}~#KNLYDm4WHRi) zm1W@?IqkWIjZ12?vcnfDE~)jrpgKmDCz`z9&2SXQHxn3P=)0V^V?Uhqn~W`y3V~D- N+@x@Bhd)^P void decrypt(uint16_t *v) { - uint16_t v0 = v[0], v1 = v[1], sum = 0x3780, i; /* set up */ - uint16_t delta = 0x626f; /* a key schedule constant */ + uint16_t v0 = v[0], v1 = v[1], i; uint16_t k0 = 0x7065; // "pe" uint16_t k1 = 0x7065; // "pe" uint16_t k2 = 0x7275; // "ru" uint16_t k3 = 0x6e73; // "ns" for (i = 0; i < 128; i++) { - //printf("Intermediate v0: 0x%x | v1: 0x%x\n", v0, v1); /* basic cycle - // start */ v1 -= ((v0 << 4) + k2) ^ (v0) ^ ((v0 >> 5) + k3); v0 -= ((v1 << 4) + k0) ^ (v1) ^ ((v1 >> 5) + k1); - sum -= delta; - } /* end cycle */ + } v[0] = v0; v[1] = v1; } diff --git a/polictf/tea_cversion/tea-encrypt.c b/polictf/tea_cversion/tea-encrypt.c index 7227f07..3395365 100644 --- a/polictf/tea_cversion/tea-encrypt.c +++ b/polictf/tea_cversion/tea-encrypt.c @@ -5,21 +5,15 @@ #include void encrypt(uint16_t *v) { - uint16_t v0 = v[0], v1 = v[1], sum = 0, i; /* set up */ - uint16_t delta = 0x626f; + uint16_t v0 = v[0], v1 = v[1], i; uint16_t k0 = 0x7065; // "pe" uint16_t k1 = 0x7065; // "pe" uint16_t k2 = 0x7275; // "ru" uint16_t k3 = 0x6e73; // "ns" - // printf("v0: 0x%x, v1: 0x%x\n", v0, v1); for (i = 0; i < 128; i++) { - sum += delta; v0 += ((v1 << 4) + k0) ^ (v1) ^ ((v1 >> 5) + k1); v1 += ((v0 << 4) + k2) ^ (v0) ^ ((v0 >> 5) + k3); - // printf("Intermediate v0: 0x%x | v1: 0x%x\n", v0, v1); } - // printf("SUM: 0x%x\n", sum); - // printf("v0: 0x%x, v1: 0x%x\n", v0, v1); v[0] = v0; v[1] = v1; } diff --git a/polictf/tea_cversion/test.py b/polictf/tea_cversion/test.py deleted file mode 100644 index cd58135..0000000 --- a/polictf/tea_cversion/test.py +++ /dev/null @@ -1,12 +0,0 @@ -from pwn import * - -r = remote("127.0.0.1", 8888) - - -with open("./encrypted") as f: - data = f.read() - -print(r.recv()) -r.send("{}\n".format(len(data))) -r.send("{}\n".format(data)) -print(r.recv()) \ No newline at end of file