本文整理汇总了Python中pygments.lexers.NasmLexer方法的典型用法代码示例。如果您正苦于以下问题:Python lexers.NasmLexer方法的具体用法?Python lexers.NasmLexer怎么用?Python lexers.NasmLexer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.lexers
的用法示例。
在下文中一共展示了lexers.NasmLexer方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_asm
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import NasmLexer [as 别名]
def show_asm(self, item, primary):
cur = self.db_cursor()
if primary:
db = "main"
else:
db = "diff"
ea = str(int(item[1], 16))
sql = "select prototype, assembly, name from %s.functions where address = ?"
sql = sql % db
cur.execute(sql, (ea, ))
row = cur.fetchone()
if row is None:
Warning("Sorry, there is no assembly available for the selected function.")
else:
fmt = HtmlFormatter()
fmt.noclasses = True
fmt.linenos = True
asm = self.prettify_asm(row["assembly"])
final_asm = "; %s\n%s proc near\n%s\n%s endp\n"
final_asm = final_asm % (row["prototype"], row["name"], asm, row["name"])
src = highlight(final_asm, NasmLexer(), fmt)
title = "Assembly for %s" % row["name"]
cdiffer = CHtmlViewer()
cdiffer.Show(src, title)
cur.close()
示例2: show_asm
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import NasmLexer [as 别名]
def show_asm(self, item, primary):
cur = self.db_cursor()
if primary:
db = "main"
else:
db = "diff"
ea = str(int(item[1], 16))
sql = "select prototype, assembly, name from %s.functions where address = ?"
sql = sql % db
cur.execute(sql, (ea, ))
row = cur.fetchone()
if row is None:
warning("Sorry, there is no assembly available for the selected function.")
else:
fmt = HtmlFormatter()
fmt.noclasses = True
fmt.linenos = True
asm = self.prettify_asm(row["assembly"])
final_asm = "; %s\n%s proc near\n%s\n%s endp\n"
final_asm = final_asm % (row["prototype"], row["name"], asm, row["name"])
src = highlight(final_asm, NasmLexer(), fmt)
title = "Assembly for %s" % row["name"]
cdiffer = CHtmlViewer()
cdiffer.Show(src, title)
cur.close()
示例3: __init__
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import NasmLexer [as 别名]
def __init__(self, trace=True, sca_mode=False,sca_HD=False):
self.breakpoints = []
self.skips = []
self.emu = None
self.disasm = None
self.uc_reg = None
self.mapped_regions = []
self.page_size = 0
self.functions = {}
self.function_names = {}
self.profile_counter = 0
self.OTHER_REGS = {}
self.OTHER_REGS_NAMES = {}
# Tracing properties
self.trace = trace
self.mem_trace = False
self.function_calls = False
self.trace_regs = False
self.stubbed_functions = {}
self.sca_mode = sca_mode
## Prepare a live disassembler
self.asm_hl = NasmLexer()
self.asm_fmt = formatter(outencoding="utf-8")
colorama.init()
self.trace_reset()
# Take into account another leakage model
self.sca_HD = sca_HD
示例4: cap_disasm
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import NasmLexer [as 别名]
def cap_disasm(self, ip):
md = capstone.Cs(self.state.project.arch.cs_arch, self.state.project.arch.cs_mode)
r = ""
code = self.state.memory.load(ip, MAX_DISASS_LENGHT*10)
code = self.state.solver.eval(code, cast_to=bytes)
cnt = 0
for i in md.disasm(code, MAX_DISASS_LENGHT*10):
r += "0x%x:\t%s\t%s\n" % (ip + i.address, i.mnemonic, i.op_str)
cnt += 1
if cnt == 18: break
return highlight(r, NasmLexer(), TerminalFormatter())
示例5: __pstr_codeblock
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import NasmLexer [as 别名]
def __pstr_codeblock(self, ip) -> str:
"""Get the pretty version of a basic block with Pygemnts"""
try:
block = self.state.project.factory.block(ip)
code = self._disassembler.disass_block(block)
return highlight(code, NasmLexer(), TerminalFormatter())
except SimEngineError:
return None
示例6: lexer_nasm
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import NasmLexer [as 别名]
def lexer_nasm():
yield NasmLexer()
示例7: _syntax_highlighting
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import NasmLexer [as 别名]
def _syntax_highlighting(self, data):
try:
from pygments import highlight
from pygments.lexers import NasmLexer, GasLexer
from pygments.formatters import TerminalFormatter, Terminal256Formatter
from pygments.styles import get_style_by_name
style = get_style_by_name('colorful')
import curses
curses.setupterm()
if curses.tigetnum('colors') >= 256:
FORMATTER = Terminal256Formatter(style=style)
else:
FORMATTER = TerminalFormatter()
if self.ks.syntax == keystone.KS_OPT_SYNTAX_INTEL:
lexer = NasmLexer()
else:
lexer = GasLexer()
# When pygments is available, we
# can print the disassembled
# instructions with syntax
# highlighting.
data = highlight(data, lexer, FORMATTER)
except ImportError:
pass
finally:
data = data.encode()
return data
示例8: show_asm_diff
# 需要导入模块: from pygments import lexers [as 别名]
# 或者: from pygments.lexers import NasmLexer [as 别名]
def show_asm_diff(self, item):
cur = self.db_cursor()
sql = """select *
from (
select prototype, assembly, name, 1
from functions
where address = ?
and assembly is not null
union select prototype, assembly, name, 2
from diff.functions
where address = ?
and assembly is not null)
order by 4 asc"""
ea1 = str(int(item[1], 16))
ea2 = str(int(item[3], 16))
cur.execute(sql, (ea1, ea2))
rows = cur.fetchall()
if len(rows) != 2:
warning("Sorry, there is no assembly available for either the first or the second database.")
else:
row1 = rows[0]
row2 = rows[1]
html_diff = CHtmlDiff()
asm1 = self.prettify_asm(row1["assembly"])
asm2 = self.prettify_asm(row2["assembly"])
buf1 = "%s proc near\n%s\n%s endp" % (row1["name"], asm1, row1["name"])
buf2 = "%s proc near\n%s\n%s endp" % (row2["name"], asm2, row2["name"])
fmt = HtmlFormatter()
fmt.noclasses = True
fmt.linenos = False
fmt.nobackground = True
src = html_diff.make_file(buf1.split("\n"), buf2.split("\n"), fmt, NasmLexer())
title = "Diff assembler %s - %s" % (row1["name"], row2["name"])
cdiffer = CHtmlViewer()
cdiffer.Show(src, title)
cur.close()