Skip to content

Commit b40e1e6

Browse files
author
Blue Cosmo
committed
added code transcript
1 parent 0680363 commit b40e1e6

3 files changed

Lines changed: 154 additions & 11 deletions

File tree

ciphers/ct.py

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/usr/bin/python
2+
3+
# created by : C0SM0
4+
5+
# imports
6+
import enchant
7+
import string
8+
9+
# help menu for cipheringing process
10+
help_menu = """
11+
USAGE:
12+
key ct [FLAGS] [OPTIONS]
13+
14+
FLAGS:
15+
-b, --bruteforce Encrypt input text or file
16+
17+
OPTIONS:
18+
-i, --inputFile <input file> Input file to encrypt or decrypt
19+
-o, --output <output file> Output file for encrypted or decrypted text
20+
-t, --text <text> Input text to encrypt or decrypt
21+
-lingo, --lingo <dictionary> Set language for words to pull out
22+
-words, --words Pull out words from decoded transcripts
23+
24+
NOTES:
25+
lowercase text can be used to escape the code transcript
26+
so if we knew the first two letters were "b" and "a", we
27+
could filter as such:
28+
29+
key ct -b -t "baAAs!"
30+
31+
EXAMPLES:
32+
key ct -b -t "ABCC"
33+
key ct -b -t "ABCC" -w -l "en_US"
34+
"""
35+
36+
# -a, --alphabet <sequence> Input custom alphabet to iterate through # add me
37+
38+
# decode function [!] Each Cipher Must Have This <---------- [!]
39+
def encode(args):
40+
# Getting text from all passed in args
41+
# All other args can be grabbed the same way
42+
# Example key = input.key | range = input.range
43+
text = args.text
44+
45+
return ['This cipher does not have encoding capabilites', False]
46+
47+
# decode function [!] Each Cipher Must Have This <---------- [!]
48+
def decode(args):
49+
# Getting text from all passed in args
50+
# All other args can be grabbed the same way
51+
# Example key = input.key | range = input.range
52+
text = args.text
53+
54+
return ['This cipher does not have decoding capabilites', False]
55+
56+
57+
# dictionary detection
58+
def dictionary(transcripts, language):
59+
60+
# set language for dictionary detection
61+
language = enchant.Dict(language)
62+
output = []
63+
64+
for transcript in transcripts:
65+
66+
# show transcript if it is a word
67+
if language.check(transcript.lower()):
68+
output.append(transcript.lower())
69+
70+
return output
71+
72+
# brute force code transcript
73+
# def decode_transcripts(transcript_list, alphabet, count=1):
74+
def decode_transcripts(transcript_list, alphabet=string.ascii_uppercase, count=1):
75+
output_transcripts = []
76+
global TRANSCRIPT_SET
77+
global TRANSCRIPT
78+
79+
for transcript in transcript_list:
80+
81+
# ignore lowercase and special characters
82+
remove_lower = str.maketrans('', '', string.ascii_lowercase)
83+
remove_punctuation = str.maketrans('', '', string.punctuation)
84+
format_transcript = transcript.translate(remove_lower)
85+
new_transcript = format_transcript.translate(remove_punctuation)
86+
87+
transcript_set = set(new_transcript)
88+
89+
# get characters that are shared in both transcripts
90+
for character in (TRANSCRIPT_SET & transcript_set):
91+
92+
for letter in (alphabet):
93+
# for letter in alphabet:
94+
# ignore repeated characters
95+
96+
# TODO: fix theses goofy ahh checks
97+
if (len(transcript_set) == 1) and (letter in transcript_set) and ((new_transcript == transcript)):
98+
continue
99+
if (len(transcript_set) > 1) and (letter in transcript_set):
100+
continue
101+
102+
plaintext = transcript.replace(character, letter)
103+
output_transcripts.append(plaintext)
104+
105+
output = list(set(output_transcripts))
106+
107+
if count == len(TRANSCRIPT):
108+
return output
109+
110+
return decode_transcripts(output, alphabet, (count+1))
111+
112+
# brute function [!] Optional Per Cipher <----------------- [!]
113+
def brute(args):
114+
# Getting text from all passed in args
115+
# All other args can be grabbed the same way
116+
# Example key = input.key | range = input.range
117+
text = args.text
118+
word = args.words
119+
lang = args.lingo
120+
# alphabet = args.alphabet
121+
122+
if text:
123+
# Run Decode
124+
output = f'Bruteforcing | {text}'
125+
126+
global TRANSCRIPT_SET
127+
global TRANSCRIPT
128+
TRANSCRIPT_SET = set(text)
129+
TRANSCRIPT = text
130+
131+
# transcripts = decode_transcripts([text], alphabet)
132+
transcripts = decode_transcripts([text])
133+
134+
# filter out words
135+
if word:
136+
print(word)
137+
words = dictionary(transcripts, lang)
138+
return [f'{output}\n{transcripts}\n\nWords:\n{words}',True]
139+
140+
# Output content as string for main.py to print
141+
# Pass True if Success Message
142+
return [f'{output}\n\n{transcripts}',True]
143+
else:
144+
# Pass False if Fail Message
145+
# Return Nothing to have no output
146+
return ['An error occured, please try again', False]

install.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ if [[ "$distro" == "Debian" ]] || [[ "$distro" == "Parrot" ]] || [[ "$distro" ==
129129
pip install googletrans==3.1.0a0
130130
pip install colorama
131131
pip install pillow
132+
pip install pyenchant
132133
pip install numpy
133-
pip install twofish
134-
pip install blowfish
135134
echo -e "${green}[+] Completed${reset}"
136135

137136
elif [[ "$distro" == "Void" ]]; then
@@ -143,10 +142,6 @@ elif [[ "$distro" == "Void" ]]; then
143142
pip install Cryptography
144143
pip install googletrans==3.1.0a0
145144
pip install colorama
146-
pip install pillow
147-
pip install numpy
148-
pip install twofish
149-
pip install blowfish
150145
echo -e "${green}[+] Completed${reset}"
151146

152147
elif [[ "$distro" = "Arch" ]]; then
@@ -159,10 +154,6 @@ elif [[ "$distro" = "Arch" ]]; then
159154
python3 -m pip install Cryptography
160155
python3 -m pip install googletrans==3.1.0a0
161156
python3 -m pip install colorama
162-
python3 -m pip install pillow
163-
python3 -m pip install numpy
164-
python3 -m pip install twofish
165-
python3 -m pip install blowfish
166157
echo -e "${green}[+] Completed${reset}"
167158

168159
else

main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sys
1313
import os
1414
from colorama import Fore, Back, Style
15+
import string
1516

1617

1718
# gets list of available ciphers
@@ -150,7 +151,12 @@ def cli(args_exist):
150151
parser.add_argument('-ex', '--exclude', help='Exclude Character\n', dest='exclude', type=str)
151152
parser.add_argument('-w', '--wordlist', help='Wordlist File\n', dest='wordlist', type=str)
152153
parser.add_argument('-r', '--range', help='Range\n', dest='range', type=str)
153-
# Layerd Encryption
154+
# code transcripts
155+
parser.add_argument('-words', '--words', help='Filter out words\n', action='store_true')
156+
parser.add_argument('-lingo', '--lingo', help='Specify language ("lingo")', type=str, default='en_US')
157+
# parser.add_argument('-a', '--alphabet', help='Specify custom alphabet\n', type=str, default=string.ascii_uppercase)
158+
# parser.add_argument('-a', '--alphabet', help='Specify custom alphabet\n', type=str)
159+
# Layered Encryption
154160
parser.add_argument('-lay', '--layerd', dest='layerd', action='store_true')
155161
# Google Translate
156162
parser.add_argument('-tr', '--translate', dest='translate', action='store_true')

0 commit comments

Comments
 (0)