Skip to content

Commit e36feec

Browse files
authored
Optimize the document of Quark Script CWE-798 (#722)
* Optimize the document of Quark Script CWE-798 * Optimize the document of Quark Script CWE-798 * Optimize the document of Quark Script CWE-798 * Optimize the document of Quark Script CWE-798 * Optimize the document of Quark Script CWE-798
1 parent b147e9f commit e36feec

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

docs/source/quark_script.rst

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -399,33 +399,39 @@ Method (callComponentMethod) with urls is detected triggered!
399399

400400

401401
Detect CWE-798 in Android Application
402-
------------------------------------------------
402+
-------------------------------------------------
403403

404-
This scenario seeks to find hard-coded credentials in the APK file.
404+
This scenario seeks to find **hard-coded credentials** in the APK file.
405405

406-
CWE-798 Use of Hard-coded Credentials
407-
============================================
406+
CWE-798: Use of Hard-coded Credentials
407+
======================================
408408

409409
We analyze the definition of CWE-798 and identify its characteristics.
410410

411-
See `CWE-798 <https://cwe.mitre.org/data/definitions/798.html>`_ for more details.
411+
See `CWE-798 <https://cwe.mitre.org/data/definitions/798.html>`_ for more details.
412412

413-
.. image:: https://i.imgur.com/0G9APpf.jpg
413+
.. image:: https://imgur.com/rF8J8hE.png
414414

415415
Code of CWE-798 in ovaa.apk
416-
=========================================
416+
============================
417417

418418
We use the `ovaa.apk <https://github.com/oversecured/ovaa>`_ sample to explain the vulnerability code of CWE-798.
419419

420-
.. image:: https://i.imgur.com/ikaJlDW.jpg
420+
.. image:: https://imgur.com/Cg7DacP.png
421421

422+
CWE-798 Detection Process Using Quark Script API
423+
=================================================
424+
425+
.. image:: https://imgur.com/R8CfDqD.png
426+
427+
Let’s use the above APIs to show how the Quark script finds this vulnerability.
428+
429+
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.
422430

423431
Quark Script: CWE-798.py
424432
========================
425433

426-
Let's use the above APIs to show how the Quark script finds this vulnerability.
427-
428-
First, we design a detection rule ``findSecretKeySpec.json`` to spot on behavior using the method ``SecretKeySpec``. Then, we get all the parameter values that are input to this method. And we parse the AES key out of 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.
434+
.. image:: https://imgur.com/IOyrqDc.png
429435

430436
.. code-block:: python
431437
@@ -449,9 +455,10 @@ First, we design a detection rule ``findSecretKeySpec.json`` to spot on behavior
449455
if quarkResult.isHardcoded(AESKey):
450456
print(f"Found hard-coded {secondParam} key {AESKey}")
451457
452-
453458
Quark Rule: findSecretKeySpec.json
454-
==================================
459+
===================================
460+
461+
.. image:: https://imgur.com/2BYOE70.png
455462

456463
.. code-block:: json
457464
@@ -474,17 +481,16 @@ Quark Rule: findSecretKeySpec.json
474481
"label": []
475482
}
476483
477-
478484
Quark Script Result
479-
=====================
485+
====================
480486

481487
.. code-block:: TEXT
482488
483-
$ python3 findSecretKeySpec.py
484-
489+
$ python3 CWE-798.py
485490
Found hard-coded AES key 49u5gh249gh24985ghf429gh4ch8f23f
486491
487492
493+
488494
Detect CWE-94 in Android Application
489495
------------------------------------------------
490496

@@ -1048,7 +1054,7 @@ We use the `dvba.apk <https://github.com/rewanthtammana/Damn-Vulnerable-Bank>`_
10481054

10491055
.. image:: https://imgur.com/THWm2gN.jpg
10501056

1051-
Quark Scipt: CWE-532.py
1057+
Quark Script: CWE-532.py
10521058
========================
10531059

10541060
Let's use the above APIs to show how the Quark script finds this vulnerability.

0 commit comments

Comments
 (0)