Repository navigation
Expand file tree
/
Copy pathstart_mac.sh
More file actions
executable file
·57 lines (46 loc) · 2.05 KB
/
Copy pathstart_mac.sh
File metadata and controls
executable file
·57 lines (46 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# ═══════════════════════════════════════════════════════
# NetControl - macOS Launcher
# Enables IP forwarding and runs with sudo
# ═══════════════════════════════════════════════════════
set -e
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
CYAN='\033[0;36m'
NC='\033[0m'
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$SCRIPT_DIR/NetControl"
BINARY="$PROJECT_DIR/bin/Release/net8.0/NetControl"
echo -e "${CYAN}"
echo "╔══════════════════════════════════════╗"
echo "║ NetControl - macOS Launcher ║"
echo "╚══════════════════════════════════════╝"
echo -e "${NC}"
# ── Check if built ──
if [ ! -f "$BINARY" ] && [ ! -f "$BINARY.dll" ]; then
echo -e "${RED}[ERROR] NetControl not built. Run ./install_mac.sh first.${NC}"
exit 1
fi
# ── Check for root ──
if [ "$EUID" -ne 0 ]; then
echo -e "${YELLOW}[!] NetControl requires root privileges for network access.${NC}"
echo -e "${YELLOW} Relaunching with sudo...${NC}"
echo ""
exec sudo bash "$0" "$@"
fi
# ── Enable IP forwarding (required for MITM on macOS) ──
echo -e "${YELLOW}[1/2] Enabling IP forwarding...${NC}"
CURRENT_FWD=$(sysctl -n net.inet.ip.forwarding)
sysctl -w net.inet.ip.forwarding=1 > /dev/null 2>&1
echo -e "${GREEN}[OK] IP forwarding enabled.${NC}"
# ── Launch ──
echo -e "${YELLOW}[2/2] Launching NetControl...${NC}"
echo ""
cd "$PROJECT_DIR"
dotnet run --configuration Release --no-build
EXIT_CODE=$?
# ── Restore IP forwarding to previous state ──
sysctl -w net.inet.ip.forwarding=$CURRENT_FWD > /dev/null 2>&1
echo -e "${GREEN}[OK] IP forwarding restored to previous state ($CURRENT_FWD).${NC}"
exit $EXIT_CODE