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 0000000..f199367 Binary files /dev/null and b/tasks/reverse/server/srv differ