"|" this is the symbol for pipe and we use it to pipe the output of a command.
-d stands for delimiter
-f stands for field
In this example after cat ip.txt | grep "64 bytes" then we | cut -d " "(we are delimiting the space character) -f 4(selecting field 4 after delimiting spaces) this is very common for finding IP Addresses.
Then to eliminate ":" we are using the tr (translate) command:
First of all creating a .sh file with our favourite text editor.
Ex: nano ipsweep.sh
#!/bin/bashfor ip in'seq 1 254'; docatip.tx|grep"64 bytes"|cut-d" "-f4|tr-d":"&done
seq (sequence)
$ (argument)
& means that the preceding commands—to the immediate left of the &—should simply be run in the background
&& means “and”
We can improve this calling the first part of the IP Address $1
|| means or
if, then, else
#!/bin/bashif[ "$1"==""]thenecho"You forgot an IP address!"echo"Syntax: ./ipsweep.sh 192.168.1"elseforipin`seq1254`;doping-c1 $1.$ip|grep"64 bytes"|cut-d""-f4|tr-d":"&donefi# close if command
#!/bin/bashold_process=$(ps-eocommand)whiletrue; do new_process=$(ps-eocommand)diff<(echo "$old_process")<(echo "$new_process")|grep-v-E"procmon|command" olf_process=$new_processdone
grep -E "{first_thing|second_thing}" or greep "{first_thing\|second_thing}" (in the second option to greep for 2 things, we are escapong the pipe(|)
greep -v "example" --> deletes the line where example exists
for i in $(seq 1 100); do echo $1; done --> 1 to 100
for i in $(001..100); do echo $1; done --> 001 to 100
Colours
#ColoursgreenColour="\e[0;32m\033[1m"endColour="\033[0m\e[0m"redColour="\e[0;31m\033[1m"blueColour="\e[0;34m\033[1m"yellowColour="\e[0;33m\033[1m"purpleColour="\e[0;35m\033[1m"turquoiseColour="\e[0;36m\033[1m"grayColour="\e[0;37m\033[1m"#How to usefunctionctrl_c(){echo-e"\n${redColour}[!] Saliendo...\n${endColour}"rmut.t*money*total_entrada_salida.tmpentradas.tmpsalidas.tmpbitcoin_to_dollars2>/dev/nulltputcnorm;exit1}
- Exiting
In the previous example we used colours to define the script exiting.
parameter_counter=0whilegetopts"e:n:i:a:h:"arg;docase$arg ine) exploration_mode=$OPTARG;letparameter_counter+=1;;n) number_output=$OPTARG;letparameter_counter+=1;;i) inspect_transaction=$OPTARG;letparameter_counter+=1;;a) inspect_address=$OPTARG;letparameter_counter+=1;;h)helpPanel;;esacdone#Then we must set up the functions for each mode, ex:functionhelpPanel(){echo-e"\n${redColour}[!] Uso: ./btcAnalyzer${endColour}"foriin$(seq180);doecho-ne"${redColour}-";done;echo-ne"${endColour}"echo-e"\n\n\t${grayColour}[-e]${endColour}${yellowColour}Modo exploración${endColour}" echo-e "\t\t${purpleColour}unconfirmed_transactions${endColour}${yellowColour}:\t Listar transacciones no confirmadas${endColour}"
echo-e"\t\t${purpleColour}inspect${endColour}${yellowColour}:\t\t\t Inspeccionar un hash${endColour}"echo-e"\t\t${purpleColour}address${endColour}${yellowColour}:\t\t\t Inspeccionar una dirección${endColour}" echo-e "\n\t${grayColour}[-n]${endColour}${yellowColour}Limitar el número de resultados${endColour}${blueColour}(Ejemplo: -n 10)${endColour}"
echo-e "\n\t${grayColour}[-i]${endColour}${yellowColour}Proporcionar el hash de transacción${endColour}${blueColour}(Ejemplo: -i 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f)${endColour}"
echo-e "\n\t${grayColour}[-a]${endColour}${yellowColour}Proporcionar la dirección de transacción${endColour}${blueColour}(Ejemplo: -a 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa)${endColour}"
echo-e"\n\t${grayColour}[-h]${endColour}${yellowColour}Mostrar este panel de ayuda${endColour}\n"#Then to show the help panel when using an incorrect parameter:if[ $parameter_counter-eq0 ];thenhelpPanelelse if[ "$(echo $exploration_mode)"=="unconfirmed_transactions"];then if[ !"$number_output"];then number_output=100unconfirmedTransactions $number_outputelseunconfirmedTransactions $number_outputfi elif[ "$(echo $exploration_mode)"=="inspect"];theninspectTransaction $inspect_transaction elif[ "$(echo $exploration_mode)"=="address"];theninspectAddress $inspect_addressfifi