Add showcase of Quark Script Generate using Quark Script Agent #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Quark Script Agent
Introducing Quark's new member, the Quark Script Agent, the first AI assistant in the Quark team. This agent enables users to perform analyses using natural language, without the need for programming or scripting expertise, making the process simple and user-friendly.
The Quark Script Agent integrates with LangChain, which utilizes OpenAI's large language models to act as a bridge between natural language and the Quark Script API. LangChain defines the Quark Script API as a tool that large language models can understand and use. This means that users can easily call new analysis APIs using natural language commands by simply adding new tools as needed.
Showcase: Detecting CWE-798 with Quark Script Agent
Here's an example of using the Quark Script Agent with the
quarkScriptAgent.py
. This agent can currently detect CWE-798 vulnerability in the ovaa.apk. See the details below.Quick Start
Decode the Prompts
Here are two prompts, each for executing different analysis processes.
Used Quark Script APIs/Tools that LLM used:
loadRule
Used Quark Script APIs/Tools that LLM used:
runQuarkAnalysis
,getBehaviorOccurList
,getParameterValues
andisHardCoded
The
loadRule
,runQuarkAnalysis
,getBehaviorOccurList
,getParameterValues
, andisHardCoded
functions are treated as tools within LangChain, enabling them to be invoked through thegpt-4o
model to analyze and identify CWE-798 vulnerabilities in the ovaa.apk sample.Showcase: Generating Quark Script with Quark Script Agent
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.
Here's an example for generating a Quark Script to detect CWE-798.
Demo Video
QuarkScriptAgentDemo.mov
Decode the Prompts
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.
Assign a role to the Agent
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.
Instruct the detection process
Instruct the Quark Script Agent to detect CWE-798 using the following detection process.
Generate Quark Script
Finally, ask the Quark Script Agent to write and execute the Python code based on the detection process outlined above.
Here is the generated code:
Here is the result.
We added 2 tools,
writeCodeInFile
andexecuteCode
, to enable Quark Script Agent to generate and execute Quark Script code.quarkScriptAgent.py
.quarkScriptAgent.py
in the same folder; the LLM will automatically find files with matching names.