Skip to content

Commit 67d628e

Browse files
authored
Optimize the document of Quark Script CWE-312
1 parent 2bb149e commit 67d628e

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

CWE-312/README.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
# Detect CWE-312 in Android Application
22

3+
This scenario seeks to find **cleartext storage of sensitive data** in the APK file.
34

4-
This scenario seeks to find **cleartext storage of sensitive data** in
5-
the APK file.
6-
7-
## CWE-312 Cleartext Storage of Sensitive Information
5+
## CWE-312: Cleartext Storage of Sensitive Information
86

97
We analyze the definition of CWE-312 and identify its characteristics.
108

11-
See [CWE-312](https://cwe.mitre.org/data/definitions/312.html) for more
12-
details.
9+
See [CWE-312](https://cwe.mitre.org/data/definitions/312.html) for more details.
1310

14-
![image](https://i.imgur.com/cy2EiZx.jpg)
11+
![image](https://imgur.com/mD2uXUy.jpg)
1512

1613
## Code of CWE-312 in ovaa.apk
1714

18-
We use the [ovaa.apk](https://github.com/oversecured/ovaa) sample to
19-
explain the vulnerability code of CWE-312.
15+
We use the [ovaa.apk](https://github.com/oversecured/ovaa) sample to explain the vulnerability code of CWE-312.
16+
17+
![image](https://imgur.com/MfnYIYy.jpg)
18+
19+
## CWE-312 Detection Process Using Quark Script API
20+
21+
Let’s use the above APIs to show how the Quark script finds this vulnerability.
2022

21-
![image](https://i.imgur.com/KsFsxTu.jpg)
23+
We have designed a [Frida](https://frida.re/) script ``agent.js`` to hook a specified method and get the arguments when the method is called. It can be found in [quark-engine/quark/script/frida](https://github.com/quark-engine/quark-engine/tree/master/quark/script/frida).
24+
25+
To begin with, we hook the method ``putString`` to catch its arguments. Then, we check if sensitive information like email or password is passed. Finally, we use ``checkClearText`` imported from [Ares](https://github.com/bee-san/Ares) to check if the arguments are cleartext. If both **YES**, CWE-312 vulnerability might be caused.
2226

23-
## Quark Script CWE-312.py
27+
![image](https://imgur.com/eNjm3ES.jpg)
2428

25-
Let\'s use the above APIs to show how the Quark script finds this
26-
vulnerability.
29+
## Quark Script: CWE-312.py
2730

28-
First, we designed a [Frida](https://frida.re) script `agent.js` to hook
29-
the target method and get the arguments when the target method is
30-
called. Then we hook the method `putString` to catch its arguments.
31-
Finally, we use [Ares](https://github.com/bee-san/Ares) to check if
32-
the arguments are encrypted.
31+
![image](https://imgur.com/rxMPZX8.jpg)
3332

34-
``` python
33+
```python
3534
from quark.script.frida import runFridaHook
3635
from quark.script.ares import checkClearText
3736

@@ -62,7 +61,7 @@ for putString in fridaResult.behaviorOccurList:
6261

6362
## Frida Script: agent.js
6463

65-
``` javascript
64+
```javascript
6665
// -*- coding: utf-8 -*-
6766
// This file is part of Quark-Engine - https://github.com/quark-engine/quark-engine
6867
// See the file 'LICENSE' for copying permission.
@@ -125,7 +124,7 @@ rpc.exports["watchMethodCall"] = (classAndMethodName, methodParamTypes) => watch
125124

126125
## Quark Script Result
127126

128-
``` TEXT
127+
```TEXT
129128
$ python3 CWE-312.py
130129
The CWE-312 vulnerability is found. The cleartext is "[email protected]"
131130
The CWE-312 vulnerability is found. The cleartext is "password"

0 commit comments

Comments
 (0)