#!/bin/bash

tshark -D

read -p "Enter the device name: " device

project=$1

mkdir $HOME/Desktop/$project
cd $HOME/Desktop/$project

tshark -i $device -w scan.pcap -c 60000

tshark -r scan.pcap -T json > scan.json

grep 'ip.dst":' > $project/tmpfile.txt

grep -v '192.168.' tmpfile.txt | sort | uniq > results.txt

sed -i '/255.255.255.255/d' results.txt

sed -i 's/ //g' results.txt

sed -i 's/"ip.dst":"//g' results.txt

sed -i 's/",//g' results.txt

rm tmpfile.txt

lines=$(cat results.txt)

for ip in $lines
do
    ipCheck $ip
done

grep "malicious" *.txt > maliciousResults.txt
