from util import find_data_file from util import setup_child from util import fprint from util import run_cmd from util import win32 from util import linux from util import kill import util import time import csv import ssh def get_blocklist(config): setup_child() fprint("Downloading deny list from server") data = ssh.check_for_file(config, "BadIPs.csv", "receive") #fprint(data.stdout) csvreader = csv.reader(data.stdout.split("\n"), delimiter=',', quotechar='|') data2 = list() for row in csvreader: data2.append(row) data2 = [i for i in data2 if i] fprint(data2) return data2 def block_conn(config, datafile, res): setup_child() fprint("Searching block data") mydata = list() with open(find_data_file(datafile), newline='') as csvfile: csvreader = csv.reader(csvfile, delimiter=',', quotechar='|') for row in csvreader: mydata.append(row) #fprint(mydata) for line in mydata: fprint(line) fprint(line) srcip = line[2].split(":")[0] destip = line[4].split(":")[0] pid = line[5] for line in res: fprint(line) badsrcip = line[2] baddestip = line[4] badpid = line[11] if srcip == badsrcip or destip == baddestip: fprint("FLAG " + srcip + " " + destip + " " + pid) kill(pid)