2315 Ivy
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Didier Stevens 書中重點與實際測試 ###### tags: `兆勤` 小小補充一下這個專題在幹嘛,就是要偵測 PDF 有沒有毒,然後目前是覺得毒可能會藏在 JS 裡面 (當然其他地方也有可能,之後再說),所以我們要去抓每個 PDF 的 JS,看看有沒有貓膩。 # 用法:這個文件要解決什麼事? - 偵測PDF[^我是註解]的Javascript病毒 # 心法:解決這事打算用什麼策略? - 拿出來的Output要丟進Jstep # 技法:這個策略要怎麼執行? - Jstep 執行的六大指令[^我是註解]. [^我是註解]:PDF 語言是基於編程語言 PostScript 的語言,但 PDF 是 PostScript 的子集,沒有使其成為編程語言的功能。 ### 給專題生的 PDF 結構簡介,以利於偵測 PDF 中 Javascript 裏面的病毒 - PDF 語言是基於編程語言 PostScript 的語言,但 PDF 是 PostScript 的子集,沒有使其成為編程語言的功能。 - PDF 文件可以是二進製文件或 ASCII 文件。 每個 PDF 文檔都可以進行編碼,使其成為純 ASCII 文件,但這些文件很少見,主要用於教育目的。 大部分遇到的所有 PDF 文件都是二進制 PDF 文件。 - The elements you will need to understand in your analysis of a PDF file are indirect objects. > 1 0 obj … endobj - indirect obj 有一個 index #(示例中為 1)和一個 version #(示例中為 0),它們的內容包含在關鍵字 obj 和 endobj 之間。obj 可以通過使用它們的索引和版本號來引用其他間接對象,例如:1 0 R(這是對 obj 1 0 的引用)。 - One type of object essential for analyzing malicious PDF files is the stream object. Indirect object 5 0 in our example file is a stream object. > 5 0 obj << /Length 46 >> stream BT /F1 24 Tf 100 700 Td (Hello World)Tj ET endstream endobj This data stream is often compressed. > 5 0 obj<</Subtype/Type1C/Length 5416/Filter/FlateDecode>>stream H‰|T}T#W#Ÿ!d&"FI#ʼnNFW#åC … endstream endobj - In a malicious PDF document, the shellcode will download a Trojan from the Internet or extract it from the PDF file, write it to disk and execute it. ### PDFiD - 對 PDF 文件進行分類,可以在十六進制編輯器中打開它們,並尋找惡意 PDF 文件的跡象,例如自動操作、JavaScript 或 Flash 的存在以及易受攻擊的編碼…… - PDFiD 不是 PDF 解析器,但它會掃描 PDF 文件以查找某些 PDF 關鍵字,允許識別包含(例如: JavaScript 的 PDF 文檔或在打開時執行操作)。 PDFiD 還將處理名稱混淆。這些關鍵字的存在與否,將幫助確定 PDF 文件是否具有潛在的惡意並且需要進一步分析,或者它是否是良性的並且不需要分析。 PDFiD 查找的關鍵字如下: > obj endobj stream endstream xref trailer startxref 1. /Page: PDF 文檔的頁數。 大多數惡意 PDF 文檔只有一頁。 2. /JS:PDF 文檔包含 JavaScript 和 Flash。 大多數在野外發現的惡意 PDF 文檔都包含 JavaScript(以利用 JavaScript 漏洞和/或執行堆噴射)。 當然,您也可以在沒有惡意的情況下在 PDF 文檔中找到 JavaScript。 例如,眾所周知,政府機構使用 JavaScript 提供 PDF 格式的表單來驗證輸入。 /JavaScript:同上 /RichMedia:同上 3. /AA:查看頁面/文檔時要執行的自動操作。這通常用於在沒有用戶交互的情況下執行 JavaScript。 /OpenAction:同上 /AcroForm:同上 4. /JBIG2Decode:存在易受攻擊的過濾器。 /Colors with a value larger than 2^2:同上 >/Encrypt /ObjStm - PDFiD 的主要目的是幫助您確定 PDF 文件是否需要進一步分析。 如果 PDF 文檔包含腳本、自動操作和/或易受攻擊的過濾器,我建議您將文件標記為可疑,特別是如果它來自不受信任的來源。 ### Disarm 功能 - Disarm will disable embedded JavaScript and Flash in a PDF file. It does this by changing the case of the scripting names like this. (PDF language is a case-sensitive language) > /JavaScript → /jAVAsCRIPT /JS → /js /RichMedia → /rICHmEDIA ** pdfid.py --disarm malware1.pdf.vir ** ### 分析惡意 PDF [pdf-parser.py] - The PDF file contains JavaScript (/JS and /JavaScript), automatic actions (/AA) and is only one page long (/Page). That is a typical signature for a malicious PDF document. - pdf-parser.py 是用於分析 PDF 文件的 Python 程序。 它不是一個完整的 PDF 解析器,它只會解析惡意 PDF 文件中經常使用的 PDF 結構。 這是有目的的,因此 pdf-parser 本身包含漏洞(編程錯誤)的機會比功能齊全的 PDF 解析器要小得多。 與 PDF 渲染軟件從 trailer 開始分析 PDF 文檔不同,pdf-parser 從頭到尾順序讀取 PDF 文件。 這樣,它可以發現隱藏在文件中的 indirect obj 或其他 PDF 結構(即未在邏輯結構中引用)。 ### 功能們 (指令) 1. *$ pdf-parser.py **--stats** malware1.pdf.vir* 查看內容物![](https://i.imgur.com/j6G6LMh.png) 2. *$ pdf-parser.py **--search javascript** malware1.pdf.vir* 查找 js 內容 ( 先透過 pdfid 得知有 js )![](https://i.imgur.com/T4lBSIb.png =80%x) 3. *$ pdf-parser.py **--reference 31** malware1.pdf.vir* ( 找出 indirect obj 31 0 是如何被執行的)![](https://i.imgur.com/d4ZlWHN.png) 4. *$ pdf-parser.py **--object 34** malware1.pdf.vir* ( 現在來看看 indirect obj 34 0 在幹啥)![](https://i.imgur.com/vx9xNcA.png) 5. *$ pdf-parser.py **--object 34 --filter** malware1.pdf.vir* ( 因為我們發現它變成一個 stream obj 用 Flate 壓縮,我們要來解壓縮)![](https://i.imgur.com/XEMUhHd.png) 6. *$ pdf-parser.py **--object 34 --filter --raw** malware1.pdf.vir* ( 解出來難讀,所以施展變好讀的魔法 )![](https://i.imgur.com/r7Ge7zF.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully