漏洞免费实战部分-安卓应用漏洞学习case6

admin 2023年2月1日19:46:44评论42 views字数 2441阅读8分8秒阅读模式

安卓应用漏洞学习case6

前期回顾

漏洞免费实战部分-安卓应用层getLastPathSegment函数问题

漏洞实战部分2-安卓应用ZipEntry对象问题实战

漏洞实战部分3-ContentProvider组件的openFile接口问题

漏洞学习之PWN-easyheap分析

漏洞学习之PWN-HITCON_CTF_2016:Secret Holder

漏洞学习之PWN-绿城杯uaf_pwn 分析

漏洞学习之PWN-ASIS_CTF_2016_b00ks

漏洞学习之PWN-lctf2016:pwn200 堆利用

安卓应用漏洞学习-Content Provider组件的自定义权限

漏洞免费实战部分-安卓应用漏洞学习case5

本课程学习Content Provider组件的call函数,实现调用服务端定义方法。


/**
* Call a provider-defined method. This can be used to implement
* interfaces that are cheaper and/or unnatural for a table-like
* model.
*
* WARNING: The framework does no permission checking
* on this entry into the content provider besides the basic ability for the application
* to get access to the provider at all. For example, it has no idea whether the call
* being executed may read or write data in the provider, so can't enforce those
* individual permissions. Any implementation of this method must
* do its own permission checks on incoming calls to make sure they are allowed.
*
* @param method method name to call. Opaque to framework, but should not be {@code null}.
* @param arg provider-defined String argument. May be {@code null}.
* @param extras provider-defined Bundle argument. May be {@code null}.
* @return provider-defined return value. May be {@code null}, which is also
* the default for providers which don't implement any call methods.
*/
@Override
public @Nullable Bundle call(@NonNull String authority, @NonNull String method,
@Nullable String arg, @Nullable Bundle extras) {
return call(method, arg, extras);
}

public @Nullable Bundle call(@NonNull String method, @Nullable String arg,
@Nullable Bundle extras) {
return null;
}

默认的实现是空函数直接返回null,可以重载call函数实现一些方法。注释中有个warning标注的解释,Android framework 不对call函数的调用进行权限检查,只能是开发者自己在call函数中实现权限检查。如果没有进行权限校验,那就可能出现越权调用的情况。

实战学习:

简单的学习下这个call函数实现和call函数调用。实现一个名为case6的应用,应用启动时创建一个名为case6.db的数据库并生成表名为table_data的数据表。表中有个两个字段_id(key键并且自增长)和’ _data ’(text字段并且不能为空)

漏洞免费实战部分-安卓应用漏洞学习case6

image1

配置信息如下:

<provider
android:name=".MyContentProvider"
android:authorities="com.study.case6"
android:enabled="true"
android:exported="true"/>

调用者需要通过authorities来使用case6的call函数。增删改查等其他函数与之前文章类似故不在重复。call函数的返回值为Bundle,我们实现bundle对象并传入call-1 字符串,当调用者调用call函数时 获得MyContentProvider组件传递的 ’call-1’字符串。

@Override
public Bundle call(@NonNull String method, @Nullable String arg, @Nullable Bundle extras) {

Bundle bundle = new Bundle();
bundle.putString(method,"call-1");
bundle.putBoolean(method,true);
return bundle;
}

实现调用者为poc6的应用,应用只有一个功能去调用case6中的call函数并获取到 ’call-1’字符串。代码如下:

漏洞免费实战部分-安卓应用漏洞学习case6

image2

使用getContentResolver().call() 接口实现调用,参数1为Uri 即case6中的authorities,参数2为自定义的方法名可以是任意值但不能为空,参数3是case6应用定义的字符串参数,可以为空,参数4是case6定义的Bundle参数,可以为空。poc6运行效果图如下:

漏洞免费实战部分-安卓应用漏洞学习case6

image3

漏洞免费实战部分-安卓应用漏洞学习case6

 

 

关注微信公众号或者可以直接加作者微信:

漏洞免费实战部分-安卓应用漏洞学习case6

 

 

 漏洞免费实战部分-安卓应用漏洞学习case6



原文始发于微信公众号(安全狗的自我修养):漏洞免费实战部分-安卓应用漏洞学习case6

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年2月1日19:46:44
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   漏洞免费实战部分-安卓应用漏洞学习case6http://cn-sec.com/archives/1532411.html

发表评论

匿名网友 填写信息