@intentsolutionsio/penetration-tester 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,199 @@
1
+ #!/usr/bin/env bash
2
+ # setup_pentest_env.sh - Set up the penetration testing environment
3
+ # Installs Python dependencies and verifies tool availability.
4
+ #
5
+ # Usage:
6
+ # ./setup_pentest_env.sh [--venv]
7
+ #
8
+ # Options:
9
+ # --venv Create and use a virtual environment (recommended)
10
+
11
+ set -euo pipefail
12
+
13
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
+ REQUIREMENTS="$SCRIPT_DIR/requirements.txt"
15
+ MIN_PYTHON_MAJOR=3
16
+ MIN_PYTHON_MINOR=9
17
+
18
+ # Colors
19
+ RED='\033[0;31m'
20
+ GREEN='\033[0;32m'
21
+ YELLOW='\033[1;33m'
22
+ BLUE='\033[0;34m'
23
+ NC='\033[0m'
24
+
25
+ info() { printf "${BLUE}[*]${NC} %s\n" "$1"; }
26
+ ok() { printf "${GREEN}[+]${NC} %s\n" "$1"; }
27
+ warn() { printf "${YELLOW}[!]${NC} %s\n" "$1"; }
28
+ fail() { printf "${RED}[-]${NC} %s\n" "$1"; }
29
+
30
+ header() {
31
+ echo ""
32
+ echo "======================================"
33
+ echo " Penetration Tester - Environment Setup"
34
+ echo "======================================"
35
+ echo ""
36
+ }
37
+
38
+ check_python() {
39
+ info "Checking Python version..."
40
+
41
+ if ! command -v python3 &>/dev/null; then
42
+ fail "Python 3 is not installed."
43
+ echo " Install Python ${MIN_PYTHON_MAJOR}.${MIN_PYTHON_MINOR}+ from https://python.org"
44
+ return 1
45
+ fi
46
+
47
+ local version
48
+ version=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}')")
49
+ local major minor
50
+ major=$(python3 -c "import sys; print(sys.version_info.major)")
51
+ minor=$(python3 -c "import sys; print(sys.version_info.minor)")
52
+
53
+ if (( major < MIN_PYTHON_MAJOR )) || { (( major == MIN_PYTHON_MAJOR )) && (( minor < MIN_PYTHON_MINOR )); }; then
54
+ fail "Python $version found, but ${MIN_PYTHON_MAJOR}.${MIN_PYTHON_MINOR}+ is required."
55
+ return 1
56
+ fi
57
+
58
+ ok "Python $version"
59
+ }
60
+
61
+ setup_venv() {
62
+ local venv_dir="$SCRIPT_DIR/.venv"
63
+
64
+ if [[ -d "$venv_dir" ]]; then
65
+ info "Activating existing virtual environment..."
66
+ else
67
+ info "Creating virtual environment at $venv_dir..."
68
+ python3 -m venv "$venv_dir"
69
+ fi
70
+
71
+ # shellcheck disable=SC1091
72
+ source "$venv_dir/bin/activate"
73
+ ok "Virtual environment active: $venv_dir"
74
+ }
75
+
76
+ install_deps() {
77
+ info "Installing Python dependencies from requirements.txt..."
78
+
79
+ if [[ ! -f "$REQUIREMENTS" ]]; then
80
+ fail "requirements.txt not found at $REQUIREMENTS"
81
+ return 1
82
+ fi
83
+
84
+ if pip install -r "$REQUIREMENTS" --quiet 2>/dev/null; then
85
+ ok "All dependencies installed."
86
+ else
87
+ fail "Failed to install some dependencies. Try: pip install -r $REQUIREMENTS"
88
+ return 1
89
+ fi
90
+ }
91
+
92
+ verify_tool() {
93
+ local name="$1"
94
+ local cmd="$2"
95
+
96
+ if eval "$cmd" &>/dev/null; then
97
+ local ver
98
+ ver=$(eval "$cmd" 2>&1 | head -1)
99
+ ok "$name: $ver"
100
+ else
101
+ warn "$name: not available (optional — some scans may be limited)"
102
+ fi
103
+ }
104
+
105
+ verify_tools() {
106
+ info "Verifying tool availability..."
107
+ echo ""
108
+
109
+ verify_tool "bandit" "bandit --version"
110
+ verify_tool "pip-audit" "pip-audit --version"
111
+ verify_tool "npm" "npm --version"
112
+ verify_tool "nmap" "nmap --version"
113
+ verify_tool "curl" "curl --version"
114
+ verify_tool "openssl" "openssl version"
115
+ }
116
+
117
+ check_system_tools() {
118
+ info "Checking system tools..."
119
+
120
+ local missing=0
121
+ for tool in curl openssl; do
122
+ if command -v "$tool" &>/dev/null; then
123
+ ok "$tool is available"
124
+ else
125
+ warn "$tool is not installed (some checks may be limited)"
126
+ missing=$((missing + 1))
127
+ fi
128
+ done
129
+
130
+ return 0
131
+ }
132
+
133
+ print_summary() {
134
+ echo ""
135
+ echo "======================================"
136
+ echo " Setup Complete"
137
+ echo "======================================"
138
+ echo ""
139
+ echo "Available scanners:"
140
+ echo " - security_scanner.py HTTP headers, SSL/TLS, endpoint probing"
141
+ echo " - dependency_auditor.py npm audit, pip-audit wrapper"
142
+ echo " - code_security_scanner.py bandit + regex pattern analysis"
143
+ echo ""
144
+ echo "Quick start:"
145
+ echo " python3 $SCRIPT_DIR/security_scanner.py https://example.com"
146
+ echo " python3 $SCRIPT_DIR/dependency_auditor.py /path/to/project"
147
+ echo " python3 $SCRIPT_DIR/code_security_scanner.py /path/to/code"
148
+ echo ""
149
+ }
150
+
151
+ main() {
152
+ header
153
+
154
+ local use_venv=false
155
+ for arg in "$@"; do
156
+ case "$arg" in
157
+ --venv) use_venv=true ;;
158
+ --help|-h)
159
+ echo "Usage: $0 [--venv]"
160
+ echo ""
161
+ echo "Options:"
162
+ echo " --venv Create and use a virtual environment (recommended)"
163
+ echo " --help Show this help message"
164
+ exit 0
165
+ ;;
166
+ *)
167
+ fail "Unknown argument: $arg"
168
+ exit 1
169
+ ;;
170
+ esac
171
+ done
172
+
173
+ local errors=0
174
+
175
+ check_python || errors=$((errors + 1))
176
+
177
+ if (( errors > 0 )); then
178
+ fail "Cannot continue without Python ${MIN_PYTHON_MAJOR}.${MIN_PYTHON_MINOR}+."
179
+ exit 1
180
+ fi
181
+
182
+ if $use_venv; then
183
+ setup_venv
184
+ fi
185
+
186
+ install_deps || errors=$((errors + 1))
187
+ check_system_tools
188
+ verify_tools
189
+
190
+ if (( errors > 0 )); then
191
+ echo ""
192
+ warn "Setup completed with warnings. Some features may be limited."
193
+ exit 1
194
+ fi
195
+
196
+ print_summary
197
+ }
198
+
199
+ main "$@"