用於反組譯碼(objdump -d)輸出檔案的vim定義

來源:互聯網
上載者:User

本文譯至:http://qiita.com/shiracamus/items/61ffc618f204342e352f

在 CTF(Capture The Flag) 中經常需要查看objdump -d 或 -D反組譯碼 x86/x64 二進位檔案的結果、所以這裡就定義了vim的相關標籤。
反組譯碼的檔案經常以 *.dis 或 *.dis-intel 命名,這些檔案開啟時就可以自動對應相關的 vim 定義。

弄了一個git倉庫。
https://github.com/shiracamus/vim-syntax-x86-objdump-d ~/.vim/filetype.vim

augroup filetypedetect        au BufRead,BufNewFile *.dis* setfiletype disaugroup END
~/.vim/syntax/dis.vim
" Vim syntax file" Language:     x86/x64 GNU Disassembler (objdump -d -Mintel)" Maintainer:   @shiracamus <shiracamus@gmail.com>" Last Change:  2013 Dec 30" For version 5.x: Clear all syntax items" For version 6.0 and later: Quit when a syntax file was already loadedif version < 600  syntax clearelseif exists("b:current_syntax")  finishendiflet s:cpo_save = &cposet cpo&vimsyn case ignoresyn match disOffset     "[+-]"syn match disNumber     "[+-]\?\<0x[0-9a-f]\+\>" contains=disOffsetsyn match disNumber     "[+-]\?\<[0-9a-f]\+\>" contains=disOffsetsyn match disRegister   "\<[re]\?[abcd][xhl]\>"syn match disRegister   "\<[re]\?[sd]il\?\>"syn match disRegister   "\<[re]\?[sbi]pl\?\>"syn match disRegister   "\<r[0-9]\+[dwb]\?\>"syn match disRegister   "[^\t]\<[cdefgs]s\>"hs=s+1syn match disAt         "@"syn match disSection    " \.[a-z][a-z_\.-]*:"he=e-1syn match disSection    "@[a-z0-9_][a-z0-9_-]\+"hs=s+1 contains=disAt,disNumbersyn match disLabel      "<[a-z0-9_.][a-z0-9_.@+-]\+>"hs=s+1,he=e-1 contains=disNumber,disSectionsyn match disHexDump    ":\t\([0-9a-f][0-9a-f] \)\+"hs=s+1syn match disError      "<internal disassembler error>"syn match disError      "(bad)"syn keyword disTodo     contained TODOsyn region disComment   start="/\*" end="\*/" contains=disTodosyn match disComment    "[#;!|].*" contains=disLabel,disTodosyn match disSpecial    display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"syn region disString    start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=disSpecialsyn region disString    start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=disSpecialsyn match disFormat     ": \+file format "syn match disTitle      "^[^ ]\+: \+file format .*$" contains=disFormatsyn match disMacro      "FWORD"syn match disMacro      "QWORD"syn match disMacro      "DWORD"syn match disMacro      "BYTE"syn match disMacro      "PTR"syn match disData       ".word"syn match disData       ".short"syn match disData       ".byte"" Opecode matched disNumbersyn match disOpecode    "\<add "syn match disOpecode    "\<adc "syn match disOpecode    "\<dec "syn match disOpecode    "\<fadd "syn case match" Define the default highlighting." For version 5.7 and earlier: only when not done already" For version 5.8 and later: only when an item doesn't have highlighting yetif version >= 508 || !exists("did_dis_syntax_inits")  if version < 508    let did_dis_syntax_inits = 1    command -nargs=+ HiLink hi link <args>  else    command -nargs=+ HiLink hi def link <args>  endif  " The default methods for highlighting.  Can be overridden later  " Comment  HiLink disComment     Comment  " Constant: String, Character, Number, Boolean, Float  HiLink disNumber      Number  HiLink disString      String  " Identifier: Function  HiLink disHexDump     Identifier  "Statement: Conditional, Repeat, Label, Operator, Keyword, Exception  HiLink disLabel       Label  " PreProc: Include, Define, Macro, PreCondit  HiLink disData        Define  HiLink disMacro       Macro  " Type: StorageClass, Structure, Typedef  HiLink disRegister    StorageClass  HiLink disTitle       Typedef  " Special: SpecialChar, Tag, Delimiter, SpecialComment, Debug  HiLink disSpecial     SpecialChar  HiLink disSection     Special  " Underlined  " Ignore  " Error  HiLink disError       Error  " Todo  HiLink disTodo        Todo  delcommand HiLinkendiflet b:current_syntax = "dis"let &cpo = s:cpo_saveunlet s:cpo_save" vim: ts=8 sts=4 sw=2

最後的效果如下所示:

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.