fcrackzip: init at 1.0

authored by

Nicolò Balzarotti and committed by
Robin Gloster
9371acd8 8fa49a63

+133
+26
pkgs/tools/security/fcrackzip/default.nix
···
··· 1 + {stdenv, fetchurl}: 2 + 3 + stdenv.mkDerivation rec { 4 + name = "fcrackzip-${version}"; 5 + version = "1.0"; 6 + src = fetchurl { 7 + url = "http://oldhome.schmorp.de/marc/data/${name}.tar.gz"; 8 + sha256 = "0l1qsk949vnz18k4vjf3ppq8p497966x4c7f2yx18x8pk35whn2a"; 9 + }; 10 + 11 + # 'fcrackzip --use-unzip' cannot deal with file names containing a single quote 12 + # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=430387 13 + patches = [ ./fcrackzip_forkexec.patch ]; 14 + 15 + # Do not clash with unizp/zipinfo 16 + postInstall = "mv $out/bin/zipinfo $out/bin/fcrackzip-zipinfo"; 17 + 18 + meta = with stdenv.lib; { 19 + description = "zip password cracker, similar to fzc, zipcrack and others"; 20 + homepage = http://oldhome.schmorp.de/marc/fcrackzip.html; 21 + license = licenses.gpl2; 22 + maintainers = with maintainers; [ nico202 ]; 23 + platforms = with platforms; unix; 24 + }; 25 + } 26 +
+105
pkgs/tools/security/fcrackzip/fcrackzip_forkexec.patch
···
··· 1 + --- origin/main.c 2016-12-12 12:53:38.344285376 +0100 2 + +++ main.c 2016-12-12 13:01:41.134548824 +0100 3 + @@ -26,11 +26,13 @@ 4 + #include <string.h> 5 + 6 + #ifdef USE_UNIX_REDIRECTION 7 + -#define DEVNULL ">/dev/null 2>&1" 8 + +#define DEVNULL "/dev/null" 9 + #else 10 + -#define DEVNULL ">NUL 2>&1" 11 + +#define DEVNULL "NUL" 12 + #endif 13 + 14 + +#include <errno.h> 15 + + 16 + #include "crack.h" 17 + 18 + int use_unzip; 19 + @@ -47,21 +49,77 @@ 20 + int REGPARAM 21 + check_unzip (const char *pw) 22 + { 23 + - char buff[1024]; 24 + - int status; 25 + +pid_t cpid; 26 + +cpid = fork (); 27 + +if (cpid == -1) 28 + + { 29 + + perror ("fork"); 30 + + exit (EXIT_FAILURE); 31 + + } 32 + + 33 + +if (cpid == 0) 34 + + { 35 + + // Redirect STDERR/STDOUT to /dev/null 36 + + int oldfd_stderr, oldfd_stdout; 37 + + oldfd_stdout = dup (fileno (stdout)); 38 + + if (oldfd_stdout == -1) 39 + + { 40 + + perror ("dup for stdout"); 41 + + _exit (127); 42 + + } 43 + + oldfd_stderr = dup (fileno (stderr)); 44 + + if (oldfd_stderr == -1) 45 + + { 46 + + perror ("dup for stderr"); 47 + + _exit (127); 48 + + } 49 + + if (freopen (DEVNULL, "w", stdout) == NULL) 50 + + { 51 + + perror ("freopen " DEVNULL " for stdout"); 52 + + _exit (127); 53 + + } 54 + + if (freopen (DEVNULL, "w", stderr) == NULL) 55 + + { 56 + + perror ("freopen " DEVNULL " for stderr"); 57 + + _exit (127); 58 + + } 59 + + execlp ("unzip", "unzip", "-qqtP", pw, file_path[0], NULL); 60 + + 61 + + // When execlp failed. 62 + + // Restores the stderr/stdout redirection to print an error. 63 + + int errno_saved = errno; 64 + + dup2 (oldfd_stderr, fileno (stderr)); 65 + + dup2 (oldfd_stdout, fileno (stdout)); 66 + + close (oldfd_stderr); 67 + + close (oldfd_stdout); 68 + + errno = errno_saved; 69 + + perror ("execlp for unzip"); 70 + + _exit (127); // Returns 127 on error as system(3) does 71 + + } 72 + 73 + - sprintf (buff, "unzip -qqtP \"%s\" %s " DEVNULL, pw, file_path[0]); 74 + - status = system (buff); 75 + - 76 + -#undef REDIR 77 + + int status; 78 + 79 + - if (status == EXIT_SUCCESS) 80 + + if (waitpid (cpid, &status, 0) == -1) 81 + { 82 + - printf("\n\nPASSWORD FOUND!!!!: pw == %s\n", pw); 83 + + perror ("waitpid"); 84 + + exit (EXIT_FAILURE); 85 + + } 86 + + 87 + + // The child process does not terminated normally, OR returns the exit status 127. 88 + + if (!WIFEXITED (status) 89 + + || (WIFEXITED (status) && (WEXITSTATUS (status) == 127))) 90 + + { 91 + + fprintf (stderr, "Executing unzip failed.\n"); 92 + + exit (EXIT_FAILURE); 93 + + } 94 + +// unzip exited normally with the exit status 0 then... 95 + + if (WIFEXITED (status) && (WEXITSTATUS (status) == EXIT_SUCCESS)) 96 + + { 97 + + printf ("\n\nPASSWORD FOUND!!!!: pw == %s\n", pw); 98 + exit (EXIT_SUCCESS); 99 + } 100 + 101 + - return !status; 102 + + return 0; 103 + } 104 + 105 + /* misc. callbacks. */
+2
pkgs/top-level/all-packages.nix
··· 1663 1664 fcppt = callPackage ../development/libraries/fcppt/default.nix { }; 1665 1666 fcron = callPackage ../tools/system/fcron { }; 1667 1668 fdm = callPackage ../tools/networking/fdm {};
··· 1663 1664 fcppt = callPackage ../development/libraries/fcppt/default.nix { }; 1665 1666 + fcrackzip = callPackage ../tools/security/fcrackzip { }; 1667 + 1668 fcron = callPackage ../tools/system/fcron { }; 1669 1670 fdm = callPackage ../tools/networking/fdm {};