Программное средство для аудита паролей в информационных системах
Разработка программного средства для анализа значений хэш-функций с целью формальной оценки стойкости пароля. Проблема слабых паролей. Оценка ущерба, возникающего вследствие атаки на защищаемый объект. Метод поиска по словарям и "радужным таблицам".
Рубрика | Программирование, компьютеры и кибернетика |
Вид | дипломная работа |
Язык | русский |
Дата добавления | 10.06.2013 |
Размер файла | 1022,5 K |
Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже
Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.
{
for(quint8 i=0;i<before_hash_vector->size();i++)
{
QByteArray hash=before_hash_vector->at(i);
if (hash=="aad3b435b51404eeaad3b435b51404ee")
{
left_half_LM_password->insert(i,"solve");
right_half_LM_password->insert(i,"solve");
}
else
{
left_half_LM_password->insert(i,hash.left(16));
right_half_LM_password->insert(i,hash.right(16));
}
count_hash++;
}
while(left_half_LM_password->indexOf("solve")!=-1)
{
quint8 position=left_half_LM_password->indexOf("solve");
left_half_LM_password->remove(position);
right_half_LM_password->remove(position);
count_hash--;
}
emit find_hash("aad3b435b51404eeaad3b435b51404ee","aad3b435b51404eeaad3b435b51404ee");
}
else if ((type==type_linux_md5) || (type==type_linux_sha256) || (type==type_linux_sha512))
{
count_hash=before_hash_vector->count();
}
// поочередно выполняем задачи
while(tasks->count()!=0)
{
bool ok;
QString task=tasks->first();
quint8 type=task.left(1).toInt(&ok,10);
emit message(tr("В процессе"));
if ((stopped) || (count_hash==0))
break;
switch(type)
{
case 0:
if (brute_force(task.mid(task.indexOf("arg1")+4,task.indexOf("arg2")-task.indexOf("arg1")-4).toAscii(),
task.mid(task.indexOf("arg2")+4,task.indexOf("arg3")-task.indexOf("arg2")-4).toInt(&ok,10),
task.mid(task.indexOf("arg3")+4,task.indexOf("arg4")-task.indexOf("arg3")-4).toInt(&ok,10)))
{
if (!stopped)
emit message(tr("Завершено"));
else
emit message(tr("Отменено"));
}
break;
case 1:
if (brute_force_on_mask(task.mid(task.indexOf("arg1")+4,task.indexOf("arg2")-task.indexOf("arg1")-4).toAscii(),
task.mid(task.indexOf("arg2")+4,task.indexOf("arg3")-task.indexOf("arg2")-4).toAscii(),
task.mid(task.indexOf("arg3")+4,task.indexOf("arg4")-task.indexOf("arg3")-4).toInt(&ok,10),
task.mid(task.indexOf("arg4")+4,task.indexOf("arg5")-task.indexOf("arg4")-4).toInt(&ok,10),
task.mid(task.indexOf("arg5")+4,task.indexOf("arg6")-task.indexOf("arg5")-4).toInt(&ok,10),
task.mid(task.indexOf("arg6")+4,task.indexOf("arg7")-task.indexOf("arg6")-4).toInt(&ok,10)))
{
if (!stopped)
emit message(tr("Завершено"));
else
emit message(tr("Отменено"));
}
break;
case 2:
if (brute_force_on_dictionary(task.mid(task.indexOf("arg1")+4,task.indexOf("arg2")-task.indexOf("arg1")-4)))
{
if (!stopped)
emit message(tr("Завершено"));
else
emit message(tr("Отменено"));
}
break;
case 3:
if (brute_force_on_dictionaries(task.mid(task.indexOf("arg1")+4,task.indexOf("arg2")-task.indexOf("arg1")-4),
task.mid(task.indexOf("arg2")+4,task.indexOf("arg3")-task.indexOf("arg2")-4)))
{
if (!stopped)
emit message(tr("Завершено"));
else
emit message(tr("Отменено"));
}
break;
case 4:
if (brute_force_on_dictionary_gybrid(task.mid(task.indexOf("arg1")+4,task.indexOf("arg2")-task.indexOf("arg1")-4)))
{
if (!stopped)
emit message(tr("Завершено"));
else
emit message(tr("Отменено"));
}
break;
case 5:
if (brute_force_on_dictionaries_gybrid(task.mid(task.indexOf("arg1")+4,task.indexOf("arg2")-task.indexOf("arg1")-4),
task.mid(task.indexOf("arg2")+4,task.indexOf("arg3")-task.indexOf("arg2")-4)))
{
if (!stopped)
emit message(tr("Завершено"));
else
emit message(tr("Отменено"));
}
break;
case 6:
if (before_check())
{
if (!stopped)
emit message(tr("Завершено"));
else
emit message(tr("Отменено"));
}
break;
}
tasks->removeFirst();
}
emit complete();
}
char *Hash::LM_hash(const char *password) // алгоритм дес
{
// создаем копию из 7 символов максимум
char word[8];
memset(word,NULL,8);
// копируем туда содержимое, независимо от длины последним всегда будет NULL
if (strlen(password)>7)
memcpy(word,password,7);
else
memcpy(word,password,strlen(password));
QByteArray result;
result.clear();
// создаем ключ из 8 символов
char key[9];
memset(key,NULL,9);
// переводим слово в верхний регистр
for(quint8 i=0;i<strlen(word);i++)
if ((word[i]>96) && (word[i]<123))
word[i]-=32;
// формируем ключ
key[0] = (word[0] >> 1) << 1;
key[1] = (((word[0] & 0x01) << 6) | (word[1] >> 2)) << 1;
key[2] = (((word[1] & 0x03) << 5) | (word[2] >> 3)) << 1;
key[3] = (((word[2] & 0x07) << 4) | (word[3] >> 4)) << 1;
key[4] = (((word[3] & 0x0F) << 3) | (word[4] >> 5)) << 1;
key[5] = (((word[4] & 0x1F) << 2) | (word[5] >> 6)) << 1;
key[6] = (((word[5] & 0x3F) << 1) | (word[6] >> 7)) << 1;
key[7] = (word[6] & 0x7F) << 1;
// переопределяем алгоритм des
QCA::SymmetricKey key_for_des(QByteArray(key,9));
algorithm_DES->setup(QCA::Encode,key_for_des);
// шифруем
result.append(algorithm_DES->update(LINE).toByteArray());
return result.toHex().data();
}
unsigned int *Hash::NTLM_hash(const char *password) // max length password
{
unsigned int nt_buffer[16];
static unsigned int output[4];
quint8 i=0;
quint8 length=strlen(password);
//if (length>30)
// length=30;
memset(nt_buffer,0,64);
for(;i<length/2;i++)
nt_buffer[i]=password[2*i]|(password[2*i+1]<<16);
if (length%2==1)
nt_buffer[i]=password[length-1]|0x800000;
else
nt_buffer[i]=0x80;
nt_buffer[14] = length << 4;
unsigned int a = INIT_A;
unsigned int b = INIT_B;
unsigned int c = INIT_C;
unsigned int d = INIT_D;
// 1 раунд
a += (d ^ (b & (c ^ d))) + nt_buffer[0] ;a = (a << 3 ) | (a >> 29);
d += (c ^ (a & (b ^ c))) + nt_buffer[1] ;d = (d << 7 ) | (d >> 25);
c += (b ^ (d & (a ^ b))) + nt_buffer[2] ;c = (c << 11) | (c >> 21);
b += (a ^ (c & (d ^ a))) + nt_buffer[3] ;b = (b << 19) | (b >> 13);
a += (d ^ (b & (c ^ d))) + nt_buffer[4] ;a = (a << 3 ) | (a >> 29);
d += (c ^ (a & (b ^ c))) + nt_buffer[5] ;d = (d << 7 ) | (d >> 25);
c += (b ^ (d & (a ^ b))) + nt_buffer[6] ;c = (c << 11) | (c >> 21);
b += (a ^ (c & (d ^ a))) + nt_buffer[7] ;b = (b << 19) | (b >> 13);
a += (d ^ (b & (c ^ d))) + nt_buffer[8] ;a = (a << 3 ) | (a >> 29);
d += (c ^ (a & (b ^ c))) + nt_buffer[9] ;d = (d << 7 ) | (d >> 25);
c += (b ^ (d & (a ^ b))) + nt_buffer[10] ;c = (c << 11) | (c >> 21);
b += (a ^ (c & (d ^ a))) + nt_buffer[11] ;b = (b << 19) | (b >> 13);
a += (d ^ (b & (c ^ d))) + nt_buffer[12] ;a = (a << 3 ) | (a >> 29);
d += (c ^ (a & (b ^ c))) + nt_buffer[13] ;d = (d << 7 ) | (d >> 25);
c += (b ^ (d & (a ^ b))) + nt_buffer[14] ;c = (c << 11) | (c >> 21);
b += (a ^ (c & (d ^ a))) + nt_buffer[15] ;b = (b << 19) | (b >> 13);
// 2 раунд
a += ((b & (c | d)) | (c & d)) + nt_buffer[0] +SQRT_2; a = (a<<3 ) | (a>>29);
d += ((a & (b | c)) | (b & c)) + nt_buffer[4] +SQRT_2; d = (d<<5 ) | (d>>27);
c += ((d & (a | b)) | (a & b)) + nt_buffer[8] +SQRT_2; c = (c<<9 ) | (c>>23);
b += ((c & (d | a)) | (d & a)) + nt_buffer[12]+SQRT_2; b = (b<<13) | (b>>19);
a += ((b & (c | d)) | (c & d)) + nt_buffer[1] +SQRT_2; a = (a<<3 ) | (a>>29);
d += ((a & (b | c)) | (b & c)) + nt_buffer[5] +SQRT_2; d = (d<<5 ) | (d>>27);
c += ((d & (a | b)) | (a & b)) + nt_buffer[9] +SQRT_2; c = (c<<9 ) | (c>>23);
b += ((c & (d | a)) | (d & a)) + nt_buffer[13]+SQRT_2; b = (b<<13) | (b>>19);
a += ((b & (c | d)) | (c & d)) + nt_buffer[2] +SQRT_2; a = (a<<3 ) | (a>>29);
d += ((a & (b | c)) | (b & c)) + nt_buffer[6] +SQRT_2; d = (d<<5 ) | (d>>27);
c += ((d & (a | b)) | (a & b)) + nt_buffer[10]+SQRT_2; c = (c<<9 ) | (c>>23);
b += ((c & (d | a)) | (d & a)) + nt_buffer[14]+SQRT_2; b = (b<<13) | (b>>19);
a += ((b & (c | d)) | (c & d)) + nt_buffer[3] +SQRT_2; a = (a<<3 ) | (a>>29);
d += ((a & (b | c)) | (b & c)) + nt_buffer[7] +SQRT_2; d = (d<<5 ) | (d>>27);
c += ((d & (a | b)) | (a & b)) + nt_buffer[11]+SQRT_2; c = (c<<9 ) | (c>>23);
b += ((c & (d | a)) | (d & a)) + nt_buffer[15]+SQRT_2; b = (b<<13) | (b>>19);
// 3 раунд
a += (d ^ c ^ b) + nt_buffer[0] + SQRT_3; a = (a << 3 ) | (a >> 29);
d += (c ^ b ^ a) + nt_buffer[8] + SQRT_3; d = (d << 9 ) | (d >> 23);
c += (b ^ a ^ d) + nt_buffer[4] + SQRT_3; c = (c << 11) | (c >> 21);
b += (a ^ d ^ c) + nt_buffer[12] + SQRT_3; b = (b << 15) | (b >> 17);
a += (d ^ c ^ b) + nt_buffer[2] + SQRT_3; a = (a << 3 ) | (a >> 29);
d += (c ^ b ^ a) + nt_buffer[10] + SQRT_3; d = (d << 9 ) | (d >> 23);
c += (b ^ a ^ d) + nt_buffer[6] + SQRT_3; c = (c << 11) | (c >> 21);
b += (a ^ d ^ c) + nt_buffer[14] + SQRT_3; b = (b << 15) | (b >> 17);
a += (d ^ c ^ b) + nt_buffer[1] + SQRT_3; a = (a << 3 ) | (a >> 29);
d += (c ^ b ^ a) + nt_buffer[9] + SQRT_3; d = (d << 9 ) | (d >> 23);
c += (b ^ a ^ d) + nt_buffer[5] + SQRT_3; c = (c << 11) | (c >> 21);
b += (a ^ d ^ c) + nt_buffer[13] + SQRT_3; b = (b << 15) | (b >> 17);
a += (d ^ c ^ b) + nt_buffer[3] + SQRT_3; a = (a << 3 ) | (a >> 29);
d += (c ^ b ^ a) + nt_buffer[11] + SQRT_3; d = (d << 9 ) | (d >> 23);
c += (b ^ a ^ d) + nt_buffer[7] + SQRT_3; c = (c << 11) | (c >> 21);
b += (a ^ d ^ c) + nt_buffer[15] + SQRT_3; b = (b << 15) | (b >> 17);
output[0] = a + INIT_A;
output[1] = b + INIT_B;
output[2] = c + INIT_C;
output[3] = d + INIT_D;
return output;
}
bool Hash::check_hash(const char *variant_password)
{
// проверка флага остановки
if (stopped)
return true;
// инкремент количества сделанных операций
current++;
if (type==type_windows_LM)
{
// вычисление хэша от текущей комбинации
char *variant_hash=LM_hash(variant_password);
while((left_half_LM_password->indexOf(variant_hash))!=-1)
{
quint8 position=left_half_LM_password->indexOf(variant_hash);
left_half_LM_password->replace(position,"solve");
if ((right_half_LM_password->at(position)=="aad3b435b51404ee") || (right_half_LM_password->at(position)=="solve"))
{
left_half_LM_password->remove(position);
right_half_LM_password->remove(position);
count_hash--;
}
char word[8];
memset(word,NULL,8);
if (strlen(variant_password)>7)
memcpy(word,variant_password,7);
else
memcpy(word,variant_password,strlen(variant_password));
for(quint8 i=0;i<strlen(word);i++)
if ((word[i]>64) && (word[i]<91))
word[i]+=32;
emit find_hash(word,variant_hash);
}
while((right_half_LM_password->indexOf(variant_hash))!=-1)
{
quint8 position=right_half_LM_password->indexOf(variant_hash);
right_half_LM_password->replace(position,"solve");
if ((left_half_LM_password->at(position)=="aad3b435b51404ee") || (left_half_LM_password->at(position)=="solve"))
{
left_half_LM_password->remove(position);
right_half_LM_password->remove(position);
count_hash--;
}
char word[8];
memset(word,NULL,8);
if (strlen(variant_password)>7)
memcpy(word,variant_password,7);
else
memcpy(word,variant_password,strlen(variant_password));
for(quint8 i=0;i<strlen(word);i++)
if ((word[i]>64) && (word[i]<91))
word[i]+=32;
emit find_hash(variant_password,variant_hash);
}
// если все найдено
if (!count_hash)
return true;
}
else if (type==type_windows_NTLM)
{
// вычисление хэша от текущей комбинации
unsigned int *output=NTLM_hash(variant_password);
if (NTLM1->indexOf(output[0])!=-1)
{
quint8 position;
position=NTLM1->indexOf(output[0]);
if (NTLM2->at(position)==output[1])
if (NTLM3->at(position)==output[2])
if (NTLM4->at(position)==output[3])
{
// преобразуем хэш в шестнадцатиричное представление
static char hex_format[33];
char itoa16[17]="0123456789abcdef";
for(quint8 i=0;i<4;i++)
{
unsigned int n=output[i];
for(quint8 j=0;j<4;j++)
{
unsigned int convert=n%256;
hex_format[i*8+j*2+1]=itoa16[convert%16];
convert=convert/16;
hex_format[i*8+j*2+0]=itoa16[convert%16];
n=n/256;
}
}
hex_format[32]=NULL;
while(NTLM1->indexOf(output[0])!=-1)
{
position=NTLM1->indexOf(output[0]);
if (NTLM2->at(position)==output[1])
if (NTLM3->at(position)==output[2])
if (NTLM4->at(position)==output[3])
{
NTLM1->remove(position);
NTLM2->remove(position);
NTLM3->remove(position);
NTLM4->remove(position);
count_hash--;
}
}
find_hash(variant_password,hex_format);
}
}
// если все найдено
if (!count_hash)
return true;
}
else if ((type==type_linux_md5) || (type==type_linux_sha256) || (type==type_linux_sha512))
{
for(quint8 i=0;i<before_hash_vector->count();i++)
{
// вычисление хэша от текущей комбинации с нужной солью
QByteArray variant_hash=crypt(variant_password,before_salt_vector->at(i));
if (variant_hash==before_hash_vector->at(i))
{
emit find_hash(variant_password,variant_hash);
before_hash_vector->remove(i);
before_salt_vector->remove(i);
count_hash--;
}
}
// если все найдено
if (!count_hash)
return true;
}
return false;
}
void Hash::clear_parametrs()
{
current=0;
total=0;
count_hash=0;
stopped=false;
before_hash_vector->clear();
before_salt_vector->clear();
left_half_LM_password->clear();
right_half_LM_password->clear();
login_vector->clear();
tasks->clear();
NTLM1->clear();
NTLM2->clear();
NTLM3->clear();
NTLM4->clear();
}
bool Hash::brute_force(const char *alpha, const quint8 &min_length_password, const quint8 &max_length_password)
{
quint8 alpha_length=strlen(alpha);
quint8 first_symbol=alpha[0];
quint8 last_symbol=alpha[alpha_length-1];
quint8 position[max_length_password+1];
char current_combination[max_length_password+1];
char first_combination[max_length_password+1];
for(quint8 i=min_length_password;i<=max_length_password;i++)
{
memset(first_combination,first_symbol,i);
first_combination[i]=NULL;
memset(current_combination,first_symbol,i);
current_combination[i]=NULL;
for(quint8 j=0;j<i;j++)
position[j]=1;
position[i]=NULL;
forever
{
quint8 j=i;
static quint8 current_symbol;
while(j!=0)
{
current_symbol=current_combination[j-1];
if (current_symbol==last_symbol)
{
current_combination[j-1]=first_symbol;
position[j-1]=1;
j--;
}
else
{
current_combination[j-1]=alpha[position[j-1]];
position[j-1]++;
break;
}
}
if (check_hash(current_combination))
return true;
if (!memcmp(current_combination,first_combination,i))
break;
}
}
return true;
}
bool Hash::brute_force_on_mask(const char *alpha,const char *mask,const quint8 &min_length_password_on_left,const quint8 &max_length_password_on_left,const quint8 &min_length_password_on_right,const quint8 &max_length_password_on_right)
{
quint8 alpha_length=strlen(alpha);
quint8 mask_length=strlen(mask);
quint8 first_symbol=alpha[0];
quint8 last_symbol=alpha[alpha_length-1];
quint8 position[max_length_password_on_left+max_length_password_on_right+1];
char current_combination[max_length_password_on_left+max_length_password_on_right+1];
char first_combination[max_length_password_on_left+max_length_password_on_right+1];
char right_combination[max_length_password_on_left+max_length_password_on_right+mask_length+1];
for(quint8 i=min_length_password_on_left;i<=max_length_password_on_left;i++)
{
for(quint8 k=min_length_password_on_right;k<=max_length_password_on_right;k++)
{
memset(first_combination,first_symbol,i+k);
first_combination[i+k]=NULL;
memset(current_combination,first_symbol,i+k);
current_combination[i+k]=NULL;
memset(right_combination,first_symbol,i+k+mask_length);
right_combination[i+k+mask_length]=NULL;
for(quint8 j=0;j<i+k;j++)
position[j]=1;
position[i+k]=NULL;
forever
{
quint8 j=i+k;
static quint8 current_symbol;
while(j!=0)
{
current_symbol=current_combination[j-1];
if (current_symbol==last_symbol)
{
current_combination[j-1]=first_symbol;
position[j-1]=1;
j--;
}
else
{
current_combination[j-1]=alpha[position[j-1]];
position[j-1]++;
break;
}
}
memcpy(right_combination,current_combination,i);
memcpy(right_combination+i,mask,mask_length);
memcpy(right_combination+i+mask_length,current_combination+i,k);
if (check_hash(right_combination))
return true;
if (!memcmp(current_combination,first_combination,i+k))
break;
}
}
}
return true;
}
bool Hash::brute_force_on_dictionary(const QString &filename)
{
QFile file(filename);
if (!file.exists())
{
emit message(tr("Файл не существует"));
return false;
}
else if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
emit message(tr("Не хватает прав доступа"));
return false;
}
else
{
char buf[buffer_size];
qint8 lineLength;
while((lineLength=file.readLine(buf,buffer_size))!=-1)
{
buf[lineLength-1]=NULL;
if (check_hash(buf))
{
file.close();
return true;
}
}
file.close();
}
return true;
}
bool Hash::brute_force_on_dictionaries(const QString &filename1,const QString &filename2)
{
QFile file1(filename1);
QFile file2(filename2);
if (!file1.exists())
{
emit message(tr("Файл не существует"));
return false;
}
else if (!file1.open(QIODevice::ReadOnly | QIODevice::Text))
{
emit message(tr("Не хватает прав доступа"));
return false;
}
else if (!file2.exists())
{
emit message(tr("Файл не существует"));
return false;
}
else if (!file2.open(QIODevice::ReadOnly | QIODevice::Text))
{
emit message(tr("Не хватает прав доступа"));
return false;
}
else
{
char buf1[buffer_size];
char buf2[buffer_size];
memset(buf1,NULL,buffer_size);
memset(buf2,NULL,buffer_size);
qint8 lineLength1;
qint8 lineLength2;
char buf[buffer_size*2];
memset(buf,NULL,buffer_size*2);
while((lineLength1=file1.readLine(buf1,buffer_size))!=-1)
{
file2.reset();
buf1[lineLength1-1]=NULL;
while((lineLength2=file2.readLine(buf2,buffer_size))!=-1)
{
buf2[lineLength2-1]=NULL;
memcpy(buf,buf1,lineLength1-1);
memcpy(buf+lineLength1-1,buf2,lineLength2-1);
buf[lineLength1+lineLength2-2]=NULL;
if (check_hash(buf))
{
file1.close();
file2.close();
return true;
}
}
}
file1.close();
file2.close();
}
return true;
}
bool Hash::brute_force_on_dictionary_gybrid(const QString &filename)
{
QFile file(filename);
if (!file.exists())
{
emit message(tr("Файл не существует"));
return false;
}
else if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
emit message(tr("Не хватает прав доступа"));
return false;
}
else
{
char buf[buffer_size];
qint8 lineLength;
while((lineLength=file.readLine(buf,buffer_size))!=-1)
{
buf[lineLength-1]=NULL;
if (variant_for_hybrid(buf))
{
file.close();
return true;
}
}
file.close();
}
return true;
}
bool Hash::brute_force_on_dictionaries_gybrid(const QString &filename1,const QString &filename2)
{
QFile file1(filename1);
QFile file2(filename2);
if (!file1.exists())
{
emit message(tr("Файл не существует"));
return false;
}
else if (!file1.open(QIODevice::ReadOnly | QIODevice::Text))
{
emit message(tr("Не хватает прав доступа"));
return false;
}
else if (!file2.exists())
{
emit message(tr("Файл не существует"));
return false;
}
else if (!file2.open(QIODevice::ReadOnly | QIODevice::Text))
{
emit message(tr("Не хватает прав доступа"));
return false;
}
else
{
char buf1[buffer_size];
char buf2[buffer_size];
memset(buf1,NULL,buffer_size);
memset(buf2,NULL,buffer_size);
qint8 lineLength1;
qint8 lineLength2;
char buf[buffer_size*2];
memset(buf,NULL,buffer_size*2);
while((lineLength1=file1.readLine(buf1,buffer_size))!=-1)
{
file2.reset();
buf1[lineLength1-1]=NULL;
while((lineLength2=file2.readLine(buf2,buffer_size))!=-1)
{
buf2[lineLength2-1]=NULL;
memcpy(buf,buf1,lineLength1-1);
memcpy(buf+lineLength1-1,buf2,lineLength2-1);
buf[lineLength1+lineLength2-2]=NULL;
if (variant_for_hybrid(buf))
{
file1.close();
file2.close();
return true;
}
}
}
file1.close();
file2.close();
}
return true;
}
bool Hash::before_check()
{
// пустой пароль
check_hash("");
// пароль совпадает с логином
for(quint8 i=0;i<login_vector->count();i++)
if (check_hash(login_vector->at(i).trimmed().data()))
return true;
// комбинации с логином
for(quint8 i=0;i<login_vector->count();i++)
{
// проверка из гибридного поиска по словарю
if (variant_for_hybrid(login_vector->at(i).trimmed().data()))
return true;
}
// соседние клавиши
QFile file(QDir().currentPath()+"/before_check/horizontal_max.txt");
file.open(QIODevice::ReadOnly);
char buf[buffer_size];
qint8 lineLength;
while((lineLength=file.readLine(buf,buffer_size))!=-1)
{
buf[lineLength-1]=NULL;
if (variant_for_before_check(buf))
{
file.close();
return true;
}
}
file.close();
file.setFileName(QDir().currentPath()+"/before_check/horizontal_min.txt");
file.open(QIODevice::ReadOnly);
while((lineLength=file.readLine(buf,buffer_size))!=-1)
{
buf[lineLength-1]=NULL;
if (variant_for_before_check(buf))
{
file.close();
return true;
}
}
file.close();
file.setFileName(QDir().currentPath()+"/before_check/vertical.txt");
file.open(QIODevice::ReadOnly);
while((lineLength=file.readLine(buf,buffer_size))!=-1)
{
buf[lineLength-1]=NULL;
if (variant_for_before_check(buf))
{
file.close();
return true;
}
}
file.close();
return true;
}
bool Hash::variant_for_before_check(char *variant)
{
quint8 size=strlen(variant);
char word[buffer_size*4];
memset(word,NULL,buffer_size*4);
// сам вариант
if (check_hash(variant))
return true;
// разные регистры символов (часто встречающиеся варианты)
{
bool flag=false;
memset(word,NULL,size+1);
// чередование регистра начиная со строчной буквы
for(quint8 i=0;i<size;i++)
if (((variant[i]>96) && (variant[i]<123)) || ((variant[i]>64) && (variant[i]<91)))
{
if (flag)
{
if ((variant[i]>64) && (variant[i]<91))
word[i]=variant[i]+32;
else
word[i]=variant[i];
flag=false;
}
else
{
if ((variant[i]>96) && (variant[i]<123))
word[i]=variant[i]-32;
else
word[i]=variant[i];
flag=true;
}
}
else
word[i]=variant[i];
if (check_hash(word))
return true;
// чередование регистра начиная с заглавной буквы
for(quint8 i=0;i<size;i++)
if ((word[i]>96) && (word[i]<123))
word[i]-=32;
else if ((word[i]>64) && (word[i]<91))
word[i]+=32;
if (check_hash(word))
return true;
// верхний регистр
for(quint8 i=0;i<size;i++)
if ((word[i]>96) && (word[i]<123))
word[i]-=32;
if (check_hash(word))
return true;
// нижний регистр
for(quint8 i=0;i<size;i++)
if ((word[i]>64) && (word[i]<91))
word[i]+=32;
if (check_hash(word))
return true;
}
return false;
}
bool Hash::variant_for_hybrid(char *variant)
{
quint8 size=strlen(variant);
char word[buffer_size*4];
memset(word,NULL,buffer_size*4);
// сам вариант
if (check_hash(variant))
return true;
// повторение пароля
{
// два пароля подряд
memcpy(word,variant,size);
memcpy(word+size,variant,size);
word[size+size]=NULL;
if (check_hash(word))
return true;
// пароль+пароль
memcpy(word,variant,size);
memcpy(word+size,"+",1);
memcpy(word+size+1,variant,size);
word[size+size+1]=NULL;
if (check_hash(word))
return true;
// пароль/пароль
word[size]='/';
if (check_hash(word))
return true;
// пароль-пароль
word[size]='-';
if (check_hash(word))
return true;
// пароль\пароль
word[size]='\\';
if (check_hash(word))
return true;
}
// разные регистры символов (часто встречающиеся варианты)
{
bool flag=false;
memset(word,NULL,size+1);
// чередование регистра начиная со строчной буквы
for(quint8 i=0;i<size;i++)
if (((variant[i]>96) && (variant[i]<123)) || ((variant[i]>64) && (variant[i]<91)))
{
if (flag)
{
if ((variant[i]>64) && (variant[i]<91))
word[i]=variant[i]+32;
else
word[i]=variant[i];
flag=false;
}
else
{
if ((variant[i]>96) && (variant[i]<123))
word[i]=variant[i]-32;
else
word[i]=variant[i];
flag=true;
}
}
else
word[i]=variant[i];
if (check_hash(word))
return true;
// чередование регистра начиная с заглавной буквы
for(quint8 i=0;i<size;i++)
if ((word[i]>96) && (word[i]<123))
word[i]-=32;
else if ((word[i]>64) && (word[i]<91))
word[i]+=32;
if (check_hash(word))
return true;
// верхний регистр
for(quint8 i=0;i<size;i++)
if ((word[i]>96) && (word[i]<123))
word[i]-=32;
if (check_hash(word))
return true;
// нижний регистр
for(quint8 i=0;i<size;i++)
if ((word[i]>64) && (word[i]<91))
word[i]+=32;
if (check_hash(word))
return true;
}
// все возможные регистры пароля
{
memset(word,NULL,size+1);
quint8 count_letter=0;
for(quint8 i=0;i<size;i++)
if (((variant[i]>96) && (variant[i]<123)) || ((variant[i]>64) && (variant[i]<91)))
count_letter++;
bool position[count_letter+1];
memset(position,false,count_letter);
position[count_letter]=NULL;
for(quint8 i=0;i<size;i++)
{
if ((variant[i]>64) && (variant[i]<91))
word[i]=variant[i]+32;
else
word[i]=variant[i];
}
forever
{
quint8 j=0;
for(quint8 i=0;i<size;i++)
{
if (((word[i]>96) && (word[i]<123)) || ((word[i]>64) && (word[i]<91)))
{
if (position[j]==false)
{
word[i]-=32;
position[j]=true;
break;
}
else
{
position[j]=false;
word[i]+=32;
j++;
}
}
}
if (check_hash(word))
return true;
if (j>=count_letter)
break;
}
}
return false;
}
Размещено на Allbest.ru
Подобные документы
Определение энтропии как меры стойкости паролей, способ противодействия их взлому. Вычисление веса и информационной емкости пароля с помощью SeaMonkey, Password Strength Tester. Алгоритм работы дежурного и вспомогательного анализаторов от Microsoft.
курсовая работа [632,8 K], добавлен 18.06.2011Проблемы использования паролей на предприятии. Общие понятия и технологии идентификации и аутентификации. Принцип работы и структура программного средства SecureLogin от компании ActiveIdentity. Автоматическая генерация пароля, фишинг и фарминг.
курсовая работа [2,5 M], добавлен 22.01.2015Значение WEB-браузеров для организации доступа к Интернет-ресурсам, для просмотра страниц, видео, управления/администрирование ресурсов. Механизмы хранения паролей современных web-браузеров. Особенности применения функций дешифровки имени и пароля.
лабораторная работа [408,4 K], добавлен 04.12.2014Обзор основных используемых языков программирования (С++, Java, Pascal). Анализ существующих методов шифрования паролей. Основные понятия объектно-ориентированного программирования. Реализация приложения для генерирования паролей на языке Object Pascal.
курсовая работа [822,4 K], добавлен 07.07.2012Программа, которая будет выполнять записи в log-файл действий, идентифицированных как попытки атаки на защищаемый объект. Язык программирования PHP. Описание таблиц СУБД MySQL. Алгоритм работы программы. Вывод результата запроса через вложенный цикл.
курсовая работа [2,0 M], добавлен 26.07.2015Определение и анализ сущности брутфорса – одного из популярных методов взлома паролей на серверах и в различных программах. Характеристика клавиатурного шпиона на базе драйвера. Рассмотрение основных программ для поиска и удаления клавиатурных шпионов.
курсовая работа [100,9 K], добавлен 03.08.2017Количественная оценка стойкости пароля. Создание программы на базе разработанного алгоритма. Экспериментальная проверка количественных оценок стойкости пароля. Понятие и назначение интерфейса. Методы защиты от несанкционированного доступа к информации.
курсовая работа [22,8 K], добавлен 13.11.2009Понятие и принципы организации Web-браузеров как систем, использующихся для доступа к интернет-ресурсам для просмотра страниц, видео, управления / администрирование неких ресурсов. Механизм хранения паролей в браузерах и оценка его эффективности.
лабораторная работа [579,9 K], добавлен 04.12.2014Методика исследования и анализа средств аудита системы Windows с целью обнаружения несанкционированного доступа программного обеспечения к ресурсам вычислительных машин. Анализ угрозы информационной безопасности. Алгоритм работы программного средства.
дипломная работа [2,9 M], добавлен 28.06.2011Разработка исследовательского комплекса, решающего задачу формирования минимального полинома Жегалкина по вектору значений булевой функции методом частных полиномиальных нормальных форм. Сравнение сред программирования. Макет программного продукта.
дипломная работа [1,3 M], добавлен 29.05.2015