.NET UIAutomation实现Word文档加密暴力破解

.NET UIAutomation简介

UIAutomation是.Net 3.5之后提供的“界面自动化测试”技术,主要依靠通过Win32程序窗口和控件句柄获得控制权(反射和HOOK机制),从而达到利用程序脚本实现各类操作的目的,一般利用其实现针对Windows平台应用程序的自动化测试。

暴力破解方法

对于一个设置了密码访问限制的Word文档,可以利用UIAutomation的特点,使用不断穷举密码和密码字典的方式进行破解。

破解方法实现

可以穷举字母和数字的组合作为密码输入数据,当然你如果愿意也可以加入特殊字符,主要实现代码参见:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace PasswordCrack
{
    class Util
    {

        public void ReadLineAndCrack(string path, CrackHandler crack) {
            StreamReader reader = null;
            try
            {
                reader = new StreamReader(path, Encoding.Default);
                String line = null;
                while ((line = reader.ReadLine()) != null)
                {
                    crack(line);
                }
            }
            catch (IOException e)
            {
                System.Console.WriteLine(e.StackTrace);
            }
            finally
            {
                if (reader != null) {
                    reader.Close();
                }
            }

        }

        /**
        *通过设置需要生成的第几列字符串,生成暴力破解字符串
        *
        *参数说明:
        *@column 第几列
        *@crack 破解处理方法
        **/
        public void GenCrackWordByColumn(int column, CrackHandler crack) {
            string[] columns = new string[column];
            GenColumnsWord(columns, 0, columns.Length, crack);
        }

        /**
        *通过设置需要生成的字符串位数范围,生成暴力破解字符串
        *
        *参数说明:
        *@begin 起始位
        *@length 从起始位开始的长度范围
        *@crack 破解处理方法
        **/
        public void GenCrackWordByScope(int begin, int length, CrackHandler crack) {
            for (int i = begin; i < begin + length; i++)
            {
                if ((begin < 1) || (length < 0)) {
                    break;
                }
                string[] columns = new string[i];
                GenColumnsWord(columns, 0, columns.Length, crack);
            }
        }

        /**
        *通过设置需要生成的字符串最大位数,生成暴力破解字符串
        *
        *参数说明:
        *@bit 数组位数
        *@crack 破解处理方法
        **/
        public void GenCrackWord(int bit, CrackHandler crack) {
            for (int i = 0; i < bit; i++) {
                string[] columns = new string[i + 1];
                GenColumnsWord(columns, 0, columns.Length, crack);
            }
        }
        /**
        *按列数生成暴力破解字符串,生成方式为遍历该函数中所设定的字符组合
        *
        *参数说明:
        *@columns 用于保存所生成字符串的数组
        *@index 生成第几列数据,初始引用是需设置为0
        *@bit 数组位数
        *@crack 破解处理方法
        **/
        public void 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值