Commit 5fef7573 authored by ABHISHEK KUMAR's avatar ABHISHEK KUMAR

Added Lab3

parent 327124a5
#!/bin/bash
ssh-keygen -t rsa
ssh-copy-id -i ~/.ssh/id_rsa.pub $1"@"$2
ssh $1"@"$2
\ No newline at end of file
#!/bin/bash
while :
do
sleep 0.5
done
\ No newline at end of file
#!/bin/bash
#subtask 3
PS1='${debian_chroot:+($debian_chroot)}\u@\h - \t [\W]:\$ '
# \t is used to display the time in hh:mm:ss format
# \W displays the current directory
#subtask 4
alias bk="cd \$OLDPWD"
#aliases bk to cd \$OLDPWD, '\$' to escape $
#subtask 5
echo -e "\033[51;31m@ @ \033[0m"
echo -e "\033[12;31m@ @ \033[0m"
echo -e "\033[53;61m@ @ \033[0m"
echo -e "\033[01;31m@ @ \033[0m"
echo -e "\033[01;32m@-----------@ \033[0m"
echo -e "\033[01;31m@ @ \033[0m"
echo -e "\033[01;31m@ @ \033[0m"
echo -e "\033[01;31m@ @ \033[0m"
Group 25 Marauders
(Shaan Vaidya 150050004) (Abhishek Kumar 150050020) (Vishwajeet Singh Bagdawat 150050046)
I pledge on my honour that I have not given or received unauthorised assistance on this assignment or any previous task. -Shaan
I pledge on my honour that I have not given or received unauthorised assistance on this assignment or any previous task. -Abhishek
I pledge on my honour that I have not given or received unauthorised assistance on this assignment or any previous task. -Vishwajeet
Contribution:
Shaan : 100%
Abhishek: 100%
Vishwajeet: 100%
Citations:
www.tutorialspoint.com/unix_commands/
- grep, tr, cut etc.
https://support.suso.com/supki/SSH_Tutorial_for_Linux
- ssh
http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/internet/node31.html
- ssh-keygen (generate ssh key)
http://linux.die.net/man/1/ssh-copy-id
- ssh-copy-id (copy the key to remote server)
Extra credits attempted:
Task A 5
Task C 4
Task A:
Bash manages autocomplete using 'readline' library which in turn provides functions for applications that allow users to edit command lines.
When tab is pressed, readline calls back to bask which in turn returns a list of possible completions. Readline then inserts as many characters that are common for all functions.
Bash also has a builtin 'complete' function to define how to complete commands. First it matches with commands, if nothing then file names. One can also customise this.
Bash also stores history and stores size in HISTSIZE variable. Can be seen using history.
Task B:
'meminfo' file in the /proc directory contains information regarding memory usage
Command used for the task:
grep -w 'MemTotal\|MemFree' meminfo | tr -d " " | cut -d \: -f 2
grep searches for the words (-w option) MemTotal and MemFree in meminfo. \| is used to escape the pipe operator as 'or'.
tr translates the data. -d option with " " argument removes spaces.
cut -d separates the data by delimiter ':'. -f option helps select data fields in output which is '2' in this case.
Task C:
Command used for 'ssh'ing : ssh shaan@mars.cse.iitb.ac.in
Command used for graphical output on local machine: ssh -X shaan@cse.iitb.ac.in
-X option enables X11 forwarding onto the local machine
Task D:
./infiniteLoop.sh &
OR
source infiniteLoop.sh &
'&' runs the script in the background directly; instead one could use bg to throw the process to background. (source infiniteLoop.sh was used as the alternative gave a 'permission denied' error) We looked this up on the internet
ps -aux | grep infiniteLoop.sh
- get pid
kill [process-id]
OR
pkill [script-name]
We started with bringing the process to foreground and then kill it but obviously it was wrong as it killed all fg processes. So we used kill [process-id] but that required to first look up the process-id using 'ps -aux' piped with grep.
pkill [script-name] kills the process started by the script whose name we passed as argument.
Group 25 Marauders
(Shaan Vaidya 150050004) (Abhishek Kumar 150050020) (Vishwajeet Singh Bagdawat 150050046)
I pledge on my honour that I have not given or received unauthorised assistance on this assignment or any previous task. -Shaan
I pledge on my honour that I have not given or received unauthorised assistance on this assignment or any previous task. -Abhishek
I pledge on my honour that I have not given or received unauthorised assistance on this assignment or any previous task. -Vishwajeet
Contribution:
Shaan : 100%
Abhishek: 100%
Vishwajeet: 100%
Regarding restricting login only through cURL or wget:
*Maybe* as cURL does not support JS or cookies, one can detect if the site is being accessed through the browser or cURL.
Regarding terminal not displaying the pokemon:
*Maybe* as the terminal does not support all characters, they just get ignored alongwith the recognised characters in between while html just ignores them and prints the one it knows.
Reflection Essay:
Bash scripting is amazing! The time when you are able to successfully run a dictionary attack is gold (Note: I *might* be exaggerating). Firstly, kudos to the ones who constructed the whole set. Besides a lot, we also learnt how to Google. cURL and Ncat is a lot of power on the command line. Regex is fun though confusing at times; an infinite number of syntaxes. sed took some time to learn. Dictionary attack was fun!
Citations:
http://alvinalexander.com/unix/edu/examples/find.shtml - find
http://www.binarytides.com/linux-find-command-examples/ - find
http://droptips.com/using-grep-and-ignoring-case-case-insensitive-grep
https://www.gnu.org/software/grep/manual/grep.html - grep
http://www.windytan.com/2013/09/lan-file-transfer-with-netcat.html - Ncat
http://teaching.idallen.com/dat2330/04f/notes/exit_status.txt - Exit statuses, for dictionary attack success
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_01.html - for loop
https://bash.cyberciti.biz/guide/If..else..fi - if construct
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_02.html - while loop
https://curl.haxx.se/docs/httpscripting.html - cURL
http://www.computerhope.com/unix/urm.htm - rm
http://www.compciv.org/topics/bash/variables-and-substitution/ - variables
https://www.gnu.org/software/gawk/manual/html_node/Printf-Examples.html - awk
http://unix.stackexchange.com/questions/177309/output-both-stderr-and-stdout-on-console-and-store-them-in-a-file-at-same-time - output redirection
http://searchnetworking.techtarget.com/definition/client-server - Read about client-server model
http://www.computerhope.com/jargon/n/netmask.htm - Read about Netmask
http://www.computerhope.com/unix/uifconfi.htm - Read about ifconfig
http://portforward.com/networking/whatisport.htm - reading for ports
http://portforward.com/networking/whatisip.htm - reading for IP Address
http://tldp.org/LDP/abs/html/x23170.html - Looked up about sed
\ No newline at end of file
Tokyo
home/abhishek/Desktop/3rd Sem/CS251/This year Labs/Lab3/Earth/Asia/
find Japan/ -iname "T*" ! -executable -size +50k -size -100k -user abhishek ! -writable| xargs gedit
cd
ls
\ No newline at end of file
GRASS Sceptile
/home/abhishek/Desktop/3rd Sem/CS251/This year Labs/Lab3/Earth/Asia/China/
grep -i '^\(grass\|water\)\s\w[^bm]\{6,10\}$' Shanghai
\ No newline at end of file
Magikarp
rm -r */
rm A*
rm {1..20}
rm *.jpg
cat $(ls -x) > ultraball.html
\ No newline at end of file
Squirtle
alpha omega
curl -s https://www.cse.iitb.ac.in/~sharat/current/cs251/Assign/Lab03/support/verify.php -d "username=alpha&password=omega"
cf3c122f1dabdc0fc4e1c37a25556bc8
f24109a62a0422577119abeb0db4f801
10.42.0.144
10.42.0.146
nc 10.42.0.146 12345 < Bulbasaur; nc -l 12345 > Slowpoke
nc 10.42.0.144 12345 < Slowpoke; nc -l 12345 > Bulbasaur
#!/bin/bash
file --mime-type * | grep 'text/x-c' | tr -d " " | cut -d \: -f 1 | while read f; do mv "$f" "$f.c"; done
file --mime-type * | grep 'application/gzip' | tr -d " " | cut -d \: -f 1 | while read f; do mv "$f" "$f.gz"; done
file --mime-type * | grep 'image/jpeg' | tr -d " " | cut -d \: -f 1 | while read f; do mv "$f" "$f.jpg"; done
file --mime-type * | grep 'text/html' | tr -d " " | cut -d \: -f 1 | while read f; do mv "$f" "$f.html"; done
#code to compile the files
# gcc *.c -o output
# ./output 2>&1 > masterball
\ No newline at end of file
ROTOM
application/gzip
image/jpeg
text/html
text/x-c
\ No newline at end of file
Magikarp
ls -ltr | awk '{print $5}'
for the final printing of characters
ls -ltr | awk '{printf "%c", $5}'
\ No newline at end of file
Hawlucha
sed -i -- 's/\(flying\|fighting\)/255 0 0/g' corruptedPokémon.ppm
sed -i -- 's/\(Def\|Sp.A\|Sp.D\|Atk\):1[0-9][0-9]/255 8 153/g' corruptedPokémon.ppm
sed -i -- 's/HP-\([0-9][0-9][0-9]\)\/[0-9][0-9][0-9]/\1/g' corruptedPokémon.ppm
sed -i -- 's/HP-\([0-9][0-9]\)\/[0-9][0-9]/\1/g' corruptedPokémon.ppm
sed -i -- 's/HP-\([0-9]\)\/[0-9]/\1/g' corruptedPokémon.ppm
\ No newline at end of file
#!/bin/bash
yes |
for a in `cat dictionary.txt`; do
unzip -qq -P $a legendaryPokemon.zip; #-qq quieter, remove error messages
if test $? -eq 0; #$? returns 0 if status success
then printf "\n $a \n";
fi
done
\ No newline at end of file
Mewtwo
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment