-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathILO2RemCon.bat
More file actions
130 lines (110 loc) · 3.91 KB
/
ILO2RemCon.bat
File metadata and controls
130 lines (110 loc) · 3.91 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
@echo off
setlocal enabledelayedexpansion
set URL="https://localhost/ie_index.htm"
set CONFIG_FILE=config.properties
set ILO_SCRIPT=bin\ILO2RemCon.bat
set SITE_LIST_PATH="https://raw.githubusercontent.com/Gouster4/ILO2RemCon/refs/heads/main/iemode.xml"
cd %~dp0
taskkill /f /im msedge.exe >nul 2>&1
:: Check if config file exists
if not exist "%CONFIG_FILE%" (
echo Config file not found. Creating new configuration...
echo.
set "input_ssh_hostname="
set "input_ssh_login="
:ask_ssh
set /p "input_ssh_hostname=Enter SSH server: "
:: Check if user entered user@server format
echo !input_ssh_hostname! | find "@" >nul
if !errorlevel! equ 0 (
:: Split user@server format
for /f "tokens=1,2 delims=@" %%a in ("!input_ssh_hostname!") do (
set "input_ssh_login=%%a"
set "input_ssh_hostname=%%b"
)
) else (
:: Ask for username separately
set /p "input_ssh_login=Enter SSH username: "
)
set /p "input_sshpass=Enter SSH password: "
set /p "input_ip=Enter iLO 2 IP address: "
set /p "input_username=Enter iLO 2 username: "
set /p "input_password=Enter iLO 2 password: "
:: Merge SSH login and hostname with @ (if not already done)
if not defined input_ssh_login (
echo Error: SSH username not defined!
goto ask_ssh
)
set "input_ssh=!input_ssh_login!@!input_ssh_hostname!"
:: Create config file WITHOUT trailing spaces
echo ip=!input_ip!> "%CONFIG_FILE%"
echo username=!input_username!>> "%CONFIG_FILE%"
echo password=!input_password!>> "%CONFIG_FILE%"
echo hostname=localhost>> "%CONFIG_FILE%"
echo ssh=!input_ssh!>> "%CONFIG_FILE%"
echo sshpass=!input_sshpass!>> "%CONFIG_FILE%"
echo.
echo Configuration saved to %CONFIG_FILE%
) else (
echo Reading configuration from %CONFIG_FILE%
)
:: Simple approach - source the config file directly
for /f "usebackq delims=" %%i in ("%CONFIG_FILE%") do (
set "line=%%i"
set "!line!"
)
:: Display configuration
echo.
echo Using configuration:
if defined ssh echo SSH: %ssh%
if defined ip echo IP: %ip%
if defined username echo Username: %username%
echo.
:: Validate required variables
if not defined ssh (
echo Error: SSH configuration not found!
pause
exit /b 1
)
:: Remove any spaces from variables (just in case)
set "clean_ip=%ip: =%"
set "clean_ssh=%ssh: =%"
set "clean_sshpass=%sshpass: =%"
:: Start SSH tunnel in background
echo Starting SSH tunnel in background...
echo.
:: Use Plink with -no-antispoof to automatically start session
echo Using Plink for SSH tunnel with password authentication...
start "SSH Tunnel" /B plink -ssh -N -pw "%clean_sshpass%" -no-antispoof -L 443:%clean_ip%:443 -L 17990:%clean_ip%:17990 -L 17988:%clean_ip%:17988 -L 22:%clean_ip%:22 -L 23:%clean_ip%:23 %clean_ssh% -L 3389:%clean_ip%:3389 %clean_ssh%
:: Wait a moment for tunnel to establish
echo Waiting for SSH tunnel to establish...
timeout /t 3 /nobreak >nul
echo Ports forwarded from %clean_ip% to localhost: 443, 17990, 17988, 22, 23
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v SecureProtocols /t REG_DWORD /d 0xA80 /f >nul 2>&1
IF ERRORLEVEL 1 (
goto :SKIPEDGE
)
reg add "HKCU\Software\Policies\Microsoft\Edge" /v InternetExplorerIntegrationSiteList /t REG_SZ /d "%SITE_LIST_PATH%" /f >nul 2>&1
IF ERRORLEVEL 1 (
goto :SKIPEDGE
)
reg add "HKCU\Software\Policies\Microsoft\Edge" /v InternetExplorerIntegrationLevel /t REG_DWORD /d "1" /f >nul 2>&1
IF ERRORLEVEL 1 (
goto :SKIPEDGE
)
gpupdate /force
timeout /t 3 /nobreak >nul
start "iLO 2" /B "msedge.exe" "%URL%"
:SKIPEDGE
:: Check if ILO script exists and run it
if exist "%ILO_SCRIPT%" (
echo Launching ILO Remote Console...
call "%ILO_SCRIPT%"
) else (
echo Warning: %ILO_SCRIPT% not found.
)
:: Kill the SSH tunnel when done
echo Closing SSH tunnel...
taskkill /im plink.exe /f >nul 2>&1
echo Done.
exit