Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ЛАБА БОС 2.docx
Скачиваний:
9
Добавлен:
23.01.2021
Размер:
123.07 Кб
Скачать

Міністерство освіти і науки України

Вінницький національний технічний університет

Факультет інформаційних технологій та комп’ютерної інженерії

Кафедра захисту інформації

Звіт

З лабораторної роботи №2 " Дослідження алгоритмів злому та генерації паролів"

Виконала студентка гр. 1БС-17б (з)

Ковальчук В.В.

Лабораторну роботу захищено

з оцінкою ____________________________

Перевірив

Доц. каф. ЗІ, к.т.н ____________________________

Баришев Ю.В.

_________________ 2021 р.

Вінниця 2021 р.

Хід роботи

За списком групи вибрано 3 варіант:

Побудуємо схему програми:

Зобразимо блок-схему перебору регістру:

Створено блок-схему рекомендацій:

Лістинг програми

Frame.java

import java.awt.Container;

import java.awt.Image;

import javax.swing.ImageIcon;

import javax.swing.JFrame;

class Frame extends JFrame{

public Frame(){

setTitle("Лаба 2");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setBounds(100,100,700,500);

setResizable(false);

setLocationRelativeTo(null);

setContentPane(new BgPanel());

Container cont = getContentPane();

Image img = new ImageIcon("Image/key.png").getImage();

setIconImage(img);

}

}

Hash.java

import java.io.UnsupportedEncodingException;

import java.math.BigInteger;

import java.security.MessageDigest;

import java.security.NoSuchAlgorithmException;

public class Hash {

public static String Hash(String str) {

MessageDigest m = null;

try {

m = MessageDigest.getInstance("MD5");

} catch (NoSuchAlgorithmException e) {

e.printStackTrace();

}

m.reset();

try {

m.update(str.getBytes("utf-8"));

} catch (UnsupportedEncodingException e) {

e.printStackTrace();

}

String s2 = new BigInteger(1, m.digest()).toString(16);

StringBuilder sb = new StringBuilder(32);

for (int i = 0, count = 32 - s2.length(); i < count; i++) {

sb.append("0");

}

return sb.append(s2).toString();

}

}

Interface.Java

import java.awt.Color;

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.BorderFactory;

import javax.swing.JButton;

import javax.swing.JLabel;

import javax.swing.JTextArea;

import javax.swing.JTextField;

import javax.swing.border.Border;

public class Interface {

static String mess1 = "Виконується...", mess2 = "Завершено!";

static int butt = 0;

public static void Interfañe(Frame f,String hash ,JTextArea ta1,JTextArea ta2, String pass) {

Border border1 = BorderFactory.createLineBorder(Color.BLACK);

JButton Button1 = new JButton("Звичайний перебір");

Button1.setBounds(150,170,300,40);

Button1.setFont(new Font("Times New Roman", Font.BOLD,16));

Button1.setBackground(Color.RED);

Button1.setForeground(Color.BLACK);

Button1.setBorder(BorderFactory.createCompoundBorder(border1, BorderFactory.createEmptyBorder(10, 10, 10, 10)));

f.getContentPane().add(Button1);

JButton Button2 = new JButton("Перебір з додаванням трьох цифр");

Button2.setBounds(150,220,300,40);

Button2.setFont(new Font("Times New Roman", Font.BOLD,16));

Button2.setBackground(Color.RED);

Button2.setForeground(Color.BLACK);

Button2.setBorder(BorderFactory.createCompoundBorder(border1, BorderFactory.createEmptyBorder(10, 10, 10, 10)));

f.getContentPane().add(Button2);

JButton back = new JButton("Назад");

back.setBounds(550,400,100,40);

back.setFont(new Font("Times New Roman", Font.BOLD,16));

back.setBackground(Color.GRAY);

back.setForeground(Color.BLACK);

back.setBorder(BorderFactory.createCompoundBorder(border1, BorderFactory.createEmptyBorder(10, 10, 10, 10)));

f.getContentPane().add(back);

back.setVisible(false);

JButton start = new JButton("Почати");

start.setBounds(50,50,100,40);

start.setFont(new Font("Times New Roman", Font.BOLD,16));

start.setBackground(Color.GRAY);

start.setForeground(Color.BLACK);

start.setBorder(BorderFactory.createCompoundBorder(border1, BorderFactory.createEmptyBorder(10, 10, 10, 10)));

f.getContentPane().add(start);

start.setVisible(false);

JLabel l1 = new JLabel("Стан:");

l1.setFont(new Font("Times New Roman", Font.BOLD,16));

l1.setBounds(50,300,450,20);

l1.setForeground(Color.black);

f.getContentPane().add(l1);

l1.setVisible(false);

JLabel l2 = new JLabel(mess1);

l2.setFont(new Font("Times New Roman", Font.BOLD,16));

l2.setBounds(100,300,450,20);

l2.setForeground(Color.black);

f.getContentPane().add(l2);

l2.setVisible(false);

JLabel l3 = new JLabel(mess2);

l3.setFont(new Font("Times New Roman", Font.BOLD,16));

l3.setBounds(100,300,450,20);

l3.setForeground(Color.black);

f.getContentPane().add(l3);

l3.setVisible(false);

JLabel l4 = new JLabel("Ваш пароль '" + pass + "' не стійкий!");

l4.setFont(new Font("Times New Roman", Font.BOLD,16));

l4.setBounds(400,100,450,30);

l4.setForeground(Color.black);

f.getContentPane().add(l4);

l4.setVisible(false);

JLabel l5 = new JLabel("Спробуйте один з цих варіантів:");

l5.setFont(new Font("Times New Roman", Font.BOLD,16));

l5.setBounds(400,120,450,30);

l5.setForeground(Color.black);

f.getContentPane().add(l5);

l5.setVisible(false);

ta1.setFont(new Font("Century Gothic", Font.PLAIN,12));

ta1.setForeground(Color.RED);

ta1.setBackground(Color.white);

ta1.setEditable(false);

ta1.setLineWrap(true);

ta1.setWrapStyleWord(true);

ta1.setBounds(50,340,400,40);

ta1.setBorder(BorderFactory.createCompoundBorder(border1, BorderFactory.createEmptyBorder(2, 2, 2, 2)));

f.getContentPane().add(ta1);

ta1.setVisible(false);

ta2.setFont(new Font("Time New Roman", Font.PLAIN,12));

ta2.setForeground(Color.RED);

ta2.setBackground(Color.white);

ta2.setEditable(false);

ta2.setLineWrap(true);

ta2.setWrapStyleWord(true);

ta2.setBounds(468,158,168,108);

ta2.setBorder(BorderFactory.createCompoundBorder(border1, BorderFactory.createEmptyBorder(2, 2, 2, 2)));

f.getContentPane().add(ta2);

ta2.setVisible(false);

Button1.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

Button1.setVisible(false);

Button2.setVisible(false);

back.setVisible(true);

l1.setVisible(true);

ta1.setVisible(true);

start.setVisible(true);

butt=1;

}

});

Button2.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

Button1.setVisible(false);

Button2.setVisible(false);

back.setVisible(true);

l1.setVisible(true);

ta1.setVisible(true);

start.setVisible(true);

butt=2;

}

});

start.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

Thread myThready = new Thread(new Runnable()

{public void run(){l2.setVisible(true);}});

myThready.start();

int end = Iterate.Iterate(ta1,butt);

if (end==1) {

l2.setVisible(false);

l3.setVisible(true);

l4.setVisible(true);

l5.setVisible(true);

ta2.setVisible(true);

WritePass.Recommend(pass,ta2);

} else if (end==0) {

ta1.setText("Нажаль не вдалося п³д³брати пароль(");

l2.setVisible(false);

l3.setVisible(true);

}

}

});

back.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

Button1.setVisible(true);

Button2.setVisible(true);

back.setVisible(false);

l1.setVisible(false);

l2.setVisible(false);

l3.setVisible(false);

l4.setVisible(false);

l5.setVisible(false);

ta2.setVisible(false);

ta1.setVisible(false);

start.setVisible(false);

ta1.setText(null);

ta2.setText(null);

}

});

}

}

Соседние файлы в предмете Безопасность операционных систем