Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.URL;
- import java.util.ArrayList;
- import java.util.Scanner;
- import java.util.zip.CRC32;
- public class Main {
- public static void main(String[] args) throws IOException {
- long hash1 = 0x0B91A851BL; // это CRC32 хэш пароля apple123
- long hash2 = 0x0BA02B6E1L; // хэш CRC32 пароля, который нужно угадать
- // пароль состоит из слова (из файла), за котрым следует число от 1 до 9999
- // примеры паролей: master111 shadow1234
- // посчитать хэш можно и в браузере http://www.sunshine2k.de/coding/javascript/crc/crc_js.html
- // часть 1. проверяем, как пользоваться CRC32
- // используем простой алгоритм CRC32
- CRC32 crc32 = new CRC32();
- String plaintext = "apple123";
- crc32.update(plaintext.getBytes());
- // хэш - это контрольная сумма в виде числа типа long
- long checksum = crc32.getValue();
- // выводим наш хэш в шестнадцатеричной форме
- // System.out.println(Long.toHexString(checksum));
- // объект можно использовать повторно, вызвав метод reset()
- crc32.reset();
- crc32.update(plaintext.getBytes());
- checksum = crc32.getValue();
- crc32.reset();
- // System.out.println(Long.toHexString(checksum));
- // часть 2. считываем список слов из файла
- // https://github.com/danielmiessler/SecLists/blob/master/Passwords/10k_most_common.txt
- // кстати, могу рекомендовать блог автора, пишет про инф. безопасность
- // https://danielmiessler.com/blog/
- // рекомендую использовать для этого ArrayList
- ArrayList<String> words = new ArrayList<String>();
- URL url=new URL("https://github.com/danielmiessler/SecLists/blob/master/Passwords/10k_most_common.txt");
- Scanner in=new Scanner((InputStream) url.getContent());
- System.out.print("1231");
- while(in.hasNext()){
- words.add(in.nextLine());
- }
- for(int i=0;i<words.size();i++){
- String word=words.get(i);
- int a=0;
- for(int j=1;j<9999;j++){
- word+=j;
- crc32.update(word.getBytes());
- checksum=crc32.getValue();
- if(checksum==hash2){
- System.out.println(word);
- a=1;
- }
- crc32.reset();
- }
- if(a==1) break;
- }
- System.out.println("There are " + words.size() + " in dictionary file");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement