Ok so I've just recently started studying network security, and had no knowledge of linux before doing so. I was trying to write a script that will basically do what the GUI in wireshark does when you follow tcp streams and then export the objects. I have pretty much no background in coding whatsoever and I was wondering the best format to do this in. Everything worked perfectly but then I decided to add a function to test the output against the original with md5sum. I can't get it to work.
function testScript {
if [[ $test == "yes" ]]; then
echo "Type original file path: ";
read ogfpath;
md5sum "$fpath" "$ogfpath" > print
else
echo "Goodbye"
fi
}
echo -n 'Type stream number and press ENTER: '
read stream
echo -n 'Type pcap path and press ENTER: '
read pcap
echo -n 'Type magic number and press ENTER: '
read mnum
echo -n 'Type new file path and press ENTER: '
read fpath
tshark -2 -q -z follow,tcp,raw,$stream -r $pcap | tr '\n' ' ' | sed 's\ \\g' | grep -oP "(?<="$mnum").+" | sed "s/^/"$mnum"/g" | xxd -r -p > $fpath
echo -n 'Do you want to test the program (y/n)? :'
read test
testScript