Skip to content

Commit

Permalink
Merge pull request #4 from OSPG/deprecated_usages
Browse files Browse the repository at this point in the history
replace deprecated usages
  • Loading branch information
stkw0 authored Mar 8, 2024
2 parents 51179e7 + 2b93e1a commit 6d48df7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ jobs:
- run: sudo apt-get update
- run: ./deps.sh --yes
- run: pip install coverage pytest pytest-cov
- run: python ./setup.py install
- run: python ./setup.py test
- run: pip install .
- run: pytest -v --cov=binwalk testing
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Binwalk uses Py.test for tests and `pytest-cov` for test coverage:
$ sudo pip install pytest pytest-cov
```

Binwalk uses [pyqtgraph](http://www.pyqtgraph.org) to generate graphs and visualizations, which requires the following (exact dependencies may vary based on your distro refer to `deps.sh` for more details):
Binwalk uses [matplotlib](https://matplotlib.org/) to generate graphs and visualizations:

```bash
$ sudo pip install matplotlib
Expand Down
36 changes: 5 additions & 31 deletions deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,12 @@ else
distro="${2:-$(lsb_release -i|cut -f 2)}"
distro_version="${2:-$(lsb_release -r|cut -f 2|cut -c1-2)}"
fi
REQUIRED_UTILS="wget tar python"
REQUIRED_UTILS="wget python"
APTCMD="apt"
APTGETCMD="apt-get"
YUMCMD="yum"
if [ "$distro" = "Kali" ]
then
APT_CANDIDATES="git locales build-essential qt5base-dev mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract util-linux firmware-mod-kit cramfsswap squashfs-tools zlib1g-dev liblzma-dev liblzo2-dev sleuthkit default-jdk lzop cpio"
elif [ $distro_version = "14" ]
then
APT_CANDIDATES="git locales build-essential libqt4-opengl mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract cramfsprogs cramfsswap squashfs-tools zlib1g-dev liblzma-dev liblzo2-dev sleuthkit default-jdk lzop srecord cpio"
elif [ $distro_version = "15" ]
then
APT_CANDIDATES="git locales build-essential libqt4-opengl mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract cramfsprogs cramfsswap squashfs-tools zlib1g-dev liblzma-dev liblzo2-dev sleuthkit default-jdk lzop srecord cpio"
elif [ $distro_version = "16" ]
then
APT_CANDIDATES="git locales build-essential libqt4-opengl mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract cramfsprogs cramfsswap squashfs-tools zlib1g-dev liblzma-dev liblzo2-dev sleuthkit default-jdk lzop srecord cpio"
elif [ $distro_version = "18" ]
then
APT_CANDIDATES="git locales build-essential libqt4-opengl mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract cramfsswap squashfs-tools zlib1g-dev liblzma-dev liblzo2-dev sleuthkit default-jdk lzop srecord cpio"
else
APT_CANDIDATES="git locales build-essential qtbase5-dev mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract cramfsswap squashfs-tools zlib1g-dev liblzma-dev liblzo2-dev sleuthkit default-jdk lzop srecord cpio"
fi
PYTHON3_APT_CANDIDATES=""
PYTHON3_YUM_CANDIDATES=""
YUM_CANDIDATES="git gcc gcc-c++ make openssl-devel qtwebkit-devel qt-devel gzip bzip2 tar arj p7zip p7zip-plugins cabextract squashfs-tools zlib zlib-devel lzo lzo-devel xz xz-compat-libs xz-libs xz-devel xz-lzma-compat python-backports-lzma lzip pyliblzma perl-Compress-Raw-Lzma lzop srecord"
APT_CANDIDATES="git locales build-essential mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract cramfsswap squashfs-tools zlib1g-dev liblzma-dev liblzo2-dev sleuthkit lzop srecord cpio"
YUM_CANDIDATES="git gcc gcc-c++ make openssl-devel gzip bzip2 tar arj p7zip p7zip-plugins cabextract squashfs-tools zlib zlib-devel lzo lzo-devel xz xz-compat-libs xz-libs xz-devel xz-lzma-compat python-backports-lzma lzip pyliblzma perl-Compress-Raw-Lzma lzop srecord"
PYTHON="$(which python3)"

# Check for root privileges
Expand Down Expand Up @@ -194,26 +175,22 @@ then
PKGCMD="$YUMCMD"
PKGCMD_OPTS="-y install"
PKG_CANDIDATES="$YUM_CANDIDATES"
PKG_PYTHON3_CANDIDATES="$PYTHON3_YUM_CANDIDATES"
fi
else
PKGCMD="$APTGETCMD"
PKGCMD_OPTS="install -y"
PKG_CANDIDATES="$APT_CANDIDATES"
PKG_PYTHON3_CANDIDATES="$PYTHON3_APT_CANDIDATES"
fi
else
if "$APTCMD" install -s -y dpkg > /dev/null
then
PKGCMD="$APTCMD"
PKGCMD_OPTS="install -y"
PKG_CANDIDATES="$APT_CANDIDATES"
PKG_PYTHON3_CANDIDATES="$PYTHON3_APT_CANDIDATES"
else
PKGCMD="$APTGETCMD"
PKGCMD_OPTS="install -y"
PKG_CANDIDATES="$APT_CANDIDATES"
PKG_PYTHON3_CANDIDATES="$PYTHON3_APT_CANDIDATES"
fi
fi

Expand All @@ -231,12 +208,9 @@ if [ $? -ne 0 ]
echo "Package installation failed: $PKG_CANDIDATES"
exit 1
fi
install_pip_package "setuptools matplotlib capstone pycryptodome gnupg tk ubi_reader"
install_pip_package "setuptools matplotlib capstone pycryptodome gnupg ubi_reader"
install_sasquatch
install_yaffshiv
install_jefferson

if [ $distro_version = "18" ]
then
install_cramfstools
fi

4 changes: 2 additions & 2 deletions src/binwalk/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ def evaluate(self, expr):
return self._eval(ast.parse(expr).body[0].value)

def _eval(self, node):
if isinstance(node, ast.Num): # <number>
return node.n
if isinstance(node, ast.Constant): # <number>
return node.value
elif isinstance(node, ast.operator): # <operator>
return self.OPERATORS[type(node.op)]
elif isinstance(node, ast.UnaryOp):
Expand Down
2 changes: 1 addition & 1 deletion src/binwalk/core/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ def _analyze(self, signature, offset):
# but we want to display them as nicely formatted strings.
if line.type == 'date':
try:
ts = datetime.datetime.utcfromtimestamp(dvalue)
ts = datetime.datetime.fromtimestamp(dvalue, datetime.UTC)
dvalue = ts.strftime("%Y-%m-%d %H:%M:%S")
except KeyboardInterrupt as e:
raise e
Expand Down

0 comments on commit 6d48df7

Please sign in to comment.