2014年4月15日 星期二

Boost Library + VS2010 編譯環境

1.官網抓檔案v1.55 & 解壓縮(http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.7z/download)

2.開啟VS2010命令列  進入解壓縮目錄

3.先執行bootstrap.bat

4.再執行bjam runtime-link=static  (這步驟約需數十分鐘)

以下指令各對應編譯出不同的lib,若執行時找不到就要重新編譯
mt - multitheaded, get it with "bjam threading=multi"
s -  "bjam runtime-link=static"   =====>很重要,最常用的MT編譯選項就是這個
d - debug bjam variant=debug

5.完成訊息

The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

    D:/boost_1_55_0

The following directory should be added to linker library paths:

    D:\boost_1_55_0\stage\lib

6.VS2010使用
 (1) VS2010專案中加入
         Include目錄
         Lib目錄
 (2)去除使用先行編譯標頭檔
 (3)直接Include boost\xxx.hpp 即可使用




#include #include #include #include #include "windows.h" using namespace boost; using namespace std; void Thread_func(string A,string B,int C) { while(1) { cout << A<

2013年12月29日 星期日

數位麵包屑:辨識先進網路攻擊來源的七大線索

原文PDF: link


目錄
    執行摘要 2
    簡介 3
    1. 鍵盤配置 3
    2. 惡意軟體中繼資料 5
    3. 內嵌字型 6
    4. DNS 登錄 7
    5. 語言 8
    6. 遠端管理工具設定 10
    7. 行為 12
    結論 13
    關於 FireEye

總結了一些常見的辨識APT來源,且還是繁體中文的就甘心。

2013年12月27日 星期五

原文:Link
0x00 背景

隨著移動互聯的擴張,移動APP承載了更多企業的終端夢。“用戶手機安裝APP以後,企業即埋下一顆種子,可持續與用戶保持聯繫。”  種子是種下了,可要是它本身就是個[特洛伊木馬]?試想你在某某知名APP平臺下載安裝一款知名APP,深更半夜突然響起了[THE PHANTOM OF THE OPERA]那會是怎樣的一種情景!
通過這近一個月來的觀察和實驗,斗膽在這裡簡單介紹一下手機移動APP安全測試方法、工具和一些容易產生安全問題的點。(此處僅就IOS版本APP進行說明)
0x01 細節

1.工具:PC、手機;軟體:burpsuite/fiddlersqlmap
2.代理設置:首先將你的PC和手機置於同一區域網路,在PC上打開burpsuite proxy選項proxy-listeners
new/edit一下吧

在下拉清單中能夠找到PC本機IP,同時可以自訂Port,此處設置了8088
手機端,連接WIFI後,網路屬性設置代理,寫上上圖IP位址和Port

此時您的PCburpsuite就設置完成。
3.接下來就是找到你感興趣的APP對他們進行友情測試了。測試過程中,有幾個安全點我在之前提交的報告中也都提到了,WEB端存在的問題在移動端同樣存在(小夥伴們可針對OWASP TOP 10有針對性進行測試,其他此處不盡詳表),只是現在WEB前端重兵把守,兵強馬壯,而移動端尚未得到足夠的重視,相對薄弱,應者那句世界名言,我們何不找找小道前行?
說的這裡,提幾個比較具有代表性(易發現易批量應用,對隱私資料影響大)的安全關注點:
由於缺乏對移動端安全防護,並且未對APP用戶端使用者資料做過濾導致SQL注入等一系列問題
(跨站/CSRF什麼的那就不說了)
模糊的用戶權限往往造成各式各樣的越權操作,使用者隱私資料得不到安全保障;不安全的資料傳輸過程,敏感性資料篡改(登陸、支付)
應用設計存在邏輯缺陷導致的跨界
移動雲端系統載體自身存在缺陷,導致伺服器淪陷。如app雲端存在遠端命令執行漏洞、任意檔上傳getshell
移動安全平臺、推廣平臺存在安全缺陷導致海量APP可被操縱,惡意APP侵害移動用戶。
以上方法針對少量APP測試還是挺實用的,這個月測試下來,就如一位皂友所說,發現這些問題是比較繁瑣,但是出現的問題概率比較大。所以問題還是挺好找的。當我孜孜不倦升級的時候@xsser 給俺一個非常不錯的建議用於批量檢測:在本地搭建http代理記錄APP訪問日誌,然後sqlmap批量掃這些去重的日誌!很贊!
0x02 總結

各廠商在APP程式開發的過程中嚴格執行開發安全處置流程同時將WEB應用防線擴至移動端!
APP應用、推廣平臺加強自身安全防範,升級安全基線,確保平臺之安全可靠,要知道,你們可承載著萬千互聯網企業的中國夢-0-
最後,各大廠商、平臺抱好你們的APP了,皂友們要來啦!



Shellcode惡意代碼分析利器 – scdbg

原文:Link
What is scdbg?

scdbg是一款多平臺開源的Shellcode模擬運行、分析工具。其基於libemulibrary搭建的虛擬環境,通過模擬32位元處理器、記憶體和基本Windows API運行環境來虛擬執行Shellcode以分析其行為。有了虛擬執行媽媽再也不用擔心我的電腦中病毒了。
基本原理
眾所周知,shellcode為了實現特定的功能必須通過調用系統API來完成-不論先前怎麼變形怎麼加密最後都會調用系統APIscdbg就是通過模擬執行以及hook多達200多個API來探測shellcode的行為。當然比如創建檔和訪問網路這些危險的API並沒有真正的在本機執行,而是通過傳回虛假的返回值來欺騙shellcode讓其平穩運行。
示例
      直接命令列輸入scdbg.exe example.sc 來看看輸出:
      其中example.sc檔就是以二進位形式保存的Shellcode,我們可以看到這段shellcode調用了兩次較關鍵的函數-CreateProcessA,第一次調用tftp.exe程式下載winapi32.exe,第二次準備執行之。很典型的下載並執行行為。有了scdbg我們就不必花很多時間在搭建測試環境、解碼shellcode、調試理解各種分支跳轉、擔心機器是否中招。。。。。。簡單明瞭。

scdbg和通常的命令列工具一樣,有著眾多參數選項,這裡只做最基本的演示,就不一一列舉。想必大家都有在命令列下痛苦的經歷,命令列的歷史就是我等小菜的血淚史,還好scdbgGUI圖形介面版:

指定偏移,自定參數一目了然。

亮點
A.  跨平臺開源
      同時支援unixwindows系統。對有系統潔癖的同學來說可以放心在unix下搭建環境“調戲”shellcode了。
B.文檔類格式漏洞
      scdbg能很容易通過對話模式分析諸如pdf,excel,word等文檔類漏洞釋放出來的shellcode。這類漏洞的相同點就是首先肯定會通過調用GetFileSize找到宿主檔案控制碼然後進行下一步操作(是這樣的吧:)。感覺這項功能還是有很多應用場景的,命令列如下:
$ ./scdbg -f test.sc -fopen bad.pdf -i
fopen(bad.pdf) = 4d565c
Loaded 312 bytes from file test.sc
Initialization Complete..
Interactive Hooks enabled
             
401083  GetFileSize(4) = 2031b
401112  GlobalAlloc(sz=2031b) = 60000
401118  SetFilePointer(hFile=4, dist=0, FILE_BEGIN)
401132  ReadFile(hFile=4, buf=60000, numBytes=2031b)
401147  CreateFile(x.exe)
        Interactive mode local file: /tmp/WHhUmhtM
401158  WriteFile()
401176  WinExec(x.exe)
其他重要功能
 記憶體監視-簡單調試ShellROPshellcode分析-記憶體dump。。。。。。


資源下載
Windows Native Source/Binaries (201 hooks - current development branch)

*nix/Cygwin Source/Binaries (100 hooks - inactive)

The older gcc compatible and cross-compilable version is available here:
(tested with cygwin/gcc 3.4 & 4.3, RHEL 2.6/ gcc 4.1)

Help screen below: (see scdbg -h for current options)

 scdbg is an adaption of the libemu library and sctest project
 Libemu Copyright (C) 2007  Paul Baecher & Markus Koetter
 scdbg developer: David Zimmer
 Compile date: Apr 14 2011 21:02:02

 /foff hexnum          starts execution at file offset
 /mm                   enabled Memory Monitor (logs access to key addresses)
 /mdll                 Monitor Dll - log direct access to dll memory (hook detection/patches)
 /nc                   no color (if using sending output to other apps)
 /f fpath              load shellcode from file specified.
 /o hexnum             base offset to use (default: 0x401000)
 /redir ip:port        redirect connect to ip (port optional)
 /i                    enable interactive hooks
 /v                    verbosity, can be used up to 4 times, ex. /v /v /vv
 /e int                verbosity on error (3 = debug shell)
 /t int                time to delay (ms) between steps when v=1 or 2
 /h                    show this help
 /ba hexnum            break above - breaks if eip > hexnum
 /bp hexnum            set breakpoint on addr or api name (same as -laa  -vvv)
 /bs int               break on step (shortcut for -las  -vvv)
 /a                    adjust offsets to file offsets not virtual
 /d                    dump unpacked shellcode (requires /f)
 /las int              log at step ex. -las 100
 /laa hexnum           log at address or api ex. -laa 0x401020 or -laa ReadFile
 /s int                max number of steps to run (def=2000000, -1 unlimited)
 /hex                  show hex dumps for hook reads/writes
 /findsc               detect possible shellcode buffers (brute force)
 /dump                 view hexdump of the target file (can be used with /foff)
 /disasm int           Disasm int lines (can be used with /foff)
 /fopen file           Opens a handle to  for use with GetFileSize() scanners
 /- /+                 increments or decrements GetFileSize, can use multiple times
 /hooks                dumps a list all implemented api hooks
 /r                    show analysis report at end of run
 /pp                   peb patch - required for some shellcodes (rare)
 /b0                   break if 00 00 add [eax],al
 /patch fpath          load patch file  for libemu memory
 /dir  folder          process all .sc files in  echo results to .txt

   dbg> shell prompt commands:
        ? - help, this help screen, h also works
        v - change verbosity (0-4)
        g - go - continue with v=0
        s - step, continues execution, ENTER also works
        c - reset step counter
        r - execute till return (v=0 recommended)
        u - unassembled address
        b - break at address
        m - reset max step count (-1 = infinate)
        e - set eip
        w - dWord dump,(32bit ints) prompted for hex base addr and then size
        d - Dump Memory (hex dump) prompted for hex base addr and then size
        x - execute x steps (use with reset step count)
        t - set time delay (ms) for verbosity level 1/2
        k - show stack
        i - break at instruction (scans disasm for next string match)
        f - dereF registers (show any common api addresses in regs)
        o - step over
        .lp - lookup - get symbol for address
        .pl - reverse lookup - get address for symbol
        .seh - shows current value at fs[0]
        .reg - manually set register value
        .poke1 - write a single byte to memory
        .poke4 - write a 4 byte value to memory
        .savemem - saves a memdump of specified range to file
        q - quit