This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Setup Metasploit in Termux Docker | |
on: | |
push: | |
branches: | |
- main | |
- feature/* | |
pull_request: | |
branches: | |
- main | |
- feature/* | |
jobs: | |
checkout-dns: # nslookup github.com outside of docker | |
runs-on: ubuntu-latest | |
steps: | |
- name: Wait for DNS | |
run: | | |
sudo apt update | |
sudo apt install -y dnsutils | |
# List of hostnames | |
hostnames=("packages.termux.dev" "raw.githubusercontent.com" "packages-cf.termux.dev" "termux.dev") | |
# Output file | |
output_file="hosts_output.txt" | |
# Clear or create the output file | |
> "$output_file" | |
# Loop through each hostname | |
for hostname in "${hostnames[@]}"; do | |
# Perform nslookup and extract the IP address | |
ip=$(nslookup -type=A $hostname | grep -m 1 'Address: ' | awk '{ print $2 }') | |
if [ -n "$ip" ]; then | |
# Append to file in hosts file format | |
echo "$ip $hostname" >> "$output_file" | |
else | |
echo "No IP found for $hostname" >> "$output_file" | |
fi | |
done | |
# Display the contents of the output file | |
cat "$output_file" | |
- name: Upload hosts file | |
uses: actions/upload-artifact@v3 | |
with: | |
name: hosts-file | |
path: hosts_output.txt | |
setup-metasploit: | |
needs: checkout-dns | |
runs-on: ubuntu-latest # Runs on the GitHub-hosted runner | |
steps: | |
- name: Download hosts file | |
uses: actions/download-artifact@v3 | |
with: | |
name: hosts-file | |
path: . | |
- name: Use Docker Container | |
uses: addnab/docker-run-action@v3 | |
with: | |
image: termux/termux-docker:x86_64 | |
options: -v ${{ github.workspace }}/hosts_output.txt:/etc/hosts | |
run: | | |
# Your commands that run inside the Docker container | |
echo "Checking DNS readiness..." | |
max_attempts=$((2 * 60 / 5)) | |
attempt=1 | |
while [ $attempt -le $max_attempts ]; do | |
if curl -Is https://termux.dev > /dev/null; then | |
echo "DNS is ready and HTTP request to Termux was successful." | |
break | |
else | |
if [ $attempt -eq $max_attempts ]; then | |
echo "Timeout reached. DNS is still not ready." | |
exit 1 | |
fi | |
attempt=$((attempt + 1)) | |
sleep 5 | |
fi | |
done | |
curl -O -fsSL https://raw.githubusercontent.com/gushmazuko/metasploit_in_termux/feature/github-actions/metasploit.sh | |
chmod +x metasploit.sh | |
bash metasploit.sh |