mirror of
https://github.com/dobin/avred
synced 2026-06-08 13:54:13 +00:00
refactor: fix plain file
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
import os
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import os
|
||||
from reducer import scanData
|
||||
|
||||
# no PE file, just check its content
|
||||
def analyzeFilePlain(filename, scanner):
|
||||
data = None
|
||||
with open(filename, "rb") as file:
|
||||
data = file.read()
|
||||
matches = scanData(scanner, data, os.path.basename(filename), 0, len(data))
|
||||
return data, matches
|
||||
@@ -2,21 +2,25 @@
|
||||
|
||||
import argparse
|
||||
from scanner import ScannerRest
|
||||
from plugins.analyzer_office import analyzeFileWord, augmentFileWord
|
||||
from plugins.analyzer_pe import analyzeFileExe, augmentFilePe
|
||||
from analyzer_plain import analyzeFilePlain
|
||||
from config import Config
|
||||
import logging
|
||||
from utils import saveMatchesToFile
|
||||
from verifier import verify
|
||||
from plugins.file_pe import FilePe
|
||||
from model.model import FileData
|
||||
|
||||
import pickle
|
||||
from plugins.file_office import FileOffice
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from config import Config
|
||||
from utils import saveMatchesToFile
|
||||
from verifier import verify
|
||||
from model.model import FileData
|
||||
from model.model import Match
|
||||
|
||||
from plugins.analyzer_office import analyzeFileWord, augmentFileWord
|
||||
from plugins.analyzer_pe import analyzeFileExe, augmentFilePe
|
||||
from plugins.analyzer_plain import analyzeFilePlain
|
||||
from plugins.file_pe import FilePe
|
||||
from plugins.file_office import FileOffice
|
||||
from plugins.file_plain import FilePlain
|
||||
|
||||
log_format = '[%(levelname)-8s][%(asctime)s][%(filename)s:%(lineno)3d] %(funcName)s() :: %(message)s'
|
||||
|
||||
|
||||
@@ -105,6 +109,10 @@ def scanFile(args, scanner):
|
||||
analyzerOptions["remove"] = args.remove
|
||||
analyzerOptions["ignoreText"] = args.ignoreText
|
||||
|
||||
else:
|
||||
logging.error("File ending not supported")
|
||||
os.exit(1)
|
||||
|
||||
# matches
|
||||
if os.path.exists(filenameMatches):
|
||||
logging.info("Loading matches from file")
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
from reducer import scanData
|
||||
|
||||
# no PE file, just check its content
|
||||
def analyzeFilePlain(filePlain, scanner):
|
||||
matchesIntervalTree = scanData(scanner, filePlain.data, filePlain.filename, 0, len(filePlain.data))
|
||||
return matchesIntervalTree
|
||||
+1
-1
@@ -1,5 +1,4 @@
|
||||
import logging
|
||||
import pefile
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
import copy
|
||||
@@ -99,6 +98,7 @@ class FilePe():
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
def printSections(self):
|
||||
for section in self.sections:
|
||||
print(f"Section {section.name}\t addr: {hex(section.addr)} size: {section.size} ")
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
||||
class FilePlain():
|
||||
def __init__(self):
|
||||
self.filepath = None
|
||||
self.filename = None
|
||||
self.data = b""
|
||||
|
||||
|
||||
def loadFromFile(self, filepath: str):
|
||||
self.filepath = filepath
|
||||
self.filename = os.path.basename(filepath)
|
||||
|
||||
with open(self.filepath, "rb") as f:
|
||||
self.data = f.read()
|
||||
Reference in New Issue
Block a user