首页 \ 问答 \ 设计Bash脚本以删除恶意软件(Designing a Bash Script to Remove Malware)

设计Bash脚本以删除恶意软件(Designing a Bash Script to Remove Malware)

我在大学的技术台工作。 人们总是在他们的macbook上加入大量恶意软件(我以为mac不能得病毒?)。 通常的过程是删除不良应用程序并对系统/库文件进行排序,以查找相关的plist或其他不良内容。 这个过程可能需要很长时间,所以我想我会尝试创建一个自动删除文件的脚本。 我对bash并不是很熟悉,但它会像这样。

问题是定义一个任意变量,不知道如何做到这一点。

#!/bin/bash
TR = malware_quary
sudo find / -name malware_quary |
while read filename
do
    if(malware_quary = "*mackeeper*")
        read -p "Are you sure you want to remove " +malware_quary+"? " -n 1 -r
        echo
        if [[ ! $REPLY =~ ^[Yy]$ ]]
        then
            cat malware_quary < ~/Desktop/log.txt
        rm malware_quary
        fi
done

我将继续添加各种其他恶意软件(即管道,genieo等)的条件,直到我构建了一个扩展的日志文件,我可以在其中运行所有结果。


I work at a tech desk for my university. People are always coming in with globs of malware on their macbooks (I thought mac's couldn't get virus'?). The usual process is removing the bad applications and sorting through the system/library files to find associated plists or additional bad stuff. This process can take a hell of a long time so I thought I would try and create an automated script for removing files. I'm not super familiar with bash, but it would go something like this.

The issue is defining an arbitrary variable, not sure how to do this.

#!/bin/bash
TR = malware_quary
sudo find / -name malware_quary |
while read filename
do
    if(malware_quary = "*mackeeper*")
        read -p "Are you sure you want to remove " +malware_quary+"? " -n 1 -r
        echo
        if [[ ! $REPLY =~ ^[Yy]$ ]]
        then
            cat malware_quary < ~/Desktop/log.txt
        rm malware_quary
        fi
done

I will continue to add if conditions for various other malware (ie conduit, genieo, etc..) until I have built an extensive log file where I can just run all the results against it.


原文:https://stackoverflow.com/questions/26852666
更新时间:2023-11-14 15:11

最满意答案

  1. 这条生产线究竟如何运作? 为什么参数解包允许该函数为可变参数模板中的每个参数执行?

参数包扩展是一些涉及参数包的模式,后跟...

所以expr(T)...是一个以expr(T)为模式的包扩展,它扩展为expr(T0), expr(T1), expr(T2), ..., expr(TN)参数包中的Ti

包扩展只能在某些上下文中使用,例如参数列表或初始化列表,因此在这种情况下,每个子表达式的结果用于形成数组int _[]的初始化列表。 该数组未使用且仅存在,因此其初始化程序可用作进行包扩展的上下文。 每个子表达式都是这样的形式(SubscribeToType<Ti>(blah, blah), 0)这意味着函数调用的结果被丢弃,表达式的值为0.这是一个允许包装的一点点扩展以生成包含N个整数的braced-init-list,因为这是初始化数组所需要的。

  1. 我非常肯定这条线可以用lambda代替。 你怎么能用lambda表达式替换该行?

你为什么想要?

它可以,但你需要在lambda中进行非常类似的包扩展,所以它不会简化任何事情。


  1. How, exactly, does the line work? How come parameter unpacking is allowing that function to execute for each parameter in the variadic template?

A parameter pack expansion is some pattern involving a parameter pack followed by ...

So expr(T)... is a pack expansion with expr(T) as its pattern, and it expands to expr(T0), expr(T1), expr(T2), ..., expr(TN) for each Ti in the parameter pack.

A pack expansion can only be used in certain contexts, such as argument lists, or initializer lists, so in this case the results of each sub-expression is being used to form an initializer list for the array int _[]. The array is unused and only exists so that its initializer can be used as the context in which to do the pack expansion. Each sub-expression is of the form (SubscribeToType<Ti>(blah, blah), 0) which means the result of the function call is discarded and the expression has the value 0. This is a bit of a kluge to allow the pack expansion to produce a braced-init-list containing N integers, because that's what's needed to initialize the array.

  1. I am very certain this line could be replaced by a lambda. How could you replace the line with a lambda expression?

Why would you want to?

It could, but you'd need a very similar pack expansion in the lambda, so it wouldn't simplify anything.

相关问答

更多
  • 如果您想将参数封装到any ,您可以使用以下设置。 我也让any类更有用,尽管它在技术上并不是any课程。 #include #include struct any { enum type {Int, Float, String}; any(int e) { m_data.INT = e; m_type = Int;} any(float e) { m_data.FLOAT = e; m_type = Float;} any(char* ...
  • 我不明白为什么func(f); 给我一个编译错误 编译器不知道你想让Params 精确到 double ,它认为也许你想要它推出一个包含更多元素的包,比如double, int, void*, char或者double, double, double或者其他包类型,并且它不知道如何从参数f推论出来。 从理论上讲, std::function可以有其他专门的std::function ,它可以从f构造出来,并且可以让编译器为Params推导出一个不止一种类型的包(它不能在没有实例化 ...
  • 它用g ++ 4.7.2和clang ++ 3.2编译好。 这可能是一个编译器错误。 似乎vc11没有正确实现扩展包。 It compiles fine with g++ 4.7.2 and clang++ 3.2. It is probably a compiler bug. It seems that vc11 doesn't implement expanding packs properly.
  • (重复我对OP的评论。) line instate force = &Self::memberMethod;的实际问题instate force = &Self::memberMethod; 是一个缺少template关键字: instate force = &Self::template memberMethod; 请参阅,例如,我必须在何处以及为何要使用“模板”和“typename”关键字? 实际上,这里不需要显式模板参数[ ...
  • 这条生产线究竟如何运作? 为什么参数解包允许该函数为可变参数模板中的每个参数执行? 参数包扩展是一些涉及参数包的模式,后跟... 所以expr(T)...是一个以expr(T)为模式的包扩展,它扩展为expr(T0), expr(T1), expr(T2), ..., expr(TN)参数包中的Ti 。 包扩展只能在某些上下文中使用,例如参数列表或初始化列表,因此在这种情况下,每个子表达式的结果用于形成数组int _[]的初始化列表。 该数组未使用且仅存在,因此其初始化程序可用作进行包扩展的上下文。 每个子 ...
  • 要添加到以前的答案,您还需要有一个方便的语法来调用permutefun ,但是当前的模板参数 template 不方便,因为你必须打电话 permutefun (ar); 解决方案是通过两个步骤推导出参数: #include template struct Sequence {}; template
  • 这不是参数包扩展的有效位置。 C ++标准草案部分介绍了包扩展的有效上下文14.5.3 变量模板 ,其中说: 一个包扩展由一个模式和一个省略号组成,其实例在列表中产生零或多个模式实例(如下所述)。 模式的形式取决于扩展发生的环境。 Pack扩展可以在以下上下文中发生: - 在功能参数包(8.3.5)中; 该模式是没有省略号的参数声明。 - 在包扩展模板参数包(14.1)中: - 如果模板参数包是参数声明; 该模式是没有省略号的参数声明; - 如果模板参数包是带有模板参数列表的类型参数; 该模式是没有省略号的 ...
  • 如果你可以基于N自动生成,我想你可以编写代码来做你一般需要的东西(你试图用variadics的评论会强化这一点)。 事实上,你的函数也是模板化的,不幸的是,事情比我想要的要复杂得多。 有比我要给出的更简单的解决方案,但是我看到的唯一的解决方案要求您明确指定类型,或者延迟检查可以在编译时完成的运行时。 就目前而言,我能看到做你想做的事情的唯一方法就是使用可变参数模板。 这得到了你想要的大部分: template class System { template
  • 这是因为当你将ostream传递给另一个模板时,它需要一个基本转换为ostream ,而当你将它传递给转发write(std::cout, ...)的模板write(std::cout, ...)时,它不需要任何转换。 因此,如果您传递ostringstream ,它会选择更通用的模板,该模板将ostringstream转发为参数以输出到更具体的模板。 输出ostringstream将其转换为void* ,然后打印。 你可以用is_base_of解决这个is_base_of (对我来说比使用is_conve ...
  • 最后的迭代将调用foo<>() 。 它与double foo() { … }不匹配,因为它不是模板函数。 你无法修复它 template double foo() { return 0; } 因为T不能推断出来。 但是您可以为T提供默认值,以便foo<>()变为有效: template // <--- double foo() { return 0; } The final iteration will call fo ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)