Sometimes you wonder you might want to create several Mach-O executable files on macOS for any fun or test purpose where each Mach-O has different hash such as ( MD5, SHA1, or SHA256 ) from one another. The following script will help you in achieving that.
Pre-requisites:
1. Command-line tools for macOS need to be installed on mac prior to executing the below script.
How to Run:
1. Copy the following code snippet to a file and save it with the name randomMachoGenerator.sh.
2. Run the bash script as sh randomMachoGenerator.sh in Terminal.
3. The following script will compile and execute unique Mach-O binaries inside the directory.
#!/usr/bin/env bash
START=1
END=10
echo 'Generating random Mach-O binaries'
for ((n=$START; n<=$END; n++))
do
#Generating 12 letter random string
STATEMENT=$(dd if=/dev/urandom count=1 2> /dev/null | uuencode -m - | sed -ne 2p | cut -c-12)
cat > randomMachoGenerator.cpp << EOF
#include
using namespace std;
int main() {
cout << "${STATEMENT}"<< endl;
return 0;
}
EOF
g++ randomMachoGenerator.cpp -o Random_macho${n}
#execute the binaries built in above step
./Random_macho${n}
done
The script is also available at : https://github.com/anandmpandit/bash-scripts/blob/master/randomMachoGenerator.sh
Comments
Post a Comment