1. Лучший говнокод

    В номинации:
    За время:
  2. Pascal / Говнокод #1008

    +115.1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    case Key of
      'F','f','а' : Key:='А';
      '<',',','б' : Key:='Б';
      'D','d','в' : Key:='В';
      'U','u','г' : Key:='Г';
      'L','l','д' : Key:='Д';
      'T','t','е' : Key:='Е';
      '~','`','ё' : Key:='Ё';
      ':',';','ж' : Key:='Ж';
      'P','p','з' : Key:='З';
      'B','b','и' : Key:='И';
      'Q','q','й' : Key:='Й';
      'R','r','к' : Key:='К';
      'K','k','л' : Key:='Л';
      'V','v','м' : Key:='М';
      'Y','y','н' : Key:='Н';
      'J','j','о' : Key:='О';
      'G','g','п' : Key:='П';
      'H','h','р' : Key:='Р';
      'C','c','с' : Key:='С';
      'N','n','т' : Key:='Т';
      'E','e','у' : Key:='У';
      'A','a','ф' : Key:='Ф';
      '{','[','х' : Key:='Х';
      'W','w','ц' : Key:='Ц';
      'X','x','ч' : Key:='Ч';
      'I','i','ш' : Key:='Ш';
      'O','o','щ' : Key:='Щ';
      'M','m','ь' : Key:='Ь';
      '}',']','ъ' : Key:='Ъ';
      '"','''','э' : Key:='Э';
      'S','s','ы' : Key:='Ы';
      '>','.','ю' : Key:='Ю';
      'Z','z','я' : Key:='Я';
     end;

    висит на процедуре Edit1KeyPress :)

    guest, 06 Мая 2009

    Комментарии (18)
  3. Pascal / Говнокод #14988

    +115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    library ch;
    uses
      Windows,SysUtils,controls,graphics,extctrls,shellapi,Unit1 in 'Unit1.pas' {Form1};
    type
      NTStatus = cardinal;
      far_jmp = packed record
        push: byte;
        PProc: pointer;
        ret: byte;
      end;
      OldCode = packed record
        one: dword;
        two: dword;
      end;
    const
      STATUS_ACCESS_DENIED = NTStatus($C0000022);
      STATUS_SUCCESS = NTStatus($00000000);
    function CreateProcessW(lpApplicationName: PWideChar; lpCommandLine: PWideChar;
      lpProcessAttributes, lpThreadAttributes: PSecurityAttributes;
      bInheritHandles: BOOL; dwCreationFlags: dword; lpEnvironment: pointer;
      lpCurrentDirectory: PWideChar; const lpStartupInfo: TStartupInfo;
      var lpProcessInformation: TProcessInformation): BOOL; stdcall;
      external 'kernel32.dll' name 'CreateProcessW';
    var
      CPA: pointer;
      OldCPA: OldCode;
      JmpCPA: far_jmp;
      b:cardinal;
    
    procedure UnHook;
    begin
      WriteProcessMemory(INVALID_HANDLE_VALUE, CPA, @OldCPA, sizeof(OldCode), b);
    end;
    
    function FalseCreateProcessW():boolean;
    begin
      SetLastError(ERROR_ACCESS_DENIED);
      result:=falsecreateprocessw
    end;
    function TrueCreateProcessW(lpApplicationName: PWideChar;
      lpCommandLine: PWideChar; lpProcessAttributes, lpThreadAttributes
      : PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: dword;
      lpEnvironment: pointer; lpCurrentDirectory: PWideChar;
      const lpStartupInfo: TStartupInfo;
      var lpProcessInformation: TProcessInformation): BOOL; stdcall;
    begin
      WriteProcessMemory(INVALID_HANDLE_VALUE, CPA, @OldCPA, sizeof(OldCode), b);
      Result := CreateProcessW(lpApplicationName, lpCommandLine,
        lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags,
        lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
      WriteProcessMemory(INVALID_HANDLE_VALUE, CPA, @JmpCPA, sizeof(far_jmp), b);
    end;
     function NewCreateProcessW(lpApplicationName: PWideChar;
      lpCommandLine: PWideChar; lpProcessAttributes, lpThreadAttributes
      : PSecurityAttributes; bInheritHandles: BOOL; dwCreationFlags: dword;
      lpEnvironment: pointer; lpCurrentDirectory: PWideChar;
      const lpStartupInfo: TStartupInfo;
      var lpProcessInformation: TProcessInformation): bool; stdcall;
      var
        reason:string;
    begin
      result:=true;// подавляем ошибку "Доступ запрещен"
     // если что-то нам не понравилось, выходм
      else
      // или выполняем командную строку 
        Result := TrueCreateProcessW(lpApplicationName, lpCommandLine,
        lpProcessAttributes, lpThreadAttributes, bInheritHandles, dwCreationFlags,
        lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInformation);
    end;
    procedure SetHook;
    begin
       CPA := GetProcAddress(getmodulehandle('kernel32.dll'), 'CreateProcessW');
       ReadProcessMemory(INVALID_HANDLE_VALUE, CPA, @OldCPA, sizeof(OldCode), b);
       JmpCPA.push := $68;
       JmpCPA.PProc := @NewCreateProcessW;
       JmpCPA.ret := $C3;
       WriteProcessMemory(INVALID_HANDLE_VALUE, CPA, @JmpCPA, sizeof(far_jmp), b);
    
    end;
    function MessageProc(code: integer; wParam: word; lParam: longint)
      : longint; stdcall;
    begin
      Result := CallNextHookEx(0, code, wParam, lParam);
    end;
    procedure SetGlobalHookProc();
    begin
      SetWindowsHookEx(WH_GETMESSAGE, @MessageProc, HInstance, 0);
      sleep(infinite);
    end;
    procedure SetGlobalHook();
    var
      //hMutex: dword;
      TrId: dword;
    begin
        CreateMutex(nil, False, 'Vhook@016');
        if GetLastError = 0 then
        CreateThread(nil, 0, @SetGlobalHookProc, nil, 0, trid)
    end;

    procedure DLLEntryPoint(dwReason: dword);
    begin
    case dwReason of
    DLL_PROCESS_ATTACH:
    begin
    SetHook;
    SetGlobalHook;
    end;
    DLL_PROCESS_DETACH:
    begin
    UnHook;
    end;
    end;
    end;
    begin
    DllProc := @DLLEntryPoint;
    DLLEntryPoint(DLL_PROCESS_ATTACH);
    end.


    Товарищи, как можно поправить этот код, чтобы библиотека подгружалась только к процессу "explorer.exe" и патчила в его памяти CreateProcessW?

    Stertor, 26 Февраля 2014

    Комментарии (16)
  4. C++ / Говнокод #14740

    +115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    Сколько помнишь пятен солнца,
     Сколько раз горел в огне?
     Сколько раз ты изгнан вон был,
     Сколько раз ты гнил во тьме?
    
     За богохульство был распят Иисус,
     За вольнодумие стреляют и сжигают,
     Прикованный к кресту я молча обоссусь,
     Но вам не вымолить из губ моих
     Признаний
    
     Ватикан - мразь и твари,
     Переходы полнит кровь,
     Здесь кичатся билетом до рая...
     Купленным ценою слёз,
     Свет ста тысяч ртутных ламп,
     Боль ста тысяч рваных ран,
     Вот наверное и всё...
     Дьявол вновь берет своё
    
     Тлен смыкает свои пальцы,
     Сдавливая горло мне,
     Призраки немых скитальцев,
     Как и ты, горят в огне,
     Павшие в провалы ночи,
     Мы не смеем попрекать
     Иисуса, его дочерь,
     Делят что одну кровать
    
     За доброту был скован Прометей,
     И за радушие еще пока сажают,
     Топчите труп мой, брошенный, в говне,
     Но вам не вымолить из губ моих 
     Признаний
    
     Паутина склепа давит
     На кровавые глаза,
     Здесь никто ничто не знает,
     Но желает показать
     Как он чтит и как страдает,
     Как дарует благодать,
     В самом низменном желаньи,
     Перед страхом умирать
    
     Астарты глаза
     Видят грех и во тьме,
     Громким криком созвав
     На суд Бафомэт,
     Всего лишь ответы,
     Ни пытки, не боль,
     Но тех уже нету,
     Кто ответит за роль...
    
     Из круга ангелов бы изгнан Сатана,
     И по лицу до ныне выбирают,
     Я ниц пойду, с булыжником до дна,
     И моих тайн никто и не узнает...
     Но смерть и боль, жестокая война,
     На ложе богородица, не кровью -
     Соком истекает,
     И над морями изумрудного вина
     Кресты так пошло, показушно догорают...

    Не знаю почему, но называется это стихотворение "крестоблядство".
    Пруф: http://www.stihi.ru/2012/11/23/2001
    у автора и спрашивайте, где же здесь С++

    TarasB, 20 Февраля 2014

    Комментарии (5)
  5. C# / Говнокод #14622

    +115

    1. 1
    2. 2
    3. 3
    4. 4
    for (int i = 0; i < 40; i++)
    {
    GC.Collect();
    }

    чтоб наверняка :))

    alex0f0b, 17 Февраля 2014

    Комментарии (4)
  6. Си / Говнокод #14098

    +115

    1. 1
    2. 2
    3. 3
    #define TEN    10
    #define TEEN   100
    #define TEEEN  1000

    glook, 15 Ноября 2013

    Комментарии (9)
  7. C# / Говнокод #13455

    +115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    private string GenerateUserName(ISession session)
    {
      string userName = "";
      while (true)
      {
        if (IsBrand) userName = FName.Replace(" ", "");
        else userName = string.Format("{0}.{1}", FName, LName);
    
        if (String.IsNullOrEmpty(FName) && String.IsNullOrEmpty(LName))
        {
          userName = UserID.ToString();
        }
        else
        {
          var i = 0;
          while (UserBeanHelper.GetUserByUserName(session, userName) != null)
          {
            i++;
            userName = string.Format("{0}.{1}-{2}", FName, LName, i);
          }
        }
    
        UserTransferBean userByUserName = UserBeanHelper.GetUserByUserName(session, userName);
        if (userByUserName != null)
           ;
        else
        {
          break;
        }
      }
      return userName;
    }

    DarkThinker, 19 Июля 2013

    Комментарии (9)
  8. Java / Говнокод #13054

    +115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    /**
     * Converts the Accpac fields to names that do not
     * require Sherlock Holmes to decipher.
     * 
     * @param arcus Accpac customer object
     */
    public Store(final ARCus arcus) {
    	name = trim(arcus.getIdcust());
    	description = trim(arcus.getNamecust());
    	addressLine1 = trim(arcus.getTextstre1());
    	addressLine2 = trim(arcus.getTextstre2());
    	addressLine3 = trim(arcus.getTextstre3());
    	addressLine4 = trim(arcus.getTextstre4());
    	suburb = trim(arcus.getNamecity());
    	state = trim(arcus.getCodestte());
    	postalCode = trim(arcus.getCodepstl());
    	country = trim(arcus.getCodectry());
    	contactName = trim(arcus.getNamectac());
    	phone1 = trim(arcus.getTextphon1());
    	phone2 = trim(arcus.getTextphon2());
    	email = trim(arcus.getEmail2());
    	department = arcus.getAudtorg();
    }

    someone, 27 Мая 2013

    Комментарии (43)
  9. C# / Говнокод #12558

    +115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
     
    namespace ConsoleApplication49
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("Введите 16-ричное число(не более 32 знаков)");
                string s = Console.ReadLine();
                string result = "";
                string t = "123456789abcdef0";
                int i = 0;
                char[] a = new char[32];
                a = s.ToCharArray();
                char[] b = new char[16];
                b = t.ToCharArray();
                while (i<a.Length) 
                 {
                     if (a[i] != b[0]) ; else result += "0001";
                     if (a[i] != b[1]) ; else result += "0010";
                     if (a[i] != b[2]) ; else result += "0011";
                     if (a[i] != b[3]) ; else result += "0100";
                     if (a[i] != b[4]) ; else result += "0101";
                     if (a[i] != b[5]) ; else result += "0110";
                     if (a[i] != b[6]) ; else result += "0111";
                     if (a[i] != b[7]) ; else result += "1000";
                     if (a[i] != b[8]) ; else result += "1001";
                     if (a[i] != b[9]) ; else result += "1010";
                     if (a[i] != b[10]) ; else result += "1011";
                     if (a[i] != b[11]) ; else result += "1100";
                     if (a[i] != b[12]) ; else result += "1101";
                     if (a[i] != b[13]) ; else result += "1110";
                     if (a[i] != b[14]) ; else result += "1111";
                     if (a[i] != b[15]) ; else result += "0000";
                     i++;
                 };
                 Console.WriteLine("{0} в двоичном виде выглядит так {1}",s,result);
                 
                Console.ReadKey();
            
            }
        }
    }

    Перевод из 16ричной в двоичную СС

    Psilon, 08 Февраля 2013

    Комментарии (30)
  10. Java / Говнокод #12539

    +115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    try {
    	// Store settings in the database as a JSON string
    	machine.setSettings(CustomJacksonRepresentation.createCanonicalObjectMapper().writeValueAsString(
    			request.getSettings()));
    } catch (final JsonMappingException e) {
    	// We obtained request by parsing JSON in the first place,
    	// no way it can fail to be serialized back o_O
    	throw new AssertionError(e);
    } catch (final JsonGenerationException e) {
    	// See above
    	throw new AssertionError(e);
    } catch (final IOException e) {
    	// Why does writeValueAsString throw IOException anyway? How CAN you fail to write to a String?
    	// Seriously, what were the writers of Jackson smoking that they exposed IOException in the API
    	// in a method specifically designed to serialize to String, just because the underlying implementation
    	// uses StringWriter (which doesn't really throw IOException anyway)?
    	// I mean, I understand if the string is too long to fit in memory, but that's an OutOfMemoryError
    	throw new AssertionError(e);
    }

    someone, 05 Февраля 2013

    Комментарии (1)
  11. C# / Говнокод #12313

    +115

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    public bool checkUser(UserModel model = null)
    {
    	check:
    	if(model != null)
    		if(model.authenticated != false)
    			if(model._id > 0)
    				return true;
    			else
    				goto check;
    		else
    			goto check;
    	else
    		goto check;
    	return false;
    }

    а вдруг?!

    d3n4, 19 Декабря 2012

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