This repository was archived by the owner on Sep 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASM-Helper.bat
executable file
·234 lines (181 loc) · 6.26 KB
/
ASM-Helper.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
::ORG N/A
::Copyright Unlicense
::NAME ASM-Helper.bat
::PURPOSE Expedite helper for Reverse Engineering Command.
::AUTHOR Justin Musgrove <[email protected]>
::Revision 00.00.01 20160513
@ECHO OFF
SETLOCAL EnableDelayedExpansion
TITLE ASM Decompiler Helper
MODE CON COLS=80 LINES=25
GOTO :EndComments
Revision: 00.00.01 20160907 - JM: Initial Version
- Empty shell
GOALS KEY: X Complete, C CANX, M Moved, p particial
PRIORITY: 1 HIGH, 2 MED, 3 LOW
GOALS: - Sanity Checks: Ensure program will run gooooood
3:[ ] Windows Version check, WinXP, Win7
2:[ ] Detect between dir and file, run different
1:[ ] Ensure gracefull, or glorious crashes
- Tool choice for user
1:[ ] Prompt user for type of output
- Working area
1:[ ] Desktop working folder based on time
1:[ ] Copy original file with pre-fix "MOD-"
2:[ ] Verbose debug output of the file
2:[ ] Record information of the target file
LICENSE:
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>
:EndComments
:: Program locations ##==-- START
:: HIEW
SET ASM.1="%USERPROFILE%\Desktop\lab files\hiew\hiew.exe"
:: dump
::SET ASM.2="%ProgramFiles%\Microsoft Visual Studio .NET 2003\Vc7\bin\dumpbin.exe"
SET ASM.2="%ProgramFiles%\Microsoft Visual Studio .NET 2003\Common7\IDE\dumpbin.exe"
:: Program locations ##==-- END
:: Main ##==-- START
:: Sanity Check ##==-- START
:: Super complicated way of checking if tools exists
:: Probably should of just used EnableDelayedExpansions
FOR /L %%? IN (1,1,2) DO (
IF NOT EXIST !ASM.%%?! (
CALL :Syntax "Unable to Found tools" !ASM.%%?!
GOTO :EOF
)
)
:: Sanity Check ##==-- END
:: Parse file into sections to work with
SET _dragIN=%1
IF NOT DEFINED _dragIN (
CALL :Syntax "Unable to detect file"
GOTO :EOF
)
CALL :WhatAmI %_dragIN%
IF %isDir% EQU 1 (
CALL :Syntax "Target is a Dir, Not Yet supported"
GOTO :EOF
)
FOR %%? IN (%_dragIN%) DO (
SET TGT.path=%%~dp?
SET TGT.name=%%~nx?
)
SET TGT.SRC="%TGT.path%\%TGT.name%"
:: Function DragIN --==## END
:: Grag current time
CALL :CurrentTime
:: Create Play ground
CALL :WorkingDir PlayGround
:: Menu Loop ##==-- START
:MLoop.1
SET userChoice=
CLS
ECHO Detected File: %TGT.name%
ECHO PlayGround: \Desktop\PlayGround\%myTime%-%TGT.name%
ECHO.
ECHO Directory Contents:
DIR /B
ECHO.
ECHO 1).....Start dumpbin
ECHO.
ECHO 2).....Start HIEW Tool
ECHO.
ECHO Anything else to quit
ECHO.
SET /P userChoice=Choose:
IF "%userChoice%" == "1" GOTO :TOOL.dumpbin
IF "%userChoice%" == "2" GOTO :TOOL.HIEW
:: IF /I "%userChoice" == "Q" GOTO :EOF
:: Menu Loop ##==-- END
:: Main ##==-- END
START .
GOTO :EOF
:: Functions ##==-- START ------------------------------------------------------
:TOOL.HIEW
FOR %%? IN (PLAY-%TGT.name%) DO SET TGT.sname=%%~s?
%ASM.1% %TGT.sname%
GOTO :MLoop.1
:TOOL.dumpbin
IF NOT DEFINED VS71COMNTOOLS (
"C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\bin\vcvars32.bat"
)
FOR %%? IN (data idata rdata) DO (
%ASM.2% /RAWDATA:BYTES /SECTION:.%%? PLAY-%TGT.name% > %TGT.name%-%%?.txt
)
GOTO :MLoop.1
:: Function Workingdir ##==--------------------------------------------------------
:Workingdir
:: Set the working directory to play in
SET DIR.BASE=%USERPROFILE%\Desktop\%~1\%myTime%-%TGT.name%
MKDIR "%DIR.BASE%"
PUSHD "%DIR.BASE%"
SET /P M=Creating playground copies of %TGT.name%... <NUL
FOR %%? IN (ORIG PLAY) DO (
COPY %TGT.SRC% %%?-%TGT.name% >NUL
)
ECHO DONE
CALL :TIMEOUT 3
EXIT /B
:: Function WhatAmI ##==--------------------------------------------------------
:: Takes argument and converts to 8.3 format. Needed if file has spaces
:WhatAmI
FOR %%i IN (%1) DO IF EXIST %%~si\NUL SET isDir=1
EXIT /B
:: Function TIMEOUT ##==--------------------------------------------------------
:TIMEOUT
::Because Windows XP doesn't have the "timeout /T 2" command. Meh
SETLOCAL
PING -n %1 127.0.0.1 >NUL
EXIT /B
:: function CurrentTime ##==----------------------------------------------------
:CurrentTime
:: Set Global variable myTime
:: Lets hope that we always have 24H clock
:: SET SET D.Full=%DATE:~10%%DATE:~7,2%%DATE:~4,2%
:: Pull date from "builtin date variable"
SET D.Y=%DATE:~10%
SET D.M=%DATE:~7,2%
SET D.D=%DATE:~4,2%
:: SET T.Full=%TIME:~0,2%%TIME:~3,2%.%TIME:~6,2%
:: Pull time from "builtin time variable"
SET T.H=%TIME:~0,2%
SET T.M=%TIME:~3,2%
SET T.S=%TIME:~6,2%
:: Set time based on the above
:: SET myTime=%D.Full%-%T.Full%
SET myTime=%D.Y%%D.M%%D.D%-%T.H: =0%%T.M%.%T.S%
EXIT /B
:: Function Syntax ##==---------------------------------------------------------
:Syntax
COLOR C
SET MSG1=%~1
SET MSG2=%~2
TITLE ASM Decompiler Helper ERROR: %~1
CLS
ECHO.
ECHO Something went wrong!
IF DEFINED MSG1 ECHO %~1
IF DEFINED MSG2 ECHO %~2
ECHO.
ECHO USAGE: Please drag file on top of this batch file
PAUSE >NUL
:: Functions ##==-- END