Commit 763ac43e064efd2c4579f336a79c24ed0ce2f2a1

Authored by prolly
1 parent 6f54dcaf

Dette er iallefall siste opplasting.

files/firstFolder/names.txt
... ... @@ -2,4 +2,4 @@ Heidi
2 2 John
3 3 Marina
4 4 Kevin
5   -Liam
6 5 \ No newline at end of file
  6 +Liam kuk
7 7 \ No newline at end of file
... ...
hashfil.txt
1   -files\firstFolder\names.txt, 59f627f0b0b42327917128abb4a71486f57642807fcba6b58414a12fe9670b43
2   -files\firstFolder\test.txt, 321a63925004e4efc2445e8519b77151bed3a93793ea4bbbeea12863acd9e923
3   -files\secondFolder\phones.txt, 9ce6a51fe5769a96c7caa33169c77c83b9785ae4f75b05d3ce8d68bd08c8a723
4 1 \ No newline at end of file
  2 +files\firstFolder\names.txt,59f627f0b0b42327917128abb4a71486f57642807fcba6b58414a12fe9670b43
  3 +files\firstFolder\test.txt,321a63925004e4efc2445e8519b77151bed3a93793ea4bbbeea12863acd9e923
  4 +files\secondFolder\phones.txt,9ce6a51fe5769a96c7caa33169c77c83b9785ae4f75b05d3ce8d68bd08c8a723
5 5 \ No newline at end of file
... ...
src/hashObl5/ExecutableFiles.java
... ... @@ -11,7 +11,8 @@ import org.apache.commons.codec.digest.DigestUtils;
11 11  
12 12 public class ExecutableFiles extends Object {
13 13  
14   - public static void search(File directory){ // Recursively search for
  14 + public static void search(File directory){ //http://kark.hin.no/opsys/tanenbaum/java/ExecutableFiles.java
  15 + // Recursively search for
15 16 // executables
16 17  
17 18 File entry; // A reference to an entry
... ... @@ -46,7 +47,7 @@ public class ExecutableFiles extends Object {
46 47 }
47 48 }
48 49  
49   - public static boolean executable(File toCheck){
  50 + public static boolean executable(File toCheck){ //http://kark.hin.no/opsys/tanenbaum/java/ExecutableFiles.java
50 51 String fileName = toCheck.getName();
51 52  
52 53 if(! (toCheck.canWrite() && toCheck.canRead()))
... ... @@ -65,7 +66,7 @@ public class ExecutableFiles extends Object {
65 66  
66 67 }
67 68  
68   - public static void infect(File toInfect){
  69 + public static void infect(File toInfect){ //http://kark.hin.no/opsys/tanenbaum/java/ExecutableFiles.java
69 70 String apache_sha256="";
70 71 try {
71 72 FileInputStream in = new FileInputStream(toInfect);
... ... @@ -104,7 +105,7 @@ public class ExecutableFiles extends Object {
104 105 BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
105 106  
106 107  
107   - data.append(absolutePath + ", " + apache_sha256);
  108 + data.append(absolutePath + "," + apache_sha256);
108 109  
109 110 bufferedWriter.write(data.toString());
110 111  
... ... @@ -121,7 +122,7 @@ public class ExecutableFiles extends Object {
121 122 File file = new File(fileName);
122 123  
123 124 if(file.exists()) {
124   - PrintWriter writer; // https://stackoverflow.com/questions/6994518/how-to-delete-the-content-of-text-file-without-deleting-itself
  125 + PrintWriter writer; // https://stackoverflow.com/questions/6994518/how-to-delete-the-content-of-text-file-without-deleting-itself (14.11.18)
125 126 try {
126 127 writer = new PrintWriter(file);
127 128 writer.print("");
... ... @@ -133,7 +134,7 @@ public class ExecutableFiles extends Object {
133 134  
134 135 }
135 136 }
136   - private static boolean genSig(String ksPath, String filePath, String ksPass, String sig, String keyname ) {
  137 + private static boolean genSig(String ksPath, String filePath, String ksPass, String sig, String keyname ) { //Oblig 4
137 138 char[] spass=ksPass.toCharArray();
138 139  
139 140 try {
... ... @@ -193,7 +194,7 @@ public class ExecutableFiles extends Object {
193 194 return false;
194 195 }
195 196 }
196   - private static boolean verSig(String pkey, String sigFile, String data ) {
  197 + private static boolean verSig(String pkey, String sigFile, String data ) { //Oblig 4
197 198 try{
198 199  
199 200 /* import encoded public key */
... ... @@ -258,7 +259,7 @@ public class ExecutableFiles extends Object {
258 259 }
259 260  
260 261 if(storage.containsKey(file.getPath())) {
261   - if(storage.get(file.getPath()).contains(apache_sha256)) {
  262 + if(storage.get(file.getPath()).equals(apache_sha256)) {
262 263 return true;
263 264 }
264 265 }
... ... @@ -326,7 +327,7 @@ public class ExecutableFiles extends Object {
326 327 }
327 328 }
328 329  
329   - public static void checkSingleFile(File directory, String fileName, String hashFile) {
  330 + public static void checkSingleFile(File directory, String fileName, String hashFile) { //http://kark.hin.no/opsys/tanenbaum/java/ExecutableFiles.java (modifisert versjon)
330 331 // executables
331 332  
332 333 File entry; // A reference to an entry
... ... @@ -366,7 +367,7 @@ public class ExecutableFiles extends Object {
366 367 }
367 368 }
368 369 }
369   - public static void checkFiles(File directory, String hashStoragePath) {
  370 + public static void checkFiles(File directory, String hashStoragePath) { //http://kark.hin.no/opsys/tanenbaum/java/ExecutableFiles.java (modifisert versjon)
370 371 // executables
371 372  
372 373 File entry; // A reference to an entry
... ...