public void Initialization(IAsyncTaskProgress asyn, params string[] pluginPaths) { if (!_Isloaded) { _Isloaded = true; Plugins = new Dictionary <PluginType, Type>(); List <string> existList = new List <string>(); List <string> dirs = new List <string>(); dirs.Add(AppDomain.CurrentDomain.BaseDirectory); dirs.AddRange(pluginPaths); foreach (var dir in dirs) { var files = System.IO.Directory.GetFiles(dir, "XLY.SF.Project.Plugin.*.dll", System.IO.SearchOption.AllDirectories); foreach (var dllFile in files) { if (existList.Contains(System.IO.Path.GetFileName(dllFile))) { continue; } existList.Add(System.IO.Path.GetFileName(dllFile)); var ass = Assembly.LoadFile(dllFile); foreach (var cla in ass.GetTypes().Where(t => t.GetCustomAttribute <PluginContainerAttribute>() != null && !t.IsAbstract && !t.IsInterface)) { Plugins[cla.GetCustomAttribute <PluginContainerAttribute>().PluginType] = cla; } } } } }
/// <summary> /// /// </summary> /// <param name="script"></param> /// <param name="asyn"></param> /// <param name="argrument"></param> /// <param name="paramValues"></param> /// <param name="isThrowExeception"></param> /// <returns></returns> public object Execute(string script, IAsyncTaskProgress asyn, object[] argrument = null, Dictionary <string, object> paramValues = null, bool isThrowExeception = true) { try { if (!FileHelper.IsValid(script)) { throw new Exception("Python File '" + script + "' is not exist!"); } InitEnvriment(script); dynamic py = LoadPythonScript(script); var result = py.main(argrument, asyn); return(result); } catch (Exception e) { if (isThrowExeception) { throw e; } return(null); } finally { Dispose(); } }
protected override void Initialize(DataReportPluginArgument arg, IAsyncTaskProgress progress) { if (!Directory.Exists(arg.ReportPath)) { Directory.CreateDirectory(arg.ReportPath); } }
/// <summary> /// 初始化 /// </summary> public void Initialization(IAsyncTaskProgress asyn, params string[] pluginPaths) { if (!_Isloaded) { PluginContainerAdapter.Instance.Initialization(asyn, pluginPaths); _Isloaded = true; Plugins = new Dictionary <AbstractPluginInfo, IPlugin>(); var pluginLoaders = new List <IPluginLoader>() { new JavascriptPluginLoader(), new NetPluginLoader(), new ZipPluginLoader() }; foreach (var loader in pluginLoaders) { var pls = loader.Load(asyn, pluginPaths); foreach (var pl in pls) { if (null != pl.PluginInfo) { Plugins.Add(pl.PluginInfo as AbstractPluginInfo, pl); } } } } }
/// <summary> /// 执行插件 /// </summary> /// <param name="plugin">要执行的插件</param> /// <param name="asyn">异步通知</param> /// <param name="callback">插件执行完回调</param> public void ExecutePlugin(DataParsePluginInfo plugin, IAsyncTaskProgress asyn, Action <IDataSource> callback) { var pl = Plugins[plugin] as AbstractDataParsePlugin; if (null != pl) { pl.StartTime = DateTime.Now; IDataSource ds = null; try { ds = pl.Execute(null, asyn) as IDataSource; } finally { ds?.BuildParent(); } if (ds != null) { ds.PluginInfo = plugin; } pl.EndTime = DateTime.Now; callback?.Invoke(ds); } }
public override object Execute(object arg, IAsyncTaskProgress progress) { TreeDataSource ds = new TreeDataSource(); try { var pi = PluginInfo as DataParsePluginInfo; var mmailFile = pi.SourcePath[0].Local; if (!FileHelper.IsValid(mmailFile)) { return(ds); } BuildData(ds, pi.SaveDbPath, mmailFile); } catch (System.Exception ex) { Framework.Log4NetService.LoggerManagerSingle.Instance.Error("提取安卓网易邮箱数据出错!", ex); } finally { ds?.BuildParent(); } return(ds); }
public override object Execute(object arg, IAsyncTaskProgress progress) { SimpleDataSource ds = null; try { var pi = PluginInfo as DataParsePluginInfo; ds = new SimpleDataSource(); ds.Type = typeof(Calendar); ds.Items = new DataItems <Calendar>(pi.SaveDbPath); ds.Items.AddRange(GetCalendars(Path.Combine(pi.SourcePath[0].Local, "Calendar.db"))); ds.Items.AddRange(GetCalendars(Path.Combine(pi.SourcePath[1].Local, "Calendar.db"))); ds.Items.AddRange(GetVivoCalendars(pi.SourcePath[2].Local)); } catch (Exception ex) { Framework.Log4NetService.LoggerManagerSingle.Instance.Error("提取安卓设备日历信息出错!", ex); } finally { ds?.BuildParent(); } return(ds); }
/// <summary> /// 采用备份方式拷贝用户数据 支持IOS8.3及其以上系统 /// </summary> /// <param name="device">设备</param> /// <param name="targetPath">目标路径</param> /// <param name="asyn"></param> /// <returns></returns> public string CopyUserData(Device device, string targetPath, IAsyncTaskProgress asyn) { //1.初始化相关参数 InitCopyUserData(device, 100, asyn); //2.文件拷贝 var res = IOSDeviceCoreDll.CopyUserData(targetPath, device.ID, _CopyUserDataCallback); if (0 != res) { IsCopying = false; } else { while (IsCopying) { Thread.Sleep(500); } } //3.清理 ClearCopyUserData(); return(Path.Combine(targetPath, device.ID)); }
public override object Execute(object arg, IAsyncTaskProgress progress) { SimpleDataSource ds = null; try { var pi = PluginInfo as DataParsePluginInfo; ds = new SimpleDataSource(); ds.Type = typeof(Bluetooth); ds.Items = new DataItems <Bluetooth>(pi.SaveDbPath); if (FileHelper.IsValidDictory(pi.SourcePath[0].Local)) { BuildData(ds, pi.SourcePath[0].Local); } } catch (System.Exception ex) { Framework.Log4NetService.LoggerManagerSingle.Instance.Error("提取安卓设备蓝牙信息数据出错!", ex); } finally { ds?.BuildParent(); } return(ds); }
public override object Execute(object arg, IAsyncTaskProgress progress) { SimpleDataSource ds = null; try { var pi = PluginInfo as DataParsePluginInfo; ds = new SimpleDataSource(); ds.Type = typeof(SwitchTimeInfo); ds.Items = new DataItems <SwitchTimeInfo>(pi.SaveDbPath); ds.Items.AddRange(GetHuawei(pi.SourcePath[0].Local, pi.SourcePath[1].Local)); ds.Items.AddRange(GetSamsung(pi.SourcePath[2].Local, pi.SourcePath[3].Local)); ds.Items.AddRange(GetOppo(pi.SourcePath[4].Local)); } catch (Exception ex) { Framework.Log4NetService.LoggerManagerSingle.Instance.Error("提取安卓设备开关机时间数据出错!", ex); } finally { ds?.BuildParent(); } return(ds); }
/// <summary> /// 暂停镜像 /// </summary> public void Pause(IAsyncTaskProgress asyn) { if (null != MirrorService && MirrorService.EnableSuspend) { MirrorService.Suspend(asyn); } }
public override object Execute(object arg, IAsyncTaskProgress progress) { TreeDataSource ds = new TreeDataSource(); try { var pi = PluginInfo as DataParsePluginInfo; var databasesPath = pi.SourcePath[0].Local; if (!FileHelper.IsValidDictory(databasesPath)) { return(ds); } new AndroidTencentMapDataParserCoreV1_0(pi.SaveDbPath, pi.SourcePath[0].Local, pi.SourcePath[1].Local, pi.SourcePath[2].Local).BuildData(ds); } catch (System.Exception ex) { Framework.Log4NetService.LoggerManagerSingle.Instance.Error("提取安卓腾讯地图数据出错!", ex); } finally { ds?.BuildParent(); } return(ds); }
/// <summary> /// 执行JavaScript脚本,该脚本同源SPF脚本格式,在后续只兼容执行,不再添加新脚本 /// </summary> /// <param name="content">脚本内容(替换了$source之后的内容)</param> /// <param name="asyn">消息通知</param> /// <param name="argrument">传入main函数的参数,JavaScript脚本应该为空</param> /// <param name="paramValues">其它需要设置到脚本的动态参数</param> /// <param name="isThrowExeception">如果执行出现错误,是否抛出异常</param> /// <returns></returns> public object Execute(string content, IAsyncTaskProgress asyn, object[] argrument = null, Dictionary <string, object> paramValues = null, bool isThrowExeception = true) { try { using (JavascriptContext context = new JavascriptContext()) { context.SetParameter("XLY", SingleWrapperHelper <XLYEngine> .Instance); var ac = new Action <object>(s => { SingleWrapperHelper <XLYEngine> .Instance.Debug.Write(s); }); context.SetParameter("log", ac); if (paramValues != null) { foreach (var pk in paramValues) { context.SetParameter(pk.Key, pk.Value); } } //所有脚本均从main函数开始执行。 //content += string.Format(@" // var ___result = main({0}); // ___result; //", argrument); var obj = context.Run(content); return(obj); } } catch (Exception ex) { if (isThrowExeception) { throw ex; } return(null); } }
public override object Execute(object arg, IAsyncTaskProgress progress) { SimpleDataSource ds = null; try { var pi = PluginInfo as DataParsePluginInfo; ds = new SimpleDataSource(); ds.Type = typeof(KeyValueItem); ds.Items = new DataItems <KeyValueItem>(pi.SaveDbPath); BuildData(ds, pi); } catch (System.Exception ex) { Framework.Log4NetService.LoggerManagerSingle.Instance.Error("提取安卓设备属性(镜像)数据出错!", ex); } finally { ds?.BuildParent(); } return(ds); }
public MirrorControlerBox(SPFTask task, Mirror mirror, IAsyncTaskProgress asyn) { _task = task; _mirror = mirror; _asyn = asyn; _mirrorControler = new MirrorControler(); }
public override void Execute(Mirror mirror, IAsyncTaskProgress asyn) { var device = mirror.Source as Device; DeviceManager = device.DeviceManager as IOSDeviceManager; //数据缓存路径 var tempSavePath = FileHelper.ConnectPath(mirror.Target, "temp"); FileHelper.CreateExitsDirectorySafe(tempSavePath); //数据备份 var resPath = DeviceManager.CopyUserData(device, tempSavePath, asyn); if (!FileHelper.IsValidDictory(resPath)) {//数据拷贝失败! } //打包 mirror.Local = FileHelper.ConnectPath(mirror.Target, mirror.TargetFile); ZipFile.CreateFromDirectory(resPath, mirror.Local); if (!FileHelper.IsValid(mirror.Local)) {//打包失败! } //删除缓存文件 FileHelper.DeleteDirectorySafe(tempSavePath); }
public override object Execute(object arg, IAsyncTaskProgress progress) { MMSDataSource ds = null; try { var pi = PluginInfo as DataParsePluginInfo; ds = new MMSDataSource(pi.SaveDbPath); var databasesFilePath = pi.SourcePath[0].Local; if (!FileHelper.IsValid(databasesFilePath)) { return(ds); } BuildData(ds, databasesFilePath); } catch (System.Exception ex) { Framework.Log4NetService.LoggerManagerSingle.Instance.Error("提取安卓彩信数据出错!", ex); } finally { ds?.BuildParent(); } return(ds); }
public override object Execute(object arg, IAsyncTaskProgress progress) { EarlyWarningPluginArgument ewArg = (EarlyWarningPluginArgument)arg; DeviceDataSource ds = ewArg.DeviceDataSource; List <DataNode> dataNodes = ewArg.DataNodes; IDataSource dataSource = ds.DataSource; foreach (DataNode dataNode in dataNodes) { //todo 此处dataNode.SensitiveData.CategoryName != "关键字"为硬代码 if (dataNode.SensitiveData.CategoryName != "关键字") { continue; } if (dataSource.Items != null) { string cmd = string.Format("{1} like '%{2}%'", dataSource.Items.DbTableName, SqliteDbFile.JsonColumnName, dataNode.SensitiveData.Value); IEnumerable <dynamic> result = dataSource.Items.FilterByCmd <dynamic>(cmd); foreach (AbstractDataItem item in result) { item.SensitiveId = dataNode.SensitiveData.SensitiveId; } } //todo TreeDataSource } return(null); }
public override object Execute(object arg, IAsyncTaskProgress progress) { EarlyWarningPluginArgument ewArg = (EarlyWarningPluginArgument)arg; DeviceDataSource ds = ewArg.DeviceDataSource; EarlyWarningResult earlyWarningResult = ewArg.EarlyWarningResult; List <DataNode> dataNodes = ewArg.DataNodes; IDataSource dataSource = ds.DataSource; TreeDataSource treeDataSource = dataSource as TreeDataSource; if (treeDataSource == null || treeDataSource.TreeNodes.Count < 1) { return(null); } foreach (DataNode dataNode in dataNodes) { //todo 此处dataNode.SensitiveData.CategoryName != "URL"为硬代码 if (dataNode.SensitiveData.CategoryName != "URL") { continue; } //todo 此处可以直接匹配,书签和历史记录 foreach (TreeNode treeNode in treeDataSource.TreeNodes) { string cmd = string.Format("{1} like '%{2}%'", treeNode.Items.DbTableName, SqliteDbFile.JsonColumnName, dataNode.SensitiveData.Value); IEnumerable <dynamic> result = treeNode.Items.FilterByCmd <dynamic>(cmd); earlyWarningResult.SqlDb.WriteResult(result, treeNode.Items.DbTableName, (Type)treeNode.Type); } } return(null); }
public override object Execute(object arg, IAsyncTaskProgress progress) { TreeDataSource ds = new TreeDataSource(); try { var pi = PluginInfo as DataParsePluginInfo; BuildData(ds, pi.SaveDbPath, "IOS微信", pi.SourcePath[0].Local); BuildData(ds, pi.SaveDbPath, "Ai.粉色微信", pi.SourcePath[1].Local); foreach (var source in pi.SourcePath.Skip(2)) { BuildData(ds, pi.SaveDbPath, "微信分身", source.Local); } } catch (Exception ex) { LoggerManagerSingle.Instance.Error("提取微信数据出错!", ex); } finally { ds?.BuildParent(); } return(ds); }
/// <summary> /// 继续镜像 /// </summary> public void Continue(IAsyncTaskProgress asyn) { if (null != MirrorService && MirrorService.EnableSuspend) { MirrorService.Continue(asyn); } }
/// <summary> /// 执行数据镜像 /// </summary> /// <param name="task">任务</param> /// <param name="mirror">镜像源信息</param> /// <param name="asyn">异步通知</param> public void Execute(SPFTask task, Mirror mirror, IAsyncTaskProgress asyn) { //生成保存目录 FileHelper.CreateExitsDirectorySafe(mirror.Target); //镜像 MirrorService = SingleWrapperHelper <MirrorServiceFactory> .GetInstance().GetInstance(mirror); MirrorService.Execute(mirror, asyn); if (FileHelper.IsValid(mirror.Local)) {//镜像成功 mirror.VerifyCode = FileHelper.MD5FromFileUpper(mirror.Local); //生成MD5文件 var md5File = mirror.Local.TrimEnd(SPFTask.EXT_MIRROR) + SPFTask.EXT_VERIFYCODE_FILE; FileHelper.CreateFile(md5File, mirror.VerifyCode, Encoding.UTF8); //生成设备信息文件 var deviceFile = mirror.Local.TrimEnd(SPFTask.EXT_MIRROR) + SPFTask.EXT_DEVICE; Serializer.SerializeToBinary(task.Device, deviceFile); task.TaskMirrorFilePath = mirror.Local; task.VerifyCodes.Add(new FileVerifyCode() { FilePath = mirror.Local, VerifyCode = mirror.VerifyCode }); } }
public object Execute(object arg, IAsyncTaskProgress progress) { var p = arg as DataReportPluginArgument; Initialize(p, progress); ExportData(p, progress); ExportFile(p, progress); return(ExportCompleted(p, progress)); }
/// <summary> /// 加载插件 /// </summary> /// <param name="asyn"></param> /// <returns></returns> public IEnumerable <IPlugin> Load(IAsyncTaskProgress asyn, params string[] pluginPaths) { if (!IsLoaded) { this.LoadPlugin(asyn, pluginPaths); this.IsLoaded = true; } return(this.Plugins); }
/// <summary> /// 获取文件系统 /// </summary> /// <param name="device"></param> /// <param name="iAsync"></param> /// <returns></returns> public FNodeX GetFileSystem(IFileSystemDevice device, SingleTaskReporterBase iAsync) { IAsync = iAsync; CreateFileServiceAbstractX(device, iAsync); if (fileServiceX == null) { return(null); } _systemTree = fileServiceX.GetFileSystem(); return(_systemTree); }
public override object Execute(object arg, IAsyncTaskProgress progress) { var context = GetContext(); if (context == null) { throw new System.Exception("Dont find context!"); } DataParsePluginInfo p = PluginInfo as DataParsePluginInfo; return(context?.Execute(p.ScriptObject, progress)); }
/// <summary> /// 构造函数 /// </summary> /// <param name="device">当前处理的设备</param> /// <param name="iAsyn">异步消息通知</param> protected FileServiceAbstractX(IFileSystemDevice device, IAsyncTaskProgress iAsyn) { Asyn = iAsyn; Device = device; if (AllFileNodeX == null) { AllFileNodeX = new List <FNodeX>(); } if (GetUserPartitionFiles == null) { GetUserPartitionFiles = new NodeCollection(); } }
protected override void Initialize(DataReportPluginArgument arg, IAsyncTaskProgress progress) { DataReportPluginInfo plugin = (DataReportPluginInfo)PluginInfo; if (plugin.Modules.Count == 0) { throw new Exception("Modules is null"); } _module = plugin.Modules.FirstOrDefault(m => m.Name == arg.ReportModuleName) ?? plugin.Modules[0]; //默认使用第一个模板 if (!Directory.Exists(arg.ReportPath)) { Directory.CreateDirectory(arg.ReportPath); } BaseUtility.Helper.FileHelper.CopyDirectory(_module.ZipTempDirectory, arg.ReportPath); //拷贝模板文件目录 }
public override object Execute(object arg, IAsyncTaskProgress progress) { var task = arg as SPFTask; DataParsePluginInfo p = PluginInfo as DataParsePluginInfo; var files = task.SourceFiles.Where(s => p.SourcePath.Any(k => k.Config == s.Config)); var str = string.Empty; if (files.IsValid()) { str = Serializer.JsonSerilize(files.Select(s => s.Local)); } var js = p.ScriptObject.Replace("$source", str); var obj = ExecuteJs(js, progress); return(null); }
protected override void LoadPlugin(IAsyncTaskProgress asyn, params string[] pluginPaths) { try { Plugins = new List <IPlugin>(); List <string> existList = new List <string>(); List <string> dirs = new List <string>(); dirs.Add(AppDomain.CurrentDomain.BaseDirectory); dirs.AddRange(pluginPaths); foreach (var dir in dirs) { var files = System.IO.Directory.GetFiles(dir, "XLY.SF.Project.Plugin.*.dll", System.IO.SearchOption.AllDirectories); foreach (var dllFile in files) { if (existList.Contains(System.IO.Path.GetFileName(dllFile))) { continue; } existList.Add(System.IO.Path.GetFileName(dllFile)); var ass = Assembly.LoadFile(dllFile); foreach (var cla in ass.GetTypes().Where(t => t.GetCustomAttribute <PluginAttribute>() != null && !t.IsAbstract && !t.IsInterface)) { var plu = ass.CreateInstance(cla.FullName) as IPlugin; if (null != plu && null != plu.PluginInfo) { if (Plugins.Any(p => p.PluginInfo.Guid == plu.PluginInfo.Guid)) { LoggerManagerSingle.Instance.Error($"C#插件加载出错!重复的Guid:{plu.PluginInfo.Guid}"); } else { Plugins.Add(plu); } } } } } } catch (Exception ex) { LoggerManagerSingle.Instance.Error(ex, "C#插件加载出错!"); } }