You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CWE-798/README.md
+22-22Lines changed: 22 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,36 +1,35 @@
1
1
# Detect CWE-798 in Android Application
2
2
3
-
This scenario seeks to find hard-coded credentials in the APK file.
3
+
This scenario seeks to find **hard-coded credentials** in the APK file.
4
4
5
-
## CWE-798 Use of Hard-coded Credentials
5
+
## CWE-798: Use of Hard-coded Credentials
6
6
7
7
We analyze the definition of CWE-798 and identify its characteristics.
8
8
9
-
See [CWE-798](https://cwe.mitre.org/data/definitions/798.html) for more
10
-
details.
9
+
See [CWE-798](https://cwe.mitre.org/data/definitions/798.html) for more details.
11
10
12
-

11
+

13
12
14
13
## Code of CWE-798 in ovaa.apk
15
14
16
-
We use the [ovaa.apk](https://github.com/oversecured/ovaa) sample to
17
-
explain the vulnerability code of CWE-798.
15
+
We use the [ovaa.apk](https://github.com/oversecured/ovaa) sample to explain the vulnerability code of CWE-798.
18
16
19
-

17
+

20
18
21
-
## Quark Script: CWE-798.py
22
19
23
-
Let\'s use the above APIs to show how the Quark script finds this
24
-
vulnerability.
20
+
## CWE-798 Detection Process Using Quark Script API
21
+
22
+

23
+
24
+
Let’s use the above APIs to show how the Quark script finds this vulnerability.
25
+
26
+
First, we design a detection rule ``findSecretKeySpec.json`` to spot on behavior using the constructor ``SecretKeySpec``. Second, we get all the parameter values from this constructor. Then, we parse the AES key from the parameter values. Finally, we check if the AES key is hardcoded in the APK file. If the answer is **YES**, BINGO!!! We find hard-coded credentials in the APK file.
25
27
26
-
First, we design a detection rule `findSecretKeySpec.json` to spot on
27
-
behavior using the method `SecretKeySpec`. Then, we get all the
28
-
parameter values that are input to this method. And we parse the AES key
29
-
out of the parameter values. Finally, we check if the AES key is
30
-
hardcoded in the APK file. If the answer is YES, BINGO!!! We find
31
-
hard-coded credentials in the APK file.
28
+
## Quark Script: CWE-798.py
29
+
30
+

32
31
33
-
```python
32
+
```python
34
33
import re
35
34
from quark.script import runQuarkAnalysis, Rule
36
35
@@ -54,7 +53,9 @@ for secretKeySpec in quarkResult.behaviorOccurList:
54
53
55
54
## Quark Rule: findSecretKeySpec.json
56
55
57
-
```json
56
+

57
+
58
+
```json
58
59
{
59
60
"crime": "Detect APK using SecretKeySpec.",
60
61
"permission": [],
@@ -77,8 +78,7 @@ for secretKeySpec in quarkResult.behaviorOccurList:
77
78
78
79
## Quark Script Result
79
80
80
-
```TEXT
81
-
$ python3 findSecretKeySpec.py
82
-
81
+
```TEXT
82
+
$ python3 CWE-798.py
83
83
Found hard-coded AES key 49u5gh249gh24985ghf429gh4ch8f23f
0 commit comments