noraj / OSCP-Exam-Report-Template-Markdown

:orange_book: Markdown Templates for Offensive Security OSCP, OSWE, OSCE, OSEE, OSWP exam report
https://noraj.github.io/OSCP-Exam-Report-Template-Markdown/
MIT License
3.49k stars 743 forks source link

ArchLinux PKGBUILD #17

Open noraj opened 3 years ago

noraj commented 3 years ago

ArchLinux PKGBUILD

D3vil0p3r commented 1 year ago

ArchLinux PKGBUILD

Hello @noraj Happy to meet you also here in this your wonderful project. If you wish, I can try to make a PKGBUILD for this. It could be very nice having it in some Arch repos. Just need to understand the name of the package: like OSERT or SecuReport or others.

noraj commented 1 year ago

Hi, thanks. osert is a good idea.

D3vil0p3r commented 1 year ago

Hi, thanks. osert is a good idea.

Just some considerations:

D3vil0p3r commented 1 year ago

Here the current PKGBUILD (currently, as described in the first bullet above, we need to retrieve eisvogel manually, unless it will be brought on this repository or obtained by the PKGBUILD in some efficient manner:

pkgname=osert
pkgver=69.8dc1a32
pkgrel=1
pkgdesc="Markdown Templates for Offensive Security exam reports."
arch=('any')
url='https://github.com/noraj/OSCP-Exam-Report-Template-Markdown'
license=('GPL3')
depends=('p7zip' 'pandoc' 'texlive-core' 'texlive-fontsextra' 'texlive-latexextra' 'xdg-utils')
makedepends=('git' 'unzip')
source=("git+https://github.com/noraj/OSCP-Exam-Report-Template-Markdown.git"
        "https://github.com/Wandmalfarbe/pandoc-latex-template/releases/download/v2.0.0/Eisvogel.tar.gz")
sha256sums=('SKIP'
            'c9bf5d7019b65a28b397cb1ac12676bce11f5badb10a156098073950a07d3e37')

pkgver() {
  cd OSCP-Exam-Report-Template-Markdown/
  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare(){
  tar -zxvf Eisvogel.tar.gz
}

package() {
  mkdir -p "$pkgdir/usr/share/$pkgname"
  mkdir -p "$pkgdir/usr/bin"
  mkdir -p "$pkgdir/usr/share/pandoc/data/templates/"

  mv eisvogel.latex "$pkgdir/usr/share/pandoc/data/templates/"

  cp -rf "${srcdir}/OSCP-Exam-Report-Template-Markdown/src" "${pkgdir}/usr/share/$pkgname/"
  install -Dm 755 -t "$pkgdir/usr/share/$pkgname/" "${srcdir}/OSCP-Exam-Report-Template-Markdown/generate.rb"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec /usr/share/$pkgname/generate.rb "\$@"
EOF

  chmod a+x "$pkgdir/usr/bin/$pkgname"
}

PS: about the 2nd bullet point of my previous comment, I implemented that approach on the Pull Request I opened on generate.rb.

Instead of textlive-most that consists in 12 packages: 1) texlive-bibtexextra 2) texlive-core 3) texlive-fontsextra 4) texlive-formatsextra 5) texlive-games 6) texlive-humanities 7) texlive-latexextra 8) texlive-music 9) texlive-pictures 10) texlive-pstricks 11) texlive-publishers 12) texlive-science, I identified the three needed packages for OSERT: texlive-core, texlive-fontsextra and texlive-latexextra. In this way the user can keep just the texlive packages he/she needs.

noraj commented 1 year ago

I'm noting in Arch that from pandoc pkg the eisvogel template is not provided anymore, so it must be retrieved from AUR or manually from its git repo. Could be good to insert eisvogel.latex file in your OSERT repo?

You should retrieve it from the git and add it in sources.

Ref.

Currently my approach on PKGBUILD was installing the src files (the .md ones) to /usr/share/osert and, according the logic of generate.rb, the output will be stored in /usr/share/osert/output folder. Since for storing output, privileges are needed, the user should run osert by sudo. For avoiding this, could I try to edit generate.rb in order that, when the user selects the preferred .md file, it will be copied in its current or $home folder, the tool will inform the user to write the .md report and, when he/she wrote it, to run a command like osert -i OSCP-xxx.md -o OSCP-xxx.pdf, so the user can edit the .md file with its exam evidences, and then, I would like to add a -i/-o or --input/--output arguments so that the user can save the .pdf in its preferred location (and avoid to save it in /usr subfolders)? Once done I can make a PR for it

Good point, I should think about that.

D3vil0p3r commented 1 year ago

I'm noting in Arch that from pandoc pkg the eisvogel template is not provided anymore, so it must be retrieved from AUR or manually from its git repo. Could be good to insert eisvogel.latex file in your OSERT repo?

You should retrieve it from the git and add it in sources.

Ref.

Currently my approach on PKGBUILD was installing the src files (the .md ones) to /usr/share/osert and, according the logic of generate.rb, the output will be stored in /usr/share/osert/output folder. Since for storing output, privileges are needed, the user should run osert by sudo. For avoiding this, could I try to edit generate.rb in order that, when the user selects the preferred .md file, it will be copied in its current or $home folder, the tool will inform the user to write the .md report and, when he/she wrote it, to run a command like osert -i OSCP-xxx.md -o OSCP-xxx.pdf, so the user can edit the .md file with its exam evidences, and then, I would like to add a -i/-o or --input/--output arguments so that the user can save the .pdf in its preferred location (and avoid to save it in /usr subfolders)? Once done I can make a PR for it

Good point, I should think about that.

I edited my comment above with the updated PKGBUILD code. Now it retrieves and stores eisvogel.latex automatically. In the Pull Request of the repo, you can find the generate.rb updated with the file input/output approach. The following is a screen of the osert -h command:

image
D3vil0p3r commented 1 year ago

I just updated the code in the PR. I hope it could be good for you @noraj

Now the user for first chooses the certification and then only the templates related to the chosen certification are shown. I used a nested array of objects. Then, each certification and some related output are colored according to the original OffSec certifications badge colors.

Also, now when the user inserts its OSID and Author (email address), it is automatically added in the .md file so it does not need to change this information manually. Also the date field in the .md file is automatically filled with the current date.

image

When run the command quoted in the screen above, the result will be the following with already author, OSID and current date information written:

image
noraj commented 1 year ago

I'll review and modify #35 soon. Thanks for your great PR.

D3vil0p3r commented 1 year ago

I'll review and modify #35 soon. Thanks for your great PR.

You're welcome.

noraj commented 1 year ago

I made a PR on BA with a cleaner PKGBUILD https://github.com/BlackArch/blackarch/pull/3569/files

D3vil0p3r commented 1 year ago

I made a PR on BA with a cleaner PKGBUILD https://github.com/BlackArch/blackarch/pull/3569/files

When the PR will be merged to BA repo, I will test it on Athena OS.