| 1 |
HT Editor |
| 2 |
========= |
| 3 |
|
| 4 |
This is HT 2.1.0; Have fun... |
| 5 |
|
| 6 |
About |
| 7 |
===== |
| 8 |
|
| 9 |
This program is a file viewer, editor and analyzer for text, binary, and |
| 10 |
(especially) executable files. |
| 11 |
|
| 12 |
This program is free software; you can redistribute it and/or |
| 13 |
modify it under the terms of the GNU General Public License version |
| 14 |
2 as published by the Free Software Foundation. |
| 15 |
|
| 16 |
This program is distributed in the hope that it will be useful, but |
| 17 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 19 |
General Public License for more details. |
| 20 |
|
| 21 |
You should have received a copy of the GNU General Public License |
| 22 |
along with this program; if not, write to the Free Software |
| 23 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 24 |
02110-1301 USA. |
| 25 |
|
| 26 |
Key bindings |
| 27 |
============ |
| 28 |
|
| 29 |
* General key bindings |
| 30 |
|
| 31 |
Return follow link (if applicable) |
| 32 |
Backspace undo "follow link" |
| 33 |
Space/F6 choose view mode |
| 34 |
Alt+[1-9] select window |
| 35 |
Alt+0 select window list |
| 36 |
Ctrl+Left/Right scroll left/right |
| 37 |
Cursor keys move around |
| 38 |
Page Up/Down next/prev page |
| 39 |
Alt+S toggle select |
| 40 |
Ctrl+Ins/Alt+C copy |
| 41 |
Shift+Ins/Alt+V insert |
| 42 |
Ctrl+Del/Alt+D delete |
| 43 |
Shift+Del/Alt+X cut |
| 44 |
|
| 45 |
* Window key bindings |
| 46 |
|
| 47 |
Alt+F3/Ctrl+W close window |
| 48 |
Ctrl+F5 resize/move mode |
| 49 |
(in resize/move mode only:) |
| 50 |
Space toggle resize/move mode |
| 51 |
Cursor keys resize/move window |
| 52 |
Escape/Return/Ctrl+F5leave resize/move mode |
| 53 |
|
| 54 |
* Analyser key bindings |
| 55 |
|
| 56 |
c continue code analysis at cursor |
| 57 |
f follow dword ptr at address |
| 58 |
n name current address (empty string to delete) |
| 59 |
x show xrefs (search for xrefs) |
| 60 |
# edit comments |
| 61 |
s define a string |
| 62 |
i define an integer (32bit) |
| 63 |
h define a halfword (16bit) |
| 64 |
b define a byte (8bit) |
| 65 |
Ctrl+A call assembler |
| 66 |
Ctrl+F goto start of current function |
| 67 |
(indicated in the 2nd line) |
| 68 |
Ctrl+L goto previous label |
| 69 |
Ctrl+T show recursive function references |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
Note: Some keys don't work in HT-posix. Try using Escape instead of |
| 74 |
Control or something... |
| 75 |
|
| 76 |
Authors |
| 77 |
======= |
| 78 |
|
| 79 |
* Stefan Weyergraf |
| 80 |
|
| 81 |
* Sebastian Biallas <[email protected]> |
| 82 |
|
| 83 |
Features |
| 84 |
======== |
| 85 |
|
| 86 |
HT contains some very advanced and useful features, which you should |
| 87 |
carefully inspect: |
| 88 |
|
| 89 |
General features |
| 90 |
================ |
| 91 |
|
| 92 |
1. Supported file formats |
| 93 |
* common object file format (COFF/XCOFF32) |
| 94 |
- header |
| 95 |
- image with code/data analyser (x86) |
| 96 |
* executable and linkable format (ELF) |
| 97 |
- header |
| 98 |
- section headers |
| 99 |
- program headers |
| 100 |
- symbol tables |
| 101 |
- image with code/data analyser (x86, AMD64, Alpha, |
| 102 |
PowerPC, ARM, AVR) and relocations |
| 103 |
* linear executables (LE) |
| 104 |
- header |
| 105 |
- VxD descriptor |
| 106 |
- object table |
| 107 |
- page table |
| 108 |
- image with code/data analyser (x86) |
| 109 |
- auto-relocation layer (only internal refs for now) |
| 110 |
* standard dos executables (MZ) |
| 111 |
- header |
| 112 |
- relocations |
| 113 |
- image (disassembly only) |
| 114 |
* new executables (NE) |
| 115 |
- header |
| 116 |
- segments |
| 117 |
- names |
| 118 |
- entrypoints |
| 119 |
- image with code/data analyser (x86) |
| 120 |
- auto-relocation layer (pretty complete) |
| 121 |
* portable executables (PE32, PE64) |
| 122 |
- header |
| 123 |
- import section |
| 124 |
- delay-import section |
| 125 |
- export section |
| 126 |
- resources |
| 127 |
- image with code/data analyser (x86, AMD64, PowerPC, |
| 128 |
Alpha, ARM) |
| 129 |
- preliminary support for .net executables |
| 130 |
* java class files (CLASS) |
| 131 |
- header |
| 132 |
- image with code/data analyser (java bytecode |
| 133 |
disassembler) |
| 134 |
* Mach exe/link format (MachO) |
| 135 |
- header |
| 136 |
- image with code/data analyser (x86, AMD64, PowerPC, |
| 137 |
ARM) |
| 138 |
* X-Box executable (XBE) |
| 139 |
- header |
| 140 |
- imports |
| 141 |
- image with code/data analyser (x86) |
| 142 |
* Flat (FLT) |
| 143 |
- header |
| 144 |
- image with data analyser (no disassembler yet) |
| 145 |
* PowerPC executable format (PEF) |
| 146 |
- header |
| 147 |
- imports - image with code/data analyser (PowerPC) |
| 148 |
* Still some to be implemented (M$-OBJ, ARCH, LX) |
| 149 |
2. Code & Data Analyser |
| 150 |
- finds branch sources and destinations recursively |
| 151 |
- finds procedure entries |
| 152 |
- creates labels based on this information |
| 153 |
- creates xref information |
| 154 |
- allows to interactively analyse unexplored code (press 'c') |
| 155 |
- allows to create/rename/delete labels (press 'n') |
| 156 |
- allows to create/edit comments (press '#') |
| 157 |
3. Target systems |
| 158 |
- GNU/Linux |
| 159 |
- FreeBSD |
| 160 |
- Win32 |
| 161 |
|
| 162 |
Configuration files |
| 163 |
=================== |
| 164 |
|
| 165 |
Global configuration |
| 166 |
-------------------- |
| 167 |
|
| 168 |
HT automatically creates a file to store its configuration. It is |
| 169 |
called '~/.htcfg2' on Unices and 'ht.cfg2' (where ht.exe resides) on |
| 170 |
Windows. More specifically it contains HT's registry and the *Note |
| 171 |
Global history::. |
| 172 |
|
| 173 |
Per file configuration |
| 174 |
---------------------- |
| 175 |
|
| 176 |
The analyser (for analysable files) will be stored in an extra file |
| 177 |
called 'FILENAME.htcfg', where FILENAME is the analysed file. This file |
| 178 |
contains all information to restore the complete state of the analyser. |
| 179 |
|
| 180 |
Clipboard |
| 181 |
========= |
| 182 |
|
| 183 |
All open files and dialogs use the common clipboard, where all copied |
| 184 |
and cut text or binary data is stored. Clipboard operations are |
| 185 |
normally binary safe, that means you can copy some binary data out of a |
| 186 |
file and paste it into an input line. Exceptions are only the \0 |
| 187 |
character (binary null), it will be converted to a space in places where |
| 188 |
it would not make sense (e.g. file open). |
| 189 |
|
| 190 |
Although the clipboard won't be saved between different HT sessions |
| 191 |
(ie. you will loose it when exiting HT), you can either save and load |
| 192 |
it or part of it manually (via Edit->paste into/copy from file) or rely |
| 193 |
on the input lines' *Note history: Global history, which is stored and |
| 194 |
retrieved from the config file automatically. |
| 195 |
|
| 196 |
Global history |
| 197 |
============== |
| 198 |
|
| 199 |
HTs history system is global, which means that you can use it for all |
| 200 |
open files. Histories are also grouped by their context. I.e. |
| 201 |
file-related and regex-search-related dialogs have their own history |
| 202 |
(who would want to open "[0-9][0-9a-z]+" anyway?). |
| 203 |
|
| 204 |
History entries are stored within the *Note Configuration files::, so |
| 205 |
they can be reused when you relaunch. |
| 206 |
|
| 207 |
You can delete a history entry by pressing DEL inside the history |
| 208 |
popup. |
| 209 |
|
| 210 |
Expression evaluation |
| 211 |
===================== |
| 212 |
|
| 213 |
HT contains a very powerful expression evaluator which is used in all |
| 214 |
dialogs where expressions are expected. These are mainly |
| 215 |
blockoperation, goto, search and of course evaluate itself |
| 216 |
(Edit->Evaluate). |
| 217 |
|
| 218 |
You can use all standard math operators (+ - / * % **), logical |
| 219 |
operators (! && || ^^), relational operators (== != < > <= >=), bit |
| 220 |
operators (~ & | ^), string operators (. for concatenation), |
| 221 |
parenthesis, the ternary operator (a?b:c), functions and symbols (both |
| 222 |
depending on context). |
| 223 |
|
| 224 |
The evaluator uses integer, string and float types depending on |
| 225 |
context. You can always convert a result via the 'int()', 'string()' |
| 226 |
and 'float()' functions to appropriate type. Try Edit->Evaluate to see |
| 227 |
how it works... |
| 228 |
|
| 229 |
Functions and symbols |
| 230 |
--------------------- |
| 231 |
|
| 232 |
You can always use the standard built-in math ('round', 'sin', 'random', |
| 233 |
etc.) and string ('strcmp', 'strchr', 'sprintf', etc.) functions, they |
| 234 |
work more or less like the corresponding C functions (actually they ARE |
| 235 |
more or less wrappers for them); see 'eval/eval.y' for details (sorry |
| 236 |
but a detailed help would get outdated rather soon). |
| 237 |
|
| 238 |
The symbol _ always refers to the last result. If you are in a hex |
| 239 |
buffer, the variable 'first' contains the offset of the first byte and |
| 240 |
the variable 'last' contains the offset of the last byte. This is |
| 241 |
useful, for instance, if you want to jump to the last byte of a file. |
| 242 |
|
| 243 |
When using *Note Block operations::, or searching you have some |
| 244 |
context depending functions and symbols; see these sections for |
| 245 |
explanation. |
| 246 |
|
| 247 |
Block operations |
| 248 |
================ |
| 249 |
|
| 250 |
Block operation (Blockop) is a very powerful tool to perform |
| 251 |
modifications on binary files. It is available in hex viewer only. |
| 252 |
|
| 253 |
Blockop takes four parameters: START, END, MODE and EXPRESSION. |
| 254 |
Blockop works as follows: |
| 255 |
|
| 256 |
* START: Start at the offset specified by START |
| 257 |
* REPEAT: Evaluate EXPRESSION and store n bytes (1 - byte, 2 - word, |
| 258 |
4 - dword, variable - string) at the current offset. Increment |
| 259 |
current offset by n. Stop if END has been reached. |
| 260 |
|
| 261 |
Special variables/functions that can be used in EXPRESSION: |
| 262 |
|
| 263 |
'readbyte(ofs)' |
| 264 |
read a byte from offset OFS, returns a number |
| 265 |
'readstring(ofs, size)' |
| 266 |
read SIZE bytes from offset OFS, returns a string |
| 267 |
'i' |
| 268 |
contains the iteration count/index starting with 0 |
| 269 |
'o' |
| 270 |
contains the current offset |
| 271 |
|
| 272 |
Search and its different modes |
| 273 |
============================== |
| 274 |
|
| 275 |
The search function is one of the most advanced functions of HT. It is |
| 276 |
invoked through F7, Shift-F7 continues a search from cursor. Depending |
| 277 |
on context (ie. file type and mode) the following modes are enabled: |
| 278 |
|
| 279 |
bin: ASCII / Hex |
| 280 |
---------------- |
| 281 |
|
| 282 |
Enter an exact search string either via ascii characters or via |
| 283 |
hexadecimal interpretation. This is the fastest search mode. You may |
| 284 |
specify a case-insensitive search. |
| 285 |
|
| 286 |
bin: eval str |
| 287 |
------------- |
| 288 |
|
| 289 |
Enter an expression, it will be evaluated ONCE (difference to the 4th |
| 290 |
mode), and HT will then search for the result-string. This is pretty |
| 291 |
useful when searching for intermixed text and control-chars/binary, e.g. |
| 292 |
'"hello world\n\0"' |
| 293 |
|
| 294 |
display: regex |
| 295 |
-------------- |
| 296 |
|
| 297 |
As the prefix indicates, this search doesn't search in the binary file |
| 298 |
but in the display on screen. HT searches for a regular expression so |
| 299 |
this can be very powerful, e.g. in PE/Image you can search for |
| 300 |
'(add|sub).+?,\ [78]$'. This will find all add or sub instructions with |
| 301 |
second parameter 7 or 8. |
| 302 |
|
| 303 |
expr nonzero |
| 304 |
------------ |
| 305 |
|
| 306 |
This is the slowest but also most advanced search mode. Enter an |
| 307 |
expression and the search stops if this expression evaluates to non-zero |
| 308 |
(it will be evaluated on every byte). In this mode there are two |
| 309 |
predefined symbols and some functions: I is always the number of current |
| 310 |
iteration and O stands for the current offset in file. With the |
| 311 |
functions 'readbyte(ofs)' and 'readstring(ofs, size)' you access the |
| 312 |
file's content. |
| 313 |
|
| 314 |
It's easier to understand this with examples: |
| 315 |
|
| 316 |
1. Searching for patterns: |
| 317 |
|
| 318 |
a. Enter 'readbyte(o) == readbyte(o+1)' |
| 319 |
This will search for two equal bytes ("AA", "55", "!!", etc.). |
| 320 |
b. Enter '(readbyte(o) == readbyte(o+1)-1) && |
| 321 |
(readbyte(o)==readbyte(o+2)-2)' |
| 322 |
This will search for three ascending bytes ("ABC", "123", |
| 323 |
etc). |
| 324 |
|
| 325 |
2. Search with special functions: |
| 326 |
|
| 327 |
With HT you can easily detect the RSA key in the 'ADVAPI32.DLL': |
| 328 |
Search for 'entropy(readstring(o, 64)) > 82' in expr!=0 mode, and |
| 329 |
you will find it very quickly. How does it work? 'readstring(o, |
| 330 |
64)' reads a 64 byte string from current offset and entropy |
| 331 |
calculates the entropy ("randomness") of a string (result is |
| 332 |
0..100). So the search stops if a entropy greater than 82% |
| 333 |
(guessed value) is encountered, which normally indicates packed or |
| 334 |
encryted data. |
| 335 |
|
| 336 |
Note: the 'entropy()' function is not the best of its kind, if you |
| 337 |
know of a better one please let us know! |
| 338 |
|
| 339 |
Command line options |
| 340 |
==================== |
| 341 |
|
| 342 |
'--' treat all additional parameters as file names |
| 343 |
|
| 344 |
'-v' '--version' show version and copyright on console |
| 345 |
|
| 346 |
'-h' '--help' show help |
| 347 |
|
| 348 |
'-t' '--text' load file(s) in text editor mode |
| 349 |
|
| 350 |
'-b' '--bin' load file(s) in hex editor mode |
| 351 |
|
| 352 |
'-a' '--auto' try to guess file type |
| 353 |
|
| 354 |
Where to download? |
| 355 |
================== |
| 356 |
|
| 357 |
The HT homepage is located at <http://hte.sourceforge.net> |
| 358 |
|
| 359 |
Downloads are available from the 'download' section. Please also take a |
| 360 |
look at <http://sourceforge.net/projects/hte> |
| 361 |
|