From a80d1d07a7492e4ac45ee6945174eb6a72ba8d8e Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Sat, 15 Oct 2016 19:58:39 +0300 Subject: [PATCH] Added new software bundle 'mll_utils'. Currently it contains a disk nuke utility/script which securely wipes partitions/disks. --- src/.config | 3 +- src/overlay_mll_utils.sh | 6 ++ src/overlay_mll_utils_01_prepare.sh | 12 ++++ src/overlay_mll_utils_02_disk_erase.sh | 80 ++++++++++++++++++++++++++ src/overlay_mll_utils_03_install.sh | 17 ++++++ 5 files changed, 117 insertions(+), 1 deletion(-) create mode 100755 src/overlay_mll_utils.sh create mode 100755 src/overlay_mll_utils_01_prepare.sh create mode 100755 src/overlay_mll_utils_02_disk_erase.sh create mode 100755 src/overlay_mll_utils_03_install.sh diff --git a/src/.config b/src/.config index 15a703c28..d6f267d5f 100644 --- a/src/.config +++ b/src/.config @@ -148,10 +148,11 @@ COPY_SOURCE_ISO=true # dropbear - SSH server and client. # java - installs Oracle's JRE or JDK. Manual preparations are required. # felix - Apache Felix OSGi framework. +# mll_utils - set of executable utilities (mll-*). # # Refer to the README file for more information. # -#OVERLAY_BUNDLES=glibc_full,links,dropbear,java,felix +#OVERLAY_BUNDLES=glibc_full,links,dropbear,java,felix,mll_utils # This property enables the standard penguin boot logo in the upper left corner # of the screen. The property is used in 'xx_build_kernel.sh'. The default value diff --git a/src/overlay_mll_utils.sh b/src/overlay_mll_utils.sh new file mode 100755 index 000000000..8b049832f --- /dev/null +++ b/src/overlay_mll_utils.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +time sh overlay_mll_utils_01_prepare.sh +time sh overlay_mll_utils_02_disk_erase.sh +time sh overlay_mll_utils_03_install.sh + diff --git a/src/overlay_mll_utils_01_prepare.sh b/src/overlay_mll_utils_01_prepare.sh new file mode 100755 index 000000000..4ff261df5 --- /dev/null +++ b/src/overlay_mll_utils_01_prepare.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +echo "Preparing the Minimal Linux Live utilities folder. This may take a while..." +rm -rf work/overlay/mll_utils +mkdir -p work/overlay/mll_utils/sbin + +echo "Miminal Linux Live utilities folder has been prepared." + +cd $SRC_DIR + diff --git a/src/overlay_mll_utils_02_disk_erase.sh b/src/overlay_mll_utils_02_disk_erase.sh new file mode 100755 index 000000000..c0a666994 --- /dev/null +++ b/src/overlay_mll_utils_02_disk_erase.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +if [ ! -d "$SRC_DIR/work/overlay/mll_utils" ] ; then + echo "The directory $SRC_DIR/work/overlay/mll_utils does not exist. Cannot continue." + exit 1 +fi + +cd work/overlay/mll_utils + +# 'mll-disk-erase' BEGIN + +# This script erases disks in secure way by overwriting all sectors with random +# data. Data recovery is impossible even for NSA and CIA. +cat << CEOF > sbin/mll-disk-erase +#!/bin/sh + +PRINT_HELP=false + +if [ "\$1" = "" -o "\$1" = "-h" -o "\$1" = "--help" ] ; then + PRINT_HELP=true +fi + +# Put more business logic here (if needed). + +if [ "\$PRINT_HELP" = "true" ] ; then + cat << DEOF + This utility wipes disk partitions or entire disks in secure way by + overwriting all sectors with random data. Use the '-h' or '--help' option + to print again this information. Requires root permissions. + + Usage: mll-disk-erase DEVICE [loops] + + DEVICE The device which will be wiped. Specify only the name, e.g. 'sda'. + The utility will automatically convert this to '/dev/sda' and will + exit with warning message if the actual device does not exist. + + loops How many times to wipe the specified partition or disk. The default + value is 1. Use higher value for multiple wipes in order to ensure + that no one can recover your data. + + mll-disk-erase sdb 8 + + The above example wipes '/dev/sdb' 8 times in row. +DEOF + + exit 0 +fi + +if [ ! "$(id -u)" = "0" ] ; then + echo "You need root permissions. Use '-h' or '--help' for more information." + exit 1 +fi + +if [ ! -e /dev/\$1 ] ; then + echo "Device '/dev/\$1' does not exist. Use '-h' or '--help' for more information." + exit 1 +fi + +NUM_LOOPS=1 + +if [ ! "\$2" = "" ] ; then + NUM_LOOPS=\$2 +fi + +for n in \$(seq \$NUM_LOOPS) ; do + dd if=/dev/urandom of=/dev/\$1 bs=1024b conv=notrunc +done + +CEOF + +chmod +rx sbin/mll-disk-erase + +# 'mll-disk-erase' END + +echo "Utility script 'mll-disk-erase' has been generated." + +cd $SRC_DIR + diff --git a/src/overlay_mll_utils_03_install.sh b/src/overlay_mll_utils_03_install.sh new file mode 100755 index 000000000..fbc621bab --- /dev/null +++ b/src/overlay_mll_utils_03_install.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +SRC_DIR=$(pwd) + +if [ ! -d "$SRC_DIR/work/overlay/mll_utils" ] ; then + echo "The directory $SRC_DIR/work/overlay/mll_utils does not exist. Cannot continue." + exit 1 +fi + +# Copy all generated files to the source overlay folder. +cp -r $SRC_DIR/work/overlay/mll_utils/* \ + $SRC_DIR/work/src/minimal_overlay + +echo "All utilities have been installed." + +cd $SRC_DIR +