Skip to content

Commit 424ebe7

Browse files
committed
fix: Windows charmap crash + skip Python check in packaged builds
- Fixed fatal UnicodeEncodeError on Windows: banner box-drawing chars (U+2566 etc.) crash cp1252 console. Added sys.stdout UTF-8 reconfigure at import time + ASCII fallback banner on encode failure. - Applied UTF-8 fix to logger.py so all log output is safe on Windows. - Skip checkPythonDependency() when app.isPackaged — packaged builds use the self-contained wshawk-bridge binary, no system Python needed.
1 parent 1f47fe4 commit 424ebe7

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

desktop/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ function checkPythonDependency() {
157157
}
158158

159159
app.whenReady().then(() => {
160-
checkPythonDependency();
160+
// Only check for system Python in dev mode — packaged builds use
161+
// the self-contained wshawk-bridge binary (PyInstaller) which bundles
162+
// its own Python interpreter and all pip dependencies.
163+
if (!app.isPackaged) checkPythonDependency();
161164
startPythonSidecar();
162165
createWindow();
163166

wshawk/__main__.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@
1212
import time
1313
import re
1414
import os
15+
import sys
1516
from datetime import datetime
1617
from typing import List, Dict, Optional, Any
1718
from urllib.parse import urlparse
1819
import ssl
1920

21+
# Force UTF-8 output on Windows to prevent charmap encoding crashes
22+
if sys.platform == 'win32':
23+
try:
24+
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
25+
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
26+
except Exception:
27+
pass
28+
2029
from .logger import setup_logging, get_logger, VULN_LEVEL, SUCCESS_LEVEL, Colors
2130

2231
# Initialize logging on import
@@ -25,7 +34,8 @@
2534
class Logger:
2635
@staticmethod
2736
def banner():
28-
banner = f"""
37+
try:
38+
banner = f"""
2939
{Colors.CYAN}{Colors.BOLD}
3040
╦ ╦╔═╗╦ ╦╔═╗╦ ╦╦╔═
3141
║║║╚═╗╠═╣╠═╣║║║╠╩╗
@@ -35,7 +45,20 @@ def banner():
3545
{Colors.CYAN}Created by: Regaan (@regaan){Colors.END}
3646
{Colors.BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━{Colors.END}
3747
"""
38-
print(banner)
48+
print(banner)
49+
except UnicodeEncodeError:
50+
# ASCII fallback for terminals that can't render Unicode
51+
banner = f"""
52+
{Colors.CYAN}{Colors.BOLD}
53+
_ _ ___ _ _ ____ _ _ _ _
54+
| | | |__| |__| | | |_/
55+
|_/|_| | | | | | |_/|_| | \\_
56+
{Colors.END}
57+
{Colors.YELLOW}WebSocket Security Scanner V3.0.5{Colors.END}
58+
{Colors.CYAN}Created by: Regaan (@regaan){Colors.END}
59+
{Colors.BLUE}========================================{Colors.END}
60+
"""
61+
print(banner)
3962

4063
@staticmethod
4164
def info(msg):

wshawk/logger.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
from pathlib import Path
1414
from typing import Optional
1515

16+
# Force UTF-8 on Windows to prevent charmap encoding crashes
17+
# when payloads or output contain non-ASCII characters
18+
if sys.platform == 'win32':
19+
try:
20+
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
21+
sys.stderr.reconfigure(encoding='utf-8', errors='replace')
22+
except Exception:
23+
pass
24+
1625
# Color codes for terminal output
1726
class Colors:
1827
HEADER = '\033[95m'

0 commit comments

Comments
 (0)