-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign.bat
201 lines (150 loc) · 6.76 KB
/
sign.bat
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
@ECHO OFF
TITLE Aetherx - Signtool
SETLOCAL ENABLEDELAYEDEXPANSION
MODE con:cols=125 lines=30
MODE 125,30
GOTO comment_end
-----------------------------------------------------------------------------------------------------
Aetherx - Signtool
Signs an exe or dll dragged onto the executable.
signtool.exe path must be added to your environment variables for Windows
-----------------------------------------------------------------------------------------------------
:comment_end
ECHO.
SET dir_home=%~dp0
SET dir_lib=.lib
SET file_src=%~1
SET CERT_THUMBPRINT=58a1539d6988d76f44bae27c27ed5645d3b1222a
SET echo=ECHO
SET file_cfg=cfg\config.ini
:: -----------------------------------------------------------------------------------------------------
:: define: libraries
:: DO NOT EDIT
:: -----------------------------------------------------------------------------------------------------
:: -----------------------------------------------------------------------------------------------------
:: define: gpg library
:: -----------------------------------------------------------------------------------------------------
SET signtool=signtool
:: -----------------------------------------------------------------------------------------------------
:: config file
:: -----------------------------------------------------------------------------------------------------
if exist !dir_home!/!file_cfg! (
for /F "tokens=*" %%I in ( %file_cfg% ) do set %%I
)
:: -----------------------------------------------------------------------------------------------------
:: define: signtool
:: attempt to locate signtool via where command
:: -----------------------------------------------------------------------------------------------------
WHERE /Q %signtool%
IF !ERRORLEVEL! NEQ 0 (
cls
%echo% ERROR
%echo% This script has detected that the command %signtool% is not accessible.
%echo%.
TITLE Aetherx - Signtool Missing [Error]
%echo% Press any key to acknowledge error and try anyway ...
PAUSE >nul
cls
)
:: -----------------------------------------------------------------------------------------------------
:: remove trailing slash
:: -----------------------------------------------------------------------------------------------------
IF %dir_home:~-1%==\ SET dir_home=%dir_home:~0,-1%
:: -----------------------------------------------------------------------------------------------------
:: func: NEXT
:: continue script
:: -----------------------------------------------------------------------------------------------------
:NEXT
%echo% Select an option:
%echo% 1 Sign EXE /Bin/Release
%echo% 2 Sign EXE + DLL Current folder
%echo% 3 Sign EXE Only Current folder
%echo%.
%echo%.
set /P v_input_cs_type=" Enter Choice: "
%echo%.
if [!v_input_cs_type!]==[] (
%echo% No choice provided, defaulting to OPTION
%echo%.
GOTO SIGN_EXE_SUBFOLDERS
)
if /I "%v_input_cs_type%" EQU "1" (
GOTO SIGN_EXE_SUBFOLDERS
)
if /I "%v_input_cs_type%" EQU "2" (
GOTO SIGN_EXE_DLL_CUROLDER
)
if /I "%v_input_cs_type%" EQU "3" (
GOTO SIGN_EXE_ONLY_CUROLDER
) else (
%echo%.
%echo% Unrecognized Option !v_input_cs_type!
%echo%.
goto NEXT
)
:: -----------------------------------------------------------------------------------------------------
:: func: SIGN > EXE ONLY > SUBFOLDER
:: sign exe subfolders
:: -----------------------------------------------------------------------------------------------------
:SIGN_EXE_SUBFOLDERS
for /R "bin/Release/" %%f in ( *.exe ) do (
call signtool sign /sha1 "%CERT_THUMBPRINT%" /fd SHA256 /d "Aetherx" /du "https://github.com/Aetherinox" /t http://timestamp.comodoca.com/authenticode "%%f"
)
goto FINISH
:: -----------------------------------------------------------------------------------------------------
:: func: SIGN > EXE + DLL > CURRENT FOLDER
:: sign exe, dll current folder
:: -----------------------------------------------------------------------------------------------------
:SIGN_EXE_DLL_CUROLDER
:: -----------------------------------------------------------------------------------------------------
:: sign DLL
:: -----------------------------------------------------------------------------------------------------
for %%f in ( *.dll ) do (
call signtool sign /sha1 "%CERT_THUMBPRINT%" /fd SHA256 /d "Aetherx" /du "https://github.com/Aetherinox" /t http://timestamp.comodoca.com/authenticode "%%f"
)
:: -----------------------------------------------------------------------------------------------------
:: sign EXE
:: -----------------------------------------------------------------------------------------------------
for %%f in ( *.exe ) do (
set FILENAME=%%~nxf
echo !FILENAME!
If "!FILENAME!"=="!FILENAME:signtool=!" (
call signtool sign /sha1 "%CERT_THUMBPRINT%" /fd SHA256 /d "Aetherx" /du "https://github.com/Aetherinox" /t http://timestamp.comodoca.com/authenticode "!FILENAME!"
) else (
echo Filename "!FILENAME!" contains signtool -- not signing
)
)
goto FINISH
:: -----------------------------------------------------------------------------------------------------
:: func: SIGN > EXE > CURRENT FOLDER
:: sign exe, dll current folder
:: -----------------------------------------------------------------------------------------------------
:SIGN_EXE_ONLY_CUROLDER
:: -----------------------------------------------------------------------------------------------------
:: sign EXE
::
:: skip attempting to sign signtool.exe
:: -----------------------------------------------------------------------------------------------------
for %%f in ( *.exe ) do (
set FILENAME=%%~nxf
echo Checking !FILENAME!
If "!FILENAME!"=="!FILENAME:signtool=!" (
call signtool sign /sha1 "%CERT_THUMBPRINT%" /fd SHA256 /d "Aetherx" /du "https://github.com/Aetherinox" /t http://timestamp.comodoca.com/authenticode "!FILENAME!"
) else (
echo Skipping "!FILENAME!" -- not signing
)
)
goto FINISH
:: -----------------------------------------------------------------------------------------------------
:: finish
:: -----------------------------------------------------------------------------------------------------
:FINISH
%echo%.
%echo%.
timeout /t 1 /nobreak >nul
TITLE Aetherx - Signtool (Complete)
%echo%.
%echo%.
%echo% Press any key to close utility
PAUSE >nul
Exit /B 0