Primul script bash dupa ce am terminat seria BusyBox

2

Buna ziua doamnelor si domnilor si bine v-am regasit. Ma numesc Zero Davila, iar astazi vom scrie un mic shell cript in bash,foarte simplu si foarte simplu de inteles, ca preludiul seriei de bash scripting care va urma, daca o pot pune asa. Pentru scriptul de astazi nu vom volosi nimic prea complex, doar cateva comenzi rudimentare care le-am invatat in seria busybox. Intai vom afisa un meniu cu o serie de echouri. Apoi vom prelua date de la utilizator folosind comanda read, utilizatorul trebuie sa introduca un integer intre 1 si 6, apoi folosind niste conditionale if, in functie de numarul introdus, vom afisa niste instructiuni iar apoi vom executa o comanda, totul din script. Scriptul propriuzis doar distruge sau sterge sau rescrie date de pe masina curenta de linux, folosind programull dd, iar  comenzile sunt deja scrise in script, si vor fi completate de utilizator, pentru a evita greseli, sincer, comanda dd mereu m-a
facut putin paranoic. Meniul scriptului ne va da de ales intre a umple un hard cu zerouri, a umple un hard cu date random, a sterge un hard, toate de mai sus si pentru anumite partitii ale unor anumite harduri, sau a sterge un Master Boot Record, care  e un tip special de sector boot, e primul sector fizic chiar, care e executat la sfarsitul rutinei biosului, dupa ce pornimmasina.

#!/bin/bash

echo “””

.,:clooll:,.
;dKWMMMMMMMMMMMMWKx:
:XMMMMMMMMMMMMMMMMMMMMX:
oMMMMMMMMMMMMMMMMMMMMMMMMl
.WlXMMMMMMMMMMMMMMMMMMMMXcN.
,N 0MMMMMMMMMMMMMMMMMMMMX K;
.N;cMMMMMMMMMMMMMMMMMMMMo,W.
:k.MXkdlcckMMMMk:clokXM,dc
.’X. .NMMW. K:
,x’ oM: .OMMMM0. :Wx .x,
OMWl dMWk:;dNWoc:oWNd::xWMk :WMO
,KMMMMNkc’ .dKWMMMMd ;’ oMMMMW0d. .:dXMMMM0′
.”..;oONMNkc’ .;xWMd.xo.oMMk;. .:xXMWKd:”,;.
.cxXMc’l,cNWWWWWNXo’c,:MNkl’
…loccllooccccll’..
.Kcccllodlccl:X.
.,oON:oWN0kkOOkk0NWo,NOo,.
.dxddkKWMKx:. .oOXWWWWXOo. .:xXMWKxoooo.
.OMMMk:. .c0MMM0,
.WX, ;XM’
‘ .,
# # #
# # # # # # # # # # # # # ###### #####
# # ## # # # # # # # # # # # # #
# # # # # # # ## ### # # # ##### # #
# # # # # # # ## # # # # # # #####
# # # ## # # # # # # # # # # # #
####### # # # #### # # # # # ###### ###### ###### # #
#============================================= By Zero Davila 2016
“””

echo “[1] Zero fill Hard Drive”
echo “[2] Random data fill HD *4SECURITY*”
echo “[3] Wipe Master Boot Record”
echo “[4] Wipe specific partition”
echo “[5] Zero fill specific partition”
echo “[6] Random data fill partition *4SEC*”

read -p “[ ! ]> ” INPUT

if [[ $INPUT -eq 1 ]]
then
echo “[*] You have chosen to Zero Fill a Hard Drive!”
echo “[*] This will take some time…”
echo “[*] The command about to be executed is :”
echo “[!] dd if=/dev/zero of=/dev/sdX bs=1M”
echo “[*] Replace X with the target drive letter.”
echo “[*] ‘a’ is the first HD, ‘b’ is the second, etc.”
echo “[*] If unsure, or if you only have one hard drive, insert the letter ‘a'”
read -p “ZeroFillHD> ” TARGET1
sudo dd if=/dev/zero of=/dev/sd$TARGET1 bs=1M
fi

if [[ $INPUT -eq 2 ]]
then
echo “[*] You have chosen to Random Data Fill a Hard Drive!”
echo “[*] This is used for security purposes and will take some time…”
echo “[*] The command about to be executed is :”
echo “[!] dd if=/dev/urandom of=/dev/sdX bs=1M”
echo “[*] Replace X with the target drive letter.”
echo “[*] ‘a’ is the first HD, ‘b’ is the second, etc.”
echo “[*] If unsure, or if you only have one hard drive, insert the letter ‘a'”
read -p “RandFillHD> ” TARGET2
sudo dd if=/dev/urandom of=/dev/sd$TARGET2 bs=1M
fi

if [[ $INPUT -eq 3 ]]
then
echo “[*] You have chosen to Wipe the Master Boot Record!”
echo “[*] The command about to be executed is :”
echo “[!] dd if=/dev/zero of=/dev/hdX bs=446 count=1”
echo “[*] Replace X with the target drive letter.”
echo “[*] ‘a’ is the first HD, ‘b’ is the second, etc.”
echo “[*] If unsure, or if you only have one hard drive, insert the letter ‘a'”
read -p “WipeMBR> ” TARGET3
sudo dd if=/dev/zero of=/dev/hd$TARGET3 bs=446 count=1
fi

if [[ $INPUT -eq 4 ]]
then
echo “[*] You have chosen to Wipe a Specific Partition!”
echo “[*] The command about to be executed is :”
echo “[!] dd if=/dev/zero of=/dev/sdXY bs=446 count=1”
echo “[*] Replace X with the target drive letter, Y with partition number”
echo “[*] ‘a’ is the first HD, ‘b’ is the second, etc.”
echo “[*] ‘1’ is the first partition, ‘2’ the second, etc.”
echo “[*] If unsure, or if you only have one hard drive, insert the letter ‘a'”
echo “[*] If unsure, or if you only have one disk partition, insert the number ‘1’”
read -p “TargetDrive> ” TARGET4
read -p “TargetPartition> ” TARGET5
sudo dd if=/dev/zero of=/dev/sd$TARGET4$TARGET5 bs=446 count=1
fi

if [[ $INPUT -eq 5 ]]
then
echo “[*] You have chosen to Zero Fill a Partition!”
echo “[*] This will take some time…”
echo “[*] The command about to be executed is :”
echo “[!] dd if=/dev/zero of=/dev/sdXY bs=1M”
echo “[*] Replace X with the target drive letter, Y with partition number”
echo “[*] ‘a’ is the first HD, ‘b’ is the second, etc.”
echo “[*] ‘1’ is the first partition, ‘2’ the second, etc.”
echo “[*] If unsure, or if you only have one hard drive, insert the letter ‘a'”
echo “[*] If unsure, or if you only have one disk partition, insert the number ‘1’”
read -p “TargetDrive> ” TARGET6
read -p “TargetPartition> ” TARGET7
sudo dd if=/dev/zero of=/dev/sd$TARGET6$TARGET7 bs=1M
fi

if [[ $INPUT -eq 6 ]]
then
echo “[*] You have chosen to Random Data Fill a Partition!”
echo “[*] This is used for security purposes and will take some time…”
echo “[*] The command about to be executed is :”
echo “[!] dd if=/dev/urandom of=/dev/sdXY bs=1M”
echo “[*] Replace X with the target drive letter, Y with partition number”
echo “[*] ‘a’ is the first HD, ‘b’ is the second, etc.”
echo “[*] ‘1’ is the first partition, ‘2’ the second, etc.”
echo “[*] If unsure, or if you only have one hard drive, insert the letter ‘a'”
echo “[*] If unsure, or if you only have one disk partition, insert the number ‘1’”
read -p “TargetDrive> ” TARGET8
read -p “TargetPartition> ” TARGET9
sudo dd if=/dev/urandom of=/dev/sd$TARGET8$TARGET9 bs=1M
fi

2 Comments
  1. Costi says

    Buna,puteti sa imi faceti doua introuri cu numele de Gamerita XD si Costy YTB

  2. Costi says

    Buna,puteti sa imi faceti doua introuri cu numele de Gamerita XD si Costy YTB

Leave A Reply

Your email address will not be published.