From f69fa9a14bd4335f256053c039eaabe229dbbb36 Mon Sep 17 00:00:00 2001 From: nihonium Date: Tue, 30 Apr 2024 16:05:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B5=D0=BC=D0=B8=D0=BD=D0=B0=D1=80=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D1=80=D0=B5=D0=B2=D0=B5=D1=80=D1=81=D1=83=20-?= =?UTF-8?q?=20=D0=93=D1=80=D0=B8=D1=88=D0=B0=D0=B5=D0=B2=20=D0=B8=20=D0=9E?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=B2=D0=BD=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/reverse/server/grishaev.c | 54 ++++++++++++++++++++++++++ tasks/reverse/server/ostrovnoi.c | 64 +++++++++++++++++++++++++++++++ tasks/reverse/server/srv | Bin 0 -> 16784 bytes 3 files changed, 118 insertions(+) create mode 100644 tasks/reverse/server/grishaev.c create mode 100644 tasks/reverse/server/ostrovnoi.c create mode 100755 tasks/reverse/server/srv diff --git a/tasks/reverse/server/grishaev.c b/tasks/reverse/server/grishaev.c new file mode 100644 index 0000000..dc5c8ce --- /dev/null +++ b/tasks/reverse/server/grishaev.c @@ -0,0 +1,54 @@ +#include +#include +#include +#include + +unsigned int MakeChecksum(unsigned char *buffer, int len) +{ + unsigned int result; + + result = 0; + for (int i = 0; i < len; i = i + 1) { + result = (result << 3 | result >> 0x1d) ^ buffer[i]; + } + return result; +} + +//0: [CHECKSUM] - 4 bytes +//[ +//4: [TIME] - 4 bytes +//8: [PAYLOAD + HEADER LEN] - 1 byte +//9: [TYPE] - 1 byte +//10: [PAYLOAD LEN] - 1 byte +//11: [PAYLOAD] +//] + +int main() { + unsigned char type = 0x2A; + unsigned char payload[] = "g1mm3_th3_k3y"; + unsigned char payload_len = strlen(payload); + + unsigned char *flag_payload = malloc(payload_len); + for (int i = 0; i < payload_len; ++i) + flag_payload[i] = payload[i] ^ 42; + + unsigned char packet_len = payload_len + 7; + time_t create_time = time(NULL); + + char *packet = calloc(payload_len + 0xb, sizeof(char)); + + memcpy(&packet[11], flag_payload, payload_len); + memcpy(&packet[10], &payload_len, 1); + memcpy(&packet[9], &type, 1); + memcpy(&packet[8], &packet_len, 1); + memcpy(&packet[4], &create_time, 4); + + int crc = MakeChecksum(packet + 4, packet_len); + memcpy(packet, &crc, 4); + + // Output + fwrite(packet, 1, payload_len + 0xb, stdout); + + free(packet); + free(flag_payload); +} diff --git a/tasks/reverse/server/ostrovnoi.c b/tasks/reverse/server/ostrovnoi.c new file mode 100644 index 0000000..392327b --- /dev/null +++ b/tasks/reverse/server/ostrovnoi.c @@ -0,0 +1,64 @@ +#include +#define _GNU_SOURCE /* See feature_test_macros(7) */ +#include +#include +#include + +unsigned int MakeChecksum(unsigned char* param_1,unsigned long param_2) +{ + unsigned int local_14; + unsigned long local_10; + + local_14 = 0; + for (local_10 = 0; local_10 < param_2; local_10 = local_10 + 1) { + local_14 = (local_14 << 3 | local_14 >> 0x1d) ^ param_1[local_10]; + } + return local_14; +} +//unsigned int MakeChecksum(unsigned char *buffer, int len) +//{ +// unsigned int result; +// +// result = 0; +// for (int i = 0; i < len; i = i + 1) { +// result = (result << 3 | result >> 0x1d) ^ buffer[i]; +// } +// return result; +//} + +int* MakePacket(void *string,size_t str_len,char param_3) +{ + unsigned int uVar1; + int* puVar2; + time_t tVar3; + + puVar2 = (int*)calloc(1,str_len + 0xb); + /* Копируем из param_1 uVar2_size байт со сдвигом 11 + байт от начала puVar2 + */ + memcpy((void *)((long)puVar2 + 0xb),string,str_len); + *(char *)((long)puVar2 + 9) = param_3; + *(char *)((long)puVar2 + 10) = (char)str_len; + tVar3 = time((time_t *)0x0); + puVar2[1] = (int)tVar3; + *(char *)(puVar2 + 2) = (char)str_len + '\a'; + uVar1 = MakeChecksum(puVar2 + 1,str_len + 7); + *puVar2 = uVar1; + return puVar2; +} + +int main() +{ + int* meow; + char* string = strdup("g1mm3_th3_k3y"); + for (int i = 0; i < 13; i++) + { + string[i] = string[i] ^ 42; + } + meow = MakePacket(string, 13, 0x2A); + + FILE* fp = fopen("out.txt", "w"); + fwrite((void*)meow, 1, 24, stdout); + fclose(fp); + free(string); +} diff --git a/tasks/reverse/server/srv b/tasks/reverse/server/srv new file mode 100755 index 0000000000000000000000000000000000000000..f1993671e153b97437ef3aa4b831b23a6c705d93 GIT binary patch literal 16784 zcmeHOeQ;FQb-%mfLqO2V6kLiwSQ9$~PFYI`CuJ`@nxaYLS0yH99~c2{0K zVc`~sSjNLfQA0AR?eRy4WD=V=X-9P!A`=G|a1m}Zshp-jXVPSwI_d7@;kD z=iYl(Z(sDkMYjn{yZ-h9eTLT^;CV9Fj6B|We7)GSrP zRMab;^rli)^KQC-hLU5-<>mT(1+nJmCNtwjxX&_r26`o_ODvGbmj6; zZ#uM0x51jrkli8v1G#S3t10V6gU-ZB~A{AA8_m^1xSl;Ggio zlOFi>9{68*;7uNQ*dq?lKz8qTPvy zEfG`V(OArauSqKzOZG_8vk#(hIF&YGFKQ>!ux%wfGwBYP>WI-Kvr=r>v~gXFxh&MU zyqulLHBDrfg;of2WBX<^Ze^_9|m{4rTxBd%$_ zZ$SbpuwTrei2#Y$OJ1jr=)rJFuZN7cY5aUxs+HF@=5u!|oYoG##7W@11DDqYN=%G7 zaBd3~U2@YR!VX+tQpr-ofzzDFsV%H>WCtBxPWOdXmhieV zD#Qa0JmA2)9Jsy&m8Crne2zoD-+}**13%!vX`SVCD6Dei&pZY}4~G>)IL&#So(iiR z;lIlu=#j8u2%oRA^7m+1F@*n~%F5s2uwn>bptACJB&-<1X-%u9Y6Pkgs7By}ion}} zo8LDE-mEnSr=Gq;2;*SR_Ls(tfmdtKN*78i{swUAw(sFLurQ1q@w7`2#e50rwll=j z5?36P{0ZXy#OEac67jV37KbJOBJs4u6^}^%E5y?hTs$oKr-`Sfu6RK5UnHKU$6}A< zKTA9xieNsyHV3)x^^h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