Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task3 #51

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions task-2/team-16/host_network_moniter.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
18:51:39 => 26/05/2022 :ping success 142.250.67.174 host is up
20:26:44 => 26/05/2022 :ping success 142.250.67.174 host is up
20:30:17 => 26/05/2022 :ping success 142.250.67.174 host is up
21:36:15 => 01/06/2022 :ping success 142.250.67.174 host is up
21:40:43 => 01/06/2022 :ping success DEFAULTVALUE host is up
21:42:39 => 01/06/2022 :ping success host is up
21:48:18 => 01/06/2022 :ping success host is up
21:48:35 => 01/06/2022 :ping success 1 host is up
21:50:16 => 01/06/2022 :ping success host is up
21:53:17 => 01/06/2022 :ping success 142.250.67.174 host is up
21:53:39 => 01/06/2022 :ping success 0 host is up
21:54:40 => 01/06/2022 :ping success 10.0.0.1 host is up
21:54:49 => 01/06/2022 :ping success 10.0.0.11 host is up
21:55:25 => 01/06/2022 :ping success 192.168.1.45 host is up
36 changes: 36 additions & 0 deletions task-2/team-16/script1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

#requiement sudo permission and nmap installed
PORT_FILE="port_file.txt"

function port_find() {
echo "--------------------------------------------------------------------------------------"
sudo nmap -sT -O "$1" >port_file.txt
port=""
while read -r line; do
if [ "$line" = "PORT STATE SERVICE" ]; then
re='^[0-9]+$'
read -r line
port=$(echo "$line" | awk '{print $1}')
status=$(echo "$line" | awk '{print $2}')
p=${port:0:1}
while [[ $p =~ $re ]]; do
echo 'port '"$port" 'of the host '"$1" 'is' "$status"
read -r line
port=$(echo "$line" | awk '{print $1}')
p=${port:0:1}
done
# echo 'port '"$port" 'of the host '"$1" 'is' "$status"
# p=$(echo "$line" | awk '{print $1}')

fi
done <$PORT_FILE
if [ "$port" = "" ]; then
printf '%s\n Host seems down. If it is really up, but blocking our ping probes' "$line"
fi
rm port_file.txt
}
echo "--------------------------------------------------------------------------------------"
echo "Enter an ip : "
read -r ip
port_find "$ip"
32 changes: 32 additions & 0 deletions task-2/team-16/script2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash


function status_record() {
time=$(date +%k:%M:%S)
date=$(date +%d/%m/%Y)
suc_or_fal=""
up_or_down=""


ping "$1" &
sleep 5 && pingResponse=$? && kill -9 "$(pgrep ping)"


if [ $pingResponse -eq 0 ]; then
up_or_down="up"
suc_or_fal="success"
else
up_or_down="not up"
suc_or_fal="failed"
fi

result="${time} => ${date} :ping ${suc_or_fal} $1 host is ${up_or_down}"
echo "$result"
echo "$result" >> host_network_moniter.txt
}

while true; do
status_record "142.250.67.174"
sleep 60m

done
83 changes: 83 additions & 0 deletions task-2/team-16/script3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash

curl -X GET http://gincy.pythonanywhere.com/ -H "Accept: */*"
echo
echo "==========================================================================="

# Task 3
curl -X GET http://gincy.pythonanywhere.com/getusers -H "Accept: */*"



echo
echo "==========================================================================="



# Task 4
echo "User vinay : "
curl -X POST http://gincy.pythonanywhere.com/login -H "Authorization: "username":"vinay"," -H "Content-Type: application/json" --data-binary @- <<DATA
{
"username":"vinay"
}
DATA

echo "---------------------------------------------------------------------------"

echo "User johan : "
curl -X POST http://gincy.pythonanywhere.com/login -H "Authorization: "username":"johan"," -H "Content-Type: application/json" --data-binary @- <<DATA
{
"username":"johan"
}
DATA

echo "---------------------------------------------------------------------------"

echo "User alice : "
curl -X POST http://gincy.pythonanywhere.com/login -H "Authorization: "username":"alice"," -H "Content-Type: application/json" --data-binary @- <<DATA
{
"username":"alice"
}
DATA


echo
echo "==========================================================================="



echo "User vinay : "
curl -X GET http://gincy.pythonanywhere.com/getid -H "Accept: */*" -H "Authorization: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoidmluYXkiLCJpZCI6NCwiZXhwIjoxNzAzOTQ5NDc5fQ.-7GoR85YvyoZbfhP5PjdX3RyeMrpmvCa8N0i9bXqvm8""

echo "---------------------------------------------------------------------------"

echo "User johan : "
curl -X GET http://gincy.pythonanywhere.com/getid -H "Accept: */*" -H "Authorization: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiam9oYW4iLCJpZCI6NCwiZXhwIjoxNzAzOTQ5NDc5fQ.UFV_KQu1UGReoBzZ9QiJIcTa6XfZm1OnXoypLlb8icg""

echo "---------------------------------------------------------------------------"

echo "User alice : "
curl -X GET http://gincy.pythonanywhere.com/getid -H "Accept: */*" -H "Authorization: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoiYWxpY2UiLCJpZCI6NCwiZXhwIjoxNzAzOTQ5NDc5fQ.av8RVoE3oZhK70238Gd43EzOYHsldnYTiyupJpSUlVU""






# LOG_FILE="../access.log"
# read -rp "Enter an IP (Pressing enter uses 42.236.10.125): " input
# input=${input:-"42.236.10.125"}
# function ipdetail () {
# local givenIp="$1"

# while read -r line; do
# ip=$(echo "$line" | awk '{print $1}')
# if [[ "${givenIp}" == "${ip}" ]]; then
# echo "$line"
# echo "--------------------------------------------------------------------------------------"
# fi

# done < $LOG_FILE

# }
# ipdetail "${input}"
Binary file not shown.
Binary file not shown.