String comparison in Windbg script

后端 未结 3 517
感情败类
感情败类 2021-02-07 11:29

Using Windbg script I want to check the presence of a certain string in an argument of any function.

0:000> g
Breakpoint 0 hit
eax=00000001 ebx=00000000 ecx=0         


        
3条回答
  •  难免孤独
    2021-02-07 12:17

    wow Thomas that is probably termed as going to the extremes

    @deb if finding a match is the main requirement you can try some thing like this

    0:000> .printf "%y\n" , @eip
    USER32!MessageBoxW (7e466534)
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    0:000> du poi(@esp+8)
    00408168  "cannot find "hello""
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    0:000> .foreach /pS 1 /ps 100 (place { dpu @esp+8 l1 }) { s -u place l100 "\"hello\"" }
    00408180  0022 0068 0065 006c 006c 006f 0022 0000  ".h.e.l.l.o."...
    0040827a  0022 0068 0065 006c 006c 006f 0022 0020  ".h.e.l.l.o.". .
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    0:000> .foreach /pS 1 /ps 100 (place { dpu @esp+8 l1 }) { s -u place l100 "\"z\"" }
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    0:000> .foreach /pS 1 /ps 100 (place { dpu @esp+8 l1 }) { s -u place l100 "\"zoop\"" }
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    0:000> .foreach /pS 1 /ps 100 (place { dpu @esp+8 l1 }) { s -[l 20]u place l100 "can" }
    00408168  0063 0061 006e 006e 006f 0074 0020 0066  c.a.n.n.o.t. .f.
    0040819c  0063 0061 006e 006e 006f 0074 0020 0066  c.a.n.n.o.t. .f.
    004081d0  0063 0061 006e 006e 006f 0074 0020 0066  c.a.n.n.o.t. .f.
    00408204  0063 0061 006e 006e 006f 0074 0020 0066  c.a.n.n.o.t. .f.
    00408238  0063 0061 006e 006e 006f 0074 0020 0066  c.a.n.n.o.t. .f.
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    0:000> .foreach /pS 1 /ps 100 (place { dpu @esp+8 l1 }) { s -[1]u place l100 "can" }
    0x00408168
    0x0040819c
    0x004081d0
    0x00408204
    0x00408238
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    0:000> .foreach /pS 1 /ps 100 (place { dpu @esp+8 l1 }) { .foreach (vlace { s -[1]u place l100 "can"} ) {du vlace} }
    00408168  "cannot find "hello""
    0040819c  "cannot find "iello""
    004081d0  "cannot find "jello""
    00408204  "cannot find "fello""
    00408238  "cannot find "kello""
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    0:000> .foreach /pS 1 /ps 100 (place { dpu @esp+8 l1 }) { .foreach (vlace { s -[1]u place l100 "ello"} ) {du vlace} } 
    00408184  "ello""
    004081b8  "ello""
    004081ec  "ello""
    00408220  "ello""
    00408254  "ello""
    0040827e  "ello" baby"
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    0:000> lsf msgboxw.cpp
    msgboxw.cpp
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    0:000> ls 0,15
         1: #include 
         2: #pragma comment(lib,"user32.lib")
         3: int main (void)
         4: {
         5:     MessageBoxW(0,L"cannot find \"hello\"",L"test",0);
         6:     MessageBoxW(0,L"cannot find \"iello\"",L"test",0);
         7:     MessageBoxW(0,L"cannot find \"jello\"",L"test",0);
         8:     MessageBoxW(0,L"cannot find \"fello\"",L"test",0);
         9:     MessageBoxW(0,L"cannot find \"kello\"",L"test",0);
        10:     MessageBoxW(0,L"saying \"hello\" baby",L"test",0);
        11: return 0;
        12: }
        13: 
        14: 
    0:000> $ ----------------------------------------------------------------------------------------------------------------------
    

提交回复
热议问题