众所周知,360加固仅对Activity的onCreate函数进行了vmp加强保护,但一般我们的核心代码都不在该函数里,这样就起不到应有的保护作用了,那怎样才能把核心代码放到onCreate里呢?
首先分析,360加固识别onCreate规则,一个继承Activity的类,并且该类下实现了Activity的onCreate函数,并在AndroidManifest.xml里注册该activity
但是这样的实现IDE会提示,无法通过编译
直接加个注解即可,让它不提示
360成功加固了该onCreate函数
然后是调用,一般常规的调用就是startActivity->进入系统代码->然后由系统实例化Activity->最后调用app里实现的onCreate函数,但其实app也可以自己实例化该activity,直接new Request()
即可,但该实例化不要放在子线程里,否则会报
activity对象实例化后,就可以去调onCreate函数了,这里调用onCreate函数就没有线程限制了,任意线程都可以调用
这样就实现在任意线程主动调用onCreate函数了,虽然onCreate没有返回值,但是有Bundle参数,直接把返回值放在Bundle参数里即可
比如核心代码是一个网络请求
由于android系统限制,网络请求需要放在子线程里
这样就实现了核心代码的vmp保护
不过这样使用起来肯定是不太方便的,比如函数参数和返回值的处理,为此笔者优化了下代码,封装了一个库: VMP361
使用时,直接继承其中的VMP361.Method类,把要保护的核心代码放入onCreate方法,然后在 AndroidManifest.xml 里注册即可
其中super.onCreate(args)调用父类的onCreate,参数交给父类解析,然后就可以用getArg(0)可以获取对应索引的参数,返回值为泛型,可以自动转换类型,result(result)将处理后的结果返回
接下来就可以调用了
一行代码搞定:
将要想保护的函数或类加上注解,比如
然后通过AS插件,自动化提取被注解的函数的代码,放到一个以<类名>+<函数名>命名的Activity里的onCreate方法里,并将该Activity注册到AndroidManifest.xml里,最后再通过上面说的一行代码调用即可
当然,这只是一种最简单的函数,实际函数可能要复杂的多,比如涉及外部变量和函数调用等等
不过不确定360加固保护onCreate的个数有没有限制,有知道的大佬可以评论区说下
声明:转载请注明出处,原帖地址:kanxue & shlu's note
public
class
Request
extends
Activity {
protected
void
onCreate(Bundle savedInstanceState) {
}
}
public
class
Request
extends
Activity {
protected
void
onCreate(Bundle savedInstanceState) {
}
}
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
manifest
xmlns:android
=
"ed7K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4y4U0K9r3g2E0j5i4y4Q4x3X3g2S2L8X3c8J5L8$3W2V1i4K6u0W2j5$3!0E0i4K6u0r3j5i4m8C8i4K6u0r3M7X3g2K6i4K6u0r3j5h3&6V1M7X3!0A6k6l9`.`."
xmlns:tools
=
"fa5K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4y4U0K9r3g2E0j5i4y4Q4x3X3g2S2L8X3c8J5L8$3W2V1i4K6u0W2j5$3!0E0i4K6u0r3N6r3!0G2L8s2x3`."
>
<
application
>
<
activity
android:name
=
"xxx.xxxx.Request"
/>
</
application
>
</
manifest
>
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
manifest
xmlns:android
=
"ed7K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4y4U0K9r3g2E0j5i4y4Q4x3X3g2S2L8X3c8J5L8$3W2V1i4K6u0W2j5$3!0E0i4K6u0r3j5i4m8C8i4K6u0r3M7X3g2K6i4K6u0r3j5h3&6V1M7X3!0A6k6l9`.`."
xmlns:tools
=
"fa5K9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4y4U0K9r3g2E0j5i4y4Q4x3X3g2S2L8X3c8J5L8$3W2V1i4K6u0W2j5$3!0E0i4K6u0r3N6r3!0G2L8s2x3`."
>
<
application
>
<
activity
android:name
=
"xxx.xxxx.Request"
/>
</
application
>
</
manifest
>
Overriding method should call
super
.onCreate
Overriding method should call
super
.onCreate
public
class
Request
extends
Activity {
@SuppressLint
(
"MissingSuperCall"
)
protected
void
onCreate(Bundle savedInstanceState) {
}
}
public
class
Request
extends
Activity {
@SuppressLint
(
"MissingSuperCall"
)
protected
void
onCreate(Bundle savedInstanceState) {
}
}
public
class
Request
extends
Activity {
@SuppressLint
(
"MissingSuperCall"
)
protected
void
onCreate(Bundle savedInstanceState) {
String urlString =
"b89K9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6F1L8%4c8W2i4K6u0W2M7$3S2D9N6g2)9J5k6h3k6&6K9b7`.`."
;
StringBuilder result =
new
StringBuilder();
HttpsURLConnection urlConnection =
null
;
try
{
URL url =
new
URL(urlString);
urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setRequestMethod(
"GET"
);
urlConnection.setConnectTimeout(
10000
);
urlConnection.setReadTimeout(
10000
);
int
responseCode = urlConnection.getResponseCode();
if
(responseCode == HttpsURLConnection.HTTP_OK) {
InputStream in = urlConnection.getInputStream();
BufferedReader reader =
new
BufferedReader(
new
InputStreamReader(in));
String line;
while
((line = reader.readLine()) !=
null
) {
result.append(line);
}
reader.close();
in.close();
}
else
{
result.append(
"响应码:"
).append(responseCode);
}
}
catch
(Exception e) {
e.printStackTrace();
result.append(
"异常:"
).append(e.getMessage());
}
finally
{
if
(urlConnection !=
null
) {
urlConnection.disconnect();
}
}
System.out.println(result);
}
}
public
class
Request
extends
Activity {
@SuppressLint
(
"MissingSuperCall"
)
protected
void
onCreate(Bundle savedInstanceState) {
String urlString =
"b89K9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6F1L8%4c8W2i4K6u0W2M7$3S2D9N6g2)9J5k6h3k6&6K9b7`.`."
;
StringBuilder result =
new
StringBuilder();
HttpsURLConnection urlConnection =
null
;
try
{
URL url =
new
URL(urlString);
urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setRequestMethod(
"GET"
);
urlConnection.setConnectTimeout(
10000
);
urlConnection.setReadTimeout(
10000
);
int
responseCode = urlConnection.getResponseCode();
if
(responseCode == HttpsURLConnection.HTTP_OK) {
InputStream in = urlConnection.getInputStream();
BufferedReader reader =
new
BufferedReader(
new
InputStreamReader(in));
String line;
while
((line = reader.readLine()) !=
null
) {
result.append(line);
}
reader.close();
in.close();
}
else
{
result.append(
"响应码:"
).append(responseCode);
}
}
catch
(Exception e) {
e.printStackTrace();
result.append(
"异常:"
).append(e.getMessage());
}
finally
{
if
(urlConnection !=
null
) {
urlConnection.disconnect();
}
}
System.out.println(result);
}
}
public
class
Main
extends
Activity {
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button request= findViewById(R.id.request);
Request requestObj=
new
Request();
request.setOnClickListener(v->{
new
Thread(()->requestObj.onCreate(
null
)).start();
});
}
}
public
class
Main
extends
Activity {
@Override
protected
void
onCreate(Bundle savedInstanceState) {
super
.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button request= findViewById(R.id.request);
Request requestObj=
new
Request();
request.setOnClickListener(v->{
new
Thread(()->requestObj.onCreate(
null
)).start();
});
}
}
public
class
Request
extends
VMP361.Method {
@Override
protected
void
onCreate(Bundle args) {
super
.onCreate(args);
String urlString =
"bedK9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6F1L8%4c8W2i4K6u0W2M7$3S2D9N6g2)9J5k6h3k6&6K9g2)9K6c8X3q4J5k6K6m8Q4x3@1b7`."
+getArg(
0
);//获取参数
StringBuilder result =
new
StringBuilder();
HttpsURLConnection urlConnection =
null
;
try
{
URL url =
new
URL(urlString);
urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setRequestMethod(
"GET"
);
urlConnection.setConnectTimeout(
10000
);
urlConnection.setReadTimeout(
10000
);
int
responseCode = urlConnection.getResponseCode();
if
(responseCode == HttpsURLConnection.HTTP_OK) {
InputStream in = urlConnection.getInputStream();
BufferedReader reader =
new
BufferedReader(
new
InputStreamReader(in));
String line;
while
((line = reader.readLine()) !=
null
) {
result.append(line);
}
reader.close();
in.close();
}
else
{
result.append(
"响应码:"
).append(responseCode);
}
}
catch
(Exception e) {
e.printStackTrace();
result.append(
"异常:"
).append(e.getMessage());
}
finally
{
if
(urlConnection !=
null
) {
urlConnection.disconnect();
}
}
result(result);
}
}
public
class
Request
extends
VMP361.Method {
最后于 2小时前
被逆向涉猎编辑
,原因: