You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.6 KiB
C

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <stdio.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <string.h>
#include <time.h>
#include <stdlib.h>
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);
}