Skip to content

Commit

Permalink
Add a CI to generate packages for Kali (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
zinwang committed Feb 7, 2024
1 parent 7d7656a commit d75fea4
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
exclude_paths:
- '.github/workflows/kali-package.dockerfile'
15 changes: 15 additions & 0 deletions .github/workflows/kali-package.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
From kalilinux/kali-rolling:latest

RUN apt-get update -y && apt-get install --no-install-recommends -y \
git python3 python3-pip debhelper \
dh-virtualenv build-essential devscripts equivs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /root/
COPY quark-engine /root/quark-engine

WORKDIR /root/quark-engine
RUN touch Makefile

CMD ["dpkg-buildpackage", "-us", "-uc", "-b"]
34 changes: 34 additions & 0 deletions .github/workflows/kali-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Kali Package CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup environments for packaging
run: |
cd ..
cp quark-engine/.github/workflows/kali-package.dockerfile .
docker build . --file kali-package.dockerfile -t packaging_for_kali
cd -
- name: Packaging
run: |
docker run --name factory packaging_for_kali:latest
docker cp factory:/root/ .
- name: Upload package as artifact
uses: actions/upload-artifact@v3
with:
name: kali-package
path: '${{ github.workspace }}/root/*.deb'

24 changes: 4 additions & 20 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@ Source: quark-engine
Section: misc
Priority: optional
Maintainer: Kali Developers <devel@kali.org>
Uploaders: JunWei Song <sungboss2004@gmail.com>
Uploaders: Zin Wong <chriswangxxxxx@gmail.com>
Build-Depends: debhelper-compat (= 12),
dh-python,
python3-all,
androguard,
python3-setuptools,
python3-requests,
python3-prettytable,
python3-tqdm,
python3-colorama,
python3-click,
python3-graphviz,
python3-prompt-toolkit
dh-virtualenv (>= 0.8),
python3,

Standards-Version: 24.2.1
Homepage: https://github.com/quark-engine/quark-engine
Expand All @@ -24,14 +15,7 @@ Package: quark-engine
Architecture: all
Depends: ${misc:Depends},
${python3:Depends},
androguard,
python3-requests,
python3-prettytable,
python3-tqdm,
python3-colorama,
python3-click,
python3-graphviz,
python3-prompt-toolkit
rizin
Description: Android Malware (Analysis | Scoring System)
Quark-Engine is a full-featured Android analysis framework written in
Python for hunting threat intelligence inside the APK, DEX files.
Expand Down
3 changes: 3 additions & 0 deletions debian/quark-engine.links
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/opt/venvs/quark-engine/bin/quark usr/bin/quark
/opt/venvs/quark-engine/bin/freshquark usr/bin/freshquark

2 changes: 2 additions & 0 deletions debian/quark-engine.triggers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export PYBUILD_NAME=quark-engine
export PYBUILD_DISABLE=test

%:
dh $@ --with python3 --buildsystem=pybuild
dh $@ --with python-virtualenv
98 changes: 98 additions & 0 deletions docs/source/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,101 @@ To submit your patch, just create a Pull Request from your GitHub fork.
If you don't know how to create a Pull Request take a look to `GitHub help`_.

.. _`GitHub help`: https://help.github.com/articles/using-pull-requests/

Packaging
==========

Kali Linux
-----------

Steps For Packaging
"""""""""""""""""""""

Quark is available in the Kali Linux repository. So you can install Quark with ``apt install quark-engine`` in Kali Linux. However, you can also create your own Kali package with the steps below.

**Step 1: Setup environment for packaging**


Install the necessary packages in the latest version of `Kali Linux <https://www.kali.org>`_.

.. code-block:: bash
sudo apt update && apt-get install git python3 python3-pip \
build-essential debhelper devscripts equivs
**Step 2: Download the source code of Quark**

Download the source code of Quark to the ``quark-engine`` directory.

.. code-block:: bash
git clone https://github.com/quark-engine/quark-engine.git
Enter the ``quark-engine`` directory.

.. code-block:: bash
cd quark-engine
**Step 3: Update the version information (optional)**

You can update the version number and changelog of the package. If you want to update the version number, change ``Standards-Version`` in the ``debian/control`` file. If you want to update the changelog, add the descriptions of new changes at the beginning of the ``debian/changelog`` file following the `Debian changelog format <https://www.debian.org/doc/manuals/maint-guide/dreq.en.html#changelog>`_.


**Step 4: Create the package**

Create a package for Kali Linux.

.. code-block:: bash
dpkg-buildpackage -us -uc -b
Go to the previous directory.

.. code-block:: bash
cd ..
Then, you can see the package named ``quark-engine_<<version>>.deb``, where ``<<version>>`` is the version number defined in the ``debian/control`` file.


**Step 5: Install Quark**

Install Quark using the created package.

.. code-block:: bash
sudo apt install ./quark-engine_<<version>>.deb
Get The Automatically Created Package
""""""""""""""""""""""""""""""""""""""
We have automated the above steps with a GitHub CI for convenience. Whenever receiving a pull request or commit, the GitHub CI will create a package automatically. Then, you can get the package with the steps below.
**Step 1: Navigate to the result page of the GitHub CI**
Click the ``Actions`` tab on the GitHub page of Quark.
.. image:: https://i.imgur.com/tpBB18r.png
Click the ``Kali Package CI`` workflow in the left sidebar.
.. image:: https://i.imgur.com/kAYOHdO.png
**Step 2: Download the Kali package of the specific PR or commit**
Click the pull request or commit you want.
.. image:: https://i.imgur.com/8bJkcAa.png
Download the ``kali-package`` artifact in the Artifacts area.
.. image:: https://i.imgur.com/rlfiBI4.png
Decompress the downloaded Zip file to get the package.

0 comments on commit d75fea4

Please sign in to comment.