- 1
Пиздец-оффтоп #50
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−1
Пиздец-оффтоп #50
#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
#49: https://govnokod.ru/28298 https://govnokod.xyz/_28298
−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
0
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/
0
#!/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';
Покритикуйте скрипт
−2
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
Инженер компании Боинг ебался с жеребцами и умер.
−6
хде хруст?
Превед, говнокод. Чому нет категории для раста?
−1
#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>
*/
0
Пиздец-оффтоп #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
0
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
0
Какой сильный момент... Гундяеву такое не по зубам.
https://youtu.be/Mx4yIsbb0Us?t=10869
Священник держит в руках монстранцию, в оригинале - ящик (ковчег) с дарами.