binwalk: update to 2.4.1.

This commit is contained in:
suyun@aosc.io 2024-06-13 10:55:17 +08:00 committed by Leah Neukirchen
parent a360c73ad8
commit c8a4daf26e
4 changed files with 5 additions and 131 deletions

View File

@ -1,14 +0,0 @@
https://github.com/ReFirmLabs/binwalk/issues/566
https://github.com/ReFirmLabs/binwalk/issues/569
--- a/testing/tests/test_firmware_zip.py
+++ b/testing/tests/test_firmware_zip.py
@@ -10,6 +10,8 @@
'''
expected_results = [
[0, 'Zip archive data, at least v1.0 to extract, name: dir655_revB_FW_203NA/'],
+ [51, 'Zip archive data, at least v2.0 to extract, compressed size: 6395868, uncompressed size: 6422554, name: dir655_revB_FW_203NA/DIR655B1_FW203NAB02.bin'],
+ [6395993, 'Zip archive data, at least v2.0 to extract, compressed size: 14243, uncompressed size: 61440, name: dir655_revB_FW_203NA/dir655_revB_release_notes_203NA.doc'],
[6410581, 'End of Zip archive, footer length: 22'],
]

View File

@ -1,22 +0,0 @@
Index: binwalk-2.3.3/src/binwalk/modules/extractor.py
===================================================================
--- binwalk-2.3.3.orig/src/binwalk/modules/extractor.py
+++ binwalk-2.3.3/src/binwalk/modules/extractor.py
@@ -966,7 +966,7 @@ class Extractor(Module):
# Fork a child process
child_pid = os.fork()
- if child_pid is 0:
+ if child_pid == 0:
# Switch to the run-as user privileges, if one has been set
if self.runas_uid is not None and self.runas_gid is not None:
os.setgid(self.runas_uid)
@@ -981,7 +981,7 @@ class Extractor(Module):
rval = subprocess.call(shlex.split(command), stdout=tmp, stderr=tmp)
# A true child process should exit with the subprocess exit value
- if child_pid is 0:
+ if child_pid == 0:
sys.exit(rval)
# If no os.fork() happened, just return the subprocess exit value
elif child_pid is None:

View File

@ -1,90 +0,0 @@
--- a/src/binwalk/core/module.py
+++ b/src/binwalk/core/module.py
@@ -688,6 +688,16 @@ class Modules(object):
else:
return '--' + opt
+ @staticmethod
+ def _imp_load_source(name, path):
+ import importlib.util
+ import importlib.machinery
+ loader = importlib.machinery.SourceFileLoader(name, path)
+ spec = importlib.util.spec_from_file_location(name, path, loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ loader.exec_module(module)
+ return module
+
def list(self, attribute="run"):
'''
Finds all modules with the specified attribute.
@@ -704,14 +714,13 @@ class Modules(object):
modules[module] = module.PRIORITY
# user-defined modules
- import imp
user_modules = binwalk.core.settings.Settings().user.modules
for file_name in os.listdir(user_modules):
if not file_name.endswith('.py'):
continue
module_name = file_name[:-3]
try:
- user_module = imp.load_source(module_name, os.path.join(user_modules, file_name))
+ user_module = _imp_load_source(module_name, os.path.join(user_modules, file_name))
except KeyboardInterrupt as e:
raise e
except Exception as e:
--- a/src/binwalk/core/plugin.py
+++ b/src/binwalk/core/plugin.py
@@ -1,7 +1,6 @@
# Core code for supporting and managing plugins.
import os
-import imp
import inspect
import binwalk.core.common
import binwalk.core.settings
@@ -131,6 +130,15 @@ class Plugins(object):
return klass
raise Exception("Failed to locate Plugin class in " + plugin)
+ def _imp_load_source(self, name, path):
+ import importlib.util
+ import importlib.machinery
+ loader = importlib.machinery.SourceFileLoader(name, path)
+ spec = importlib.util.spec_from_file_location(name, path, loader=loader)
+ module = importlib.util.module_from_spec(spec)
+ loader.exec_module(module)
+ return module
+
def list_plugins(self):
'''
Obtain a list of all user and system plugin modules.
@@ -180,7 +188,7 @@ class Plugins(object):
module = file_name[:-len(self.MODULE_EXTENSION)]
try:
- plugin = imp.load_source(module, os.path.join(plugins[key]['path'], file_name))
+ plugin = self._imp_load_source(module, os.path.join(plugins[key]['path'], file_name))
plugin_class = self._find_plugin_class(plugin)
plugins[key]['enabled'][module] = True
@@ -222,7 +230,7 @@ class Plugins(object):
continue
try:
- plugin = imp.load_source(module, file_path)
+ plugin = self._imp_load_source(module, file_path)
plugin_class = self._find_plugin_class(plugin)
class_instance = plugin_class(self.parent)
--- a/src/binwalk/core/magic.py
+++ b/src/binwalk/core/magic.py
@@ -428,7 +428,7 @@ class Magic(object):
# Regex rule to find format strings
self.fmtstr = re.compile("%[^%]")
# Regex rule to find periods (see self._do_math)
- self.period = re.compile("\.")
+ self.period = re.compile(r'\.')
def reset(self):
self.display_once = set()

View File

@ -1,16 +1,16 @@
# Template file for 'binwalk'
pkgname=binwalk
version=2.3.4
revision=3
version=2.4.1
revision=1
build_style=python3-module
hostmakedepends="python3-setuptools"
depends="python3"
short_desc="Easy tool for analyzing/reversing/extracting firmware images"
maintainer="Duncaen <duncaen@voidlinux.org>"
license="MIT"
homepage="https://github.com/ReFirmLabs/binwalk"
distfiles="https://github.com/ReFirmLabs/binwalk/archive/v${version}.tar.gz"
checksum=60416bfec2390cec76742ce942737df3e6585c933c2467932f59c21e002ba7a9
homepage="https://github.com/OSPG/binwalk"
distfiles="https://github.com/OSPG/binwalk/archive/v${version}.tar.gz"
checksum=26d13afd3610b39a38a3062a34c05d94dacda3f6f6aa6d1d19e42b61fabe1c8f
post_extract() {
vsed -i -e 's;/etc/bash_completion.d/%s;%s.bash;' setup.py