Skip to content

Bash

Linux bash script, basic script that records the website availability HTTP code 200s, 300s, 400s, 500s

Linux bash script, basic script that records the website availability HTTP code 200s, 300s, 400s, 500s

"Linux bash script, basic script that records the website availability HTTP code 200s, 300s, 400s, 500s"

To do next... color coding alerts maybe?!

the-linux-bash-script

#!/bin/bash

IFS='
'

LIST_URLs="https://www.antoniofeijao.com/
https://www.antoniofeijao.pt/
https://www.antoniocloud.com/
https://antonio.cloud/
https://www.cyberantonio.com/
https://www.cloudsecurity.cc/
https://www.securitygames.net/
https://www.root.pt/
https://www.ninja.pt/
https://www.ntp.pt/"


for URL in $(echo ${LIST_URLs} | tr '\ ' '\n'); do
    while true; do
        LOGS="${URL:8:-1}-$(date +%F).txt" && \
        DATE=$(date +%F-%H%M-%Ss) && \
        RESULT=$(curl -I ${URL} --silent | head -n 1) && \
        echo -e "${DATE}; \t ${URL}; \t ${RESULT}" >> ${LOGS} && \
        sleep 15
    done &
done

Happy learning,

Antonio Feijao

cyberantonioctf

AWS EC2 userdata sample script to build an Webpage

Sample of an AWS EC2 userdata script that installs apache and automatically creates an index.html file as a landing webpage with information about the instance - instanceId, availabilityZone, instanceType and region. This could also be used with launch configuration on an Auto Scaling Group (ASG) to use as multiple instances on Elastic Load Balancing load balancer (ALB) to easy show the usage of multiple instances behind the load balancer.

At your own risk, always review what you are running.

To run this userdata script, add the below into the EC2 userdata

#!/bin/bash
curl https://raw.githubusercontent.com/AntonioFeijaoUK/aws-ec2-userdata-samples/master/sample01-hello-world-region-az.sh | bash

Repository is here https://github.com/AntonioFeijaoUK/aws-ec2-userdata-samples

Direct link is here https://raw.githubusercontent.com/AntonioFeijaoUK/aws-ec2-userdata-samples/master/sample01-hello-world-region-az.sh

Other samples on AWS

If you tried it and helped you understand better how it works, please leave a comment.


Happy learning

Antonio Feijao UK

linux-command-tee-examples-how-it-works

tee command in Linux command line, how tee works, simple explanations.

The tee command has an input on the and one or more exists or outputs.

Output to a file or more, or another command AND output to the screen.

cat SAMPLE_FILE | tee > this_file.log

INPUT >>> ----|-----  >>> output_file1 output_file2 output_file3 OR/AND | output_to_another_command
              |
              |
              |
              |
              |

              also >>>> output_to_screen (unless you `2>/dev/null` (TBC?!) )

Happy learning

Antonio Feijao UK

linux-command-xargs-for-parallel-execution

xargs command can be used to "speed up" Linux commands by running the same command multiple times in parallel.

WORK IN PROGRESS

cat FILE_WITH_COMAMND_OR_WHATEVER | xargs -n1 -P10

-n1 reads one line at a time

-P10 runs up to 10 parallel commands


Happy learning

Antonio Feijao UK