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-319/README.md
+21-21Lines changed: 21 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,38 +1,36 @@
1
1
# Detect CWE-319 in Android Application
2
2
3
-
4
-
This scenario seeks to find **Cleartext Transmission of Sensitive
5
-
Information** in the APK file.
3
+
This scenario seeks to find **Cleartext Transmission of Sensitive Information** in the APK file.
6
4
7
5
## CWE-319 Cleartext Transmission of Sensitive Information
8
6
9
7
We analyze the definition of CWE-319 and identify its characteristics.
10
8
11
-
See [CWE-319](https://cwe.mitre.org/data/definitions/319.html) for more
12
-
details.
9
+
See [CWE-319](https://cwe.mitre.org/data/definitions/319.html) for more details.
13
10
14
-

11
+

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

17
+

22
18
23
-
## Quark Script: CWE-319.py
19
+
## CWE-319 Detection Process Using Quark Script API
20
+
21
+

22
+
23
+
Let’s use the above APIs to show how the Quark script finds this vulnerability. This sample uses the package `Retrofit` to request Web APIs, but the APIs use cleartext protocols.
24
24
25
-
Let\'s use the above APIs to show how the Quark script finds this
26
-
vulnerability. This sample uses the package Retrofit to request Web
27
-
APIs, but the APIs use cleartext protocols.
25
+
We first design a detection rule `setRetrofitBaseUrl.json` to spot on behavior that sets the base URL of the Retrofit instance. Then, we loop through a custom list of cleartext protocol schemes and use API `behaviorInstance.hasString(pattern, isRegex)` to filter if there are arguments that are URL strings with cleartext protocol.
28
26
29
-
We first design a detection rule `setRetrofitBaseUrl.json` to spot on
30
-
behavior that sets the base URL of the Retrofit instance. Then, we loop
31
-
through a custom list of cleartext protocol schemes and use API
32
-
`behaviorInstance.hasString(pattern, isRegex)` to filter arguments that
33
-
are URL strings with cleartext protocol.
27
+
If the answer is **YES**, CWE-319 vulnerability is caused.
34
28
35
-
```python
29
+
## Quark Script: CWE-319.py
30
+
31
+

32
+
33
+
```python
36
34
from quark.script import runQuarkAnalysis, Rule
37
35
38
36
SAMPLE_PATH="./ovaa.apk"
@@ -62,7 +60,9 @@ for setRetrofitBaseUrl in quarkResult.behaviorOccurList:
62
60
63
61
## Quark Rule: setRetrofitBaseUrl.json
64
62
65
-
```json
63
+

64
+
65
+
```json
66
66
{
67
67
"crime": "Set Retrofit Base Url",
68
68
"permission": [],
@@ -86,7 +86,7 @@ for setRetrofitBaseUrl in quarkResult.behaviorOccurList:
Copy file name to clipboardExpand all lines: CWE-327/README.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,36 +1,34 @@
1
1
# Detect CWE-327 in Android Application
2
2
3
-
This scenario seeks to find **Use of a Broken or Risky Cryptographic
4
-
Algorithm** in the APK file.
3
+
This scenario seeks to find **Use of a Broken or Risky Cryptographic Algorithm** in the APK file.
5
4
6
-
# CWE-327 Use of a Broken or Risky Cryptographic Algorithm
5
+
##CWE-327 Use of a Broken or Risky Cryptographic Algorithm
7
6
8
7
We analyze the definition of CWE-327 and identify its characteristics.
9
8
10
-
See [CWE-327](https://cwe.mitre.org/data/definitions/327.html) for more
11
-
details.
9
+
See [CWE-327](https://cwe.mitre.org/data/definitions/327.html) for more details.
12
10
13
-

11
+

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

17
+

21
18
22
-
## Quark Script CWE-327.py
19
+
## CWE-327 Detection Process Using Quark Script API
20
+
21
+

22
+
23
+
Let’s use the above APIs to show how the Quark script finds this vulnerability.
23
24
24
-
Let's use the above APIs to show how the Quark script finds this
25
-
vulnerability.
25
+
We first design a detection rule `useOfCryptographicAlgo.json` to spot on behavior using cryptographic algorithms. Then, we use API `behaviorInstance.hasString(pattern, isRegex)` with a list to check if the algorithm is risky. If **YES**, that may cause the exposure of sensitive data.
26
26
27
-
We first design a detection rule `useOfCryptographicAlgo.json` to spot
28
-
on behavior using cryptographic algorithms. Then, we use API
29
-
`behaviorInstance.hasString(pattern, isRegex)` with a list to check if
30
-
the algorithm is risky. If YES, that may cause the exposure of sensitive
31
-
data.
27
+
## Quark Script CWE-327.py
28
+
29
+

32
30
33
-
```python
31
+
```python
34
32
from quark.script import runQuarkAnalysis, Rule
35
33
36
34
SAMPLE_PATH="InjuredAndroid.apk"
@@ -52,7 +50,9 @@ for useCryptoAlgo in quarkResult.behaviorOccurList:
52
50
53
51
## Quark Rule: useOfCryptographicAlgo.json
54
52
55
-
```json
53
+

54
+
55
+
```json
56
56
{
57
57
"crime": "Use of cryptographic algorithm",
58
58
"permission": [],
@@ -75,7 +75,7 @@ for useCryptoAlgo in quarkResult.behaviorOccurList:
75
75
76
76
## Quark Script Result
77
77
78
-
```TEXT
78
+
```TEXT
79
79
$ python3 CWE-327.py
80
80
CWE-327 is detected in method, Lb3nac/injuredandroid/k; b (Ljava/lang/String;)Ljava/lang/String;
81
81
CWE-327 is detected in method, Lb3nac/injuredandroid/k; a (Ljava/lang/String;)Ljava/lang/String;
Copy file name to clipboardExpand all lines: CWE-328/README.md
+16-18Lines changed: 16 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,36 +1,34 @@
1
1
# Detect CWE-328 in Android Application
2
2
3
-
4
-
This scenario seeks to find **the use of weak Hash**.
3
+
This scenario seeks to find the **Use of Weak Hash**.
5
4
6
5
## CWE-328 Use of Weak Hash
7
6
8
7
We analyze the definition of CWE-328 and identify its characteristics.
9
8
10
-
See [CWE-328](https://cwe.mitre.org/data/definitions/328.html) for more
11
-
details.
9
+
See [CWE-328](https://cwe.mitre.org/data/definitions/328.html) for more details.
12
10
13
-

11
+

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

17
+

21
18
22
-
## Quark Script: CWE-328.py
19
+
## CWE-328 Detection Process Using Quark Script API
20
+
21
+

23
22
24
-
Let's use the above APIs to show how the Quark script finds this
25
-
vulnerability.
23
+
Let's use the above APIs to show how the Quark script finds this vulnerability.
24
+
25
+
First, we use API `findMethodInAPK(samplePath, targetMethod)` to find the method `MessageDigest.getInstance()` or `SecretKeyFactory.getInstance()`. Next, we use API `methodInstance.getArguments()` with a list to check if the method uses weak hashing algorithms. If **YES**, that causes CWE-328 vulnerability.
26
+
27
+
## Quark Script: CWE-328.py
26
28
27
-
First, we use API `findMethodInAPK(samplePath, targetMethod)` to find
28
-
the method `MessageDigest.getInstance()` or
29
-
`SecretKeyFactory.getInstance()`. Next, we use API
30
-
`methodInstance.getArguments()` with a list to check if the method uses
31
-
weak hashing algorithms. If **YES**, that causes CWE-328 vulnerability.
29
+

32
30
33
-
```python
31
+
```python
34
32
from quark.script import findMethodInAPK
35
33
36
34
SAMPLE_PATH="./allsafe.apk"
@@ -75,7 +73,7 @@ for setHashAlgo in methodsFound:
75
73
76
74
## Quark Script Result
77
75
78
-
```TEXT
76
+
```TEXT
79
77
$ python3 CWE-328.py
80
78
CWE-328 is detected in ./allsafe.apk,
81
79
and it occurs in method, Linfosecadventures/allsafe/challenges/SQLInjection; md5 (Ljava/lang/String;)Ljava/lang/String;
0 commit comments