mirror of
https://github.com/bee-san/RustScan.git
synced 2026-11-07 09:46:04 -10:00
Compare commits
102
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07ebe429ea | ||
|
|
f1ef3be688 | ||
|
|
71091bfe86 | ||
|
|
e797458f43 | ||
|
|
2b409c9d33 | ||
|
|
ef8852aeff | ||
|
|
98794d8187 | ||
|
|
9221567d25 | ||
|
|
c5e518889e | ||
|
|
981c1741fe | ||
|
|
a88d311ecf | ||
|
|
c782b07041 | ||
|
|
971f2523f5 | ||
|
|
d1cd45ec29 | ||
|
|
a6213bc1a3 | ||
|
|
e1689e506c | ||
|
|
85f4eb5a30 | ||
|
|
34744424d7 | ||
|
|
ba5d51788a | ||
|
|
b17b733580 | ||
|
|
3b06a34885 | ||
|
|
e3f129e6d1 | ||
|
|
604ff2acf0 | ||
|
|
a8c52917c3 | ||
|
|
cbf0f94ca1 | ||
|
|
4a7101b2f5 | ||
|
|
07e7b30f51 | ||
|
|
43c43ae91d | ||
|
|
4f19e42ebb | ||
|
|
f1810702ab | ||
|
|
0c0433d628 | ||
|
|
de98d0044e | ||
|
|
55e388241e | ||
|
|
d969699fff | ||
|
|
4542798c7b | ||
|
|
69629c4fc3 | ||
|
|
8676de1c19 | ||
|
|
90708aec1d | ||
|
|
094a6f00e7 | ||
|
|
840daac9d2 | ||
|
|
b171ed7c88 | ||
|
|
5a9cfeeb40 | ||
|
|
6a25fb1d98 | ||
|
|
bddda4d2c8 | ||
|
|
75c7d6215b | ||
|
|
d9dec00197 | ||
|
|
1634bab1b4 | ||
|
|
c58c389b1e | ||
|
|
d150802c04 | ||
|
|
dd9e075e56 | ||
|
|
d3229ff9a9 | ||
|
|
aae43ef47e | ||
|
|
387edc7b05 | ||
|
|
bb01c3b5ee | ||
|
|
89541eddfe | ||
|
|
45537cf6cd | ||
|
|
b039db77f0 | ||
|
|
8350947caf | ||
|
|
c7776873bb | ||
|
|
306df13861 | ||
|
|
88c58f3170 | ||
|
|
4e3c2a5649 | ||
|
|
d6fa72ae34 | ||
|
|
9ce001f60f | ||
|
|
f81312d63b | ||
|
|
04224b6a72 | ||
|
|
086812f2a2 | ||
|
|
85959b8c13 | ||
|
|
e29aa7747c | ||
|
|
640003f22c | ||
|
|
66de4e7ee0 | ||
|
|
7edff6d767 | ||
|
|
5198994cbd | ||
|
|
cabeb6b1cb | ||
|
|
2956073d0d | ||
|
|
2c55f1ae58 | ||
|
|
e3bd50c922 | ||
|
|
d5ed38ef60 | ||
|
|
e4937567b8 | ||
|
|
f90d56f02b | ||
|
|
fdd74c9dab | ||
|
|
8b253edaed | ||
|
|
9ebc04cece | ||
|
|
26f387adc0 | ||
|
|
a46096dab5 | ||
|
|
9c0992dcd0 | ||
|
|
347985ea52 | ||
|
|
cafcc10b2e | ||
|
|
371ef81c7b | ||
|
|
54bc6bf191 | ||
|
|
042a1c7b6c | ||
|
|
aed0d71de8 | ||
|
|
ea428a1a22 | ||
|
|
da41cb062d | ||
|
|
0a40d1539a | ||
|
|
c3d24feebe | ||
|
|
0a09da40aa | ||
|
|
6ffd5f741e | ||
|
|
4f964b7d47 | ||
|
|
3887dbb93f | ||
|
|
9c2c03f68c | ||
|
|
7d8b36aaef |
No files matched your search
@@ -7,6 +7,10 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
IMPORTANT: If you do not fill this out, your issue will be automatically closed.
|
||||
|
||||
As of November 2024, RustScan no longer offiically supports any packages other than `cargo`. If you have an issue with Docker or a `.deb`, please bring it up with whoever created it :)
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
|
||||
+169
-86
@@ -1,96 +1,179 @@
|
||||
name: Build
|
||||
on:
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
schedule:
|
||||
- cron: '00 01 * * *'
|
||||
name: CD Pipeline
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install stable toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Run cargo check
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
|
||||
test:
|
||||
name: Test Suite
|
||||
build-nix:
|
||||
env:
|
||||
IN_PIPELINE: true
|
||||
runs-on: ${{ matrix.os }}
|
||||
if: github.ref == 'refs/heads/master'
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
rust: [stable]
|
||||
runs-on: ${{ matrix.os }}
|
||||
type: [ubuntu-x64, ubuntu-x86, armv7, aarch64]
|
||||
include:
|
||||
- type: ubuntu-x64
|
||||
os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-musl
|
||||
name: x86_64-linux-rustscan
|
||||
path: target/x86_64-unknown-linux-musl/release/rustscan
|
||||
pkg_config_path: /usr/lib/x86_64-linux-gnu/pkgconfig
|
||||
- type: ubuntu-x86
|
||||
os: ubuntu-latest
|
||||
target: i686-unknown-linux-musl
|
||||
name: x86-linux-rustscan
|
||||
path: target/i686-unknown-linux-musl/release/rustscan
|
||||
pkg_config_path: /usr/lib/i686-linux-gnu/pkgconfig
|
||||
- type: armv7
|
||||
os: ubuntu-latest
|
||||
target: armv7-unknown-linux-gnueabihf
|
||||
name: armv7-linux-rustscan
|
||||
path: target/armv7-unknown-linux-gnueabihf/release/rustscan
|
||||
pkg_config_path: /usr/lib/x86_64-linux-gnu/pkgconfig
|
||||
- type: aarch64
|
||||
os: ubuntu-latest
|
||||
target: aarch64-unknown-linux-gnu
|
||||
name: aarch64-linux-rustscan
|
||||
path: target/aarch64-unknown-linux-gnu/release/rustscan
|
||||
pkg_config_path: /usr/lib/x86_64-linux-gnu/pkgconfig
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install stable toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
- uses: actions/checkout@v4
|
||||
- name: Cache cargo & target directories
|
||||
uses: Swatinem/rust-cache@v2
|
||||
- name: Build binary
|
||||
uses: houseabsolute/actions-rust-cross@v0
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Run cargo test
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
|
||||
lints:
|
||||
name: Lints
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Install stable toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
command: build
|
||||
target: ${{ matrix.target }}
|
||||
args: "--locked --release"
|
||||
strip: true
|
||||
toolchain: stable
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Run cargo fmt
|
||||
uses: actions-rs/cargo@v1
|
||||
- name: Build tar.gz for homebrew installs
|
||||
if: matrix.type == 'ubuntu-x64'
|
||||
run: |
|
||||
tar czf ${{ matrix.name }}.tar.gz -C target/x86_64-unknown-linux-musl/release rustscan
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
- name: Run cargo clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
name: ${{ matrix.name }}
|
||||
path: ${{ matrix.path }}
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: matrix.type == 'ubuntu-x64'
|
||||
with:
|
||||
command: clippy
|
||||
args: -- -D warnings
|
||||
|
||||
- name: Run rustdoc lints
|
||||
uses: actions-rs/cargo@v1
|
||||
name: ${{ matrix.name }}.tar.gz
|
||||
path: ${{ matrix.name }}.tar.gz
|
||||
build-deb:
|
||||
needs: [build-nix]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
IN_PIPELINE: true
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install cargo-deb
|
||||
run: cargo install -f cargo-deb
|
||||
- uses: awalsh128/cache-apt-pkgs-action@v1
|
||||
with:
|
||||
command: doc
|
||||
args: --workspace --all-features --no-deps --document-private-items
|
||||
packages: musl-tools # provides musl-gcc
|
||||
version: 1.0
|
||||
- name: Install musl toolchain
|
||||
run: rustup target add x86_64-unknown-linux-musl
|
||||
- name: Deb Build
|
||||
run: cargo deb --target=x86_64-unknown-linux-musl
|
||||
- name: Upload Deb Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: rustscan.deb
|
||||
path: ./target/x86_64-unknown-linux-musl/debian/*
|
||||
|
||||
build-macos:
|
||||
env:
|
||||
IN_PIPELINE: true
|
||||
runs-on: macos-latest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Cache cargo & target directories
|
||||
uses: Swatinem/rust-cache@v2
|
||||
- name: Build binary
|
||||
uses: houseabsolute/actions-rust-cross@v0
|
||||
with:
|
||||
command: build
|
||||
target: x86_64-apple-darwin
|
||||
args: "--locked --release"
|
||||
strip: true
|
||||
toolchain: stable
|
||||
- name: Build tar.gz for homebrew installs
|
||||
run: |
|
||||
tar czf x86_64-macos-rustscan.tar.gz -C target/x86_64-apple-darwin/release rustscan
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: x86_64-macos-rustscan
|
||||
path: target/x86_64-apple-darwin/release/rustscan
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: x86_64-macos-rustscan.tar.gz
|
||||
path: x86_64-macos-rustscan.tar.gz
|
||||
|
||||
build-macos-aarch64:
|
||||
env:
|
||||
IN_PIPELINE: true
|
||||
runs-on: macos-latest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Cache cargo & target directories
|
||||
uses: Swatinem/rust-cache@v2
|
||||
- name: Build binary
|
||||
uses: houseabsolute/actions-rust-cross@v0
|
||||
with:
|
||||
command: build
|
||||
target: aarch64-apple-darwin
|
||||
args: "--locked --release"
|
||||
strip: true
|
||||
toolchain: stable
|
||||
- name: Build tar.gz for homebrew installs
|
||||
run: |
|
||||
tar czf aarch64-macos-rustscan.tar.gz -C target/aarch64-apple-darwin/release rustscan
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: aarch64-macos-rustscan
|
||||
path: target/aarch64-apple-darwin/release/rustscan
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: aarch64-macos-rustscan.tar.gz
|
||||
path: aarch64-macos-rustscan.tar.gz
|
||||
|
||||
build-windows:
|
||||
env:
|
||||
IN_PIPELINE: true
|
||||
runs-on: ${{ matrix.os }}
|
||||
if: github.ref == 'refs/heads/master'
|
||||
strategy:
|
||||
matrix:
|
||||
type: [windows-x64, windows-x86]
|
||||
include:
|
||||
- type: windows-x64
|
||||
os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
name: x86_64-windows-rustscan.exe
|
||||
path: target\x86_64-pc-windows-msvc\release\rustscan.exe
|
||||
- type: windows-x86
|
||||
os: windows-latest
|
||||
target: i686-pc-windows-msvc
|
||||
name: x86-windows-rustscan.exe
|
||||
path: target\i686-pc-windows-msvc\release\rustscan.exe
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Cache cargo & target directories
|
||||
uses: Swatinem/rust-cache@v2
|
||||
- name: Build binary
|
||||
uses: houseabsolute/actions-rust-cross@v0
|
||||
with:
|
||||
command: build
|
||||
target: ${{ matrix.target }}
|
||||
args: "--locked --release"
|
||||
strip: true
|
||||
toolchain: stable
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.name }}
|
||||
path: ${{ matrix.path }}
|
||||
@@ -0,0 +1,19 @@
|
||||
name: Dependabot Auto-Merge
|
||||
on: pull_request
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
dependabot:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.actor == 'dependabot[bot]' }}
|
||||
steps:
|
||||
- name: Enable auto-merge for Dependabot PRs
|
||||
run: |
|
||||
gh pr review --approve "$PR_URL"
|
||||
gh pr merge --auto --merge "$PR_URL"
|
||||
env:
|
||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,38 +0,0 @@
|
||||
name: Release - Distribute Docker image
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+'
|
||||
# release:
|
||||
# types: [published]
|
||||
|
||||
jobs:
|
||||
push_to_registry:
|
||||
name: Push Docker image to Docker Hub
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out the repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
password: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
username: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: rustscan/rustscan
|
||||
flavor: latest=true
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: ${{ contains(fromJson('["push", "release"]'), github.event_name) }} # Publish to docker registry only on push event or new release.
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
@@ -1,216 +0,0 @@
|
||||
name: Release - Distribute binaries
|
||||
on:
|
||||
# If we want to make release using github interface.
|
||||
# release:
|
||||
# types: [published]
|
||||
# If we want to make release by pushing new tag.
|
||||
push:
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'Cargo.toml'
|
||||
- 'Cargo.lock'
|
||||
- '.github/workflows/release.yml'
|
||||
|
||||
env:
|
||||
BIN_NAME: rustscan
|
||||
PROJECT_NAME: rustscan
|
||||
REPO_NAME: RustScan/RustScan
|
||||
BREW_TAP: RustScan/homebrew-tap
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false # don't fail other jobs if one fails
|
||||
matrix:
|
||||
# aarch64-linux is failing due to python3 missing issues during tests. I'm removing it for now.
|
||||
# build: [x86_64-linux, aarch64-linux, x86_64-macos, aarch64-macos, x86_64-windows, x86_64-win-gnu]
|
||||
build: [x86_64-linux, x86_64-macos, aarch64-macos, x86_64-windows, x86_64-win-gnu]
|
||||
include:
|
||||
- build: aarch64-macos
|
||||
os: macos-latest
|
||||
rust: stable
|
||||
target: aarch64-apple-darwin
|
||||
cross: true
|
||||
# - build: aarch64-linux
|
||||
# os: ubuntu-20.04
|
||||
# rust: stable
|
||||
# target: aarch64-unknown-linux-gnu
|
||||
# cross: true
|
||||
- build: x86_64-linux
|
||||
os: ubuntu-20.04
|
||||
rust: stable
|
||||
target: x86_64-unknown-linux-gnu
|
||||
cross: false
|
||||
- build: x86_64-macos
|
||||
os: macos-latest
|
||||
rust: stable
|
||||
target: x86_64-apple-darwin
|
||||
cross: false
|
||||
- build: x86_64-windows
|
||||
os: windows-2019
|
||||
rust: stable
|
||||
target: x86_64-pc-windows-msvc
|
||||
cross: false
|
||||
- build: x86_64-win-gnu
|
||||
os: windows-2019
|
||||
rust: stable-x86_64-gnu
|
||||
target: x86_64-pc-windows-gnu
|
||||
cross: false
|
||||
|
||||
steps:
|
||||
- name: Set Git config (windows only)
|
||||
if: contains(matrix.os, 'windows') # Windows is missing some dependencies
|
||||
run: |
|
||||
git config --global pack.windowMemory "100m"
|
||||
git config --global pack.packSizeLimit "100m"
|
||||
git config --global pack.threads "1"
|
||||
git config --global pack.deltaCacheSize "512m"
|
||||
|
||||
- name: Install dependencies
|
||||
if: contains(matrix.build, 'aarch64-linux') # Windows is missing some dependencies
|
||||
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu python3
|
||||
|
||||
- name: Install python 3.10
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Install ${{ matrix.rust }} toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: ${{ matrix.rust }}
|
||||
target: ${{ matrix.target }}
|
||||
override: true
|
||||
|
||||
- name: Run cargo test
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
use-cross: ${{ matrix.cross }}
|
||||
command: test
|
||||
args: --release --locked --target ${{ matrix.target }}
|
||||
|
||||
- name: Build release binary
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
use-cross: ${{ matrix.cross }}
|
||||
command: build
|
||||
args: --release --locked --target ${{ matrix.target }}
|
||||
|
||||
- name: Calculate tag name
|
||||
# if: contains(matrix.build, 'linux')
|
||||
shell: bash
|
||||
run: |
|
||||
name=dev
|
||||
if [[ ${GITHUB_REF} =~ refs/tags/[0-9]+.[0-9]+.[0-9]+ ]]; then
|
||||
name=${GITHUB_REF#refs/tags/}
|
||||
fi
|
||||
echo "TAG=$name" >> $GITHUB_ENV
|
||||
id: tagname
|
||||
|
||||
- name: Build and package artifacts
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir dist
|
||||
if [[ "${{ matrix.build }}" =~ "windows" ]]; then
|
||||
cp "target/${{ matrix.target }}/release/$BIN_NAME.exe" "dist/"
|
||||
else
|
||||
cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/"
|
||||
fi
|
||||
|
||||
if [[ "${{ matrix.build }}" =~ "linux" ]]; then
|
||||
cargo install cargo-deb
|
||||
cargo deb --target ${{ matrix.target }} --deb-version ${TAG}
|
||||
cp "target/${{ matrix.target }}/debian/rustscan_${TAG}_amd64.deb" "dist/" || true
|
||||
fi
|
||||
|
||||
- uses: actions/[email protected]
|
||||
with:
|
||||
name: bins-${{ matrix.build }}
|
||||
path: dist
|
||||
|
||||
package:
|
||||
name: Package
|
||||
needs: [build]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: dist
|
||||
|
||||
- name: Calculate tag name
|
||||
# if: contains(matrix.build, 'linux')
|
||||
shell: bash
|
||||
run: |
|
||||
name=dev
|
||||
if [[ ${GITHUB_REF} =~ refs/tags/[0-9]+.[0-9]+.[0-9]+ ]]; then
|
||||
name=${GITHUB_REF#refs/tags/}
|
||||
fi
|
||||
echo "TAG=$name" >> $GITHUB_ENV
|
||||
id: tagname
|
||||
|
||||
- name: Build archive
|
||||
shell: bash
|
||||
run: |
|
||||
set -ex
|
||||
rm -rf tmp
|
||||
mkdir tmp
|
||||
for dir in dist/bins-* ; do
|
||||
platform=${dir#"dist/bins-"}
|
||||
unset exe
|
||||
if [[ $platform =~ "win" ]]; then
|
||||
exe=".exe"
|
||||
fi
|
||||
pkgname=$PROJECT_NAME-$TAG-$platform
|
||||
mkdir tmp/$pkgname
|
||||
cp $dir/$BIN_NAME$exe dist/ || true
|
||||
mv $dir/$BIN_NAME$exe tmp/$pkgname
|
||||
chmod +x tmp/$pkgname/$BIN_NAME$exe
|
||||
|
||||
if [[ $platform =~ "linux" ]]; then
|
||||
mv "$dir/rustscan_${TAG}_amd64.deb" dist/ || true
|
||||
fi
|
||||
|
||||
tar cJf dist/$pkgname.tar.xz -C tmp $pkgname
|
||||
7z a dist/$pkgname.zip tmp/$pkgname
|
||||
done
|
||||
|
||||
- name: Upload binaries to release
|
||||
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'release'
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: dist/*
|
||||
file_glob: true
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: true
|
||||
|
||||
# - uses: mislav/bump-homebrew-formula-action@v3
|
||||
# with:
|
||||
# formula-path: ${{env.PROJECT_NAME}}.rb
|
||||
# homebrew-tap: ${{ env.BREW_TAP }}
|
||||
# download-url: 'https://github.com/${{ env.REPO_NAME }}/releases/download/${{ github.ref }}/${{env.PROJECT_NAME}}-${{ github.ref }}-x86_64-macos.tar.xz'
|
||||
# commit-message: updating formula for ${{ env.PROJECT_NAME }}
|
||||
# env:
|
||||
# COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
|
||||
|
||||
- run: cargo publish --token ${CRATES_TOKEN}
|
||||
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || github.event_name == 'release'
|
||||
env:
|
||||
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
|
||||
@@ -0,0 +1,34 @@
|
||||
name: Test
|
||||
on:
|
||||
pull_request:
|
||||
branches: [master]
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
test:
|
||||
name: Test Suite
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
rust: [stable]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install stable toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: ${{ matrix.rust }}
|
||||
override: true
|
||||
|
||||
- uses: taiki-e/install-action@nextest
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
|
||||
- name: Install Just
|
||||
uses: extractions/setup-just@v2
|
||||
|
||||
- name: Run just
|
||||
run: just test
|
||||
Generated
+699
-251
File diff suppressed because it is too large.
Load diff
+19
-15
@@ -17,33 +17,33 @@ exclude = [
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.9", features = ["derive", "wrap_help"] }
|
||||
colored = "2.1.0"
|
||||
async-std = "1.7.0"
|
||||
clap = { version = "4.5.13", features = ["derive", "wrap_help"] }
|
||||
colored = "3.0.0"
|
||||
async-std = "1.13.0"
|
||||
futures = "0.3"
|
||||
rlimit = "0.10.1"
|
||||
log = "0.4.22"
|
||||
env_logger = "0.11.3"
|
||||
anstream = "=0.6.14"
|
||||
dirs = "5.0.1"
|
||||
rlimit = "0.10.2"
|
||||
log = "0.4.25"
|
||||
env_logger = "0.11.6"
|
||||
anstream = "=0.6.18"
|
||||
dirs = "6.0.0"
|
||||
gcd = "2.0.1"
|
||||
rand = "0.8.5"
|
||||
colorful = "0.2.1"
|
||||
rand = "0.9.0"
|
||||
colorful = "0.3.2"
|
||||
ansi_term = "0.12.1"
|
||||
toml = "0.8.14"
|
||||
toml = "0.8.20"
|
||||
serde = "1.0.124"
|
||||
serde_derive = "1.0.116"
|
||||
cidr-utils = "0.6.1"
|
||||
itertools = "0.13.0"
|
||||
hickory-resolver = { version = "0.24.0", features = ["dns-over-rustls"] }
|
||||
itertools = "0.14.0"
|
||||
hickory-resolver = { version = "0.24.3", features = ["dns-over-rustls"] }
|
||||
anyhow = "1.0.40"
|
||||
subprocess = "0.2.6"
|
||||
text_placeholder = { version = "0.5", features = ["struct_context"] }
|
||||
once_cell = "1.19.0"
|
||||
once_cell = "1.20.3"
|
||||
|
||||
[dev-dependencies]
|
||||
parameterized = "2.0.0"
|
||||
wait-timeout = "0.2"
|
||||
criterion = { version = "0.5", features = ["html_reports"] }
|
||||
|
||||
[package.metadata.deb]
|
||||
depends = "$auto, nmap"
|
||||
@@ -61,3 +61,7 @@ path = "src/main.rs"
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ["cfg(tarpaulin_include)"] }
|
||||
|
||||
[[bench]]
|
||||
name = "benchmark_portscan"
|
||||
harness = false
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
# Build Stage
|
||||
FROM rust:alpine as builder
|
||||
LABEL maintainer="RustScan <https://github.com/RustScan>"
|
||||
RUN apk add --no-cache build-base
|
||||
|
||||
# Encourage some layer caching here rather then copying entire directory that includes docs to builder container ~CMN
|
||||
WORKDIR /app/rustscan
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
COPY src/ src/
|
||||
RUN cargo build --release
|
||||
|
||||
# Release Stage
|
||||
FROM alpine:3.20.2 as release
|
||||
LABEL author="Hydragyrum <https://github.com/Hydragyrum>"
|
||||
LABEL author="LeoFVO <https://github.com/LeoFVO>"
|
||||
|
||||
RUN addgroup -S rustscan && \
|
||||
adduser -S -G rustscan rustscan && \
|
||||
ulimit -n 100000 && \
|
||||
apk add --no-cache nmap nmap-scripts wget ca-certificates bind-tools
|
||||
|
||||
USER rustscan
|
||||
COPY --from=builder /app/rustscan/target/release/rustscan /usr/local/bin/rustscan
|
||||
|
||||
ENTRYPOINT [ "/usr/local/bin/rustscan" ]
|
||||
@@ -9,16 +9,6 @@
|
||||
|
||||
![Arch Linux package][badge-1] ![Built with Rust][badge-2] ![GitHub All Releases][badge-3] ![Crates.io][badge-4] ![Discord][badge-5] ![Actions][badge-6]
|
||||
|
||||
|
||||
---
|
||||
|
||||
| 🐋 `(Recommended)` | 👩💻 | 🏗️ | 🔧 |
|
||||
| :---------------------------------------------------------: | :---------------------------: | :-------------------------: | :-------------------------: |
|
||||
| [![Docker][DockerPic]][Docker] | [![Kali][Kali1]][Kali/Debian] | [![Arch][Arch]][Arch-Linux] | [![apple][apple]][Homebrew] |
|
||||
| `docker pull rustscan/rustscan:latest`</br>[Docker][usage-0] | [Link to Documentation][kali] | `yay -S rustscan` | `brew install rustscan` |
|
||||
|
||||
---
|
||||
|
||||
</div>
|
||||
|
||||
# 🤔 What is this?
|
||||
@@ -27,6 +17,32 @@
|
||||
|
||||
The Modern Port Scanner. **Find ports quickly (3 seconds at its fastest)**. Run scripts through our scripting engine (Python, Lua, Shell supported).
|
||||
|
||||
# 🛠️ Installation
|
||||
|
||||
You can install RustScan's binary from our [releases page](https://github.com/RustScan/RustScan/releases).
|
||||
|
||||
We would prefer you to install with a package manager so it is tested and works for your system.
|
||||
|
||||
RustScan is in many repositories already. Install it with whatever tools you wish:
|
||||
|
||||
[](https://repology.org/project/rustscan/versions)
|
||||
|
||||
RustScan only officially supports Cargo installations, if you want to use that please install Rust and then `cargo install rustscan`
|
||||
|
||||
Example installations include:
|
||||
|
||||
MacOS:
|
||||
|
||||
```
|
||||
brew install rustscan
|
||||
```
|
||||
|
||||
Arch:
|
||||
|
||||
```
|
||||
yay rustscan
|
||||
```
|
||||
|
||||
# ✨ Features
|
||||
|
||||
- Scans all 65k ports in **3 seconds**.
|
||||
@@ -47,7 +63,6 @@ The Modern Port Scanner. **Find ports quickly (3 seconds at its fastest)**. Run
|
||||
- 🐋 [Docker Usage][toc-docker-usage]
|
||||
- 🦜 [Discord][discord]
|
||||
- 🤸 [Usage][usage-1]
|
||||
- 🎪 [Community][toc-community]
|
||||
|
||||
# 🔭 Why RustScan?
|
||||
|
||||
@@ -105,21 +120,6 @@ RustScan is one of the first penetration testing tools that aims to be entirely
|
||||
|
||||
RustScan has continuous integration testing that aims to ensure it is accessible, and we are constantly working on ways to improve our accessibility and ensure _everyone_ can use RustScan.
|
||||
|
||||
# 📖 Full Installation Guide
|
||||
|
||||
You can find our guide [here][install-1].
|
||||
|
||||
## 🦊 Community Distributions
|
||||
|
||||
Here are all of RustScan's community distributions.
|
||||
|
||||
If you maintain a community distribution and want it listed here, leave an issue / pull request / Discord message or however, you want to let us know.
|
||||
|
||||
- [Open Suse][distributions-1]
|
||||
- [Fedora/CentOS][distributions-2]
|
||||
|
||||
[![Packaging status][rustscan-svg]][repology-1]
|
||||
|
||||
# 🤸 Usage
|
||||
|
||||
We have 2 usage guides. [Basic Usage][usage-1] and [Things you may want to do][usage-2].
|
||||
@@ -145,7 +145,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<!-- markdownlint-disable -->
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"><a href="https://skerritt.blog"><img src="https://avatars3.githubusercontent.com/u/10378052?v=4" width="100px;" alt=""/><br /><sub><b>Brandon</b></sub></a><br /><a href="#infra-brandonskerritt" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/RustScan/RustScan/commits?author=brandonskerritt" title="Tests">⚠️</a> <a href="https://github.com/RustScan/RustScan/commits?author=brandonskerritt" title="Code">💻</a> <a href="#design-brandonskerritt" title="Design">🎨</a></td>
|
||||
<td align="center"><a href="https://skerritt.blog"><img src="https://avatars3.githubusercontent.com/u/10378052?v=4" width="100px;" alt=""/><br /><sub><b>Bee</b></sub></a><br /><a href="#infra-beeskerritt" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/RustScan/RustScan/commits?author=beeskerritt" title="Tests">⚠️</a> <a href="https://github.com/RustScan/RustScan/commits?author=beesan" title="Code">💻</a> <a href="#design-beeskerritt" title="Design">🎨</a></td>
|
||||
<td align="center"><a href="https://sakiir.ovh"><img src="https://avatars1.githubusercontent.com/u/9950578?v=4" width="100px;" alt=""/><br /><sub><b>SakiiR</b></sub></a><br /><a href="https://github.com/RustScan/RustScan/commits?author=SakiiR" title="Code">💻</a> <a href="https://github.com/RustScan/RustScan/issues?q=author%3ASakiiR" title="Bug reports">🐛</a></td>
|
||||
<td align="center"><a href="https://github.com/smackhack"><img src="https://avatars2.githubusercontent.com/u/48143394?v=4" width="100px;" alt=""/><br /><sub><b>smackhack</b></sub></a><br /><a href="#ideas-smackhack" title="Ideas, Planning, & Feedback">🤔</a> <a href="#example-smackhack" title="Examples">💡</a></td>
|
||||
<td align="center"><a href="http://bernardoamc.github.io/"><img src="https://avatars0.githubusercontent.com/u/428984?v=4" width="100px;" alt=""/><br /><sub><b>Bernardo Araujo</b></sub></a><br /><a href="https://github.com/RustScan/RustScan/commits?author=bernardoamc" title="Code">💻</a> <a href="https://github.com/RustScan/RustScan/issues?q=author%3Abernardoamc" title="Bug reports">🐛</a> <a href="#design-bernardoamc" title="Design">🎨</a></td>
|
||||
@@ -232,4 +232,4 @@ This project follows the [all-contributors](https://github.com/all-contributors/
|
||||
[badge-3]: https://img.shields.io/github/downloads/rustscan/rustscan/total?label=GitHub%20Downloads
|
||||
[badge-4]: https://img.shields.io/crates/d/rustscan?label=Cargo%20Downloads
|
||||
[badge-5]: https://img.shields.io/discord/754001738184392704
|
||||
[badge-6]: https://github.com/RustScan/RustScan/workflows/Continuous%20integration/badge.svg?branch=master
|
||||
[badge-6]: https://github.com/RustScan/RustScan/actions/workflows/build.yml/badge.svg?branch=master
|
||||
@@ -0,0 +1,80 @@
|
||||
use async_std::task::block_on;
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use rustscan::input::{PortRange, ScanOrder};
|
||||
use rustscan::port_strategy::PortStrategy;
|
||||
use rustscan::scanner::Scanner;
|
||||
use std::net::IpAddr;
|
||||
use std::time::Duration;
|
||||
|
||||
fn portscan_tcp(scanner: &Scanner) {
|
||||
let _scan_result = block_on(scanner.run());
|
||||
}
|
||||
|
||||
fn portscan_udp(scanner: &Scanner) {
|
||||
let _scan_result = block_on(scanner.run());
|
||||
}
|
||||
|
||||
fn bench_address() {
|
||||
let _addrs = ["127.0.0.1".parse::<IpAddr>().unwrap()];
|
||||
}
|
||||
|
||||
fn bench_port_strategy() {
|
||||
let range = PortRange {
|
||||
start: 1,
|
||||
end: 1_000,
|
||||
};
|
||||
let _strategy = PortStrategy::pick(&Some(range.clone()), None, ScanOrder::Serial);
|
||||
}
|
||||
|
||||
fn criterion_benchmark(c: &mut Criterion) {
|
||||
let addrs = vec!["127.0.0.1".parse::<IpAddr>().unwrap()];
|
||||
let range = PortRange {
|
||||
start: 1,
|
||||
end: 1_000,
|
||||
};
|
||||
let strategy_tcp = PortStrategy::pick(&Some(range.clone()), None, ScanOrder::Serial);
|
||||
let strategy_udp = PortStrategy::pick(&Some(range.clone()), None, ScanOrder::Serial);
|
||||
|
||||
let scanner_tcp = Scanner::new(
|
||||
&addrs,
|
||||
10,
|
||||
Duration::from_millis(10),
|
||||
1,
|
||||
false,
|
||||
strategy_tcp,
|
||||
true,
|
||||
vec![],
|
||||
false,
|
||||
);
|
||||
|
||||
c.bench_function("portscan tcp", |b| {
|
||||
b.iter(|| portscan_tcp(black_box(&scanner_tcp)))
|
||||
});
|
||||
|
||||
let scanner_udp = Scanner::new(
|
||||
&addrs,
|
||||
10,
|
||||
Duration::from_millis(10),
|
||||
1,
|
||||
false,
|
||||
strategy_udp,
|
||||
true,
|
||||
vec![],
|
||||
true,
|
||||
);
|
||||
|
||||
let mut udp_group = c.benchmark_group("portscan udp");
|
||||
udp_group.measurement_time(Duration::from_secs(20));
|
||||
udp_group.bench_function("portscan udp", |b| {
|
||||
b.iter(|| portscan_udp(black_box(&scanner_udp)))
|
||||
});
|
||||
udp_group.finish();
|
||||
|
||||
// Benching helper functions
|
||||
c.bench_function("parse address", |b| b.iter(bench_address));
|
||||
|
||||
c.bench_function("port strategy", |b| b.iter(bench_port_strategy));
|
||||
}
|
||||
|
||||
criterion_group!(benches, criterion_benchmark);
|
||||
criterion_main!(benches);
|
||||
@@ -194,7 +194,7 @@ fn parser(payload: &str) -> Vec<u8> {
|
||||
for (idx, char) in payload.chars().enumerate() {
|
||||
if char == '\\' && payload.chars().nth(idx + 1) == Some('x') {
|
||||
continue;
|
||||
} else if char.is_ascii_digit() {
|
||||
} else if char.is_ascii_hexdigit() {
|
||||
tmp_str.push(char);
|
||||
if tmp_str.len() == 2 {
|
||||
bytes.push(u8::from_str_radix(&tmp_str, 16).unwrap());
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
test:
|
||||
cargo nextest run
|
||||
cargo clippy -- --deny warnings
|
||||
cargo clippy --tests -- --deny warnings
|
||||
cargo fmt --check
|
||||
cargo doc --workspace --all-features --no-deps --document-private-items
|
||||
|
||||
fix:
|
||||
cargo fmt
|
||||
cargo clippy --fix
|
||||
|
||||
# release only runs if test runs
|
||||
release: test
|
||||
git checkout master
|
||||
git pull
|
||||
cargo generate-lockfile
|
||||
cargo publish
|
||||
git push
|
||||
+129
-17
@@ -1,4 +1,5 @@
|
||||
//! Provides functions to parse input IP addresses, CIDRs or files.
|
||||
use std::collections::BTreeSet;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{prelude::*, BufReader};
|
||||
use std::net::{IpAddr, SocketAddr, ToSocketAddrs};
|
||||
@@ -27,6 +28,8 @@ use crate::warning;
|
||||
///
|
||||
/// let ips = parse_addresses(&opts);
|
||||
/// ```
|
||||
///
|
||||
/// Finally, any duplicates are removed to avoid excessive scans.
|
||||
pub fn parse_addresses(input: &Opts) -> Vec<IpAddr> {
|
||||
let mut ips: Vec<IpAddr> = Vec::new();
|
||||
let mut unresolved_addresses: Vec<&str> = Vec::new();
|
||||
@@ -66,6 +69,18 @@ pub fn parse_addresses(input: &Opts) -> Vec<IpAddr> {
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, craft a list of addresses to be excluded from the scan.
|
||||
let mut excluded_ips: BTreeSet<IpAddr> = BTreeSet::new();
|
||||
if let Some(exclude_addresses) = &input.exclude_addresses {
|
||||
for addr in exclude_addresses {
|
||||
excluded_ips.extend(parse_address(addr, &backup_resolver));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicated/excluded IPs.
|
||||
let mut seen = BTreeSet::new();
|
||||
ips.retain(|ip| seen.insert(*ip) && !excluded_ips.contains(ip));
|
||||
|
||||
ips
|
||||
}
|
||||
|
||||
@@ -87,7 +102,7 @@ pub fn parse_address(address: &str, resolver: &Resolver) -> Vec<IpAddr> {
|
||||
.map(|cidr| cidr.iter().map(|c| c.address()).collect())
|
||||
.ok()
|
||||
.or_else(|| {
|
||||
format!("{}:{}", &address, 80)
|
||||
format!("{}:80", &address)
|
||||
.to_socket_addrs()
|
||||
.ok()
|
||||
.map(|mut iter| vec![iter.next().unwrap().ip()])
|
||||
@@ -187,8 +202,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_correct_addresses() {
|
||||
let mut opts = Opts::default();
|
||||
opts.addresses = vec!["127.0.0.1".to_owned(), "192.168.0.0/30".to_owned()];
|
||||
let opts = Opts {
|
||||
addresses: vec!["127.0.0.1".to_owned(), "192.168.0.0/30".to_owned()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert_eq!(
|
||||
@@ -203,10 +221,71 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_addresses_with_address_exclusions() {
|
||||
let opts = Opts {
|
||||
addresses: vec!["192.168.0.0/30".to_owned()],
|
||||
exclude_addresses: Some(vec!["192.168.0.1".to_owned()]),
|
||||
..Default::default()
|
||||
};
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert_eq!(
|
||||
ips,
|
||||
[
|
||||
Ipv4Addr::new(192, 168, 0, 0),
|
||||
Ipv4Addr::new(192, 168, 0, 2),
|
||||
Ipv4Addr::new(192, 168, 0, 3)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_addresses_with_cidr_exclusions() {
|
||||
let opts = Opts {
|
||||
addresses: vec!["192.168.0.0/29".to_owned()],
|
||||
exclude_addresses: Some(vec!["192.168.0.0/30".to_owned()]),
|
||||
..Default::default()
|
||||
};
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert_eq!(
|
||||
ips,
|
||||
[
|
||||
Ipv4Addr::new(192, 168, 0, 4),
|
||||
Ipv4Addr::new(192, 168, 0, 5),
|
||||
Ipv4Addr::new(192, 168, 0, 6),
|
||||
Ipv4Addr::new(192, 168, 0, 7),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_addresses_with_incorrect_address_exclusions() {
|
||||
let opts = Opts {
|
||||
addresses: vec!["192.168.0.0/30".to_owned()],
|
||||
exclude_addresses: Some(vec!["192.168.0.1".to_owned()]),
|
||||
..Default::default()
|
||||
};
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert_eq!(
|
||||
ips,
|
||||
[
|
||||
Ipv4Addr::new(192, 168, 0, 0),
|
||||
Ipv4Addr::new(192, 168, 0, 2),
|
||||
Ipv4Addr::new(192, 168, 0, 3)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_correct_host_addresses() {
|
||||
let mut opts = Opts::default();
|
||||
opts.addresses = vec!["google.com".to_owned()];
|
||||
let opts = Opts {
|
||||
addresses: vec!["google.com".to_owned()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert_eq!(ips.len(), 1);
|
||||
@@ -214,8 +293,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_correct_and_incorrect_addresses() {
|
||||
let mut opts = Opts::default();
|
||||
opts.addresses = vec!["127.0.0.1".to_owned(), "im_wrong".to_owned()];
|
||||
let opts = Opts {
|
||||
addresses: vec!["127.0.0.1".to_owned(), "im_wrong".to_owned()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert_eq!(ips, [Ipv4Addr::new(127, 0, 0, 1),]);
|
||||
@@ -223,39 +305,67 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_incorrect_addresses() {
|
||||
let mut opts = Opts::default();
|
||||
opts.addresses = vec!["im_wrong".to_owned(), "300.10.1.1".to_owned()];
|
||||
let opts = Opts {
|
||||
addresses: vec!["im_wrong".to_owned(), "300.10.1.1".to_owned()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert!(ips.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_hosts_file_and_incorrect_hosts() {
|
||||
// Host file contains IP, Hosts, incorrect IPs, incorrect hosts
|
||||
let mut opts = Opts::default();
|
||||
opts.addresses = vec!["fixtures/hosts.txt".to_owned()];
|
||||
let opts = Opts {
|
||||
addresses: vec!["fixtures/hosts.txt".to_owned()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert_eq!(ips.len(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_empty_hosts_file() {
|
||||
// Host file contains IP, Hosts, incorrect IPs, incorrect hosts
|
||||
let mut opts = Opts::default();
|
||||
opts.addresses = vec!["fixtures/empty_hosts.txt".to_owned()];
|
||||
let opts = Opts {
|
||||
addresses: vec!["fixtures/empty_hosts.txt".to_owned()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert_eq!(ips.len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_naughty_host_file() {
|
||||
// Host file contains IP, Hosts, incorrect IPs, incorrect hosts
|
||||
let mut opts = Opts::default();
|
||||
opts.addresses = vec!["fixtures/naughty_string.txt".to_owned()];
|
||||
let opts = Opts {
|
||||
addresses: vec!["fixtures/naughty_string.txt".to_owned()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert_eq!(ips.len(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_duplicate_cidrs() {
|
||||
let opts = Opts {
|
||||
addresses: vec!["79.98.104.0/21".to_owned(), "79.98.104.0/24".to_owned()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let ips = parse_addresses(&opts);
|
||||
|
||||
assert_eq!(ips.len(), 2_048);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolver_default_cloudflare() {
|
||||
let opts = Opts::default();
|
||||
@@ -269,9 +379,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn resolver_args_google_dns() {
|
||||
let mut opts = Opts::default();
|
||||
// https://developers.google.com/speed/public-dns
|
||||
opts.resolver = Some("8.8.8.8,8.8.4.4".to_owned());
|
||||
let opts = Opts {
|
||||
resolver: Some("8.8.8.8,8.8.4.4".to_owned()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let resolver = get_resolver(&opts.resolver);
|
||||
let lookup = resolver.lookup_ip("www.example.com.").unwrap();
|
||||
|
||||
+105
-74
@@ -3,36 +3,38 @@ use std::collections::BTreeMap;
|
||||
|
||||
fn generated_data() -> BTreeMap<Vec<u16>, Vec<u8>> {
|
||||
let mut map = BTreeMap::new();
|
||||
map.insert(vec![7], vec![0, 0]);
|
||||
map.insert(vec![7], vec![13, 10, 13, 10]);
|
||||
map.insert(
|
||||
vec![53, 69, 5353, 26198],
|
||||
vec![0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
);
|
||||
map.insert(
|
||||
vec![53, 5353, 26198],
|
||||
vec![119, 119, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 7, 4, 0, 0, 16, 0, 3],
|
||||
vec![
|
||||
119, 119, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 7, 224, 75, 208, 0, 1, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
vec![67],
|
||||
vec![
|
||||
1, 1, 6, 0, 1, 35, 69, 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 84,
|
||||
133, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 6, 0, 1, 35, 69, 103, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 14, 53, 212, 216, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 6, 56, 37, 54, 51, 80, 16,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 130, 83, 99, 53, 1, 8, 255,
|
||||
],
|
||||
);
|
||||
map.insert(vec![69], vec![0, 1, 112, 0]);
|
||||
map.insert(vec![69], vec![0, 1, 127, 0, 206, 0]);
|
||||
map.insert(vec![80], vec![18, 52, 86, 120, 153, 144]);
|
||||
map.insert(
|
||||
vec![111],
|
||||
vec![
|
||||
114, 17, 48, 0, 0, 0, 0, 0, 0, 0, 32, 0, 24, 96, 0, 1, 151, 112, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
114, 254, 29, 19, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 134, 160, 0, 1, 151, 124, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
@@ -2770,15 +2772,15 @@ fn generated_data() -> BTreeMap<Vec<u16>, Vec<u8>> {
|
||||
65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534,
|
||||
],
|
||||
vec![
|
||||
51, 0, 0, 0, 0, 0, 0, 0, 2, 0, 97, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
62, 236, 227, 202, 0, 0, 0, 0, 0, 0, 0, 2, 0, 188, 97, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
vec![123],
|
||||
vec![
|
||||
144, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 97, 87, 128, 0, 0,
|
||||
217, 0, 10, 250, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 198, 241, 94, 219, 120, 0, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
@@ -2798,33 +2800,40 @@ fn generated_data() -> BTreeMap<Vec<u16>, Vec<u8>> {
|
||||
1192, 1193, 1194, 1195, 1196, 1197, 1198,
|
||||
],
|
||||
vec![
|
||||
5, 0, 0, 49, 0, 0, 0, 4, 128, 0, 0, 0, 16, 0, 0, 8, 16, 129, 0, 0, 0, 0, 0, 16, 0, 0,
|
||||
0, 0, 0, 16, 0, 18, 52, 86, 120, 144, 18, 52, 86, 120, 151, 3, 0, 0, 152, 118, 84, 50,
|
||||
16, 1, 35, 69, 103, 137, 112, 48, 0,
|
||||
5, 0, 11, 3, 16, 0, 0, 0, 72, 0, 0, 0, 1, 0, 0, 0, 184, 16, 184, 16, 0, 0, 0, 0, 1, 0,
|
||||
0, 0, 0, 0, 1, 0, 1, 35, 69, 103, 137, 171, 205, 239, 1, 35, 69, 103, 137, 171, 205,
|
||||
239, 231, 3, 0, 0, 254, 220, 186, 152, 118, 84, 50, 16, 1, 35, 69, 103, 137, 171, 205,
|
||||
239, 231, 3, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
vec![137],
|
||||
vec![1, 145, 0, 16, 0, 1, 0, 0, 0, 0, 0, 0, 32, 0, 0, 33, 0, 1],
|
||||
vec![
|
||||
1, 145, 0, 16, 0, 1, 0, 0, 0, 0, 0, 0, 32, 202, 170, 170, 170, 170, 170, 170, 170, 170,
|
||||
170, 170, 170, 170, 170, 170, 160, 0, 2, 16, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
vec![161, 260, 3401],
|
||||
vec![
|
||||
48, 16, 32, 16, 0, 64, 97, 18, 2, 1, 0, 2, 1, 0, 2, 1, 0, 48, 7, 48, 5, 6, 1, 0, 5, 0,
|
||||
48, 58, 2, 1, 3, 48, 15, 2, 2, 74, 105, 2, 3, 0, 255, 227, 4, 1, 4, 2, 1, 3, 4, 16, 48,
|
||||
14, 4, 0, 2, 1, 0, 2, 1, 0, 4, 0, 4, 0, 4, 0, 48, 18, 4, 0, 4, 0, 160, 12, 2, 2, 55,
|
||||
240, 2, 1, 0, 2, 1, 0, 48, 0,
|
||||
],
|
||||
);
|
||||
map.insert(vec![177], vec![0, 1, 0, 2, 0, 1, 0]);
|
||||
map.insert(
|
||||
vec![389],
|
||||
vec![
|
||||
48, 132, 0, 0, 0, 32, 32, 16, 118, 56, 64, 0, 0, 2, 64, 64, 0, 1, 0, 0, 16, 0, 32, 16,
|
||||
0, 32, 22, 64, 16, 16, 8, 112, 8, 64, 0, 0, 0,
|
||||
48, 132, 0, 0, 0, 45, 2, 1, 7, 99, 132, 0, 0, 0, 36, 4, 0, 10, 1, 0, 10, 1, 0, 2, 1, 0,
|
||||
2, 1, 100, 1, 1, 0, 135, 11, 190, 204, 160, 132, 0, 0, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
vec![427],
|
||||
vec![
|
||||
2, 1, 0, 0, 96, 0, 0, 0, 0, 0, 16, 0, 32, 0, 0, 1, 80, 0, 112, 0, 0, 0,
|
||||
2, 1, 0, 0, 96, 0, 0, 0, 0, 0, 16, 0, 46, 0, 0, 0, 21, 236, 238, 206, 174, 0, 7, 222,
|
||||
250, 0, 0, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
@@ -2833,34 +2842,36 @@ fn generated_data() -> BTreeMap<Vec<u16>, Vec<u8>> {
|
||||
12446, 12546, 12646, 12746, 12846, 12946, 13046,
|
||||
],
|
||||
vec![
|
||||
22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 1, 0, 0, 32, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 119,
|
||||
116, 1, 136, 34, 0, 24, 147, 8, 6, 66, 146, 38, 64, 136, 22, 137, 25, 48, 0, 0, 0, 32,
|
||||
2, 1, 0,
|
||||
22, 254, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 1, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 42, 254,
|
||||
253, 0, 0, 0, 0, 124, 119, 64, 30, 138, 200, 34, 160, 160, 24, 255, 147, 8, 202, 172,
|
||||
10, 100, 47, 201, 34, 100, 188, 8, 168, 22, 137, 25, 63, 0, 0, 0, 2, 0, 47, 1, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
vec![500],
|
||||
vec![
|
||||
0, 17, 34, 51, 68, 85, 102, 119, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 2, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 152, 1, 1, 0, 4, 3, 0, 0, 36, 1, 1, 0,
|
||||
0, 128, 1, 0, 5, 128, 2, 0, 2, 128, 3, 0, 1, 128, 4, 0, 2, 128, 0, 0, 16, 0, 0, 4, 0,
|
||||
0, 0, 1, 3, 0, 0, 36, 2, 1, 0, 0, 128, 1, 0, 5, 128, 2, 0, 1, 128, 3, 0, 1, 128, 4, 0,
|
||||
2, 128, 0, 0, 16, 0, 0, 4, 0, 0, 0, 1, 3, 0, 0, 36, 3, 1, 0, 0, 128, 1, 0, 1, 128, 2,
|
||||
0, 2, 128, 3, 0, 1, 128, 4, 0, 2, 128, 0, 0, 16, 0, 0, 4, 0, 0, 0, 1, 0, 0, 0, 36, 4,
|
||||
1, 0, 0, 128, 1, 0, 1, 128, 2, 0, 1, 128, 3, 0, 1, 128, 4, 0, 2, 128, 0, 0, 16, 0, 0,
|
||||
4, 0, 0, 0, 1,
|
||||
0, 192, 0, 0, 0, 164, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 152, 1, 1, 0, 4, 3, 0, 0, 36, 1,
|
||||
1, 0, 0, 128, 1, 0, 5, 128, 2, 0, 2, 128, 3, 0, 1, 128, 4, 0, 2, 128, 11, 0, 1, 0, 12,
|
||||
0, 4, 0, 0, 0, 1, 3, 0, 0, 36, 2, 1, 0, 0, 128, 1, 0, 5, 128, 2, 0, 1, 128, 3, 0, 1,
|
||||
128, 4, 0, 2, 128, 11, 0, 1, 0, 12, 0, 4, 0, 0, 0, 1, 3, 0, 0, 36, 3, 1, 0, 0, 128, 1,
|
||||
0, 1, 128, 2, 0, 2, 128, 3, 0, 1, 128, 4, 0, 2, 128, 11, 0, 1, 0, 12, 0, 4, 0, 0, 0, 1,
|
||||
0, 0, 0, 36, 4, 1, 0, 0, 128, 1, 0, 1, 128, 2, 0, 1, 128, 3, 0, 1, 128, 4, 0, 2, 128,
|
||||
11, 0, 1, 0, 12, 0, 4, 0, 0, 0, 1,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
vec![500, 4500],
|
||||
vec![
|
||||
49, 39, 3, 129, 9, 137, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
5, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 80, 1, 1, 0, 2, 3, 0, 0, 36, 1, 1, 0, 0, 128, 1, 0,
|
||||
5, 128, 2, 0, 2, 128, 4, 0, 2, 128, 3, 0, 3, 128, 0, 0, 16, 0, 0, 4, 0, 0, 1, 0, 0, 0,
|
||||
2, 64, 32, 16, 0, 8, 0, 16, 0, 88, 0, 32, 0, 24, 0, 64, 0, 40, 0, 48, 0, 56, 0, 0, 1,
|
||||
0, 0, 0, 64, 0, 0, 16, 0, 0, 1, 129, 37, 22, 144, 89, 145, 119, 150, 88, 116, 97, 0, 0,
|
||||
0, 4, 0, 0, 1, 68, 4, 135, 86, 136, 82, 87, 112, 6, 35, 0, 0, 1, 73, 8, 9, 19, 105, 96,
|
||||
134, 56, 21, 66, 113, 0, 0, 0, 20, 38, 36, 67, 134, 19, 23, 35, 99, 8, 25,
|
||||
49, 39, 252, 176, 56, 16, 158, 137, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 2, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 204, 13, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 80, 1, 1, 0, 2, 3, 0, 0, 36,
|
||||
1, 1, 0, 0, 128, 1, 0, 5, 128, 2, 0, 2, 128, 4, 0, 2, 128, 3, 0, 3, 128, 11, 0, 1, 0,
|
||||
12, 0, 4, 0, 0, 14, 16, 0, 0, 0, 36, 2, 1, 0, 0, 128, 1, 0, 5, 128, 2, 0, 1, 128, 4, 0,
|
||||
2, 128, 3, 0, 3, 128, 11, 0, 1, 0, 12, 0, 4, 0, 0, 14, 16, 13, 0, 0, 24, 30, 43, 81,
|
||||
105, 5, 153, 28, 125, 124, 150, 252, 191, 181, 135, 228, 97, 0, 0, 0, 4, 13, 0, 0, 20,
|
||||
64, 72, 183, 213, 110, 188, 232, 133, 37, 231, 222, 127, 0, 214, 194, 211, 13, 0, 0,
|
||||
20, 144, 203, 128, 145, 62, 187, 105, 110, 8, 99, 129, 181, 236, 66, 123, 31, 0, 0, 0,
|
||||
20, 38, 36, 77, 56, 237, 219, 97, 179, 23, 42, 54, 227, 208, 207, 184, 25,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
@@ -2872,15 +2883,16 @@ fn generated_data() -> BTreeMap<Vec<u16>, Vec<u8>> {
|
||||
map.insert(
|
||||
vec![623],
|
||||
vec![
|
||||
6, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 32, 24, 136, 16, 3, 136, 4,
|
||||
6, 0, 255, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 32, 24, 200, 129, 0, 56, 142, 4, 181,
|
||||
],
|
||||
);
|
||||
map.insert(vec![626], vec![18, 112, 1]);
|
||||
map.insert(vec![626], vec![225, 39, 0, 26, 170, 170]);
|
||||
map.insert(vec![1194], vec![56, 1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0]);
|
||||
map.insert(
|
||||
vec![1604],
|
||||
vec![
|
||||
16, 0, 19, 0, 40, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
30, 0, 1, 48, 2, 253, 168, 227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
@@ -2890,16 +2902,19 @@ fn generated_data() -> BTreeMap<Vec<u16>, Vec<u8>> {
|
||||
map.insert(
|
||||
vec![1701],
|
||||
vec![
|
||||
128, 32, 3, 0, 0, 0, 0, 0, 0, 0, 0, 128, 8, 0, 0, 0, 0, 0, 1, 128, 8, 0, 0, 0, 2, 1, 0,
|
||||
128, 0, 0, 0, 0, 120, 0, 0, 0, 0, 3, 0, 0, 0, 3, 128, 8, 0, 0, 0, 9, 0, 0,
|
||||
200, 2, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 128, 8, 0, 0, 0, 0, 0, 1, 128, 8, 0, 0, 0, 2, 1,
|
||||
0, 128, 14, 0, 0, 0, 7, 202, 128, 10, 0, 0, 0, 3, 0, 0, 0, 3, 128, 8, 0, 0, 0, 9, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(vec![1900], vec![17, 35, 146, 85, 37, 82, 80, 25, 0]);
|
||||
map.insert(
|
||||
vec![1900],
|
||||
vec![234, 193, 18, 57, 37, 82, 85, 37, 1, 144, 10, 221, 206, 93],
|
||||
);
|
||||
map.insert(
|
||||
vec![2049],
|
||||
vec![
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 134, 48, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 134, 163, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
@@ -2908,61 +2923,75 @@ fn generated_data() -> BTreeMap<Vec<u16>, Vec<u8>> {
|
||||
);
|
||||
map.insert(
|
||||
vec![2302],
|
||||
vec![0, 2, 18, 96, 18, 96, 144, 96, 38, 87, 64, 134, 132, 130],
|
||||
vec![
|
||||
0, 2, 241, 38, 1, 38, 240, 144, 166, 240, 38, 87, 78, 172, 160, 236, 248, 104, 228,
|
||||
141, 33,
|
||||
],
|
||||
);
|
||||
map.insert(vec![3283], vec![1, 64, 1, 3]);
|
||||
map.insert(vec![3386], vec![64, 16, 0, 72, 0]);
|
||||
map.insert(vec![3386], vec![78, 1, 0, 4, 222, 254, 200, 0]);
|
||||
map.insert(
|
||||
vec![3478],
|
||||
vec![0, 1, 0, 0, 33, 18, 68, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
vec![
|
||||
0, 1, 0, 0, 33, 18, 164, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
vec![3784],
|
||||
vec![
|
||||
1, 117, 117, 49, 49, 112, 33, 41, 148, 25, 8, 88, 36, 1, 17, 150, 115, 98, 129, 50, 9,
|
||||
18, 117,
|
||||
1, 231, 229, 117, 49, 163, 23, 11, 33, 207, 191, 43, 153, 78, 221, 25, 172, 222, 8, 95,
|
||||
139, 36, 10, 17, 25, 182, 115, 111, 173, 40, 19, 210, 10, 185, 18, 117,
|
||||
],
|
||||
);
|
||||
map.insert(vec![4665, 4666, 4672, 6429], vec![70]);
|
||||
map.insert(vec![4665, 4666, 4672, 6429], vec![228, 96]);
|
||||
map.insert(vec![5351], vec![0, 0]);
|
||||
map.insert(
|
||||
vec![5353],
|
||||
vec![0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 9, 7, 4, 5, 0, 0, 0, 0],
|
||||
vec![
|
||||
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 9, 236, 224, 125, 208, 77, 5, 202, 0, 0, 12, 0, 1,
|
||||
],
|
||||
);
|
||||
map.insert(vec![5632], vec![]);
|
||||
map.insert(vec![5683], vec![1, 1, 4]);
|
||||
map.insert(vec![6481], vec![0, 0]);
|
||||
map.insert(vec![7777], vec![0]);
|
||||
map.insert(vec![5683], vec![1, 1, 206, 187, 224, 76]);
|
||||
map.insert(vec![6481], vec![190, 0, 0]);
|
||||
map.insert(vec![7777], vec![224]);
|
||||
map.insert(
|
||||
vec![8767],
|
||||
vec![
|
||||
64, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 2, 133, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
|
||||
0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
244, 190, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 43, 168, 94, 174, 160, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 202, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
vec![9987],
|
||||
vec![
|
||||
5, 113, 105, 17, 152, 144, 0, 0, 0, 0, 41, 116, 132, 87, 153, 8, 25, 65, 1, 98, 50, 99,
|
||||
72, 52, 72, 56, 133, 20, 86, 144, 149, 35, 48, 9, 114, 23, 18, 64, 97, 23, 101, 118,
|
||||
72, 82, 130, 98, 54, 81, 135, 23, 56, 56, 18, 115, 71, 115, 80, 153, 114, 36, 144, 33,
|
||||
118, 97, 39, 38, 49, 113, 149, 150, 153, 149, 112, 80, 57, 69, 96, 67, 20, 89, 33, 67,
|
||||
3, 35, 50, 88, 99, 152, 133, 38, 85, 32, 37, 151, 34, 64, 146, 137, 65, 23, 38,
|
||||
5, 202, 127, 22, 156, 17, 249, 137, 0, 0, 0, 0, 2, 157, 116, 139, 69, 170, 123, 239,
|
||||
185, 158, 254, 173, 8, 25, 186, 207, 65, 224, 22, 162, 50, 108, 243, 207, 244, 142, 60,
|
||||
68, 131, 200, 141, 81, 69, 111, 144, 149, 35, 62, 0, 151, 43, 28, 113, 178, 78, 192,
|
||||
97, 241, 215, 111, 197, 126, 246, 72, 82, 191, 130, 106, 162, 59, 101, 170, 24, 122,
|
||||
23, 56, 195, 129, 39, 195, 71, 252, 167, 53, 186, 252, 15, 157, 157, 114, 36, 157, 252,
|
||||
2, 23, 109, 107, 177, 45, 114, 198, 227, 23, 28, 149, 217, 105, 153, 87, 206, 221, 223,
|
||||
5, 220, 3, 148, 86, 4, 58, 20, 229, 173, 154, 43, 20, 48, 58, 35, 163, 37, 173, 232,
|
||||
230, 57, 138, 133, 42, 198, 223, 229, 93, 45, 160, 47, 93, 156, 215, 43, 36, 251, 176,
|
||||
156, 194, 186, 137, 180, 27, 23, 162, 182,
|
||||
],
|
||||
);
|
||||
map.insert(vec![10001], vec![1, 0, 0, 0]);
|
||||
map.insert(vec![10080], vec![38, 0, 0, 0, 0, 0, 0]);
|
||||
map.insert(
|
||||
vec![10080],
|
||||
vec![170, 218, 38, 234, 222, 0, 0, 0, 0, 0, 14, 14, 206],
|
||||
);
|
||||
map.insert(vec![11211], vec![0, 16, 0, 1, 0]);
|
||||
map.insert(
|
||||
vec![17185],
|
||||
vec![
|
||||
114, 55, 114, 55, 0, 0, 0, 0, 0, 0, 0, 2, 85, 85, 85, 85, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 16, 0, 0, 0, 48, 0, 0, 0, 48, 0, 0, 0,
|
||||
32, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 85, 16, 0, 0, 0, 60, 0, 0, 0, 3, 0,
|
||||
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
],
|
||||
);
|
||||
map.insert(
|
||||
@@ -2970,23 +2999,25 @@ fn generated_data() -> BTreeMap<Vec<u16>, Vec<u8>> {
|
||||
26000, 26001, 26002, 26003, 27960, 27961, 27962, 27963, 30720, 30721, 30722, 30723,
|
||||
44400,
|
||||
],
|
||||
vec![],
|
||||
vec![255, 255, 255, 255, 234],
|
||||
);
|
||||
map.insert(
|
||||
vec![
|
||||
27015, 27016, 27017, 27018, 27019, 27020, 27021, 27022, 27023, 27024, 27025, 27026,
|
||||
27027, 27028, 27029,
|
||||
],
|
||||
vec![0],
|
||||
vec![255, 255, 255, 255, 206, 238, 224],
|
||||
);
|
||||
map.insert(vec![27444], vec![68]);
|
||||
map.insert(vec![27910, 27911, 27912, 27913], vec![]);
|
||||
map.insert(vec![27444], vec![68, 173]);
|
||||
map.insert(vec![27910, 27911, 27912, 27913], vec![255, 255, 255, 255]);
|
||||
map.insert(
|
||||
vec![31337],
|
||||
vec![99, 18, 22, 113, 51, 133, 88, 98, 117, 73, 147, 37],
|
||||
vec![
|
||||
206, 99, 209, 210, 22, 231, 19, 207, 56, 165, 165, 134, 178, 117, 75, 153, 170, 50, 88,
|
||||
],
|
||||
);
|
||||
map.insert(vec![34555], vec![]);
|
||||
map.insert(vec![64738], vec![0, 0, 0, 0]);
|
||||
map.insert(vec![64738], vec![0, 0, 0, 0, 171, 205, 239]);
|
||||
map
|
||||
}
|
||||
|
||||
|
||||
+14
-2
@@ -89,6 +89,10 @@ pub struct Opts {
|
||||
#[arg(short, long)]
|
||||
pub no_config: bool,
|
||||
|
||||
/// Hide the banner
|
||||
#[arg(long)]
|
||||
pub no_banner: bool,
|
||||
|
||||
/// Custom path to config file
|
||||
#[arg(short, long, value_parser)]
|
||||
pub config_path: Option<PathBuf>,
|
||||
@@ -151,6 +155,10 @@ pub struct Opts {
|
||||
#[arg(short, long, value_delimiter = ',')]
|
||||
pub exclude_ports: Option<Vec<u16>>,
|
||||
|
||||
/// A list of comma separated CIDRs, IPs, or hosts to be excluded from scanning.
|
||||
#[arg(short = 'x', long = "exclude-addresses", value_delimiter = ',')]
|
||||
pub exclude_addresses: Option<Vec<String>>,
|
||||
|
||||
/// UDP scanning mode, finds UDP ports that send back responses
|
||||
#[arg(long)]
|
||||
pub udp: bool,
|
||||
@@ -217,7 +225,7 @@ impl Opts {
|
||||
self.ports = Some(ports);
|
||||
}
|
||||
|
||||
merge_optional!(range, resolver, ulimit, exclude_ports);
|
||||
merge_optional!(range, resolver, ulimit, exclude_ports, exclude_addresses);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,10 +245,12 @@ impl Default for Opts {
|
||||
resolver: None,
|
||||
scan_order: ScanOrder::Serial,
|
||||
no_config: true,
|
||||
no_banner: false,
|
||||
top: false,
|
||||
scripts: ScriptsRequired::Default,
|
||||
config_path: None,
|
||||
exclude_ports: None,
|
||||
exclude_addresses: None,
|
||||
udp: false,
|
||||
}
|
||||
}
|
||||
@@ -266,6 +276,7 @@ pub struct Config {
|
||||
command: Option<Vec<String>>,
|
||||
scripts: Option<ScriptsRequired>,
|
||||
exclude_ports: Option<Vec<u16>>,
|
||||
exclude_addresses: Option<Vec<String>>,
|
||||
udp: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -281,7 +292,7 @@ impl Config {
|
||||
/// addresses = ["127.0.0.1", "127.0.0.1"]
|
||||
/// ports = [80, 443, 8080]
|
||||
/// greppable = true
|
||||
/// scan_order: "Serial"
|
||||
/// scan_order = "Serial"
|
||||
/// exclude_ports = [8080, 9090, 80]
|
||||
/// udp = false
|
||||
///
|
||||
@@ -340,6 +351,7 @@ mod tests {
|
||||
scan_order: Some(ScanOrder::Random),
|
||||
scripts: None,
|
||||
exclude_ports: None,
|
||||
exclude_addresses: None,
|
||||
udp: Some(false),
|
||||
}
|
||||
}
|
||||
|
||||
+10
-10
@@ -21,17 +21,17 @@
|
||||
//! start: 1,
|
||||
//! end: 1_000,
|
||||
//! };
|
||||
//! let strategy = PortStrategy::pick(&Some(range), None, ScanOrder::Random);
|
||||
//! let strategy = PortStrategy::pick(&Some(range), None, ScanOrder::Random); // can be serial, random or manual https://github.com/RustScan/RustScan/blob/master/src/port_strategy/mod.rs
|
||||
//! let scanner = Scanner::new(
|
||||
//! &addrs,
|
||||
//! 10,
|
||||
//! Duration::from_millis(100),
|
||||
//! 1,
|
||||
//! true,
|
||||
//! strategy,
|
||||
//! true,
|
||||
//! vec![9000],
|
||||
//! false,
|
||||
//! &addrs, // the addresses to scan
|
||||
//! 10, // batch_size is how many ports at a time should be scanned
|
||||
//! Duration::from_millis(100), //T imeout is the time RustScan should wait before declaring a port closed. As datatype Duration.
|
||||
//! 1, // Tries, how many retries should RustScan do?
|
||||
//! true, // greppable is whether or not RustScan should print things, or wait until the end to print only the ip
|
||||
//! strategy, // the port strategy used
|
||||
//! true, // accessible, should the output be A11Y compliant?
|
||||
//! vec![9000], // What ports should RustScan exclude?
|
||||
//! false, // is this a UDP scan?
|
||||
//! );
|
||||
//!
|
||||
//! let scan_result = block_on(scanner.run());
|
||||
|
||||
+40
-35
@@ -35,6 +35,9 @@ extern crate log;
|
||||
/// Faster Nmap scanning with Rust
|
||||
/// If you're looking for the actual scanning, check out the module Scanner
|
||||
fn main() {
|
||||
#[cfg(not(unix))]
|
||||
let _ = ansi_term::enable_ansi_support();
|
||||
|
||||
env_logger::init();
|
||||
let mut benchmarks = Benchmark::init();
|
||||
let mut rustscan_bench = NamedTimer::start("RustScan");
|
||||
@@ -59,7 +62,7 @@ fn main() {
|
||||
|
||||
debug!("Scripts initialized {:?}", &scripts_to_run);
|
||||
|
||||
if !opts.greppable && !opts.accessible {
|
||||
if !opts.greppable && !opts.accessible && !opts.no_banner {
|
||||
print_opening(&opts);
|
||||
}
|
||||
|
||||
@@ -80,11 +83,6 @@ fn main() {
|
||||
#[cfg(not(unix))]
|
||||
let batch_size: u16 = AVERAGE_BATCH_SIZE;
|
||||
|
||||
// Added by wasuaje - 01/26/2024:
|
||||
// exclude_ports is an exclusion port list
|
||||
//
|
||||
// Added by brendanglancy - 5/19/2024:
|
||||
// udp is an option to do a udp scan
|
||||
let scanner = Scanner::new(
|
||||
&ips,
|
||||
batch_size,
|
||||
@@ -197,22 +195,17 @@ fn main() {
|
||||
#[allow(clippy::items_after_statements, clippy::needless_raw_string_hashes)]
|
||||
fn print_opening(opts: &Opts) {
|
||||
debug!("Printing opening");
|
||||
let s = format!(
|
||||
"{}\n{}\n{}\n{}\n{}",
|
||||
r#".----. .-. .-. .----..---. .----. .---. .--. .-. .-."#,
|
||||
r#"| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |"#,
|
||||
r#"| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |"#,
|
||||
r#"`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'"#,
|
||||
r#"The Modern Day Port Scanner."#
|
||||
);
|
||||
let s = r#".----. .-. .-. .----..---. .----. .---. .--. .-. .-.
|
||||
| {} }| { } |{ {__ {_ _}{ {__ / ___} / {} \ | `| |
|
||||
| .-. \| {_} |.-._} } | | .-._} }\ }/ /\ \| |\ |
|
||||
`-' `-'`-----'`----' `-' `----' `---' `-' `-'`-' `-'
|
||||
The Modern Day Port Scanner."#;
|
||||
|
||||
println!("{}", s.gradient(Color::Green).bold());
|
||||
let info = format!(
|
||||
"{}\n{}\n{}\n{}",
|
||||
r#"________________________________________"#,
|
||||
r#": http://discord.skerritt.blog :"#,
|
||||
r#": https://github.com/RustScan/RustScan :"#,
|
||||
r#" --------------------------------------"#
|
||||
);
|
||||
let info = r#"________________________________________
|
||||
: http://discord.skerritt.blog :
|
||||
: https://github.com/RustScan/RustScan :
|
||||
--------------------------------------"#;
|
||||
println!("{}", info.gradient(Color::Yellow).bold());
|
||||
funny_opening!();
|
||||
|
||||
@@ -302,8 +295,10 @@ mod tests {
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn batch_size_lowered() {
|
||||
let mut opts = Opts::default();
|
||||
opts.batch_size = 50_000;
|
||||
let opts = Opts {
|
||||
batch_size: 50_000,
|
||||
..Default::default()
|
||||
};
|
||||
let batch_size = infer_batch_size(&opts, 120);
|
||||
|
||||
assert!(batch_size < opts.batch_size);
|
||||
@@ -312,8 +307,10 @@ mod tests {
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn batch_size_lowered_average_size() {
|
||||
let mut opts = Opts::default();
|
||||
opts.batch_size = 50_000;
|
||||
let opts = Opts {
|
||||
batch_size: 50_000,
|
||||
..Default::default()
|
||||
};
|
||||
let batch_size = infer_batch_size(&opts, 9_000);
|
||||
|
||||
assert!(batch_size == 3_000);
|
||||
@@ -323,8 +320,10 @@ mod tests {
|
||||
fn batch_size_equals_ulimit_lowered() {
|
||||
// because ulimit and batch size are same size, batch size is lowered
|
||||
// to ULIMIT - 100
|
||||
let mut opts = Opts::default();
|
||||
opts.batch_size = 50_000;
|
||||
let opts = Opts {
|
||||
batch_size: 50_000,
|
||||
..Default::default()
|
||||
};
|
||||
let batch_size = infer_batch_size(&opts, 5_000);
|
||||
|
||||
assert!(batch_size == 4_900);
|
||||
@@ -333,9 +332,11 @@ mod tests {
|
||||
#[cfg(unix)]
|
||||
fn batch_size_adjusted_2000() {
|
||||
// ulimit == batch_size
|
||||
let mut opts = Opts::default();
|
||||
opts.batch_size = 50_000;
|
||||
opts.ulimit = Some(2_000);
|
||||
let opts = Opts {
|
||||
batch_size: 50_000,
|
||||
ulimit: Some(2_000),
|
||||
..Default::default()
|
||||
};
|
||||
let batch_size = adjust_ulimit_size(&opts);
|
||||
|
||||
assert!(batch_size == 2_000);
|
||||
@@ -344,9 +345,11 @@ mod tests {
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_high_ulimit_no_greppable_mode() {
|
||||
let mut opts = Opts::default();
|
||||
opts.batch_size = 10;
|
||||
opts.greppable = false;
|
||||
let opts = Opts {
|
||||
batch_size: 10,
|
||||
greppable: false,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let batch_size = infer_batch_size(&opts, 1_000_000);
|
||||
|
||||
@@ -355,8 +358,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_print_opening_no_panic() {
|
||||
let mut opts = Opts::default();
|
||||
opts.ulimit = Some(2_000);
|
||||
let opts = Opts {
|
||||
ulimit: Some(2_000),
|
||||
..Default::default()
|
||||
};
|
||||
// print opening should not panic
|
||||
print_opening(&opts);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Provides a means to hold configuration options specifically for port scanning.
|
||||
mod range_iterator;
|
||||
use crate::input::{PortRange, ScanOrder};
|
||||
use rand::rng;
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::thread_rng;
|
||||
use range_iterator::RangeIterator;
|
||||
|
||||
/// Represents options of port scanning.
|
||||
@@ -35,7 +35,7 @@ impl PortStrategy {
|
||||
}
|
||||
ScanOrder::Serial => PortStrategy::Manual(ports.unwrap()),
|
||||
ScanOrder::Random => {
|
||||
let mut rng = thread_rng();
|
||||
let mut rng = rng();
|
||||
let mut ports = ports.unwrap();
|
||||
ports.shuffle(&mut rng);
|
||||
PortStrategy::Manual(ports)
|
||||
@@ -105,7 +105,7 @@ mod tests {
|
||||
let range = PortRange { start: 1, end: 100 };
|
||||
let strategy = PortStrategy::pick(&Some(range), None, ScanOrder::Serial);
|
||||
let result = strategy.order();
|
||||
let expected_range = (1..=100).into_iter().collect::<Vec<u16>>();
|
||||
let expected_range = (1..=100).collect::<Vec<u16>>();
|
||||
assert_eq!(expected_range, result);
|
||||
}
|
||||
#[test]
|
||||
@@ -113,7 +113,7 @@ mod tests {
|
||||
let range = PortRange { start: 1, end: 100 };
|
||||
let strategy = PortStrategy::pick(&Some(range), None, ScanOrder::Random);
|
||||
let mut result = strategy.order();
|
||||
let expected_range = (1..=100).into_iter().collect::<Vec<u16>>();
|
||||
let expected_range = (1..=100).collect::<Vec<u16>>();
|
||||
assert_ne!(expected_range, result);
|
||||
|
||||
result.sort_unstable();
|
||||
@@ -131,7 +131,7 @@ mod tests {
|
||||
fn random_strategy_with_ports() {
|
||||
let strategy = PortStrategy::pick(&None, Some((1..10).collect()), ScanOrder::Random);
|
||||
let mut result = strategy.order();
|
||||
let expected_range = (1..10).into_iter().collect::<Vec<u16>>();
|
||||
let expected_range = (1..10).collect::<Vec<u16>>();
|
||||
assert_ne!(expected_range, result);
|
||||
|
||||
result.sort_unstable();
|
||||
|
||||
@@ -27,8 +27,8 @@ impl RangeIterator {
|
||||
|
||||
// Randomly choose a number within the range to be the first
|
||||
// and assign it as a pick.
|
||||
let mut rng = rand::thread_rng();
|
||||
let normalized_first_pick = rng.gen_range(0..normalized_end);
|
||||
let mut rng = rand::rng();
|
||||
let normalized_first_pick = rng.random_range(0..normalized_end);
|
||||
|
||||
Self {
|
||||
active: true,
|
||||
@@ -83,14 +83,14 @@ fn pick_random_coprime(end: u32) -> u32 {
|
||||
let range_boundary = end / 4;
|
||||
let lower_range = range_boundary;
|
||||
let upper_range = end - range_boundary;
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut candidate = rng.gen_range(lower_range..upper_range);
|
||||
let mut rng = rand::rng();
|
||||
let mut candidate = rng.random_range(lower_range..upper_range);
|
||||
|
||||
for _ in 0..10 {
|
||||
if end.gcd(candidate) == 1 {
|
||||
return candidate;
|
||||
}
|
||||
candidate = rng.gen_range(lower_range..upper_range);
|
||||
candidate = rng.random_range(lower_range..upper_range);
|
||||
}
|
||||
|
||||
end - 1
|
||||
@@ -103,23 +103,23 @@ mod tests {
|
||||
#[test]
|
||||
fn range_iterator_iterates_through_the_entire_range() {
|
||||
let result = generate_sorted_range(1, 10);
|
||||
let expected_range = (1..=10).into_iter().collect::<Vec<u16>>();
|
||||
let expected_range = (1..=10).collect::<Vec<u16>>();
|
||||
assert_eq!(expected_range, result);
|
||||
|
||||
let result = generate_sorted_range(1, 100);
|
||||
let expected_range = (1..=100).into_iter().collect::<Vec<u16>>();
|
||||
let expected_range = (1..=100).collect::<Vec<u16>>();
|
||||
assert_eq!(expected_range, result);
|
||||
|
||||
let result = generate_sorted_range(1, 1000);
|
||||
let expected_range = (1..=1000).into_iter().collect::<Vec<u16>>();
|
||||
let expected_range = (1..=1000).collect::<Vec<u16>>();
|
||||
assert_eq!(expected_range, result);
|
||||
|
||||
let result = generate_sorted_range(1, 65_535);
|
||||
let expected_range = (1..=65_535).into_iter().collect::<Vec<u16>>();
|
||||
let expected_range = (1..=65_535).collect::<Vec<u16>>();
|
||||
assert_eq!(expected_range, result);
|
||||
|
||||
let result = generate_sorted_range(1000, 2000);
|
||||
let expected_range = (1000..=2000).into_iter().collect::<Vec<u16>>();
|
||||
let expected_range = (1000..=2000).collect::<Vec<u16>>();
|
||||
assert_eq!(expected_range, result);
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -25,8 +25,6 @@ use std::{
|
||||
/// batch_size is how many ports at a time should be scanned
|
||||
/// Timeout is the time RustScan should wait before declaring a port closed. As datatype Duration.
|
||||
/// greppable is whether or not RustScan should print things, or wait until the end to print only the ip and open ports.
|
||||
/// Added by wasuaje - 01/26/2024:
|
||||
/// exclude_ports is an exclusion port list
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
#[derive(Debug)]
|
||||
pub struct Scanner {
|
||||
@@ -71,8 +69,6 @@ impl Scanner {
|
||||
/// Runs scan_range with chunk sizes
|
||||
/// If you want to run RustScan normally, this is the entry point used
|
||||
/// Returns all open ports as `Vec<u16>`
|
||||
/// Added by wasuaje - 01/26/2024:
|
||||
/// Filtering port against exclude port list
|
||||
pub async fn run(&self) -> Vec<SocketAddr> {
|
||||
let ports: Vec<u16> = self
|
||||
.port_strategy
|
||||
@@ -197,7 +193,10 @@ impl Scanner {
|
||||
}
|
||||
}
|
||||
|
||||
Ok(socket)
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("UDP scan timed-out for all tries on socket {}", socket),
|
||||
))
|
||||
}
|
||||
|
||||
/// Performs the connection to the socket with timeout
|
||||
@@ -223,7 +222,7 @@ impl Scanner {
|
||||
Ok(stream)
|
||||
}
|
||||
|
||||
/// Binds to a UDP socket so we can send and recieve packets
|
||||
/// Binds to a UDP socket so we can send and receive packets
|
||||
/// # Example
|
||||
///
|
||||
/// ```compile_fail
|
||||
|
||||
@@ -30,7 +30,7 @@ impl<'s> SocketIterator<'s> {
|
||||
}
|
||||
|
||||
#[allow(clippy::doc_link_with_quotes)]
|
||||
impl<'s> Iterator for SocketIterator<'s> {
|
||||
impl Iterator for SocketIterator<'_> {
|
||||
type Item = SocketAddr;
|
||||
|
||||
/// Returns a socket based on the combination of one of the provided
|
||||
|
||||
+46
-13
@@ -79,19 +79,21 @@ use crate::input::ScriptsRequired;
|
||||
use anyhow::{anyhow, Result};
|
||||
use log::debug;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::convert::TryInto;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{self, prelude::*};
|
||||
use std::net::IpAddr;
|
||||
use std::path::PathBuf;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::string::ToString;
|
||||
use subprocess::{Exec, ExitStatus};
|
||||
use text_placeholder::Template;
|
||||
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::process::ExitStatusExt;
|
||||
|
||||
static DEFAULT: &str = r#"tags = ["core_approved", "RustScan", "default"]
|
||||
developer = [ "RustScan", "https://github.com/RustScan" ]
|
||||
ports_separator = ","
|
||||
call_format = "nmap -vvv -p {{port}} {{ip}}"
|
||||
call_format = "nmap -vvv -p {{port}} -{{ipversion}} {{ip}}"
|
||||
"#;
|
||||
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
@@ -184,12 +186,14 @@ struct ExecPartsScript {
|
||||
script: String,
|
||||
ip: String,
|
||||
port: String,
|
||||
ipversion: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ExecParts {
|
||||
ip: String,
|
||||
port: String,
|
||||
ipversion: String,
|
||||
}
|
||||
|
||||
impl Script {
|
||||
@@ -244,17 +248,24 @@ impl Script {
|
||||
script: self.path.unwrap().to_str().unwrap().to_string(),
|
||||
ip: self.ip.to_string(),
|
||||
port: ports_str,
|
||||
ipversion: match &self.ip {
|
||||
IpAddr::V4(_) => String::from("4"),
|
||||
IpAddr::V6(_) => String::from("6"),
|
||||
},
|
||||
};
|
||||
to_run = default_template.fill_with_struct(&exec_parts_script)?;
|
||||
} else {
|
||||
let exec_parts: ExecParts = ExecParts {
|
||||
ip: self.ip.to_string(),
|
||||
port: ports_str,
|
||||
ipversion: match &self.ip {
|
||||
IpAddr::V4(_) => String::from("4"),
|
||||
IpAddr::V6(_) => String::from("6"),
|
||||
},
|
||||
};
|
||||
to_run = default_template.fill_with_struct(&exec_parts)?;
|
||||
}
|
||||
debug!("\nScript format to run {}", to_run);
|
||||
|
||||
execute_script(&to_run)
|
||||
}
|
||||
}
|
||||
@@ -262,19 +273,41 @@ impl Script {
|
||||
#[cfg(not(tarpaulin_include))]
|
||||
fn execute_script(script: &str) -> Result<String> {
|
||||
debug!("\nScript arguments {}", script);
|
||||
let process = Exec::shell(script);
|
||||
match process.capture() {
|
||||
Ok(c) => {
|
||||
let es = match c.exit_status {
|
||||
ExitStatus::Exited(c) => c.try_into().unwrap(),
|
||||
ExitStatus::Signaled(c) => c.into(),
|
||||
ExitStatus::Other(c) => c,
|
||||
ExitStatus::Undetermined => -1,
|
||||
|
||||
let (cmd, arg) = if cfg!(unix) {
|
||||
("sh", "-c")
|
||||
} else {
|
||||
("cmd.exe", "/c")
|
||||
};
|
||||
|
||||
match Command::new(cmd)
|
||||
.args([arg, script])
|
||||
.stdin(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.output()
|
||||
{
|
||||
Ok(output) => {
|
||||
let status = output.status;
|
||||
|
||||
let es = match status.code() {
|
||||
Some(code) => code,
|
||||
_ => {
|
||||
#[cfg(unix)]
|
||||
{
|
||||
status.signal().unwrap()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
return Err(anyhow!("Unknown exit status"));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if es != 0 {
|
||||
return Err(anyhow!("Exit code = {}", es));
|
||||
}
|
||||
Ok(c.stdout_str())
|
||||
Ok(String::from_utf8_lossy(&output.stdout).into_owned())
|
||||
}
|
||||
Err(error) => {
|
||||
debug!("Command error {}", error.to_string());
|
||||
|
||||
+2
-2
@@ -68,7 +68,7 @@ macro_rules! output {
|
||||
macro_rules! funny_opening {
|
||||
// prints a funny quote / opening
|
||||
() => {
|
||||
use rand::seq::SliceRandom;
|
||||
use rand::seq::IndexedRandom;
|
||||
let quotes = vec![
|
||||
"Nmap? More like slowmap.🐢",
|
||||
"🌍HACK THE PLANET🌍",
|
||||
@@ -98,7 +98,7 @@ macro_rules! funny_opening {
|
||||
"TreadStone was here 🚀",
|
||||
"With RustScan, I scan ports so fast, even my firewall gets whiplash 💨",
|
||||
];
|
||||
let random_quote = quotes.choose(&mut rand::thread_rng()).unwrap();
|
||||
let random_quote = quotes.choose(&mut rand::rng()).unwrap();
|
||||
|
||||
println!("{}\n", random_quote);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user