Created
June 17, 2014 23:35
-
-
Save caioluders/c962f36b924a76f1a578 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf-8 | |
''' | |
Ciphertext-only attack (COA) | |
http://en.wikipedia.org/wiki/Ciphertext-only_attack | |
no "K2 - Cryptographic Hash" do KoubackTr | |
by geolado | g3ol4d0 | |
''' | |
import re , itertools , os , string , sys | |
exposed = {} | |
def brute(cipher_data) : | |
exposed_temp = {} | |
brute_dictionary = make_dictionary(cipher_data) # Cria um dicionario com o tamanho desejado e com a var chars | |
for n in brute_dictionary : | |
cmd = "echo "+n+" | python login_COA.py" # Faz o brute | |
output = os.popen(cmd).read() | |
sys.stdout.write("\r[?] Testando senha :" + n + " ") | |
sys.stdout.flush() | |
if "Login aceito (:" in output : # Se logar , retorna um dicionario pareando cada codigo com o resultado | |
pass_list = list(n) | |
for c in cipher_data[0] : | |
exposed_temp.update({ c : pass_list[cipher_data[0].index(c)] }) | |
return exposed_temp | |
def make_dictionary(cipher_data) : | |
# Cria um dicionario para ataque em cada cifra | |
chars = string.digits+string.ascii_letters # Caracters basicos , sem pontuacao etc e tal | |
known_codes = dict(( encoded , exposed[encoded] ) for encoded in cipher_data[0] if encoded in exposed ) # Pega os codigos ja conhecidos pelo programa | |
print "[?] Já crackeado :" + str(known_codes) | |
brute_dictionary_tuple = itertools.product(chars, repeat = len(cipher_data[0]) - len(known_codes)) # Lista de produtos dos caracteres , em certo momemto vai bugar e pegar toda a memoria do seu pc (: | |
brute_dictionary = [] | |
brute_list = [] | |
for i in brute_dictionary_tuple : | |
brute_dictionary.append(i) # Faz lista da tuple | |
for i in range(len(brute_dictionary)) : | |
pass_string = "" | |
temp_counter = 0 # Gambiarra basica | |
for e in range(len(cipher_data[0])) : | |
if cipher_data[0][e] in known_codes : | |
pass_string += known_codes[cipher_data[0][e]] | |
else : | |
pass_string += brute_dictionary[i][temp_counter] | |
temp_counter += 1 | |
brute_list.append(pass_string) | |
return brute_list | |
def count_freq(cipher) : | |
cipher_splited = re.findall('..',cipher) # Regex para cortar a cifra de 2 em 2 | |
cipher_l = len(cipher_splited) # Numero de caracteres da chave que resultou a cifra | |
print "[?] Caracters :" + str(cipher_l) | |
out = [cipher_splited,cipher_l] | |
return out | |
def main() : | |
# Cifras que o atacante ja conhece | |
ciphers = ["a9z1p0","QpKzg7QQ21o0","a9z1p0H8f30e","XceW18a9z1p0","XcqZqEPfwJ","oLVg07eWXc","0Lg7VgZzXcqZVg","DDXcs0s0KzVgQQqZ","qE07qZXcQQa9z1p0"] | |
print "Ciphertext-only attack (COA)" | |
print "http://en.wikipedia.org/wiki/Ciphertext-only_attack" | |
print "no K2 - Cryptographic Hash do KoubackTr" | |
print "by geolado | g3ol4d0 " | |
for i in ciphers : | |
print "\n[?] Cracking : " + str(i) | |
cracked = brute(count_freq(i)) | |
print "[!] Cracked : " + str(cracked) | |
exposed.update(cracked) | |
print exposed | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment