From 121865a58320085d599991c64d920fe450b9797f Mon Sep 17 00:00:00 2001
From: CC862 <84750801+CC862@users.noreply.github.com>
Date: Sat, 18 Feb 2023 20:21:40 -0500
Subject: [PATCH] Revert "Prob 1 2"
---
.idea/modules.xml | 2 +-
.idea/uiDesigner.xml | 124 -----------
.idea/vcs.xml | 6 -
Prod_1_2.iml => Prod_1_1.iml | 0
out/production/Prod_1_1/SimpleCracker.class | Bin 0 -> 3112 bytes
.../common-passwords} | 0
out/production/Prod_1_1/shadow-simple | 10 +
out/production/Prod_1_2/Cracker.class | Bin 2801 -> 0 bytes
out/production/Prod_1_2/MD5Shadow.class | Bin 3772 -> 0 bytes
out/production/Prod_1_2/shadow | 10 -
src/MD5Shadow.java | 199 ------------------
src/{Cracker.java => SimpleCracker.java} | 18 +-
...{common-passwords.txt => common-passwords} | 0
src/shadow | 10 -
src/shadow-simple | 10 +
15 files changed, 32 insertions(+), 357 deletions(-)
delete mode 100644 .idea/uiDesigner.xml
delete mode 100644 .idea/vcs.xml
rename Prod_1_2.iml => Prod_1_1.iml (100%)
create mode 100644 out/production/Prod_1_1/SimpleCracker.class
rename out/production/{Prod_1_2/common-passwords.txt => Prod_1_1/common-passwords} (100%)
create mode 100644 out/production/Prod_1_1/shadow-simple
delete mode 100644 out/production/Prod_1_2/Cracker.class
delete mode 100644 out/production/Prod_1_2/MD5Shadow.class
delete mode 100644 out/production/Prod_1_2/shadow
delete mode 100644 src/MD5Shadow.java
rename src/{Cracker.java => SimpleCracker.java} (69%)
rename src/{common-passwords.txt => common-passwords} (100%)
delete mode 100644 src/shadow
create mode 100644 src/shadow-simple
diff --git a/.idea/modules.xml b/.idea/modules.xml
index f3ce226..97c3b48 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
deleted file mode 100644
index 2b63946..0000000
--- a/.idea/uiDesigner.xml
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
- -
-
-
-
-
- -
-
-
- -
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Prod_1_2.iml b/Prod_1_1.iml
similarity index 100%
rename from Prod_1_2.iml
rename to Prod_1_1.iml
diff --git a/out/production/Prod_1_1/SimpleCracker.class b/out/production/Prod_1_1/SimpleCracker.class
new file mode 100644
index 0000000000000000000000000000000000000000..ca1b432afd3cecd93d6d4eb6b0ba720df9c38d50
GIT binary patch
literal 3112
zcmaJ@`Ewg*8Gb%l(&|`Swj8?=j*~XcAt!N^7z*t=NgF#!<6=9Z3U(cHt);EB@k*=i
zt`eK8g&rKe3zP;ZN1?dfg<+hK3>ki8m|+Hn8Ge9&g5P0ko^Mxjq*yTatiI#DzUO)0
z_xt|z-i=!T9>lu|gwUlRtRjM_K<_2}vYxZ_YAJVa>5@_K1fs{xs_C5&=*o`FDToPd
z^Mxw9SI$kCrKzfClnf^U1qo>-NtNu>;>5^Ynl8Fk^dKd0S4CeoChclL_vTHn%#rKq
zRnHX|$WDz+-*%h#9J5*)PoNKJ1^p_vVW2IpK!8pjw;jeH@IZE}`eMscaFFp1P88fF
zp!&W|J9oykj2JR>R{F(l8nLx$U8x)H3zWv4)&Z>jE?RxV%A
zt5pfgFz%L$_i(qN*zhzimF{g*I;*?oyx}FV8(mU!p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-5>P%EBprkCxL(C;s)JC?huu^`Z|qA`TI>0--T~;7Q%N3
d4M<5BgAxQset+zL-@#A0li>Vkgz8tw{1@1|6?y;w
literal 0
HcmV?d00001
diff --git a/out/production/Prod_1_2/common-passwords.txt b/out/production/Prod_1_1/common-passwords
similarity index 100%
rename from out/production/Prod_1_2/common-passwords.txt
rename to out/production/Prod_1_1/common-passwords
diff --git a/out/production/Prod_1_1/shadow-simple b/out/production/Prod_1_1/shadow-simple
new file mode 100644
index 0000000..a898aa9
--- /dev/null
+++ b/out/production/Prod_1_1/shadow-simple
@@ -0,0 +1,10 @@
+user0:qtoUil1J:3DACEF3B08BDAEFF0F9402FAB9270F67
+user1:LqVLX/PV:6A3DFBD5580F3A5A421CB37F4D4B7725
+user2:Ckf4mO9I:61C42F5C40F727B657CC8402359E4A17
+user3:x62ZrMwu:0174A2A91EA1881A5BC582AEF37E6F35
+user4:2VF0AblA:D08C5912FB8E6B0A9530C5FDDACA734D
+user5:CEhrE/C7:6D48564E27D9B4626A3ADBA5F369B0F3
+user6:cWGoHf89:A4EBD768B02F3418FEF93DCD152A9F85
+user7:tqKaVL4O:7F8032B62525D9FAF339CE4128579566
+user8:T7cTnZz0:4AFB9E06F08F664F367F5E2244666FC0
+user9:60O7QHXH:92AC0B3C76BD44C8768355FB0349AA19
\ No newline at end of file
diff --git a/out/production/Prod_1_2/Cracker.class b/out/production/Prod_1_2/Cracker.class
deleted file mode 100644
index 04c9e1007a08cf2e6d997abd4f1b4626a66d5097..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 2801
zcmaJ@X;%|x6n+MhOcDl>AZWyuqJoOCRI3dx72L1^X=6piE<-YsfyqpqnILpu>|*!T
zYS)jPo_^_a4q9nF?FajzzotK+NBX=o35Mkq&Y5}N``-K9d!KvXJNf(G?K=PtM{?ruLDql;PvD^Mq4bzU9UdMq=ex`Vo#I9
zwr-AgMNyBKj0Od((6}HjUx7|8S~g>l@JQQI^Wh4SpGem-PGqc>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#}IqZib;Y1l4$#yDGeg_xWDI)d!5^Gw*o~*C~r~e*<6P
H8^r$u#TmDc
diff --git a/out/production/Prod_1_2/MD5Shadow.class b/out/production/Prod_1_2/MD5Shadow.class
deleted file mode 100644
index a8eb80e2a3a77522cff5133466da8e5c26d3a216..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 3772
zcmaJ^ZE#ar8GcT3lY4t}Y17&Q0m{d2fszyov~(ebLR-EHEnn>xN?GMLy`-UO5|SHe
ztFox9>#obH>+HCw<1!3m9Y<$acBfRpsypKk-G7dM)N%BWj8x9yb8}ltlQq-a
z`@ZMAAJ6-7-jn|R(?_!a_Tw!b9(YwK27K@f1TULc&BmmeiZ`Adx@^U40sr1aDq*(?
zck
z#kz$E2t&nc18Yz#pxNnp-_`ZS8m$`EF(-^q#|Av7;&}sg*eI~t2`*>F^4Wwv(b!|<
za%S8*n21|BW-}1C?5^JD{Y`v#b$v`&$>8~?#;(W+LQ4#J&ueW8jo2S
zJCRQ5*n}+x!m_Xx85YX!wawUQU)GFSvQ7;Kw#p*;#>{vkCQHz0U^{jQ=meOxb7yHz
zpr#ba^HRLYKr?nR*-0xEm!fQuF1hi7tmAH}TDne^h#F|cUgjfd=9rLSYy9LT0fq8i
zRqV_*gUxwBV8xg@YIUYlG1Hb{NXgXMIe}v(P!(6Yc%?)oCE^YPojAyV$!lI7JKd
z+nTe@T@_~-<iG|SaC_{MBpY6O#nhnI2{@S9B**)`|Sskd^H-hmu^W>Q2YZ
zWWSkBNZwsk?2!bM8|Yq`46Onp!Ecv5wb`sW!3OjUcFc1-NyMBEV3wT*?lCitF%@w}
zGG>nRnUH7QchyYh>DZsOa`_}r+sdN)y9b@JvFt>KBD+guut=-5IHyGIvFO=VUpTIx
zbr>nH#O!g#re(}r?piuaz)H@PFje_FBqLBW*WB(alWQ*RrD8#y$p{spn=dc(Gh*gO
zj#w!xYuf3oKy5*G0o*ggh={bkv7|fQ_1<(o8?z24WaY{iinC3&CI@myI&E|OnwcKU
z9!U@9D*Sjw$JgIQ_jk%cvE0wQE;U&tN6CS+W#-g_ACU*$r9l03x0Juh)L=4*5um{HmLLb0=Y(V
zf^T2=A;fzmJh;fG6ava%@@W(VFoYO6T}~UWNacGpr0~5xJR6z4_(bdRw$(Pw-o=L6
zFrP+4ZMe3nZ%Psot_(Nz-Smp7xxY2sr;gY0vzC`4IL|fIAcz%Mju6(N7WL$}VZGx&
zOdmS$zhPL^qBmSZoNq~ukYcM*K0(TZ%Umso@?YpGMn$#uA0pJ{6m=1QK;B20mhkKv
z0zTnwQEHT}1iPt5k(kT3@?E1y)RK(IRf$_6?mul^ihCo`Z{~pC!hspV^GxP8^3B-k
z;BIz&haKE9ODzkyTU^|7Ey<`nwA1KB;9U~IO1%&PC$t;EyR_=${4vylhx`$AQ_QXY
z0oJVw?!VsF@Bn&kt#WZ1!D%c%yDI3PY@M3>d&4wVEyW&X)>_#R`5f)JL9w5oTrg-b6y6|C(u-=`H)AX@;doM9sw?5PVP>Jw4Fh^iv0
ziKt$+b_VOC`V{nNAQYHJedGZm)7W+!{Y*D7>J__j})v-)0?NPteL6zQr-NhB}6D=BW
zEmnjAA)hoBVE>cW9J)sFXKp*Z-{pg{W5
zXa9AxBYW6|rzq7&xdD!teyqkhj+d9Pi(}|02is{j^#G6H2oK;SzKBT{p;ZK{IL^yC
zwr)7rle~a7GgA2pR1Ln5NYzX4Lzj1$aPAiQ?7;JqTlfw_{{vRkUa$ZF
diff --git a/out/production/Prod_1_2/shadow b/out/production/Prod_1_2/shadow
deleted file mode 100644
index 9b0acf0..0000000
--- a/out/production/Prod_1_2/shadow
+++ /dev/null
@@ -1,10 +0,0 @@
-user0:$1$IHQqp.5e$iBRGUi.ZZtXDXvcFHyEE20:17801:0:99999:7:::
-user1:$1$EZ66DAJc$28BvFjvBnA/DDokoiPAls1:17801:0:99999:7:::
-user2:$1$9veighCQ$pVSDQYcJ.pAYprwPkcqAm1:17801:0:99999:7:::
-user3:$1$QAsKJurv$k6nqPmZAEHBI5NfQ0HUpa/:17801:0:99999:7:::
-user4:$1$EW3CpL8A$QPwa4cl809qiEXOAr.MaJ1:17801:0:99999:7:::
-user5:$1$OpC0/rME$LC7SumvOZ9ZLilH3./aJQ.:17801:0:99999:7:::
-user6:$1$wCquloBw$y2MjiyvGMNunrRcZLRO5j/:17801:0:99999:7:::
-user7:$1$.Coe4fHg$DhwAgs6gFdTK0PwyufA.00:17801:0:99999:7:::
-user8:$1$MCpfHPHC$I1B0MMpUOEtGCBi5IHql//:17801:0:99999:7:::
-user9:$1$n13aYQ9M$dJOH0drziInPCx6FnHnex0:17801:0:99999:7:::
diff --git a/src/MD5Shadow.java b/src/MD5Shadow.java
deleted file mode 100644
index 7323c97..0000000
--- a/src/MD5Shadow.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******
-* Prepared for Project 1, CS 645, Fall 2020, NJIT
-*******/
-
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-public class MD5Shadow
-{
-
- /** magic is 1 for MD5 */
- private static String magic = "$1$";
-
- /** Characters for base64 encoding */
- private static String char64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
- private static byte[] Concat(byte[] array1, byte[] array2)
- {
- byte[] concat = new byte[array1.length + array2.length];
- for (int i = 0; i < concat.length; i++)
- {
- if (i < array1.length)
- {
- concat[i] = array1[i];
- }
- else
- {
- concat[i] = array2[i - array1.length];
- }
- }
- return concat;
- }
-
- private static byte[] PartialConcat(byte[] array1, byte[] array2, int max)
- {
- byte[] concat = new byte[array1.length + max];
-
- for (int i = 0; i < concat.length; i++)
- {
- if (i < array1.length)
- {
- concat[i] = array1[i];
- }
- else
- {
- concat[i] = array2[i - array1.length];
- }
- }
- return concat;
- }
-
- //This method would convert an value to the Base64 string
- private static String to64(int value, int length)
- {
- StringBuffer result;
-
- result = new StringBuffer();
- while (--length >= 0)
- {
- int ind = value & 0x3f;
- result.append(char64.substring(ind, ind + 1));
- value >>= 6;
- }
- return (result.toString());
- }
-
- public static String crypt(String password, String salt)
- {
- int saltEnd;
- int value;
- int i;
-
- byte[] pwBytes = null;
- byte[] saltBytes = null;
- byte[] ctx = null;
- byte[] ctx2 = null;
-
- StringBuilder result;
- MessageDigest hashGenerator = null;
- try
- {
- //initialize the MD5 hash generator
- hashGenerator = MessageDigest.getInstance("MD5");
- }
- catch (NoSuchAlgorithmException ex)
- {
- ex.printStackTrace();
- }
-
-////////////////////////////////////////Some safety checks.... can be omitted..................
- // Skip magic if it exists with the salt..... checking for accidentally using along with magic
- if (salt.startsWith(magic))salt = salt.substring(magic.length());
-
- // Remove password hash if present..... checking for accidentally using along with pw
- if ((saltEnd = salt.lastIndexOf('$')) != -1)salt = salt.substring(0, saltEnd);
-
- // Shorten the salt to 8 characters if it is longer.......... assuming the salt must be 8 chars long
- if (salt.length() > 8)
- {
- salt = salt.substring(0, 8);
- }
-///////////////////////////////////////////////////////////////////////////////////////////////
-
- ctx = (password + magic + salt).getBytes();
- ctx2 = hashGenerator.digest((password + salt + password).getBytes());
-
-
- /////////I am commenting out this one.... But for longer passwords, it should have to be enabled....
-
-// for (ind = password.length(); ind > 0; ind -= 16)
-// {
-// if (ind > 16)
-// {
-// ctx = Concat(ctx, ctx2);
-// }
-// else
-// {
-// ctx = PartialConcat(ctx, ctx2, ind);
-// }
-// }
-
- ctx = PartialConcat(ctx, ctx2, password.length());
-
-
- pwBytes = password.getBytes();
-
- //This is the equivalent of the while loop in the C code
- for (i = password.length(); i > 0; i >>= 1)
- {
- if ((i & 1) == 1)
- {
- ctx = Concat(ctx, new byte[]{0});
- }
- else
- {
- ctx = Concat(ctx, new byte[]{pwBytes[0]});
- }
- }
-
- ctx2 = hashGenerator.digest(ctx);
-
- byte[] ctx1;
-
-
- saltBytes = salt.getBytes();
-
- // Do some scramblings or mutations?!!
- for (i = 0; i < 1000; i++)
- {
- ctx1 = new byte[]
- {
- };
- if ((i & 1) == 1)
- {
- ctx1 = Concat(ctx1, pwBytes);
- }
- else
- {
- ctx1 = Concat(ctx1, ctx2);
- }
- if (i % 3 != 0)
- {
- ctx1 = Concat(ctx1, saltBytes);
- }
- if (i % 7 != 0)
- {
- ctx1 = Concat(ctx1, pwBytes);
- }
- if ((i & 1) != 0)
- {
- ctx1 = Concat(ctx1, ctx2);
- }
- else
- {
- ctx1 = Concat(ctx1, pwBytes);
- }
- ctx2 = hashGenerator.digest(ctx1);
- }
- result = new StringBuilder();
-
- // Do the shifting and add the Base64 converted hash to the result string
- value = ((ctx2[0] & 0xff) << 16) | ((ctx2[6] & 0xff) << 8) | (ctx2[12] & 0xff);
- result.append(to64(value, 4));
- value = ((ctx2[1] & 0xff) << 16) | ((ctx2[7] & 0xff) << 8) | (ctx2[13] & 0xff);
- result.append(to64(value, 4));
- value = ((ctx2[2] & 0xff) << 16) | ((ctx2[8] & 0xff) << 8) | (ctx2[14] & 0xff);
- result.append(to64(value, 4));
- value = ((ctx2[3] & 0xff) << 16) | ((ctx2[9] & 0xff) << 8) | (ctx2[15] & 0xff);
- result.append(to64(value, 4));
- value = ((ctx2[4] & 0xff) << 16) | ((ctx2[10] & 0xff) << 8) | (ctx2[5] & 0xff);
- result.append(to64(value, 4));
- value = ctx2[11] & 0xff;
- result.append(to64(value, 2));
-
-// return magic + salt + "$" + result.toString();
- return result.toString();
- }
-}
diff --git a/src/Cracker.java b/src/SimpleCracker.java
similarity index 69%
rename from src/Cracker.java
rename to src/SimpleCracker.java
index e1560d3..f02421e 100644
--- a/src/Cracker.java
+++ b/src/SimpleCracker.java
@@ -1,10 +1,11 @@
import java.io.*;
import java.math.BigInteger;
+import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Scanner;
import java.util.HashSet;
-public class Cracker {
+public class SimpleCracker {
public static String toHex(byte[] bytes) {
BigInteger bi = new BigInteger(1, bytes);
@@ -14,7 +15,7 @@ public static String toHex(byte[] bytes) {
public static void main(String[] args) throws IOException, NoSuchAlgorithmException {
// read common passwords file into a set
- File commonPasswordsFile = new File("common-passwords.txt");
+ File commonPasswordsFile = new File("common-passwords");
Scanner scanner = new Scanner(commonPasswordsFile);
HashSet commonPasswords = new HashSet<>();
while (scanner.hasNextLine()) {
@@ -23,18 +24,21 @@ public static void main(String[] args) throws IOException, NoSuchAlgorithmExcept
scanner.close();
// read shadow file and try to crack passwords
- File shadowFile = new File("shadow");
+ File shadowFile = new File("shadow-simple");
scanner = new Scanner(shadowFile);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
String[] parts = line.split(":");
String username = parts[0];
- String[] hashParts = parts[1].split("\\$");
- String salt = hashParts[2];
- String expectedHash = hashParts[3];
+ String salt = parts[1];
+ String expectedHash = parts[2];
for (String password : commonPasswords) {
- String actualHash = MD5Shadow.crypt(password,salt);
+ String candidate = salt + password;
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] candidateBytes = candidate.getBytes();
+ byte[] hashBytes = md.digest(candidateBytes);
+ String actualHash = toHex(hashBytes);
if (actualHash.equals(expectedHash)) {
System.out.println(username + ":" + password);
break;
diff --git a/src/common-passwords.txt b/src/common-passwords
similarity index 100%
rename from src/common-passwords.txt
rename to src/common-passwords
diff --git a/src/shadow b/src/shadow
deleted file mode 100644
index 9b0acf0..0000000
--- a/src/shadow
+++ /dev/null
@@ -1,10 +0,0 @@
-user0:$1$IHQqp.5e$iBRGUi.ZZtXDXvcFHyEE20:17801:0:99999:7:::
-user1:$1$EZ66DAJc$28BvFjvBnA/DDokoiPAls1:17801:0:99999:7:::
-user2:$1$9veighCQ$pVSDQYcJ.pAYprwPkcqAm1:17801:0:99999:7:::
-user3:$1$QAsKJurv$k6nqPmZAEHBI5NfQ0HUpa/:17801:0:99999:7:::
-user4:$1$EW3CpL8A$QPwa4cl809qiEXOAr.MaJ1:17801:0:99999:7:::
-user5:$1$OpC0/rME$LC7SumvOZ9ZLilH3./aJQ.:17801:0:99999:7:::
-user6:$1$wCquloBw$y2MjiyvGMNunrRcZLRO5j/:17801:0:99999:7:::
-user7:$1$.Coe4fHg$DhwAgs6gFdTK0PwyufA.00:17801:0:99999:7:::
-user8:$1$MCpfHPHC$I1B0MMpUOEtGCBi5IHql//:17801:0:99999:7:::
-user9:$1$n13aYQ9M$dJOH0drziInPCx6FnHnex0:17801:0:99999:7:::
diff --git a/src/shadow-simple b/src/shadow-simple
new file mode 100644
index 0000000..a898aa9
--- /dev/null
+++ b/src/shadow-simple
@@ -0,0 +1,10 @@
+user0:qtoUil1J:3DACEF3B08BDAEFF0F9402FAB9270F67
+user1:LqVLX/PV:6A3DFBD5580F3A5A421CB37F4D4B7725
+user2:Ckf4mO9I:61C42F5C40F727B657CC8402359E4A17
+user3:x62ZrMwu:0174A2A91EA1881A5BC582AEF37E6F35
+user4:2VF0AblA:D08C5912FB8E6B0A9530C5FDDACA734D
+user5:CEhrE/C7:6D48564E27D9B4626A3ADBA5F369B0F3
+user6:cWGoHf89:A4EBD768B02F3418FEF93DCD152A9F85
+user7:tqKaVL4O:7F8032B62525D9FAF339CE4128579566
+user8:T7cTnZz0:4AFB9E06F08F664F367F5E2244666FC0
+user9:60O7QHXH:92AC0B3C76BD44C8768355FB0349AA19
\ No newline at end of file