Тема №1. Криптосистеми з секретним ключом

Лабораторне заняття 1.9. «Засоби генерації простору словникових ключів»

Час проведення - 2 год.

Мета заняття: навчитися користуватися інструментами генерації парольних словників для криптоаналізу шифртексту.

Питання до лабораторного заняття

  1. Crunch.
  2. CUPP.
  3. Mentalist.
  4. PassphraseGen.

Контрольні запитання

  1. Що таке ключі в криптосистемах?
  2. Які існують уподобання користувачів по створенню паролів?

Програми генерації словників:

  • Crunch;
  • mentalist;
  • CUPP.

СТВОРИТИ КАТАЛОГ ІЗ СВОЇМ ПРІЗВИЩЕМ і ДАЛІ НА  ВСІХ СКРІНШОТАХ МАЄ БУТИ ВИДИМИМ КАТАЛОГ ІЗ ПРІЗВИЩЕМ ВИКОНАВЦЯ.

Завдання 9.1

В ОС Kali Linux ознайомитися із функціональністю crunch шляхом генерації словників за різними шаблонами. Виконати усі Examples.

Example 1

crunch 1 4 -o az4.txt

crunch will display a wordlist that starts at a and ends at zzzz

nano az4.txt

Example 2

crunch 1 6 abcdefg -o ag6.txt

crunch will display a wordlist using the character set abcdefg that starts at a and ends at gggggg

nano ag6.txt

Example 3

crunch 1 6 "abcdefg " -o ag6s.txt

Crunch will display a wordlist using the character set abcdefg  that starts at a and ends at (6 spaces)

nano ag6s.txt

Example 4

locate charset.lst

nano /usr/share/crunch/charset.lst

crunch 1 3 -f /usr/share/crunch/charset.lst mixalpha-numeric-all-space -o wordlist.txt

crunch  will use the mixalpha-numeric-all-space character set from charset.lst and will write the wordlist to a file named wordlist.txt.  The file will start with a and end with "        "

nano wordlist.txt

Example 5

crunch 5 5 -f /usr/share/crunch/charset.lst mixalpha-numeric-all-space -o wordlist.txt -t @d0g@ -s bd0ga

crunch should generate a  5  character  wordlist  using  the  mixalpha-number-all-space  character  set  from charset.lst  and  will  write the wordlist to a file named wordlist.txt.  The file will start at bd0ga and end at "  d0g   "

Example 6

crunch 2 3 -f /usr/share/crunch/charset.lst ualpha -s BB

crunch with start generating a wordlist at BB and end with ZZZ.  This is useful if you have to stop  generating  a  wordlist in the middle.  Just do a tail wordlist.txt and set the -s parameter to the next word in the sequence.  Be sure to rename the original wordlist BEFORE you begin as crunch  will  overwrite  the  existing wordlist.

Example 8

crunch 4 5 -p dog cat bird

The numbers aren't processed but are needed.

crunch will generate birdcatdog, birddogcat, catbirddog, catdogbird, dogbirdcat, dogcatbird.

Example 9

crunch 1 4 -o START -c 6000 -z bzip2

crunch  will generate bzip2 compressed files with each file containing 6000 words.  The filenames of the compressed files will be first_word-last_word.txt.bz2

Example 10

crunch 4 5 -b 20mib -o START

will generate 4 files: aaaa-gvfed.txt, gvfee-ombqy.txt, ombqz-wcydt.txt, wcydu-zzzzz.txt the first three files are 20MBs (real power of 2 MegaBytes) and the last file is 11MB.

Example 13

crunch 4 4  + + 123 + -t %%@^ -o wordlist.txt

       the  plus  sign (+) is a place holder so you can specify a character set for the character type.  crunch will use the default character set for the character type when crunch encounters a + (plus sign)  on  the  command line.   You  must  either  specify values for each character type or use the plus sign.  I.E. if you have two characters types you MUST either specify values for each type or use a plus sign.  So  in  this  example  the character sets will be:

       abcdefghijklmnopqrstuvwxyz

       ABCDEFGHIJKLMNOPQRSTUVWXYZ

       123

       !@#$%^&*()-_+=~`[]{}|\:;"'<>,.?/

       there is a space at the end of the above string the output will start at 11a! and end at "33z ".  The quotes show the space at the end of the string.

Example 14

crunch 5 5 -t ddd@@ -o j -p dog cat bird

any character other than one of the following: @,%^ is the placeholder for the words to permute.  The @,%^ symbols have the same function as -t. If  you  want to use @,%^ in your output you can use the -l option to specify which character you want crunch to treat as a literal. So the results are

       birdcatdogaa

       birdcatdogab

       birdcatdogac

       <skipped>

       dogcatbirdzy

       dogcatbirdzz

Example 15

crunch 7 7 -t p@ss,%^ -l a@aaaaa -o word

crunch will now treat the @ symbol as a literal character and not replace the character with a uppercase letter.

       this will generate

       p@ssA0!

       p@ssA0@

       p@ssA0#

       p@ssA0$

       <skipped>

       p@ssZ9

Згенерувати словник мобільних телефонів України з кодом 096:

# crunch 10 10 1234567890 -t 096%%%%%%% -o 096pass.txt

Завдання 9.2

Утиліта mentalist (https://github.com/sc0tfree/mentalist) має графічний інтерфейс і дозволяє вибудовувати ланцюги умов формування словника паролів.

Mentalist - це графічний інструмент для генерації користувацьких списків слів. Він використовує звичайні людські уподобання для побудови паролів і може виводити повний список слів, а також правила, сумісні з Hashcat і John the Ripper.

Опис роботи в https://github.com/sc0tfree/mentalist/wiki/How-It-Works

В ОС Kali Linux завантажити архів, розпакувати і запустити Mentalist

$ wget https://github.com/sc0tfree/mentalist/releases/download/v1.0/Mentalist-v1.0-Linux-x86_64.zip

$ unzip Mentalist-v1.0-Linux-x86_64.zip

$ ./Mentalist

При виникненні проблем в  ОС Kali Linux спробувати версію Mentalist для ОС Windows: https://github.com/sc0tfree/mentalist/releases/download/v1.0/Mentalist-v1.0-Win.zip 

Згенерувати словник на базі English Dictionary, в якому

  • друга літера слова змінює регістр;
  • повсюди йде заміна: e -> 3; i -> 1; o -> 0;
  • наприкінці слів додаються цифри від 1 до 5.

Показати згенерований словник.

Завдання 9.3

Common User Password Profile (CUPP) – генерує базу паролів, спираючись на введену інформацію про користувача (ім’я, прізвище, дата народження) для подальшого застосування в якості словника для підбору пароля.

В ОС Kali Linux

apt install cupp

cupp

1. Згенерувати словник в інтерактивному режимі, використовуючи персональні дані.

2. Завантажити і оглянути готові словники: computer, music, names, net, places, russian.

Завдання 9.4

Дуже часто наявні словники мають у своєму складі слова, що повторюються. Для видалення повторів краще використовувати інструменти ОС  Linux.

В ОС Kali Linux завантажити наданий словник passwordsworld.txt.

Порахувати кількість слів (рядків) у словнику:

# wc -l passwordsworld.txt

1215825 passwordsworld.txt

Сортуємо слова, щоб побачити повтори

# sort passwordsworld.txt > s-pass.txt

# cat s-pass.txt | more

Видаляємо повтори

# sort -u s-pass.txt > u-pass.txt

# nano u-pass.txt

Дивимось на кількість видалених повторів

# wc -l s-pass.txt u-pass.txt

 1215825 s-pass.txt

  803724 u-pass.txt

Також здійснити видалення повторів за допомогою команди uniq (приклад виконання).

Завдання 9.5

Ознайомитись із скриптом генерації парольних фраз PassphraseGen (https://github.com/dafthack/PassphraseGen).  Повторити приклади генерації парольних фраз.

Скрипт написаний для виконання в Windows PowerShell. Завантажити і розпакувати архів PassphraseGen скрипту із словниками.

Запустити PowerShell з правами адміністратора і перейти в каталог зі скриптом. Надати дозвіл в груповій  політиці запускати сторонні скрипти:

> Set-ExecutionPolicy Unrestricted

Скрипт містить функцію Invoke-PassphraseGen. Проблема з викликом скрипта, що містить функцію, полягає в тому, що функції завантажуються в область Script. Після виконання скрипта область видаляється і разом з нею видаляється функція. Функція має бути завантажена в область Global, щоб функція залишилась доступною після виконання скрипта. Це можна зробити викликом скрипта з крапкою попереду:

PS C:\Users\user\Desktop\PassphraseGen-master>. .\PassphraseGen.ps1

Надати дозвіл використовувати команду Invoke-PassphraseGen:

> Get-Command Invoke-PassphraseGen

Здійснити генерацію списку парольних фраз:

> Invoke-PassphraseGen -FourWords -Threads 20 -TotalLines 25 -Wordlist .\lists\bitcoin-bip-0039-seed-words.txt -OutputFile passphrase-list.txt

Показати  згенерований словник.

Скласти звіт, де відображений процес виконання. Звіт оформити у вигляді Google Docs та надати доступ для перевірки. Допускається звіт у вигляді відео з екрану, але обов’язково навести висновки.