关于后端:白嫖GitHub-Action-云扫描器

GitHub Action介绍

GitHub Actions 是一种继续集成和继续交付 (CI/CD) 平台,可用于自动化构建、测试和部署应用程序,执行代码质量检查,创立和公布软件包,发送告诉,执行继续集成和继续部署等等。能够依据本人的需要和工作流程来定义和配置这些自动化工作

  • 官网中文文档
  • GitHub Action市场

能够了解为GitHub提供了一台最长能够应用6小时的云服务器,每次push代码时,该云服务器都会依照你提前设定好的流程去执行一遍。

简略演示

以构建简略的 subfinder子域名收集 – nuclei漏扫 为例,先应用subfinder进行子域名收集,而后应用nuclei进行漏扫,最初将后果上传到GitHub的以后仓库中。

创立git我的项目,编写.github/workflows/blank.yml内容如下,基本上都能看懂每一步干啥,每个字段解读可参考官网文档

name: CI
on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3

      # Setup Go environment
      - name: Setup Go environment
        uses: actions/setup-go@v4.0.1
        with:
          go-version: 1.20.1

      # 装置subfinder 和 nuclei
      - name: Run Install
        run: |
          go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest
          go install -v github.com/projectdiscovery/nuclei/v2/cmd/nuclei@latest

      # 应用
      - name: Run tools
        shell: bash
        run: |
          domain=$(cat input/domain.txt)
          subfinder -d $domain -o output/subdomains.txt
          nuclei -l output/subdomains.txt -o output/vuln.txt -s medium

      # push到以后仓库
      - name: Commit files
        run: |
          git config --local user.email "github-actions[bot]@users.noreply.github.com"
          git config --local user.name "github-actions[bot]"
          git add *
          git commit -m "commit change file"

      - name: GitHub Push
        # You may pin to the exact commit or the version.
        # uses: ad-m/github-push-action@40bf560936a8022e68a3c00e7d2abefaf01305a6
        uses: ad-m/github-push-action@v0.6.0
        with:
          # Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}
          github_token: ${{ secrets.GITHUB_TOKEN }}
          branch: ${{ github.ref }}

整体目录构造如下:

.
├── .github
│   └── workflows
│       └── blank.yml
├── .gitignore
├── input
│   └── domain.txt // 内容为gm7.org
└── output
    └── res.txt

上传到Github中,Github将会通过Action主动构建,依照咱们设置的流程运行,后果如下。

后果push到仓库,可随时查看。

注意事项

创立workflow

如果要从头写一个workflow的话,倡议在Github中新建模板后再改。

此外左边有语法参考,还能够间接从市场复制想要的货色,很不便。

remote: Write access to repository not granted.

须要在以后仓库的设置中,赋予workflow写权限。

速度方面

个人感觉速度比较慢,比拟欠缺,有这精力不如间接买台服务器配了,一劳永逸。

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理