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
Here are two prompts, each for executing different analysis processes.
33
38
34
39
```
35
-
1st Prompt: Initialize the rule instance with the rule path set to "rule.json"
40
+
1st Prompt: Initialize the rule instance with the rule path set to "constructCryptoGraphicKey.json"
36
41
```
37
42
Used Quark Script APIs/Tools that LLM used: `loadRule`
38
43
@@ -44,10 +49,175 @@ Used Quark Script APIs/Tools that LLM used: `runQuarkAnalysis`, `getBehaviorOccu
44
49
45
50
The `loadRule`, `runQuarkAnalysis`, `getBehaviorOccurList`, `getParameterValues`, and `isHardCoded` functions are treated as **tools** within LangChain, enabling them to be invoked through the `gpt-4o` model to analyze and identify [CWE-798](https://cwe.mitre.org/data/definitions/798.html) vulnerabilities in the [ovaa.apk](https://github.com/oversecured/ovaa) sample.
## Showcase: Generating Quark Script with Quark Script Agent
56
+
57
+
Quark Script Agent allows you to automate the creation of Quark Script code. This lets users concentrate on designing the detection process, while the LLM and Quark Script API handle the coding. This approach greatly enhances efficiency and streamlines the workflow.
58
+
59
+
Here's an example for generating a Quark Script to detect CWE-798.
Now, let's instruct the Quark Script Agent to detect CWE-798 and write the Quark Script for the detection process using the following prompt.
68
+
69
+
#### Assign a role to the Agent
70
+
71
+
To make the Quark Script Agent's responses more precise and relevant to vulnerability detection, we assign it the role of an Android APK vulnerability analyst.
72
+
73
+
```!
74
+
User:
75
+
Now you are an Android APK vulnerability analyst. Please follow the steps below to analyze a sample.
76
+
```
77
+
78
+
```!
79
+
Agent:
80
+
Sure, I'd be happy to help with that. Please provide the sample APK file and the detection rule file that you would like to use for the analysis.
81
+
```
82
+
83
+
#### Instruct the detection process
84
+
85
+
Instruct the Quark Script Agent to detect CWE-798 using the following detection process.
86
+
87
+
```!
88
+
Detection Process:
89
+
1. Define the behavior "Construct Cryptographic Key" in the rule instance.
90
+
2. Run Quark Analysis using the rule instance on the APK sample.
91
+
3. Obtain all instances of detected behaviors from the Quark Analysis results.
92
+
4. Retrieve the parameter values for each occurred behavior.
93
+
5. Check if any parameters are hard-coded. If found, print the hard-coded parameters.
94
+
```
95
+
96
+
>Note: The prompt will include details like the sample or rule path.
97
+
98
+
99
+
1. Define the behavior "Construct Cryptographic Key" in the rule instance.
100
+
```!
101
+
User:
102
+
1. Define the behavior "Construct Cryptographic Key" in the rule instance, with the rule path set to "constructCryptoGraphicKey.json".
103
+
```
104
+
105
+
```!
106
+
Agent:
107
+
The behavior "Construct Cryptographic Key" has been successfully defined in the rule instance with the rule path set to "constructCryptoGraphicKey.json". How would you like to proceed?
108
+
```
109
+
110
+
2. Run Quark Analysis using the rule instance on the APK sample.
111
+
```!
112
+
User:
113
+
2. Run Quark Analysis using the rule instance on the APK sample "ovaa.apk".
114
+
```
115
+
```!
116
+
Agent:
117
+
The Quark analysis on the APK sample "ovaa.apk" has been completed successfully. What would you like to do next?
118
+
```
119
+
120
+
3. Obtain all instances of detected behaviors from the Quark Analysis results.
121
+
```!
122
+
User:
123
+
3. Obtain all instances of detected behaviors from the Quark Analysis results in the sample "ovaa.apk".
124
+
```
125
+
126
+
```!
127
+
Agent
128
+
I have obtained all instances of detected behaviors from the Quark Analysis results in the sample "ovaa.apk". If you need further details or specific information about these behaviors, please let me know!
129
+
```
130
+
131
+
4. Retrieve the parameter values for each occurred behavior.
132
+
```!
133
+
User:
134
+
4. Retrieve the parameter values for each occurred behavior.
135
+
```
136
+
137
+
```!
138
+
Agent:
139
+
The parameter values for the occurred behavior are:
140
+
1. "49u5gh249gh24985ghf429gh4ch8f23f"
141
+
2. "AES"
142
+
143
+
Would you like to check if any of these values are hard-coded?
144
+
```
145
+
146
+
5. Check if any parameters are hard-coded. If found, print the hard-coded parameters.
147
+
```!
148
+
User:
149
+
5. Check if any parameter values are hard-coded. If yes, display the hard-coded values.
150
+
```
151
+
152
+
```!
153
+
Agent:
154
+
The following parameter values are hard-coded:
155
+
156
+
1. `49u5gh249gh24985ghf429gh4ch8f23f`
157
+
2. `AES`
158
+
```
159
+
160
+
#### Generate Quark Script
161
+
Finally, ask the Quark Script Agent to write and execute the Python code based on the detection process outlined above.
162
+
163
+
```!
164
+
User:
165
+
Using the Quark Script API, implement the above logic in Python and save it to 'detectCWE798.py', with the rule path set to 'constructCryptoGraphicKey.json' and the sample path to 'ovaa.apk'.
166
+
```
167
+
168
+
```!
169
+
Agent:
170
+
The code has been written to `detectCWE798.py`. You can now execute this script to perform the analysis.
1. Since LangChain currently does not support passing Python instances between tools, we are temporarily using global variables to pass parameters between tools in `quarkScriptAgent.py`.
52
-
2. Place the rules, samples, and `quarkScriptAgent.py` in the same folder; the LLM will automatically find files with matching names.
53
-
3. A web GUI is under construction, please stay tuned!
218
+
1. The code is generated by OpenAI's GPT model, and the output may not always match the documentation exactly.
219
+
2. Since LangChain currently does not support passing Python instances between tools, we are temporarily using global variables to pass parameters between tools in `quarkScriptAgent.py`.
220
+
3. Place the rules, samples, and `quarkScriptAgent.py` in the same folder; the LLM will automatically find files with matching names.
221
+
4. A web GUI is under construction, please stay tuned!
0 commit comments