• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Prayer

            在一般中尋求卓越
            posts - 1256, comments - 190, trackbacks - 0, articles - 0
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            Core Dump雜記

            Posted on 2009-03-13 12:07 Prayer 閱讀(2224) 評論(5)  編輯 收藏 引用 所屬分類: LINUX/UNIX/AIX
            1、開啟系統的Core Dump功能

            ulimit -c core_file_size_in_kb

            如果要關閉該功能core_file_size_in_kb為0就行了。

            2、設置Core Dump的核心轉儲文件目錄和命名規則

            文件的命名規則放在

            /proc/sys/kernel/core_name_format文件中

            使用sysctl -w "kernel.core_name_format=/coredump/%n.core"

            上例的core文件放在/coredump目錄下,文件名是進程名+.core

            以下是一些命名的格式說明

            %P The Process ID (current->pid)
            %U The UID of the process (current->uid)
            %N The command name of the process (current->comm)
            %H The nodename of the system (system_utsname.nodename)
            %% A "%"


            3、分析核心轉儲文件

            程序如下:

            #include

            int main()

            {

            int i=0;

            int j=5;

            int tmp;

            for(; i System Environments --> Change/ Show Characteristics of Operating System

            Change/ Show Characteristics of Operating System
            Maximum number of PROCESSES allowed per user [128]
            Maximum number of pages in block I/O BUFFER CACHE [20]
            Maximum Kbytes of real memory allowed for MBUFS [0]
            Automatically REBOOT system after a crash false
            Continuously maintain DISK I/O history false
            HIGH water mark for pending write I/Os per file [33]
            LOW water mark for pending write I/Os per file [24]
            Amount of usable physical memory in Kbytes 262144
            State of system keylock at boot time normal
            Enable full CORE dump true
            Use pre-430 style CORE dump false
            Enable CPU Guard disable

            將上面列表中的“ Enable full CORE dump ”項設置為“true”。


            4. 使用下面的命令產生一個core文件:
            # kill -11
            注意:上面的命令同時也會殺掉指定的進程。


            附錄 B. 如何查看C程序產生的CORE DUMP(來源于IBM cn)
            Document #: 1317181000005

            環境

            產品:IBM C 和C++ Compiler
            平臺:AIX4.3.0以上
            版本: C for AIX version 3 以上

            問題描述

            如何查看C程序產生的CORE DUMP,并找到產生問題的根源?

            解答

            在AIX操作系統上查看C程序產生的CORE DUMP,可以使用AIX操作系統提供的命令:dbx. 如果用戶在使用時發現無此命令,則需安裝 操作系統的文件包:bos.adt.debug。
            具體使用dbx命令的方法如下:
            1。首先在進行C程序 編譯時,要使用-g選項。
            cc -g -o samp1.o samp1.c
            2.在執行完程序,并產生CORE DUMP文件core后,使用:dbx samp1.o core 命令可查看CORE DUMP。
            要想找到是哪個函數或語句引起的問題,在dbx的命令行再輸入where,即可顯示出所需的信息。dbx的命令行還可執行多種命令以完成不同的查看功能,用戶可通過help命令了解這些命令。

            Posted by vitter at February 21, 2006 02:14 PM

            如何分析一個未知二進制文件

            當你在unix下拿到一個二進制文件但不知道它是什么的時候,可以通過以下方法得到一此提示

            1. 最首先應該嘗試strings命令,比如拿到一個叫cr1的二進制文件,可以:
            $ strings cr1 | more
            里面可能會有一些對于這個cr1的描述,這些信息都是編譯之后在程序中留下的一些文本性的說明,所以可能會告訴你這個文件是什么.
            比如有輸出:
            $ strings cr1 | more

            %s %s %s%s%s -> %s%s%s (%.*s)
            Version: 2.3
            Usage: dsniff [-cdmn] [-i interface] [-s snaplen] [-f services]
            [-t trigger[,...]] [-r|-w savefile] [expression]
            ...
            /usr/local/lib/dsniff.magic
            /usr/local/lib/dsniff.services
            ...

            那么我們就可以知道,其實 cr1就是dsniff命令.

            2. 如果這樣的方法沒有幫助你的話,那么你可以嘗試:
            $ /usr/ccs/bin/nm -p cr1 | more
            比如說得到如下輸出:
            cr1:

            [Index] Value Size Type Bind Other Shndx Name
            [180] |0 | 0| FILE | LOCL | 0 |ABS | decode_smtp.c
            [2198] |160348| 320| FUNC | GLOB | 0 | 9 | decode_sniffer

            這些都是生成這個二進制文件的obj文件的文件名稱,這些名稱會告訴你這個二進制文件的作用的.

            同樣,如果希望查看二進制文件調用到的靜態庫文件都有哪些的話,可以使用nm -Du cr1來實現.

            3. 當然我們也可以通過使用dump命令來得到任何一個二進制文件的選定部分信息
            $ /usr/ccs/bin/dump -c ./cr1 | more
            dump命令的參數說明:
            -c Dump出字符串表
            -C Dump出C++符號表
            -D Dump出調試信息
            -f Dump出每個文件的頭
            -h Dump出section的頭
            -l Dump出行號信息
            -L Dump出動態與靜態鏈接庫部分內容
            -o Dump出每個程序的可執行頭
            -r Dump出重定位信息
            -s 用十六進制信息Dump出section的內容
            -t Dump符號表.

            4. 可以使用file命令得到二進制文件的信息
            $ file cr1

            5. 如果還是不清楚的話,那么我們可以使用ldd命令
            $ ldd cr1
            比如說輸出為:
            ...
            libsocket.so.1 => /usr/lib/libsocket.so.1
            librpcsvc.so.1 => /usr/lib/librpcsvc.so.1
            ...

            那么我們就可以知道這個程序與網絡庫相關,我們就可以知道它的大概功能了.

            我們也可以能過adb命令來得到一個二進制文件的執行過程.
            比如說:
            $ adb cr1
            :r
            Using device /dev/hme0 (promiscuous mode)
            192.168.2.119 -> web TCP D=22 S=1111 Ack=2013255208
            Seq=1407308568 Len=0 Win=17520
            web -> 192.168.2.119 TCP D=1111 S=22 Push Ack=1407308568

            我們知道這個程序是一個sniffer.

            6. 如果你確定要運行這個程序的話,你可以先通過:
            $ truss -f -o cr.out ./cr1
            listening on hme0
            ^C
            $

            truss命令可以幫你打開系統的信號與調用輸出.你就可以知道這個程序到底干了什么.

            有了上面這些工具的話,我們就可以大概了解到一個未知的二進制程序到底是干什么的.

            最后提示大家,運行不了解的二進制程序有嚴重的安全問題,請大家小心.

            Posted by vitter at February 21, 2006 02:16 PM

            如何分析一個二進制未知進程信息?

            在unix下,所有的事物都是文件,進程也是.文件的位置在 /proc/[PID]/object/a.out.但是這樣的文件并不能由find命令找到.

            假設我們當前有如下的進程:

            # ps -ef | more
            UID PID PPID C STIME TTY TIME CMD
            ...
            root 22889 16318 0 10:09:25 pts/1 0:00 ./srg
            ...

            我們使用strings命令就可以知道這個程序的作用:
            $ strings /proc/22889/object/a.out | more

            如果我們用strings不能得到這個進程的作用的話,我們可以嘗試先suspend這個進程:
            $ kill -STOP 22889
            然后我們使用:
            $ /usr/ucb/ps | grep T
            來查看已被停止進程信息,當然我們可以通過 kill -CONT 22889來恢復這個進程的運行. 我們可以通過gcore來對這個進程作一個core dump:
            $ gcore 22889
            生成的core.22889是這個進程的變量與堆棧信息,我們可以通過對這些信息進行分析:
            $ strings core.22889 | more

            我們也可以使用adb命令來對一個進程進行分析:
            $ adb /proc/22889/object/a.out
            這樣可以有以下回復:
            # adb /proc/22889/object/a.out -
            main:b
            :r
            breakpoint at:
            main: save %sp, -0xf8, %sp
            ...
            :s
            stopped at:
            main+4: clr %l0
            :s
            stopped at:
            main+8: sethi %hi(0x38400), %o0
            $m
            ? map
            ...
            b11 = ef632f28 e11 = ef6370ac f11 = 2f28 `/usr/lib/libsocket.so.1'
            $q

            這樣我們就可以得到這個進程在匯編下的表示,通過分析匯編結構,我們就可以知道這個程序的作用是什么了.

            也可以通過truss來對正在運行的進程進行分析:
            $ truss -vall -f -o /tmp/outfile -p 22889

            如果你希望查看某個進程的運行環境的話,你可以:
            $ /usr/ucb/ps auxeww 22889
            結果會是如下的結構:

            # /usr/ucb/ps auxeww 22889
            USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND
            root 22889 0.0 0.4 1120 896 pts/1 S 14:15:27 0:00 -
            sh _=/usr/bin/csh
            MANPATH=/usr/share/man:/usr/local/man HZ=
            PATH=/usr/sbin:/usr/bin:/usr/local/bin:/usr/ccs/bin:/usr/local/sbin:
            /opt/NSCPcom/ LOGNAME=root SHELL=/bin/ksh HOME=/
            LD_LIBRARY_PATH=/usr/openwin/lib:/usr/local/lib TERM=xterm TZ=

            查看某個進程的內存地址:
            $ ps -ealf | grep 22889
            以及內存的使用情況:
            $ ps -e -opid,vsz,rss,args
            PID VSZ RSS COMMAND
            ...
            22889 3792 1728 ./srg

            我們可以知道,這個進程使用了3792K的虛擬內存,其中有1728K內存留在物理內存中.


            為了查詢一個進程的進程結構,我們可以:
            # /etc/crash
            然后用p命令得到進程的slot, 并使用 p -f 來對某個進程的proc結構進行查詢.

            我們可以使用:
            $ /usr/proc/bin/pfiles 22889
            來查看這個進程打開了哪些文件

            當然也可以通過
            # mdb -p 22889
            來得到這個進程調用的各個模塊的信息

            Feedback

            # re: Core Dump雜記  回復  更多評論   

            2010-08-12 17:41 by MalloryOsborn
            I guess that to receive the <a href="http://bestfinance-blog.com">loans</a> from creditors you should have a good reason. Nevertheless, once I have got a credit loan, because I was willing to buy a bike.

            # re: Core Dump雜記  回復  更多評論   

            2010-08-29 06:22 by essays help
            I regularly tested some essay example and found out that this company is the respectable among them. I am return client for two years and find the work of this custom essays company team productive.

            # re: Core Dump雜記  回復  更多評論   

            2011-07-06 00:37 by thesis
            I think that you have to be awarded by the dissertation service for your best knowledge just about this post. Not a lot of people will be able to accomplish the same high quality custom dissertation.

            # re: Core Dump雜記  回復  更多評論   

            2011-07-06 03:24 by buy dissertation
            I think it's captivating, because it displays a very academic-focussed attitude. Preserving the incorruptibility of the academic system seems to be a arrangement, although directly banning reimbursed ads for such a service seems a forceless response. When the concern is known by your friends who were captivated with the results of the collaboration, about this address that for the thesis quality.

            # re: Core Dump雜記  回復  更多評論   

            2013-04-17 22:50 by Essayontime.com rewiew
            Have no idea which company to select to receive aid from? Glance over EssaysProfessors testimonials, and make a judicious choice.
            欧美无乱码久久久免费午夜一区二区三区中文字幕 | 久久精品三级视频| 国产精品99久久久久久猫咪| 国产精品久久久天天影视香蕉 | 久久99久久99小草精品免视看| 青青草原综合久久大伊人精品| 久久久久人妻一区精品| 午夜不卡久久精品无码免费| 久久综合丝袜日本网| 久久综合久久美利坚合众国| 97热久久免费频精品99| 久久免费观看视频| 精品久久久久香蕉网| 久久婷婷五月综合97色直播| 久久精品国产亚洲精品2020| 久久九九久精品国产免费直播| 亚洲精品乱码久久久久久按摩 | 久久久久人妻一区精品果冻| 无码人妻久久一区二区三区免费丨| 中文精品久久久久国产网址| 久久婷婷五月综合色奶水99啪 | 99久久精品国产毛片| 色婷婷综合久久久中文字幕| 无码精品久久一区二区三区| 欧美综合天天夜夜久久| 久久精品国产亚洲av日韩| 香蕉99久久国产综合精品宅男自| 国产精品久久久久9999高清| 一本色道久久综合亚洲精品| 综合久久精品色| 亚洲国产天堂久久综合| 久久97久久97精品免视看秋霞 | 狠狠色丁香婷婷综合久久来来去| 人妻少妇久久中文字幕| 免费精品久久天干天干| 中文字幕无码av激情不卡久久| 久久亚洲AV无码西西人体| 欧美精品丝袜久久久中文字幕 | 欧美精品乱码99久久蜜桃| 亚洲AⅤ优女AV综合久久久| 国产精品免费看久久久香蕉|