Running checksum check on an application - OSX - macos

Ive just read about the issue with Malware inside of handbrake for OSX - link to article on hacker news.
Ive got handbrake installed on a few computers of mine, so wanted to check wether i had an infected copy. To do this i ran the following terminal command as suggested via handbrakes checksum page.
COMMAND : cd /Applications shasum -a 1 HandBrake-* && shasum -a 256 HandBrake-
From this i got the following response which seems to be blank.. any ideas wether this is saying that i have an infected file or if ive just run the initial terminal command wrong ?
RESPONSE : shasum: HandBrake-: Sams-MacBook-Pro:Applications Sam$

It appears the instructions on the HandBrake website are for checking the original .dmg file downloaded and saved in the ~/Downloads directory:
~/Downloads/HandBrake-1.0.7.dmg
Open Terminal.app
cd ~/Downloads
shasum -a 1 HandBrake-* && shasum -a 256 HandBrake-*
Result:
6d2e5158f101dad94ede3d5cf5fda8fe9fd3c3b9 HandBrake-1.0.7.dmg
3cd2e6228da211349574dcd44a0f67a3c76e5bd54ba8ad61070c21b852ef89e2 HandBrake-1.0.7.dmg
If you have a version of HandBrake already installed and want to verify the shasum:
Check the version of HandBrake.app installed in /Applications
Download the corresponding .dmg from the archive page (https://handbrake.fr/old.php)
Run command (shown above) mentioned here on the .dmg and verify it matches
If the returned shasums match the corresponding version mount the .dmg
Finally, run the following commands:
shasum -a 1:
$ shasum -a 1 /Applications/HandBrake.app/Contents/MacOS/HandBrake && \
shasum -a 1 /Volumes/HandBrake-1.0.2/HandBrake.app/Contents/MacOS/HandBrake
Result:
95017f8cc3d634d71b45407830d22e65a9098cb8 /Applications/HandBrake.app/Contents/MacOS/HandBrake
95017f8cc3d634d71b45407830d22e65a9098cb8 /Volumes/HandBrake-1.0.2/HandBrake.app/Contents/MacOS/HandBrake
shasum -a 256:
$ shasum -a 256 /Applications/HandBrake.app/Contents/MacOS/HandBrake && \
shasum -a 256 /Volumes/HandBrake-1.0.2/HandBrake.app/Contents/MacOS/HandBrake
Result:
200c8ace634f792bffd3142f96c2187943c0243a441363220202552eb804dcec /Applications/HandBrake.app/Contents/MacOS/HandBrake
200c8ace634f792bffd3142f96c2187943c0243a441363220202552eb804dcec /Volumes/HandBrake-1.0.2/HandBrake.app/Contents/MacOS/HandBrake
If the hashes match (showing twice each command) then you'll know the binary is legit.

Related

Why does "which -a" show multiple (same) entries in Git Bash for Windows?

Output of which -a commands:
$ which -a grep
/usr/bin/grep
/bin/grep
/usr/bin/grep
/c/_Apps/bin/grep
/usr/bin/grep
$ which -a which
/usr/bin/which
/bin/which
/usr/bin/which
/usr/bin/which
The /usr/bin/xxx appears thrice.
Equivalent Windows where command shows unique entries:
$ where grep
D:\_Apps\Git\usr\bin\grep.exe
C:\_Apps\bin\grep.exe
$ where which
D:\_Apps\Git\usr\bin\which.exe
Git version
$ git --version
git version 2.33.0.windows.2
Entries in PATH environment variable (related to Git):
D:_Apps\Git\mingw64\bin
D:_Apps\Git\usr\bin
D:_Apps\Git\
Notes:
The reason the first command for grep shows an additional entry (/c/_Apps/bin/grep) is that I have a separate grep executable stored (along with sed and wget).
I'm using the portable version of Git for Windows
I tried searching Google with "git bash" "which" command shows multiple entries /usr/bin, but couldn't find any results (only scanned the first few entries).
Related note: I'm guessing this is why many basic Git commands are slow in my system. Even git log or git status takes a few seconds each time they run. I tried suggestions for that from other SO posts, including updating Git. None of them has worked so far.

Is there a way to unarchive a dmg file like a tar.gz file? (Using Mac OS)

I'm trying to use a program that uses Linux versions of other programs.
I ran this in bash:
c3dpath=$( command -v c3d )
if [[ -z "${c3dpath}" ]]; then
echo "Command c3d was not found. Downloading and installing software to ${SCRIPTPATH}/depends/c3d. Path will be added to PATH environment variable."
mkdir -p "${SCRIPTPATH}/depends/c3d/"
wget https://downloads.sourceforge.net/project/c3d/c3d/Nightly/c3d-nightly-Linux-x86_64.tar.gz && \
tar -xzvf c3d-nightly-Linux-x86_64.tar.gz && mv c3d-1.1.0-Linux-x86_64/* "${SCRIPTPATH}/depends/c3d/" && \
rm c3d-nightly-Linux-x86_64.tar.gz
export PATH="${SCRIPTPATH}/depends/c3d/c3d-1.1.0-Linux-x86_64/bin/:$PATH"
fi
But it downloads the linux version of the program files into my directory -- yielding the error:
{..omitted}/HippMapp3r/depends/c3d/bin/c3d: cannot execute binary file
Return Code: 126
I understand in order for this to work on my computer, I need to use the version for Mac OS, however, I stuck on how one might go about "unarchiving" the files contained within a .dmg file so I can access c3d in bin.
I edited it to this, but I understand I cannot use the tar -xzvf command in this context -- is there an equivalent to tar -xzvf to "unpack" dmg files?
c3dpath=$( command -v c3d )
if [[ -z "${c3dpath}" ]]; then
echo "Command c3d was not found. Downloading and installing software to ${SCRIPTPATH}/depends/c3d. Path will be added to PATH environment variable."
mkdir -p "${SCRIPTPATH}/depends/c3d/"
wget https://downloads.sourceforge.net/project/c3d/c3d/Nightly/c3d-nightly-MacOS-x86_64.dmg && \
tar -xzvf c3d-nightly-MacOS-x86_64.dmg * "${SCRIPTPATH}/depends/c3d/" && \
rm c3d-nightly-MacOS-x86_64.dmg
export PATH="${SCRIPTPATH}/depends/c3d/c3d-nightly-MacOS-x86_64/bin/:$PATH"
fi
Try using 7-zip. You can install it on a Mac with homebrew using:
brew install p7zip
Then run it with:
7z
Please see comment by #StefanSchmidt about a possible alternative package.
First you have to mount the DMG file.
command: hdiutil mount test.dmg

Windows Console Output from Waifu2x-caffe unintelligible

I am using Waif2x to upscale a series of images, but I am having a problem with the command I am running. I would try to troubleshoot it myself, yet I can't not make use of the error output. It reads:
âGâëü[: âéâfâïâtâ#âCâïé¬èJé»é▄é╣é±é┼é╡é╜
I think it is in Japanese as evidenced by Waifu2x's Github page. I also believe it is the same everytime, yet I cant know for sure. I am using a English Computer, and I am also a English speaker, so I really need to know what it is in English or something I can Google translate.
I have already tried the solution here as evidenced by looking at the regedit, where Name=00, Data=Consolas.
Regarding my specific problem, the Command I am typing into cmd is
waifu2x-caffe-cui -i "C:\Users\Christian\workspace\CodeLyokoUpscaleing\bin\480Frames" -e png -l png -m noise_scale -d 16 -h 1440 -n 1 -p cudnn -c 256 -b 1 --auto_start 1 --auto_exit 1 --no_overwrite 1 -y upconv_7_anime_style_art_rgb -o "C:\Users\Christian\workspace\CodeLyokoUpscaleing\bin\1440Frames"
I really think it should work as I converted it from another batch file I created that contained variables instead of file paths
waifu2x-caffe-cui -i "%~dp0480Frames" -e png -l png -m noise_scale -d 16 -h 1440 -n 1 -p cudnn -c 256 -o "%~dp01440Frames" --auto_start 1 --auto_exit 1 --no_overwrite 1 -y upconv_7_anime_style_art_rgb
But I still get the weird output.
How can I see what the error is?

How to unpack and pack pkg file?

I have a pkg file created by Install Maker for Mac.
I want to replace one file in pkg. But I must do this under Linux system, because this is a part of download process. When user starts to download file server must replace one file in pkg.
I have a solution how unpack pkg and replace a file but I dont know how pack again to pkg.
http://emresaglam.com/blog/1035
http://ilostmynotes.blogspot.com/2012/06/mac-os-x-pkg-bom-files-package.html
Packages are just .xar archives with a different extension and a specified file hierarchy. Unfortunately, part of that file hierarchy is a cpio.gz archive of the actual installables, and usually that's what you want to edit. And there's also a Bom file that includes information on the files inside that cpio archive, and a PackageInfo file that includes summary information.
If you really do just need to edit one of the info files, that's simple:
mkdir Foo
cd Foo
xar -xf ../Foo.pkg
# edit stuff
xar -cf ../Foo-new.pkg *
But if you need to edit the installable files:
mkdir Foo
cd Foo
xar -xf ../Foo.pkg
cd foo.pkg
cat Payload | gunzip -dc |cpio -i
# edit Foo.app/*
rm Payload
find ./Foo.app | cpio -o | gzip -c > Payload
mkbom Foo.app Bom # or edit Bom
# edit PackageInfo
rm -rf Foo.app
cd ..
xar -cf ../Foo-new.pkg
I believe you can get mkbom (and lsbom) for most linux distros. (If you can get ditto, that makes things even easier, but I'm not sure if that's nearly as ubiquitously available.)
Here is a bash script inspired by abarnert's answer which will unpack a package named MyPackage.pkg into a subfolder named MyPackage_pkg and then open the folder in Finder.
#!/usr/bin/env bash
filename="$*"
dirname="${filename/\./_}"
pkgutil --expand "$filename" "$dirname"
cd "$dirname"
tar xvf Payload
open .
Usage:
pkg-upack.sh MyPackage.pkg
Warning: This will not work in all cases, and will fail with certain files, e.g. the PKGs inside the OSX system installer. If you want to peek inside the pkg file and see what's inside, you can try SuspiciousPackage (free app), and if you need more options such as selectively unpacking specific files, then have a look at Pacifist (nagware).
You might want to look into my fork of pbzx here: https://github.com/NiklasRosenstein/pbzx
It allows you to stream pbzx files that are not wrapped in a XAR archive. I've experienced this with recent XCode Command-Line Tools Disk Images (eg. 10.12 XCode 8).
pbzx -n Payload | cpio -i
In addition to what #abarnert said, I today had to find out that the default cpio utility on Mountain Lion uses a different archive format per default (not sure which), even with the man page stating it would use the old cpio/odc format. So, if anyone stumbles upon the cpio read error: bad file format message while trying to install his/her manipulated packages, be sure to include the format in the re-pack step:
find ./Foo.app | cpio -o --format odc | gzip -c > Payload
#shrx I've succeeded to unpack the BSD.pkg (part of the Yosemite installer) by using "pbzx" command.
pbzx <pkg> | cpio -idmu
The "pbzx" command can be downloaded from the following link:
pbzx Stream Parser
If you are experiencing errors during PKG installation following the accepted answer, I will give you another procedure that worked for me (please note the little changes to xar, cpio and mkbom commands):
mkdir Foo
cd Foo
xar -xf ../Foo.pkg
cd foo.pkg
cat Payload | gunzip -dc | cpio -i
# edit Foo.app/*
rm Payload
find ./Foo.app | cpio -o --format odc --owner 0:80 | gzip -c > Payload
mkbom -u 0 -g 80 Foo.app Bom # or edit Bom
# edit PackageInfo
rm -rf Foo.app
cd ..
xar --compression none -cf ../Foo-new.pkg
The resulted PKG will have no compression, cpio now uses odc format and specify the owner of the file as well as mkbom.
Bash script to extract pkg: (Inspired by this answer:https://stackoverflow.com/a/23950738/16923394)
Save the following code to a file named pkg-upack.sh on the $HOME/Downloads folder
#!/usr/bin/env bash
filename="$*"
dirname="${filename/\./_}"
mkdir "$dirname"
# pkgutil --expand "$filename" "$dirname"
xar -xf "$filename" -C "$dirname"
cd "$dirname"/*.pkg
pwd
# tar xvf Payload
cat Payload | gunzip -dc |cpio -i
# cd usr/local/bin
# pwd
# ls -lt
# cp -i * $HOME/Downloads/
Uncomment the last four lines, if you are using a rudix package.
Usage:
cd $HOME/Downloads
chmod +x ./pkg-upack.sh
./pkg-upack.sh MyPackage.pkg
This was tested with the ffmpeg and mawk package from rudix.org (https://rudix.org) search for ffmpeg and mawk packages on this site.
Source : My open source projects : https://sourceforge.net/u/nathan-sr/profile/

error when switching to directory: "perl version 5.12.3 can't run /usr/bin/shasum"

I installed rvm 1.9.3 and now whenever I switch to a directory containing a .rvmrc, I get a perl error message:
~/example$ cd .. && cd example
perl version 5.12.3 can't run /usr/bin/shasum. Try the alternative(s):
/usr/bin/shasum5.10.0 (uses perl 5.10.0)
Run "man perl" for more information about multiple version support in
Mac OS X.
You may try this dirty approach. This approach will skip those check and directly use shasum in your binary directory
$ cd /usr/bin
$ ls shasum*
shasum shasum5.10.0
$ mv /usr/bin/shasum /usr/bin/your_backup_shasum
$ ln -s shasum5.10.0 shasum

Resources