Created
August 15, 2025 19:54
-
-
Save zscole/3cd43f043416cc2154975d4f26bc2134 to your computer and use it in GitHub Desktop.
Captures network connections from VS Code and Cursor
This file contains hidden or 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
| #!/bin/bash | |
| # IDE Telemetry Monitor | |
| # Captures network connections from VS Code and Cursor | |
| # Run: ./telemetry_monitor.sh | |
| # Default: 60 seconds | |
| set -euo pipefail | |
| echo "IDE Telemetry Monitor" | |
| echo "====================" | |
| echo "Monitoring network connections from VS Code and Cursor..." | |
| echo "" | |
| # Check if lsof is available | |
| if ! command -v lsof &> /dev/null; then | |
| echo "Error: lsof command not found" | |
| exit 1 | |
| fi | |
| # Create output directory | |
| mkdir -p telemetry_captures | |
| TIMESTAMP=$(date +%Y%m%d_%H%M%S) | |
| OUTPUT_FILE="telemetry_captures/capture_${TIMESTAMP}.csv" | |
| # Duration in seconds (default 60) | |
| DURATION=${1:-60} | |
| echo "Capturing for $DURATION seconds..." | |
| echo "Process,PID,LocalAddress,RemoteAddress,State" > "$OUTPUT_FILE" | |
| # Capture connections every second | |
| for ((i=1; i<=DURATION; i++)); do | |
| # Capture VS Code and Cursor connections, exclude localhost | |
| lsof -i -n -P 2>/dev/null | grep -E "Code Helper|Cursor" | grep -v "127.0.0.1" | while IFS= read -r line; do | |
| process=$(echo "$line" | awk '{print $1}') | |
| pid=$(echo "$line" | awk '{print $2}') | |
| connection=$(echo "$line" | awk '{print $9}') | |
| state=$(echo "$line" | awk '{print $10}') | |
| # Parse connection string (format: local->remote) | |
| if [[ "$connection" == *"->"* ]]; then | |
| local_addr=$(echo "$connection" | cut -d'-' -f1) | |
| remote_addr=$(echo "$connection" | cut -d'>' -f2) | |
| echo "$process,$pid,$local_addr,$remote_addr,$state" >> "$OUTPUT_FILE" | |
| fi | |
| done | |
| # Show progress | |
| echo -ne "\rProgress: $i/$DURATION seconds" | |
| sleep 1 | |
| done | |
| echo "" | |
| echo "" | |
| echo "Analysis Results" | |
| echo "================" | |
| # Count unique connections per process | |
| echo "" | |
| echo "Unique persistent connections:" | |
| # VS Code connections | |
| vscode_count=$(grep "Code" "$OUTPUT_FILE" 2>/dev/null | cut -d',' -f4 | sort -u | wc -l | tr -d ' ') | |
| echo " VS Code: $vscode_count connections" | |
| # Cursor connections | |
| cursor_count=$(grep "Cursor" "$OUTPUT_FILE" 2>/dev/null | cut -d',' -f4 | sort -u | wc -l | tr -d ' ') | |
| echo " Cursor: $cursor_count connections" | |
| # Show unique endpoints | |
| echo "" | |
| echo "Remote endpoints identified:" | |
| echo "----------------------------" | |
| # Get unique IPs and resolve them | |
| grep -v "Process,PID" "$OUTPUT_FILE" | cut -d',' -f4 | cut -d':' -f1 | sort -u | while read -r ip; do | |
| if [[ ! -z "$ip" && "$ip" != "*" ]]; then | |
| # Try to resolve hostname | |
| hostname=$(nslookup "$ip" 2>/dev/null | grep 'name =' | head -1 | sed 's/.*name = //') | |
| if [[ ! -z "$hostname" ]]; then | |
| printf " %-16s → %s\n" "$ip" "$hostname" | |
| else | |
| # Check if it's likely AWS | |
| if [[ "$ip" == "3."* || "$ip" == "52."* || "$ip" == "54."* || "$ip" == "35."* || "$ip" == "44."* ]]; then | |
| printf " %-16s → AWS EC2\n" "$ip" | |
| elif [[ "$ip" == "20."* || "$ip" == "13."* ]]; then | |
| printf " %-16s → Microsoft/Azure\n" "$ip" | |
| elif [[ "$ip" == "140.82."* ]]; then | |
| printf " %-16s → GitHub\n" "$ip" | |
| elif [[ "$ip" == "104."* ]]; then | |
| printf " %-16s → Cloudflare\n" "$ip" | |
| else | |
| printf " %-16s → Unknown\n" "$ip" | |
| fi | |
| fi | |
| fi | |
| done | |
| # Summary stats | |
| total_events=$(grep -c "," "$OUTPUT_FILE" 2>/dev/null || echo "0") | |
| echo "" | |
| echo "Summary:" | |
| echo "--------" | |
| echo " Total samples: $((total_events - 1))" | |
| echo " Duration: ${DURATION} seconds" | |
| echo " Data saved to: $OUTPUT_FILE" | |
| # Privacy implications | |
| echo "" | |
| echo "Privacy implications:" | |
| echo "--------------------" | |
| if [[ $cursor_count -gt 0 ]]; then | |
| echo " • Cursor maintains $cursor_count persistent connections" | |
| echo " All traffic routes through AWS EC2" | |
| fi | |
| if [[ $vscode_count -gt 0 ]]; then | |
| echo " • VS Code maintains $vscode_count persistent connections" | |
| echo " Telemetry goes to Microsoft/GitHub" | |
| fi | |
| echo "" | |
| echo "To reduce telemetry:" | |
| echo "-------------------" | |
| echo " VS Code: settings.json → \"telemetry.telemetryLevel\": \"off\"" | |
| echo " (Note: Extensions ignore this setting)" | |
| echo "" | |
| echo " Cursor: Privacy mode requires Business plan (\$40/month)" | |
| echo "" | |
| echo " Block at network level in /etc/hosts:" | |
| echo " 0.0.0.0 dc.services.visualstudio.com" | |
| echo " 0.0.0.0 api2.cursor.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment