From 1e806db22eaeca2de0c5474b91a04877e4ebfc5a Mon Sep 17 00:00:00 2001 From: Megamichi Date: Sun, 10 Dec 2023 13:18:13 +0100 Subject: [PATCH] upload --- c/hash_cracker | Bin 0 -> 17224 bytes c/hash_cracker.c | 133 +++++++++++++++++++++++++++++++++++++++ python/sha1_encripter.py | 24 +++++++ 3 files changed, 157 insertions(+) create mode 100755 c/hash_cracker create mode 100644 c/hash_cracker.c create mode 100644 python/sha1_encripter.py diff --git a/c/hash_cracker b/c/hash_cracker new file mode 100755 index 0000000000000000000000000000000000000000..d6db8b2cb494255df723725b5b9731da64036ece GIT binary patch literal 17224 zcmeHO4Qw07l^)7gBLBox(#Um`G}`#=R*oZDl5L%>_=mDZWtCdC&bCswXtSoorNo9J zS#lLiMqH~^)Dt5JQQNfVYmGt;(8NfufqIt)zBE6yos-m}N#!7IU7#s+7xzFWc23E; ziQ03+dv9hQce&;s4#fcn+;If$d+&Qc^S3**!<{+q+tX6waxqGa*bau$_>BVbO2x?C zk^$mnTi6Y7tzx&c>p))2F`@Sg0$PzSl;qPgi7x_*eyflvKyMQ;BT6MiihfRMa+%N& zW#vLfzfxqSY^SA5g&k4S=kim8p4n(x){m&w58EbHBm7d^^XY>0YnSyWKZMb5R{G6K zKce$kAV@^1J+V#je~XM~rwZsWDg4Tq-S3d}v(sj2PZaaObl`VJ;LpjgUHYZ&5OM5u zn}8Wn%I~kh58LIxo2Z-jQ+^Kp;FbMAR5mZ$5Ds-VY}ybG)PzHkzW$p2Ee$mdn>>lA zr=Ax9%Y}L1J$29C4puVAQizd1@;AdjHY@5^E_(Wtr|SRt;hm3-8OlU8Ql#?rgLmOWI((kfCwzvebTjBp>@PA%^wKv$|FW>s!=xzV-_y;!u40NjDDZDjhX5#4{_i{Bzi`0s0$hQA zd#ZLQ|C?Y~DBnjN@CgU}FCF4P>tNsFfWPH{*E+=igM)py1AYs{Sq(aSdI5kNStUz( zg@(qRWnhmuYs$xeBkkvG_Ds{dd!rF8Vff>QrZK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tl|nGb3Hc-%jr=@BD7z=Cnu z+OGxrdV2@J#Ug27Y2=yW&%Rn0{M7w`9*1&iTFd^XHlOC(+l*%uG&s$p`BVw2&HI^l z&z^m|n)Yb>T3QbH4r&LRcJ1+jVe_Z=Hnp|x29LbM4R}((OPld=2R@z}$OCxc`6&eZ z(FAY)mVSBEAkSHx9LR&jVS_w~pJ2#C{_8Ur`{0ZM9COg%NB@BBScR=jct9dAus8>i z2l2cLp5cJb^c#M0AOafBdio(Rf;B z3ZSM4bPy)li)1$jiub(1h1Nzne6zGm(&W5@$B@obh(!XE|a6dAL~&d7i~q z4!E%c^1Mi%A7%k(O!6>sVk8gJbZly9WZMyxoDm!pF^fPaW^85PXIA(V1YaN$1HFd7 z6Q~gvw1+r2wW7yk%oB+kx~DtR=ZVFmF+FY!SfI|n5FE%01tiq8tF;CP2yV`s$P*Zd zKo*QsBQ7)#!q+JH#*-&#po{BaKN?Cd7B-j%A9Usc*3%sY#?brWiUS20MR{X*^d31h z^aLOXNy1f(5yFFb$id$m>VoW}21bU$VWWDW!rf~T+@7i;< zv`(W8(AJv%0t8$e!F0xx)A>=U&aL-IZUDyWZ$C$h--oP;-cty}_h73(y@wN3$WT(d z|EBeLjCwu>&1k~!UNI#;7 zZ4FMZ9YmkB`47tV8&N8+$lWYI;gdFhIzLY|OolQ5Heb-_WWP7`R5h^tA$6J93{2q{~N$pz&}1i zm}nhK=jZMABoj@8j~o8UpVrMYH5l#M`jQ{fD`1279{JPyl+NMv{hy%6=LZw{Q9phk zFl;~ar}KrW4QS0+wII1G`4jyUXsrJ9`&L@|r*fWxAwQzmfwR@0*3qYGg*}y%!jK=y z%fT73T=~61b6WbhlcA)FO}*VgFvf%Z0H@n}bbc{|OH~<=X%N literal 0 HcmV?d00001 diff --git a/c/hash_cracker.c b/c/hash_cracker.c new file mode 100644 index 0000000..7ad96ea --- /dev/null +++ b/c/hash_cracker.c @@ -0,0 +1,133 @@ +#include +#include +#include +#include +#include + +void print_help(char *program_name) { + printf("Usage: %s -z -h -t \n", program_name); + printf("Options:\n"); + printf(" -z \tCharacters to use for hashing\n"); + printf(" -h \tHash to find\n"); + printf(" -t \tHash type (MD5, SHA1, SHA224, SHA256, SHA384, SHA512)\n"); + printf(" -help\t\tShow this help message\n"); +} + +char* hash(const char* data, const EVP_MD* hash_type) { + unsigned char hash[EVP_MAX_MD_SIZE]; + unsigned int hash_len; + + EVP_MD_CTX *mdctx; + mdctx = EVP_MD_CTX_new(); + + EVP_DigestInit_ex(mdctx, hash_type, NULL); + EVP_DigestUpdate(mdctx, data, strlen(data)); + EVP_DigestFinal_ex(mdctx, hash, &hash_len); + + EVP_MD_CTX_free(mdctx); + + char* hashed = malloc(sizeof(char) * (2 * hash_len + 1)); + for (int i = 0; i < hash_len; i++) { + sprintf(&hashed[i * 2], "%02x", hash[i]); + } + return hashed; +} + +int main(int argc, char *argv[]) { + char digits[256]; + char hash_text[256]; + char hash_type_str[256]; + + int c; + int z_flag = 0, h_flag = 0, t_flag = 0; + + while ((c = getopt(argc, argv, "z:h:t:help")) != -1) { + switch (c) { + case 'z': + strcpy(digits, optarg); + z_flag = 1; + break; + case 'h': + print_help(argv[0]); + exit(EXIT_SUCCESS); + case 't': + strcpy(hash_type_str, optarg); + t_flag = 1; + break; + case '?': + fprintf(stderr, "Invalid option. Use -help for usage information.\n"); + exit(EXIT_FAILURE); + } + } + + if (!(z_flag && h_flag && t_flag)) { + printf("zeichen:"); + fgets(digits, sizeof(digits), stdin); + digits[strcspn(digits, "\n")] = '\0'; + + printf("hash:"); + fgets(hash_text, sizeof(hash_text), stdin); + hash_text[strcspn(hash_text, "\n")] = '\0'; + + printf("Hashtype:"); + fgets(hash_type_str, sizeof(hash_type_str), stdin); + hash_type_str[strcspn(hash_type_str, "\n")] = '\0'; + } + + if (strcmp(hash_type_str, "help") == 0) { + print_help(argv[0]); + exit(EXIT_SUCCESS); + } + + printf("Verfügbare Hashtypen:\n"); + + const EVP_MD *hash_type; + EVP_MD *md; + const char* known_digests[] = {"MD5", "SHA1", "SHA224", "SHA256", "SHA384", "SHA512", NULL}; + + for (int i = 0; known_digests[i] != NULL; i++) { + printf("%s,", known_digests[i]); + } + printf("\n"); + + hash_type = EVP_get_digestbyname(hash_type_str); + + if (!hash_type) { + printf("Ungültiger Hash-Typ\n"); + exit(1); + } + + int len = strlen(digits); + int i = 1; + while (1) { + int n = i; + char s[256] = ""; + while (n > 0) { + char digit[2] = {digits[(n - 1) % len], '\0'}; + strcat(s, digit); + n = (n - 1) / len; + } + + // Reverse the string to get correct order + int length = strlen(s); + for (int j = 0; j < length / 2; j++) { + char temp = s[j]; + s[j] = s[length - j - 1]; + s[length - j - 1] = temp; + } + + char* hashed = hash(s, hash_type); + printf("%s %s\n", s, hashed); + + if (strcmp(hashed, hash_text) == 0) { + printf("found: %s %s\n", s, hashed); + free(hashed); + exit(0); + } + free(hashed); + + i++; + } + + return 0; +} diff --git a/python/sha1_encripter.py b/python/sha1_encripter.py new file mode 100644 index 0000000..bbe6165 --- /dev/null +++ b/python/sha1_encripter.py @@ -0,0 +1,24 @@ +import hashlib +def hash(data, hash_type): + return hashlib.new(hash_type, data.encode('utf-8')).hexdigest() if hash_type in hashlib.algorithms_available else "Ungültiger Hash-Typ" + +digits = input("zeichen:") +hash_text = input("hash:") +for a in hashlib.algorithms_available: + print(a,end=",") +print("") +type = input("Hashtype:") + +i = 0 +while 1 : + n =i + s = '' + while n > 0: + s = digits[n % len(digits)] + s + n //= len(digits) + hashed = hash(s,type) + print(s,hashed) + if hashed == hash_text: + print("found: ",s,hashed) + exit() + i += 1 \ No newline at end of file