blabberer
January 13th, 2014, 19:49
Quote:
[Originally Posted by niaren;96010]
bp 40c32a
First set a conditional break on the address right before the VM is going to execute the cmp instruction
|
the cmp al,bl is generated on the fly so cant set bp on exact address as it will always be overwitten
so bp is set on stable address few bytes above Self modifying code
Quote:
This part of the command bp /1 40c32f \"r @al,@bl;r zf = 1;gc is slightly confusing
There is a gc at the end but is that because the 'outer' BP is a conditional BP? it also works if it is just g....
|
both bps are conditional breakpoints
inner bp is an one time conditional bp (there is no explicit condition but a command needs to be executed on break so it is an implicit conditional break)
commmand executed prints al,bl and sets the zf flag so needs to go from condition
outer bp checks for cmp al,bl and on success sets a bp so needs to go from condition
Quote:
blabberer, do you know if it possible to set breakpoints on all instructions from some start address to some end address, programatically in windbg? I've tried to google but have not found out if it is possible. It is possible to set BPs on multiple functions at a time by using wildcards. |
what do you mean by programmatically ? writing a debugger extension ?
if yes then i think you can code something thats simply start disassembling to find the lenght of instruction
and set bps succesively on each instruction
if it is from windbg command line i havent needed it yet so havent thought of anything
now that you ask ill update this thread if i find a hack that sets bps from 401000 to 401010
like
bp 401000
bp 401005
bp 401006
bp 40100d
quit
update
here is a hack that sets breakpoints on 10 instruction / 2 instructions in winxp sp3 calc.exe
sed should be available in environment path for this to work
0:000>
bl
0:000>
.shell type c:\setbp.txt
[CODE]
.foreach ( place { .block { .shell -ci "u ${$arg1} ${$arg2}" sed -e 1d -e s/" ".*//g } } ) {r $t0 = place; bp @$t0 }
0:000>
$$>a< c:\setbp.txt calc!WinMain l10
0:000>
bl
0 e 01001f51 0001 (0001) 0:**** calc!WinMain
1 e 01001f56 0001 (0001) 0:**** calc!WinMain+0x5
2 e 01001f5b 0001 (0001) 0:**** calc!WinMain+0xa
3 e 01001f61 0001 (0001) 0:**** calc!WinMain+0x10
4 e 01001f62 0001 (0001) 0:**** calc!WinMain+0x11
5 e 01001f63 0001 (0001) 0:**** calc!WinMain+0x12
6 e 01001f64 0001 (0001) 0:**** calc!WinMain+0x13
7 e 01001f67 0001 (0001) 0:**** calc!WinMain+0x16
8 e 01001f69 0001 (0001) 0:**** calc!WinMain+0x18
9 e 01001f6a 0001 (0001) 0:**** calc!WinMain+0x19
10 e 01001f6c 0001 (0001) 0:**** calc!WinMain+0x1b
11 e 01001f6e 0001 (0001) 0:**** calc!WinMain+0x1d
12 e 01001f75 0001 (0001) 0:**** calc!WinMain+0x24
13 e 01001f7b 0001 (0001) 0:**** calc!WinMain+0x2a
14 e 01001f7d 0001 (0001) 0:**** calc!WinMain+0x2c
15 e 01001f7f 0001 (0001) 0:**** calc!WinMain+0x2e
0:000> bc *
0:000> bl
0:000> $$>a< c:\setbp.txt calc!WinMain calc!WinMain+8
0:000>
bl
0 e 01001f51 0001 (0001) 0:**** calc!WinMain
1 e 01001f56 0001 (0001) 0:**** calc!WinMain+0x5