2014-01-22 127 views
2

我正在關注「https://www.mandiant.com/blog/parsing-registry-hives-python/」。錯誤未定義

在運行下面的代碼:

f = open("SAMPLE1.DAT") 
buf = f.read() 
regf = RegistryParse.REGFBlock(buf, 0, false) 

for HBIN in regf.hbins(): 
    for cell in HBIN.cells(): 
     if cell.is_free(): 
      print "Unallocated cell at offset 0x%x" % (cell.offset()) 

我得到一個錯誤:

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
NameError: name 'false' is not defined 

可以什麼原因呢?現在

,就來到了:

Traceback (most recent call last): 
    File "mig.py", line 11, in <module> 
    regf = RegistryParse.REGFBlock(buf, 0, False) 
    File "/usr/local/lib/python2.7/dist-packages/Registry/RegistryParse.py", line 236, in   __init__ 
    raise ParseException("Invalid REGF ID") 
Registry.RegistryParse.ParseException: Registry Parse Exception(Invalid REGF ID) 

回答

5

Python是區分大小寫的。 False = false = fAlSe

2

使用False以大寫F:!

regf = RegistryParse.REGFBlock(buf, 0, False) 

不幸的是,博客帖子有拼錯了。

8

False應在Python資本化:

regf = RegistryParse.REGFBlock(buf, 0, False) 

記住,Python是區分大小寫的。