I’m writing a Data Ingest plugin for Autopsy and I want to open a local file"IOCs.txt", read the lines into a list and then search that list against the contents of the files ingested.
- Partially working: I can iterate through the files I import in Autopsy and find the first value in iocList, however, it won’t step to the next indices in iocList to look for the next IOC(pictured in #1 below). In a normal python script, this would be no problem, but I am having trouble identifying why.
loop through iocList and run some test(s) on the file contents
iocList = ['\x31\x33\x37\x2e\x31\x33\x35\x2e\x39\x31\x2e\x34\x39',
'\x77\x69\x70\x72\x6f\x33\x36\x35\x2e\x63\x6f\x6d']
for ioc in iocList:
result = testContents(stream1, self, file, ioc)
-
I have the logic working in a standalone python script. When I implement it with my Autopsy plugin, I receive an error in Autopsy along the lines of “no such file or path”. I do have the “ioc_sample.txt” in the same directory as the plugin module. Is it possible to open a file in a module without importing it through the Autopsy GUI?
iocList = [] with open('ioc_sample.txt', 'r') as iocFile: ilist = iocFile.readlines() for i in ilist: i = i.rstrip() ih = '\\x'.join(hex(ord(x))[2:] for x in i) #print(ih) iL = len(ih) iocList.append('\'' + ih + '\'') #print(iL)
-
What I wanted the module to do:
iocList = []
with open(‘ioc_sample.txt’, ‘r’) as iocFile:
ilist = iocFile.readlines()
for i in ilist:
i = i.rstrip()
ih = ‘\x’.join(hex(ord(x))[2:] for x in i)
#print(ih)
iL = len(ih)
iocList.append(’’’ + ih + ‘’’)
#print(iL)for ioc in iocList: result = testContents(stream1, self, file, ioc)