C# WPF 加密EXCEL文件字典破解

By jerryxjr1220 at 2023-10-16 • 0人收藏 • 268人看过

screenshots.gif

<hc:GlowWindow x:Class="WPFProgressBar.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:model="clr-namespace:WPFProgressBar.Models"
        xmlns:vm="clr-namespace:WPFProgressBar.ViewModels"
        xmlns:view="clr-namespace:WPFProgressBar.Views"
        xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:local="clr-namespace:WPFProgressBar"
        xmlns:hc="https://handyorg.github.io/handycontrol"
        d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
        mc:Ignorable="d"
        Title="MainWindow" Height="360" Width="720" 
        FontFamily="JetBrains Mono" 
        FontSize="{StaticResource TextFontSize}"
        Background="GhostWhite">
    <Window.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </Window.Resources>
    <hc:SimplePanel>
        <ScrollViewer x:Name="scrollViewer" VerticalScrollBarVisibility="Auto">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="4*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="3*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Row="0" Grid.Column="0" 
                           Text="Excel to Crack" FontSize="14"
                           Style="{StaticResource TextBlockDefaultPrimary}"
                           HorizontalAlignment="Right" VerticalAlignment="Center"/>
                <TextBox Grid.Row="0" Grid.Column="1" hc:InfoElement.Placeholder="Excel File Path..." 
                         Text="{Binding ExcelFilePath}"
                         Style="{StaticResource TextBoxExtend}"
                         VerticalAlignment="Center" Margin="20,0"/>
                <Button Grid.Row="0" Grid.Column="2" HorizontalAlignment="Left"
                        Style="{StaticResource ButtonDashedPrimary}"
                        hc:IconElement.Geometry="{StaticResource DownloadGeometry}"
                        Command="{Binding ChooseExcelFileCommand}"/>
                <TextBlock Grid.Row="1" Grid.Column="0" 
                           Text="Password Book" FontSize="14"
                           Style="{StaticResource TextBlockDefaultPrimary}"
                           HorizontalAlignment="Right" VerticalAlignment="Center"/>
                <TextBox Grid.Row="1" Grid.Column="1" hc:InfoElement.Placeholder="Password Book File Path..." 
                         Text="{Binding PasswordBookFilePath}"
                         Style="{StaticResource TextBoxExtend}"
                         VerticalAlignment="Center" Margin="20,0"/>
                <Button Grid.Row="1" Grid.Column="2" HorizontalAlignment="Left"
                        Style="{StaticResource ButtonDashedPrimary}"
                        hc:IconElement.Geometry="{StaticResource DownloadGeometry}"
                        Command="{Binding ChoosePasswordBookFileCommand}"/>
                <StackPanel Grid.Row="2" Grid.Column="0">
                    <TextBlock Text="Cracking Progress" FontSize="14"
                               Style="{StaticResource TextBlockDefaultPrimary}"
                               HorizontalAlignment="Right" VerticalAlignment="Top" />
                    <Button Style="{StaticResource ButtonPrimary}" Margin="20"
                            Content="Crack" Command="{Binding CrackingCommand}"/>
                </StackPanel>
                
                <Border Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2"
                        BorderBrush="LightGray" BorderThickness="1" CornerRadius="10" Margin="10">
                    <hc:WaveProgressBar Width="180" Minimum="0" Maximum="1" 
                                        Value="{Binding ProgressValue}" 
                                        Text="{Binding ProgressText}"/>
                </Border>
                
            </Grid>
        </ScrollViewer>
    </hc:SimplePanel>
</hc:GlowWindow>
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using CommunityToolkit.Mvvm.Messaging.Messages;
using Microsoft.Win32;
using WPFProgressBar.Models;
using Microsoft.Office.Interop.Excel;

namespace WPFProgressBar.ViewModels;

public partial class MainViewModel : ObservableObject
{
    [ObservableProperty] private string _excelFilePath;
    [ObservableProperty] private string _passwordBookFilePath;
    [ObservableProperty] private double _progressValue;
    [ObservableProperty] private string _progressText;
    public MainViewModel()
    {
        ExcelFilePath = "";
        PasswordBookFilePath = "";
        ProgressValue = 0;
        ProgressText = "Not Ready";

       
    }

    [RelayCommand]
    public void ChooseExcelFile()
    {
        FileDialog fd = new OpenFileDialog();
        fd.Filter = "Excel Files|*.xlsx";
        fd.Title = "Choose Excel File to crack...";
        var fdResult = fd.ShowDialog();
        if (fdResult == true)
        {
            ExcelFilePath = fd.FileName;
        }
    }
    
    [RelayCommand]
    public void ChoosePasswordBookFile()
    {
        FileDialog fd = new OpenFileDialog();
        fd.Filter = "TXT Files|*.txt";
        fd.Title = "Choose Password Book File...";
        var fdResult = fd.ShowDialog();
        if (fdResult == true)
        {
            PasswordBookFilePath = fd.FileName;
        }
    }
    
    [RelayCommand]
    public void Cracking()
    {
        if(ExcelFilePath.Length<1 || PasswordBookFilePath.Length<1) return;
        var passowrds = File.ReadAllLines(PasswordBookFilePath);
        
        //Application excelApp = new Application();
        //Workbook workbook = null;

        bool cracked = false;

        Task.Run(() =>
        {
            for (var index = 0; index < passowrds.Length; index++)
            {
                var pwd = passowrds[index];
                ProgressValue = (double)index / passowrds.Length;
                ProgressText = $"{(ProgressValue * 100):F1} %";
                try
                {
                    Thread.Sleep(1000);
                    if (index == passowrds.Length - 1)
                    {
                        ProgressText = $"Password: {pwd}";
                        cracked = true;
                    }
                    
                    // workbook = excelApp.Workbooks.Open(ExcelFilePath, Password: pwd);
                    // ProgressText = $"Password: {pwd}";
                    // cracked = true;
                    // break;
                }
                catch (Exception)
                {
                    cracked = false;
                }
            }
        });
        
        if (cracked)
        {
            ProgressValue = 1;
        }
        else
        {
            ProgressValue = 1;
            ProgressText = "Excel File not cracked!";
        }

        //workbook?.Close();
        //excelApp.Quit();
        
    }
    
}


登录后方可回帖

登 录
信息栏
 私人小站

本站域名

ChengXu.XYZ

投诉联系:  popdes@126.com



快速上位机开发学习,本站主要记录了学习过程中遇到的问题和解决办法及上位机代码分享

这里主要专注于学习交流和经验分享.
纯私人站,当笔记本用的,学到哪写到哪.
如果侵权,联系 Popdes@126.com

友情链接
Aardio官方
Aardio资源网


才仁机械


网站地图SiteMap

Loading...