diff --git a/Crimson_Defense/Scripts/Caesar_Cipher/caesarCAPS.py b/Crimson_Defense/Scripts/Caesar_Cipher/caesarCAPS.py index 6a83749..3b868ad 100644 --- a/Crimson_Defense/Scripts/Caesar_Cipher/caesarCAPS.py +++ b/Crimson_Defense/Scripts/Caesar_Cipher/caesarCAPS.py @@ -1,4 +1,5 @@ - +# takes in a string in all caps and prints every rotation for it + text = input("Enter string in all caps for rot: ") rot = 0 new = 0 diff --git a/Crimson_Defense/Scripts/cracked_hasher/Hasher.java b/Crimson_Defense/Scripts/cracked_hasher/Hasher.java new file mode 100644 index 0000000..e660f0c --- /dev/null +++ b/Crimson_Defense/Scripts/cracked_hasher/Hasher.java @@ -0,0 +1,22 @@ +package database; +public class Hasher { + private static boolean hash(String paramString) { + int i = 7; + int j = 593779930; + for (byte b = 0; b < paramString.length(); b++) + i = i * 31 + paramString.charAt(b); + return (i == j); + } + + public static void main(String[] paramArrayOfString) { + if (paramArrayOfString.length != 1) { + System.out.println("Usage: java Hasher "); + System.exit(1); + } + if (hash(paramArrayOfString[0])) { + System.out.println("Correct"); + } else { + System.out.println("Incorrect"); + } + } +} \ No newline at end of file diff --git a/Crimson_Defense/Scripts/cracked_hasher/README.md b/Crimson_Defense/Scripts/cracked_hasher/README.md new file mode 100644 index 0000000..b435a9a --- /dev/null +++ b/Crimson_Defense/Scripts/cracked_hasher/README.md @@ -0,0 +1,3 @@ +# Hasher + +The java script will brute force the hashing function to get the flag diff --git a/Crimson_Defense/Scripts/cracked_hasher/script.java b/Crimson_Defense/Scripts/cracked_hasher/script.java new file mode 100644 index 0000000..4141e5e --- /dev/null +++ b/Crimson_Defense/Scripts/cracked_hasher/script.java @@ -0,0 +1,46 @@ + + +public class Hasher { + + public static void main(String[] paramArrayOfString) { + + int ans = 593779930; + int A, B, C, D, E, F, G, H, I, J, K, L, M; + + int[] caps = {97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, + 119, 120, 121, 122, 45, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 83, 75, 89, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, + 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, 90}; + + for(int a = 0; a < caps.length; a++){ + A = (7 * 31) + caps[a]; + for(int b = 0; b < caps.length; b++){ + B = (A * 31) + caps[b]; + for(int c = 0; c < caps.length; c++){ + C = (B * 31) + caps[c]; + for(int d = 0; d < caps.length; d++){ + D = (C * 31) + caps[d]; + for(int e = 0; e < caps.length; e++){ + E = (D * 31) + caps[e]; + for(int f = 0; f < caps.length; f++){ + F = (E * 31) + caps[f]; + for(int g = 0; g < caps.length; g++){ + G = (F * 31) + caps[g]; + if(G > 593779000 && G < 593779999){ + System.out.println(G); + } + if(G == ans) { + System.out.println("Cracked"); + System.out.println(caps[a] + " " + caps[b] + " " + caps[c] + " " + caps[d] + " " + caps[e] + " " + caps[f] + " " + caps[g]); + return; + } + } + } + } + } + } + } + } + + System.out.println("Wrong"); + } +} diff --git a/Crimson_Defense/Scripts/dirby/dirby.py b/Crimson_Defense/Scripts/dirby/dirby.py index 656c13e..d60a544 100644 --- a/Crimson_Defense/Scripts/dirby/dirby.py +++ b/Crimson_Defense/Scripts/dirby/dirby.py @@ -1,3 +1,4 @@ +# Cole #Dirbuster-like script for sites that always return 301 import requests diff --git a/Crimson_Defense/Scripts/file_carving/get-jpegs.py b/Crimson_Defense/Scripts/file_carving/get-jpegs.py new file mode 100644 index 0000000..c0bb73a --- /dev/null +++ b/Crimson_Defense/Scripts/file_carving/get-jpegs.py @@ -0,0 +1,48 @@ +# Stephen +# Carve out every jpeg within a file +import os + +# put name of file +file_size = os.path.getsize('Candidates.pdf') +print("File Size is :", file_size, "bytes") + +file=open("Candidates.pdf","rb") +magic_bytes = b'\xff\xd8\xff\xe0' +end_bytes = b'\xff\xd9' +image_num = 0 +name = "image_found_" +ext = ".jpeg" +jpeg = False + +for i in range(0, file_size): + position = file.seek(i, 0) + + if(jpeg == False): + position_header = position + header = file.read(4) + if (header == magic_bytes): + print("new image detected") + jpeg = True + else: + position_footer = position + 2 + footer = file.read(2) + if(footer == end_bytes): + print("Found end image. Writing image to new file") + file_size = position_footer - position_header + print(file_size) + jpeg = False + + # Create new file to wriet to in binary + image_name = name + str(image_num) + ext + new_image = open(image_name, "wb") + image_num += 1 + + file.seek(position_header, 0) + data_of_image = file.read(file_size) + new_image.write(data_of_image) + file.seek(i, 0) + new_image.close() + + + +file.close() \ No newline at end of file diff --git a/Crimson_Defense/Scripts/patch/patch.py b/Crimson_Defense/Scripts/patch/patch.py index 5ee1350..e12e0a2 100644 --- a/Crimson_Defense/Scripts/patch/patch.py +++ b/Crimson_Defense/Scripts/patch/patch.py @@ -1,3 +1,4 @@ +# Cole #Goal of program is to run a bash command with every permutation of arguments #This is useful for a file that has been split up as you can cat each permutation #until you arrive at a file that passes some sort of validity check diff --git a/Crimson_Defense/Scripts/rotten/rotten.py b/Crimson_Defense/Scripts/rotten/rotten.py index 499ab3a..88c17c9 100644 --- a/Crimson_Defense/Scripts/rotten/rotten.py +++ b/Crimson_Defense/Scripts/rotten/rotten.py @@ -1,3 +1,4 @@ +# Cole #Custom caesar/rotation cipher solver with custom alphabet #Built-in sets to build from diff --git a/Crimson_Defense/Scripts/torrent_file_reconstruction/README.md b/Crimson_Defense/Scripts/torrent_file_reconstruction/README.md new file mode 100644 index 0000000..83f0a81 --- /dev/null +++ b/Crimson_Defense/Scripts/torrent_file_reconstruction/README.md @@ -0,0 +1,14 @@ +# Torrent files +You can use this if you have a pcap file containing a torrent file and you want to put it back together
+To get the pieces you need to follow the stream and get a hex
+ +to get the count export the pieces to a text file and use the countTorrentPieces script
+ +To reconstruct use this tshark command in the command line and copy and paste it into a text file
+Use the readTorrentPieces to read every piece into a construct file
+tshark -r torrent.pcap -Y 'bittorrent.piece.data and ip.dst_host == 192.168.29.129' -T fields -e frame.number -e frame.time -e frame.len -e ip.src_host -e bittorrent.piece.index -e bittorrent.piece.data -E separator=+
+ +This command will give some good details on the torrent file. Frames count IS NOT the same as the number of pieces. There can be multiple pieces in a frame.
+tshark -r torrent.pcap -q -z io,stat,1,"bittorrent.piece.data and ip.dst_host == 192.168.29.129"
+ +Finally use the constructTorrentPieces to reconstuct the torrent file.
\ No newline at end of file diff --git a/Crimson_Defense/Scripts/torrent_file_reconstruction/constructTorrentFile.py b/Crimson_Defense/Scripts/torrent_file_reconstruction/constructTorrentFile.py new file mode 100644 index 0000000..04c8728 --- /dev/null +++ b/Crimson_Defense/Scripts/torrent_file_reconstruction/constructTorrentFile.py @@ -0,0 +1,54 @@ +# used python3 + +import re +from ast import literal_eval + +READ = open("pieces.txt", "r") +construct = open("reconstruct.txt", "w") + +lines = READ.readlines() + +torrent = {} +min = 100000 +max = 0 +count = 0 +fcount = 0 + +for line in lines: + # filtering out file, just want data + pieces = re.search(r'\+.*\+', line) + pieces = pieces.group().strip('+') + pieces = pieces.split(',') + # print(pieces) + + line = line.strip('+') + data = re.search(r'\+.*\n', line) + data = data.group().rstrip().strip('+') + data = data.split(',') + # print(data) + + i = 0 + for piece in pieces: + dec = literal_eval(piece) + + if (dec > max): + max = dec + + if(dec < min): + min = dec + + torrent.update({dec:data[i]}) + fcount += 1 + i += 1 + +for i in range(min, max+1): + x = torrent.get(i) + construct.write(x) + count += 1 + +print("Min was:", min) +print("Max was:", max) +print("fcount was", fcount) +print("count was", count) + +READ.close() diff --git a/Crimson_Defense/Scripts/torrent_file_reconstruction/countTorrentPieces.py b/Crimson_Defense/Scripts/torrent_file_reconstruction/countTorrentPieces.py new file mode 100644 index 0000000..258232a --- /dev/null +++ b/Crimson_Defense/Scripts/torrent_file_reconstruction/countTorrentPieces.py @@ -0,0 +1,21 @@ +# used python3 + +import re + +READ = open("pieces.txt", "r") + +lines = READ.readlines() + +count = 0 + +for line in lines: + # using regex( findall() ) + # to extract words from string + res = re.findall(r'\w+', line) + + for word in res: + if(word == "Piece"): + count += 1 + +print(count) +READ.close() diff --git a/Crimson_Defense/Scripts/torrent_file_reconstruction/readTorrentPieces.py b/Crimson_Defense/Scripts/torrent_file_reconstruction/readTorrentPieces.py new file mode 100644 index 0000000..4191b41 --- /dev/null +++ b/Crimson_Defense/Scripts/torrent_file_reconstruction/readTorrentPieces.py @@ -0,0 +1,20 @@ +# used python3 + +import re + +READ = open("rawOutput.txt", "r") +construct = open("pieces.txt", "w") + +lines = READ.readlines() + +frames = 0 + +for line in lines: + frames += 1 + res = re.search(r'\+0x.*', line) + data = res.group() + construct.write(data) + construct.write('\n') + +print("Done. number of frames were:", frames) +READ.close()