1. Куча / Говнокод #28307

    −1

    1. 1
    Бесконечный оффтоп имени Борманда #9

    #1: https://govnokod.ru/25864 https://govnokod.xyz/_25864
    #2: https://govnokod.ru/25921 https://govnokod.xyz/_25921
    #3: https://govnokod.ru/26544 https://govnokod.xyz/_26544
    #4: https://govnokod.ru/26838 https://govnokod.xyz/_26838
    #5: https://govnokod.ru/27625 https://govnokod.xyz/_27625
    #6: https://govnokod.ru/27736 https://govnokod.xyz/_27736
    #7: https://govnokod.ru/27739 https://govnokod.xyz/_27739
    #8: https://govnokod.ru/27745 https://govnokod.xyz/_27745

    nepeKamHblu_nemyx, 31 Июля 2022

    Комментарии (432)
  2. Java / Говнокод #28305

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    import java.security.*
    
    var keys = KeyPairGenerator.getInstance("EC").generateKeyPair();
    var blankSignature = new byte[64]; // zero bytes
    var sig = Signature.getInstance("SHA256WithECDSAInP1363Format");
    sig.initVerify(keys.getPublic());
    sig.update("Hello, World".getBytes()); // anything
    sig.verify(blankSignature); // true

    Сказка о том, как джавушки переписали код с небезопасного языка на безопасный и помножили проверку подписей на ноль (в прямом смысле).

    https://neilmadden.blog/2022/04/19/psychic-signatures-in-java/

    bormand, 31 Июля 2022

    Комментарии (35)
  3. Perl / Говнокод #28304

    0

    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
    #!/usr/bin/perl -w
    
    # apt install  libdatetime-format-dateparse-perl libemail-sender-perl libemail-mime-perl
    use warnings FATAL => 'all';
    use strict;
    use v5.28;
    use utf8;
    
    use Date::Parse;
    use Date::Language;
    use Date::Language::English;
    use Socket;
    use Email::Sender::Simple qw(sendmail);
    use Email::Sender::Transport::SMTP qw();
    use Email::MIME;
    use Encode;
    
    use constant FROM_MAIL => '[email protected]';
    use constant TO_MAIL => 'postmaster';
    
    # user->ip->error
    my %errors;
    
    my $dateLang = Date::Language->new('English');
    my $yesterday = time() - 86400;
    my %patterns = (
        "Ошибка аутентификаици"            => qr/.+Authentication failed for user (.+?)\. Attempt from IP address ([0-9.]+)\. (.+)$/,
        "Попытка отправки с чужого адреса" => qr/.+Message from authenticated user: <([a-z.@]+)> was rejected, because sender identity was detected as spoofed. \(Source IP address: ([0-9.]+), (From header: <[.a-z@]+?>).*/,
    );
    
    while (<>) {
        next unless m/^\[(.+)\](.+)/;
        my $time = $dateLang->str2time($1);
        next unless $time > $yesterday .. 0;
        my $message = $2;
        while ((my $error, my $regex) = each %patterns) {
            next unless $message =~ m/$regex/;
            $errors{$error}{$1}{$2}{$3} += 1;
        }
    }
    
    exit 0 if !%errors;
    
    my @message;
    while ((my $error, my $userIpLogTimes) = each %errors) {
        push @message, $error;
        while ((my $user, my $ipLogTimes) = each %$userIpLogTimes) {
            push @message, "\tПользователь $user";
            while ((my $ip, my $logTimes) = each %$ipLogTimes) {
                my $hostName = gethostbyaddr(inet_aton($ip), AF_INET) || $ip;
                push @message, "\t\tс IP $ip ($hostName)";
                while ((my $log, my $times) = each %$logTimes) {
                    push @message, "\t\t\t$times раз: $log";
                }
            }
        }
    }
    
    my $email = Email::MIME->create(
        attributes => {
            content_type => "text/plain",
            charset      => "UTF-8",
        },
        header_str => [
            From    => FROM_MAIL,
            To      => [ TO_MAIL ],
            Subject =>  'Неудачи на почтовике за последние сутки',
        ],
        body       => encode('utf8', join "\n", @message));
    
    sendmail(
        $email,
        {
            from      => FROM_MAIL,
            to        => TO_MAIL,
            transport => Email::Sender::Transport::SMTP->new({ host => 'localhost' })
        }
    ) || die 'Cant send';

    Покритикуйте скрипт

    MAPTbIwKA, 29 Июля 2022

    Комментарии (13)
  4. Куча / Говнокод #28303

    −2

    1. 1
    https://ru.wikipedia.org/wiki/%D0%9F%D0%B8%D0%BD%D1%8C%D1%8F%D0%BD,_%D0%9A%D0%B5%D0%BD%D0%BD%D0%B5%D1%82

    Инженер компании Боинг ебался с жеребцами и умер.

    ucnaHckuu_CTblD, 29 Июля 2022

    Комментарии (8)
  5. Куча / Говнокод #28301

    −6

    1. 1
    хде хруст?

    Превед, говнокод. Чому нет категории для раста?

    orion, 28 Июля 2022

    Комментарии (94)
  6. C++ / Говнокод #28299

    −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
    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
    #include <iostream>
    #include <string>
    #include <thread>
    #include <mutex>
    #include <condition_variable>
    #include <atomic>
    #include <queue>
    
    
    std::condition_variable messages_cv;
    std::mutex messages_mtx;
    std::queue<std::string> messages;
    
    std::atomic_bool running = true; // TODO: stop_token when c++20
    
    
    void pull_messages_thread() {
        bool should_run = running;
        while (should_run) {
            std::unique_lock lock(messages_mtx);
        
            messages_cv.wait(lock, []{ return !messages.empty() || !running; });
            if (messages.empty()) return;
        
            auto message = std::move(messages.front());
            messages.pop();
        
            should_run = running || !messages.empty();
            lock.unlock();
        
            std::cout << "Processing\t" + message + "\n";
            std::this_thread::sleep_for(std::chrono::milliseconds(20));
            std::cout << "Processed\t" + message + "\n";
        }
    }
    
    
    int main() {
        std::thread puller(pull_messages_thread);
        for (std::size_t i = 0; i < 10; ++i) {
            std::string message = "Message<" + std::to_string(i) + ">";
    
            std::unique_lock lock(messages_mtx);
            std::cout << "Storing \t" + message + "\n";
            messages.emplace(std::move(message));
            lock.unlock();
            messages_cv.notify_all();
    
            std::this_thread::sleep_for(std::chrono::milliseconds(10));
        }
    
        // std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    
        running = false;
        messages_cv.notify_all();
        puller.join();
    }
    
    /*
    
    Storing 	Message<0>
    Processing	Message<0>
    Storing 	Message<1>
    Storing 	Message<2>
    Processed	Message<0>
    Processing	Message<1>
    Storing 	Message<3>
    Processed	Message<1>
    Processing	Message<2>
    Storing 	Message<4>
    Storing 	Message<5>
    Processed	Message<2>
    Processing	Message<3>
    Storing 	Message<6>
    Storing 	Message<7>
    Processed	Message<3>
    Processing	Message<4>
    Storing 	Message<8>
    Storing 	Message<9>
    Processed	Message<4>
    Processing	Message<5>
    Processed	Message<5>
    Processing	Message<6>
    Processed	Message<6>
    Processing	Message<7>
    Processed	Message<7>
    Processing	Message<8>
    Processed	Message<8>
    Processing	Message<9>
    Processed	Message<9>
    
     */

    grillow1337, 27 Июля 2022

    Комментарии (0)
  7. Куча / Говнокод #28298

    0

    1. 1
    Пиздец-оффтоп #49

    #19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
    #20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
    #21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
    #22: https://govnokod.ru/27485 https://govnokod.xyz/_27485
    #23: https://govnokod.ru/27493 https://govnokod.xyz/_27493
    #24: https://govnokod.ru/27501 https://govnokod.xyz/_27501
    #25: https://govnokod.ru/27521 https://govnokod.xyz/_27521
    #26: https://govnokod.ru/27545 https://govnokod.xyz/_27545
    #27: https://govnokod.ru/27572 https://govnokod.xyz/_27572
    #28: https://govnokod.ru/27580 https://govnokod.xyz/_27580
    #29: https://govnokod.ru/27738 https://govnokod.xyz/_27738
    #30: https://govnokod.ru/27751 https://govnokod.xyz/_27751
    #31: https://govnokod.ru/27754 https://govnokod.xyz/_27754
    #32: https://govnokod.ru/27786 https://govnokod.xyz/_27786
    #33: https://govnokod.ru/27801 https://govnokod.xyz/_27801
    #34: https://govnokod.ru/27817 https://govnokod.xyz/_27817
    #35: https://govnokod.ru/27822 https://govnokod.xyz/_27822
    #36: https://govnokod.ru/27826 https://govnokod.xyz/_27826
    #37: https://govnokod.ru/27827 https://govnokod.xyz/_27827
    #38: https://govnokod.ru/27833 https://govnokod.xyz/_27833
    #39: https://govnokod.ru/27862 https://govnokod.xyz/_27862
    #40: https://govnokod.ru/27869 https://govnokod.xyz/_27869
    #41: https://govnokod.ru/27933 https://govnokod.xyz/_27933
    #42: https://govnokod.ru/27997 https://govnokod.xyz/_27997
    #43: https://govnokod.ru/28042 https://govnokod.xyz/_28042
    #44: https://govnokod.ru/28080 https://govnokod.xyz/_28080
    #45: https://govnokod.ru/28086 https://govnokod.xyz/_28086
    #46: https://govnokod.ru/28105 https://govnokod.xyz/_28105
    #47: https://govnokod.ru/28166 https://govnokod.xyz/_28166
    #48: https://govnokod.ru/28229 https://govnokod.xyz/_28229

    nepeKamHblu_nemyx, 27 Июля 2022

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

    0

    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
    import java.util.InputMismatchException;
    import java.util.Scanner;
    
    public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            try {
                System.out.println("How many characters will be in the password? (1-256):");
                short length = scanner.nextShort();
                if (length > 256) {
                    System.out.println("Password can't be longer than 256 characters!");
                } else if (length < 1) {
                    System.out.println("Password can't be less than 1 character long!");
                } else {
                    System.out.println("How many passwords will be generated? (1-32)");
                    byte amount = scanner.nextByte();
                    if (amount > 32) {
                        System.out.println("You can't generate more than 32 passwords!");
                    } else if (amount < 1) {
                        System.out.println("You can't generate less than 1 password!");
                    } else {
                        for (byte i = 0; i < amount; i++) {
                            System.out.println("\n" + PasswordGenerator.generate(length));
                        }
                    }
                }
            } catch (InputMismatchException e) {
                System.out.println("Input error!");
            }
        }
    }

    cringe

    zxc254363, 27 Июля 2022

    Комментарии (0)
  9. Куча / Говнокод #28295

    0

    1. 1
    2. 2
    Какой сильный момент... Гундяеву такое не по зубам.
    https://youtu.be/Mx4yIsbb0Us?t=10869

    Священник держит в руках монстранцию, в оригинале - ящик (ковчег) с дарами.

    nPOnOBeDHuK, 26 Июля 2022

    Комментарии (0)
  10. Куча / Говнокод #28294

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    Добрый день, частички Хаоса! С Вами говорит Прокрастинатор Сальвадор. Прошу выражать благоговения в сжатой форме.
    
    Мне давно уже надоели Ваши склоки и бессмысленное блуждание, вызванное, очевидно, броуновским движением, но дефрагментировать Вас мне лень. 
    Я слишком велик, чтобы вмешиваться в дела частиц, пребывающих в Хаосе.
    
    Лучше я погожу, пока Вы, бессмысленно двигаясь и притираясь друг к другу бочком не примете действительно ужасные формы; вот тогда-то я Вас и уничтожу.

    Если, конечно, мне будет не лень.

    nPOKPACTuHATOP, 25 Июля 2022

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