感觉宋哥可以出一套APP渗透测试教程 从小白到老鸟
点个
在看
破30,直接写个app端渗透测试教程 m0nst3r YYDS
涉及工具
•
JEB
•
DDMS
•
frida
•
frida-dexdump
•
burpy
过程
又是喜闻乐见的加密流量!搞它。
APP是加壳的,先上
frida-dexdump
脱壳。
这么多有
encrypt
关键字的,不好找,我们上
DDMS
:
通过
profilling
,我们很容易就能定位到加密函数:
上
JEB
,打开我们已经脱掉的
dex
文件:
恩,剩下的就是写脚本了。1. 为方便测试,我们使用burpy,这样就能直接在burpsuite上操作加密解密了。2. 为方便burpy调用加密和解密,需要把hook写成rpc的形式。
Talk is cheap, show me the code
import
frida
import
sys
import
os
import
json
class
Burpy:
def
__init__
(
self
):
device
=
self
._get_android_usb_device()
pid
=
device.spawn(
"xxxx"
)
self
.session
=
device.attach(pid)
device.resume(pid)
self
.rpc
=
self
._load_rpc()
def
_get_android_usb_device(
self
):
for
x
in
frida.get_device_manager().enumerate_devices():
if
"AOSP"
in
x.name:
return
x
def
_load_rpc(
self
):
with
open
(
"/run/media/m0nst3r/SSD/work/scripts/xxxx.js"
)
as
f:
myScript
=
self
.session.create_script(f.read())
myScript.load()
return
myScript.exports
def
decrypt(
self
,header,body):
body_json
=
json.loads(body)
if
body.startswith(
'{"request"'
):
data
=
body_json.get(
'request'
).get(
'body'
)
dec_data
=
self
.rpc.dec(data)
body_json.get(
'request'
).update({
"body"
:dec_data})
else
:
data
=
body_json.get(
'response'
)
dec_data
=
self
.rpc.dec(data)
body_json.update({
"response"
:dec_data})
body
=
json.dumps(body_json)
return
header,body
def
encrypt(
self
,header,body):
body_json
=
json.loads(body)
data
=
body_json.get(
'request'
).get(
'body'
)
enc_data
=
self
.rpc.enc(data)
body_json.get(
'request'
).update({
"body"
:enc_data})
body
=
json.dumps(body_json)
return
header,body
上面是burpy脚本,主要提供frida脚本的加载和加解密功能函数,主要实现在下面的frida hook的js代码中:
setTimeout
(()
=>
{
rpc
.
exports
=
{
dec
:
function
(data) {
let
res
=
null
Java
.
perform
(()
=>
{
let
instance
=
null
Java
.
choose
(
"xxxx.SecurityManager"
,
{
onMatch
:
function
(x) {
console
.
log
(
"GetAESKey"
,
x
.
getAesKey
())
instance
=
x
}
,
onComplete
:
function
(x) {}
})
res
=
instance
.
decypt
(data)
})
return
res
}
,
enc
:
function
(data) {