Условная точка останова, EBP содержит указатель строки

Мне нужно использовать условную точку останова, чтобы найти место, где EBP-44 содержит указатель на определенную строку. Я пытался использовать ollydbg, но поскольку EBP-44 в основном равен 0 (или другой нечитаемой памяти), трассировка выполнения завершается ошибкой с Run trace: invalid condition 1 - Unable to get contents of memory. Есть какой-либо способ сделать это?

Мое состояние:

[ASCII [EBP-1C]]=="MYSTRING"

Это условие срабатывает только один раз в коде


person JINX    schedule 15.01.2014    source источник
comment
Вы можете попробовать использовать условные точки останова в GDB. Я бы рекомендовал изучить blog.vinceliu.com/2009/07/ gdbs-условные-точки останова.html   -  person ehudt    schedule 15.01.2014


Ответы (1)


инструмент ollydbg 1.10

код для демо

ebp-44:\>dir /b
ebp-44.cpp

ebp-44:\>type ebp-44.cpp
#include <stdio.h>
#include <windows.h>
int main (void)
{
    char *mystrarray[]  = {
        "humble bee", "bumblebee", NULL,"my naughty string", "my notty string",
        "my nauty string","my native string",NULL, "want to string me ",
        "come on string with me","string sings the song strong", NULL, NULL,
        "what's this string doing here in onederlaand", NULL,NULL,NULL,NULL,
        "teaching lice to string the strong","my golden bug is strumming here",
        "my gold trinket's stringing here", "my gold trinket's stringing hare",
        "want to string me ","come string me", "string sings the song strong",
        NULL,NULL,NULL,NULL,NULL,"my gold trinket's stringing hire",NULL,NULL
    };
    for (int i = 0; i < _countof(mystrarray) ; i++ )
    {
        register char *yoyo;
        yoyo = mystrarray[i];
        printf("%s\n", yoyo);
    }
    return 0;
}
ebp-44:\>cl /nologo /Zi /analyze /W4 ebp-44.cpp /link /RELEASE
ebp-44.cpp

ebp-44:\>ebp-44.exe
humble bee
bumblebee
(null)
my naughty string
my notty string
my nauty string
my native string
(null)
want to string me
come on string with me
string sings the song strong
(null)
(null)
what's this string doing here in onederlaand
(null)
(null)
(null)
(null)
teaching lice to string the strong
my golden bug is strumming here
my gold trinket's stringing here
my gold trinket's stringing hare
want to string me
come string me
string sings the song strong
(null)
(null)
(null)
(null)
(null)
my gold trinket's stringing hire
(null)
(null)

ebp-44:\>OLLYDBG.EXE ebp-44.exe

ebp-44:\>

установите breakpoint on main and f9 для запуска исполняемого файла, когда он сломается при основном хите ctrl+t (condition to pause run trace) check mark condition is true флажок в поле условия введите

STRING [[ EBP-90]] == "my gold trinket's stringing hare" 

{EBP-90] взято из просмотра разборки, может отличаться в вашем случае используйте соответствующий адрес

0040111A   |MOV     ECX, DWORD PTR SS:[EBP-8C]             ; yoyo = mystrarray[i];
00401120   |MOV     EDX, DWORD PTR SS:[EBP+ECX*4-88]
00401127   |MOV     DWORD PTR SS:[EBP-90], EDX
0040112D   |MOV     EAX, DWORD PTR SS:[EBP-90]             ; printf("%s\n", yoyo);
00401133   |PUSH    EAX
00401134   |PUSH    ebp-44.0041235C
00401139   |CALL    ebp-44.printf

нажмите ctrl+f11 (обвести)

ollydbg сломается, если [ebp-90] будет содержать строку

Log data, item 0
 Message=Conditional pause: STRING [[ EBP-90]] == "my gold trinket's stringing hare"

см. сборку выше, edx передает нашу строку в [ebp-90]

EDX=004122D0 (ebp-44.004122D0), ASCII "my gold trinket's stringing hare"
Stack SS:[0013FEE8]=004122D0 (ebp-44.004122D0), ASCII "my gold trinket's stringing hare"
ebp-44.cpp:18.  yoyo = mystrarray[i];

вот отпечаток ebp при поломке

Log data, item 0
 Message=ebp  = 13ff78  ebp-90 = 13fee8   [ebp-90] = 4122d0  [[ebp-90]]  = 6720796d  STRING [[ebp-90]]  = my gold trinket's stringing hare " see 6d792067 ascii equivalent for "my g"
person blabb    schedule 12.05.2014