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,35 +1,36 @@
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 details.
9
+
See [CWE-798](https://cwe.mitre.org/data/definitions/798.html) for more
10
+
details.
10
11
11
-

12
+

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

18
-
19
-
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.
19
+

27
20
28
21
## Quark Script: CWE-798.py
29
22
30
-

23
+
Let\'s use the above APIs to show how the Quark script finds this
24
+
vulnerability.
25
+
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.
31
32
32
-
```python
33
+
```python
33
34
import re
34
35
from quark.script import runQuarkAnalysis, Rule
35
36
@@ -53,9 +54,7 @@ for secretKeySpec in quarkResult.behaviorOccurList:
53
54
54
55
## Quark Rule: findSecretKeySpec.json
55
56
56
-

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