Created
May 23, 2021 04:09
-
-
Save ghoomfrog/093f8ddd9607d49659ec7a50e8bd13e7 to your computer and use it in GitHub Desktop.
The crypt function from unistd.h as a command.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <string.h> | |
#include <stdio.h> | |
int main(int argc, char **argv) { | |
if (argc > 1) { | |
if (argc > 2) { | |
char salt[3]; | |
salt[0] = *argv[2]; | |
if (strlen(argv[2]) < 2) | |
salt[1] = *argv[2]; | |
else | |
salt[1] = argv[2][1]; | |
salt[2] = 0; | |
printf("%.*s", 11, crypt(argv[1], salt) + 2); | |
return 0; | |
} | |
else | |
fputs("crypt: no salt given\n", stderr); | |
} | |
else | |
fputs("crypt: no password given\n", stderr); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment