第二代Java代码混淆器Allatori Java obfuscator教程:字段标签和方法标签

Allatori Java obfuscator是第二代Java代码混淆器,为您的知识产权提供全方位的保护。Allatori除了保护功能之外,还附加了一系列的功能,几乎可以抵御一切的代码攻击。同时,Allatori可以让您的程序体积更小,速度更快,效果简直让人难以置信。

在线订购   试用下载

字段标签

字段标签用于匹配字段。如果字段标签嵌套在类标签中,则它仅应用于与父类标签匹配的类。如果父标记是keep-names,那么它将应用于所有类。字段标签具有以下属性:

属性
访问 需要*。设置匹配规则。
模板 需要*。设置匹配规则。其格式如下所述。

 *必须具有访问权限或模板属性。

字段标签的模板属性具有以下格式:

[@annotation] [modifiers] [type] fieldname [instanceof classname]

字段或类型名称中的“*”符 可匹配任意数量的字符。如果名称以“regex:”开头,则将其视为标准正则表达式。 

例子:

描述
* 匹配所有字段。
private * 匹配所有私有字段。
private+ * 匹配所有字段。
protected+ * 匹配所有受保护的字段和公共字段。
static * 匹配所有静态字段。
public static * 匹配所有公共静态字段。
public int * 匹配所有公共整数字段。
java.lang.String * 匹配所有字符串字段。
java.lang.* * 将所有字段与类型匹配的java.lang包匹配。
abc* 匹配名称以“abc”开头的所有字段。
private abc* 匹配名称以“abc”开头的所有私有字段。
* instanceof java.io.Serializable 匹配所有可序列化的字段。
@java.lang.Deprecated * 匹配所有不推荐使用的字段。
regex:(a|b).* 匹配名称以“a”或“b”开头的所有字段。

方法标签

该方法标签用于匹配的方法。如果方法标签嵌套在类标签中,则它仅应用于与父类标签匹配的类。如果父标记是keep-names,那么它将应用于所有类。该方法的标签具有以下属性:

属性
访问 需要*。设置匹配规则。
模板 需要*。设置匹配规则。其格式如下所述。
参数 可选的。如果设置为“keep”,则方法参数的名称将不会更改。对于公共API方法很有用。

 *必须具有访问权限或模板属性。

方法标签的模板属性具有以下格式:

[@annotation] [modifiers] [type] methodname(arguments)

方法或类型名称中的“*”符 可匹配任意数量的字符。参数中的“*”符 与任何单个参数匹配。使用“**”来匹配任意数量的参数。如果名称以“regex:”开头,则将其视为标准正则表达式。 

例子:

描述
*(**) 匹配所有方法。
private *(**) 匹配所有私有方法。
private+ *(**) 匹配所有方法。
protected+ *(**) 匹配所有受保护的方法和公共方法。
private+ *(*) 将所有方法与一个参数完全匹配。
private+ *(*,*) 用正好两个参数匹配所有方法。
private+ *(java.lang.String) 与所有方法完全匹配一个String类型的参数。
private+ *(java.lang.String,**) 匹配所有以String作为第一个参数的方法。
private+ *(java.lang.*) 仅使用java.lang包中的一个参数来匹配所有方法。
public get*(**) 匹配所有以“get”开头的公共方法。
public *abc*(**) 匹配名称包含“abc”的所有公共方法。
private+ int *(**) 匹配所有具有int返回类型的方法。
@java.lang.Deprecated *(**) 匹配所有不推荐使用的方法。
public regex:(g|s)et.*(**) 匹配所有公共的getter和setter方法。

例子:

    <keep-names>        <!-- Stops applying further rules to classes in the com.company.abc package,             therefore all classes, methods and fields in this package will be renamed -->        <class template="class com.company.abc.*" stop="true"/>        <!-- Further rules instruct Allatori not to rename matched elements -->        <!-- Matches classes with the name "Main" in any package -->        <class template="class *.Main"/>        <!-- Matches classes with the name ending with "Bean" -->        <class template="class *Bean">            <!-- Matches all fields -->            <field access="private+"/>            <!-- Matches public integer fields -->            <field template="public int *"/>            <!-- Matches all static fields -->            <field template="static *"/>            <!-- Matches protected and public String fields -->            <field template="protected+ java.lang.String *"/>            <!-- Matches all methods -->            <method template="private+ *(**)"/>            <!-- Matches all getter methods -->            <method template="private+ get*(**)"/>            <!-- Matches all methods with String argument,                 parameter names of these methods will not be changed -->            <method template="private+ *(java.lang.String)" parameters="keep"/>        </class>        <!-- Matches serialization members -->        <class template="class * instanceof java.io.Serializable">            <field template="static final long serialVersionUID"/>            <method template="void writeObject(java.io.ObjectOutputStream)"/>            <method template="void readObject(java.io.ObjectInputStream)"/>            <method template="java.lang.Object writeReplace()"/>            <method template="java.lang.Object readResolve()"/>        </class>        <!-- Matches applets -->        <class template="class * instanceof java.applet.Applet"/>        <!-- Matches servlets -->        <class template="class * instanceof javax.servlet.Servlet"/>        <!-- Matches midlets -->        <class template="class * instanceof javax.microedition.midlet.MIDlet"/>    </keep-names>

本教程内容到这里就完结了,希望文章内容对您有所帮助~感兴趣的朋友可以下载Allatori Java obfuscator试用一下哦~


想要购买该产品的请点击“在线订购”,了解更多产品信息请点击“咨询在线客服

标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年8月27日
下一篇 2019年8月27日

相关推荐

发表回复

登录后才能评论