okhttp

mac使用frida

烈酒焚心 提交于 2021-01-07 06:57:54
mac使用frida 安装 https://github.com/frida/frida/releases 根据手机的cpu的版本,选择相应的文件,一般通过手机信息可以看到 我这里是frida-server-12.6.7-android-arm64.xz 解压frida-server-12.6.7-android-arm64.xz,然后把解压后的文件重命名frida-server 后来我使用genymotion,查看系统为x86。 所以下载了frida-server-12.7.5-android-x86.xz文件,然后解压并重命名为frida-server。 执行命令frida-server。 依次执行下面命令 $ adb push frida-server /data/local/tmp/ $ adb shell "chmod 755 /data/local/tmp/frida-server" $ adb shell "/data/local/tmp/frida-server &" 然后在电脑上测试手机是否连通 $ adb devices -l Frida大致原理是手机端安装一个server程序,然后把手机端的端口转到PC端,PC端写python脚本进行通信,而python脚本中需要hook的代码采用javascript语言。所以这么看来我们首先需要安装开始安装frida了

How to get async call to return response to main thread, using okhttp?

喜夏-厌秋 提交于 2021-01-05 07:26:05
问题 I'm trying to make a program for Android, and I'm using okhttp for json-calls. I really want to return my response to the outside of the thread I'm creating. I need to create the thread for an async call otherwise I'll get a NetworkOnMainThreadException. Problem is that I can't seem to get my response string outside the "onResponse" method, even though my responseString is a global variable in the class. Since it's async, the thread won't run in time to get my value in the global variable

Android Okhttp 拦截器中加密 请求体 (DES加密解密)

馋奶兔 提交于 2021-01-02 11:07:08
最近公司为了项目安全 使用了https 所有接口要使用DES 加密 加密 RequestBody 的value值 心想 这不是很简单吗 直接在拦截器中获取到要上传的数据 然后加密 重新赋值 很简单嘛 但是实践起来 我真的气的想要骂娘 太坑了好吗。。。。无语直接就打到我的脸上 废话不多说 让我重温一下这些坑 第一步 在网络请求类里添加拦截器 在拦截器里对上传的数据进行操作 如果是post 请求 取出来request.body(); 循环 取出 encodedValue 加密后 重新再 addEncoded 添加进去 这里要注意 URLDecoder的解码 如果是get请求 先拿到 request.url() 然后再看这个url中包含不包含请求参数 url.encodedQuery() 如果这个不为空的话 就是接下来字符串截取->修改加密->重新拼接 然后进行网络请求 然后解密 ----> 和后台商量后 后台返回的数据只对 “data” 字段的value进行了加密 好 那我只对“data” 进行解密就好了 获取到 response 对返回的json进行解析 因为后台对“data”进行加密 无疑 data是String类型的 解析解密后 怎么将解密后的data重新安装到json中呢 ? 解密后的data是String类型的 但是原本想要表达的 “data” 该是什么类型呢 不知道什么类型

How to trust SSL certificates with cross-signed root expired on android <= 5

…衆ロ難τιáo~ 提交于 2020-12-31 13:55:34
问题 I work for a company that uses a Comodo/Sectigo SSL certificate. But suddenly our app started throwing this error when sending POST to the server, in versions with android 4 and 5, with Okhttp client. HTTP FAILED: javax.net.ssl.SSLHandshakeException: com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: Certificate expired at Sat May 30 05:48:38 CDT 2020 (compared to Mon Jun 08 23:13:02 CDT 2020) I tried many StackOverflow solutions, without

How to trust SSL certificates with cross-signed root expired on android <= 5

十年热恋 提交于 2020-12-31 13:47:33
问题 I work for a company that uses a Comodo/Sectigo SSL certificate. But suddenly our app started throwing this error when sending POST to the server, in versions with android 4 and 5, with Okhttp client. HTTP FAILED: javax.net.ssl.SSLHandshakeException: com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: Certificate expired at Sat May 30 05:48:38 CDT 2020 (compared to Mon Jun 08 23:13:02 CDT 2020) I tried many StackOverflow solutions, without

How to trust SSL certificates with cross-signed root expired on android <= 5

杀马特。学长 韩版系。学妹 提交于 2020-12-31 13:46:33
问题 I work for a company that uses a Comodo/Sectigo SSL certificate. But suddenly our app started throwing this error when sending POST to the server, in versions with android 4 and 5, with Okhttp client. HTTP FAILED: javax.net.ssl.SSLHandshakeException: com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate: Certificate expired at Sat May 30 05:48:38 CDT 2020 (compared to Mon Jun 08 23:13:02 CDT 2020) I tried many StackOverflow solutions, without

Okhttp解析—Okhttp概览

血红的双手。 提交于 2020-12-31 12:04:33
Okhttp解析—Okhttp概览 Okhttp作为目前Android使用最为广泛的网络框架之一,我们有必要去深入了解一下,本文是Okhttp解析的第一篇,主要是从宏观上认识Okhttp整个架构是如何实现的。 一、什么是Okhttp HTTP是当今应用程序通过网络交换数据和媒体的方式。 有效地使用 HTTP 可以使应用加载得更快并节省带宽。 Okhttp是一个高效的HTTP Client,高效性体现在: Http / 2支持允许对同一主机的所有请求共享一个套接字 连接池减少了请求延迟 透明 GZIP 缩小了下载大小 对于重复请求,响应缓存可以完全避免网络请求 当网络出现问题时,OkHttp 不会立即结束: 它会默默地从常见的连接问题中恢复过来。 如果您的服务有多个 IP 地址,如果第一次连接失败,OkHttp 将尝试替代地址。 这对于 IPv4 + IPv6和承载于冗余数据中心的服务是必要的。 Okhttp 支持现代 TLS 特性(TLS 1.3、 ALPN、证书ping)。 它可以配置为回退到可用的连接。 并且Okhttp是易用的,其通过Builder模式设计请求 / 响应 API,支持同步阻塞调用和带回调的异步调用。 二、Okhttp的请求机制以及相关概念 首先我们来了解下HTTP client、request、response。 HTTP

CertPathValidatorException connecting to a Let's Encrypt host on Android M or earlier

情到浓时终转凉″ 提交于 2020-12-24 15:45:28
问题 [edit: If you are here for Let's Encrypt expiry event from January 2021, read this first https://letsencrypt.org/2020/12/21/extending-android-compatibility.html] Connecting to https://valid-isrgrootx1.letsencrypt.org/ via OkHttp on Android M or earlier fails, while the connection works on N or later. OkHttpClient client = new OkHttpClient(); try { Request request = new Request.Builder() .url("https://valid-isrgrootx1.letsencrypt.org/robots.txt") .build(); try (Response response = client

HTTP 请求/响应报文结构

做~自己de王妃 提交于 2020-12-18 03:26:14
请求报文和响应报文都是由以下4部分组成: 1.请求行/响应行 2.请求头/响应头 3.空行 4.消息主体(请求体/响应体) 请求报文结构 请求行 格式为:Method Request-URI HTTP-Version 结尾符 结尾符一般用\r\n 根据HTTP标准,HTTP请求可以使用多种请求方法。 序号 方法 描述 1 GET 请求指定的页面信息,并返回实体主体。 2 HEAD 类似于get请求,只不过返回的响应中没有具体的内容,用于获取报头 3 POST 向指定资源提交数据进行处理请求(例如提交表单或者上传文件)。数据被包含在请求主体中。POST请求可能会导致新的资源的建立和/或已有资源的修改。 4 PUT 从客户端向服务器传送的数据取代指定的文档的内容。 5 DELETE 请求服务器删除指定的页面。 6 CONNECT HTTP/1.1协议中预留给能够将连接改为管道方式的代理服务器。 7 OPTIONS 允许客户端查看服务器的性能。 8 TRACE 回显服务器收到的请求,主要用于测试或诊断。 请求头 通用头: 既可以出现在请求报头,也可以出现在响应报头中 Date:表示消息产生的日期和时间 Connection:允许发送指定连接的选项,例如指定连接是连续的,或者指定“close”选项,通知服务器,在响应完成后,关闭连接 Cache-Control:用于指定缓存指令

Android how to post InputStream by chunks using okhttp

随声附和 提交于 2020-12-13 03:40:49
问题 I have an issue with FileInputStream on Android with Kotlin and Okhttp. I want to post a video file by using an API, but if this file is bigger than 128mb I have to upload it chunk by chunk. So, in my request header I have to specified the Content-Range (Something like this: Content-Range bytes 0-10485759/189305151 ) And I need to post only this part of the file, that why I'm using FileInputStream, then repeat for each chunks. I'm also using FileInputStream to avoid to split the file locally