continue work on blocking
This commit is contained in:
		
							
								
								
									
										3
									
								
								auth.py
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								auth.py
									
									
									
									
									
								
							| @@ -3,10 +3,13 @@ import csv | ||||
| from util import fprint | ||||
| from util import find_data_file | ||||
| from time import sleep | ||||
| import bcrypt | ||||
|  | ||||
| def login(config, user, password, sysid): | ||||
|     fprint("Attempting to login as " + user) | ||||
|     filename = sysid + "login.csv" | ||||
|      | ||||
|     hashpasswd = bcrypt.hashpw(password.encode('utf-8'), user).decode() | ||||
|     with open(find_data_file(filename), "w", newline="") as f: | ||||
|         writer = csv.writer(f) | ||||
|         writer.writerows([[user,password,sysid],]) | ||||
|   | ||||
							
								
								
									
										39
									
								
								block.py
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								block.py
									
									
									
									
									
								
							| @@ -4,6 +4,7 @@ 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 | ||||
| @@ -12,5 +13,39 @@ import ssh | ||||
| def get_blocklist(config): | ||||
|     setup_child() | ||||
|     fprint("Downloading deny list from server") | ||||
|     data = check_for_file(config, "BadIPs.csv", "receive") | ||||
|     fprint(data.stdout) | ||||
|     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) | ||||
|  | ||||
|   | ||||
							
								
								
									
										17
									
								
								ippigeon.py
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								ippigeon.py
									
									
									
									
									
								
							| @@ -74,7 +74,12 @@ def login_done(res): | ||||
|         settings["loggedin"] = res | ||||
|         settings["continueui"] = True | ||||
|  | ||||
|  | ||||
| def blockdata_done(res): | ||||
|     fprint("FINISHED downloading block data") | ||||
|     #block_res = pool.apply_async(block.block_conn, (config, datafile, res)) | ||||
|     block.block_conn(config, datafile, res) | ||||
|      | ||||
|          | ||||
| def killall(): | ||||
|     kids = active_children() | ||||
|     for kid in kids: | ||||
| @@ -82,11 +87,7 @@ def killall(): | ||||
|     fprint("Every child has been killed") | ||||
|     os.kill(os.getpid(), 9) # dirty kill of self | ||||
|  | ||||
| def kill(pid): | ||||
|     setup_child() | ||||
|     fprint("Killing PID " + str(pid)) | ||||
|     #os.kill(pid, 9) | ||||
|     fprint("Signal 9 sent to PID " + str(pid)) | ||||
|  | ||||
|  | ||||
| def mainloop(pool): | ||||
|     # worker pool: netstat, netstat cleanup, upload, download, ui tasks | ||||
| @@ -133,8 +134,10 @@ def mainloop(pool): | ||||
|          | ||||
|      | ||||
|     if settings["block"] == True: | ||||
|         blockdata_res = pool.apply_async(block.get_blocklist, (config,)) #, callback=blockdata_done) | ||||
|         blockdata_res = pool.apply_async(block.get_blocklist, (config,), callback=blockdata_done) | ||||
|         #block.get_blocklist(config) | ||||
|         settings["block"] = False | ||||
|  | ||||
|     #fprint(settings["killbox"]) | ||||
|     if len(settings["killbox"]) > 0: | ||||
|         fprint("Kill opportunity!") | ||||
|   | ||||
							
								
								
									
										27402
									
								
								output.log
									
									
									
									
									
								
							
							
						
						
									
										27402
									
								
								output.log
									
									
									
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @@ -4,4 +4,5 @@ wxpython | ||||
| cx_Freeze | ||||
| pandas | ||||
| pyyaml | ||||
| numpy | ||||
| numpy | ||||
| bcrypt | ||||
							
								
								
									
										7
									
								
								util.py
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								util.py
									
									
									
									
									
								
							| @@ -4,6 +4,7 @@ import subprocess | ||||
| import os | ||||
| from sys import platform | ||||
| import time as t | ||||
| from time import sleep | ||||
| import uuid | ||||
|  | ||||
| win32 = platform == "win32" | ||||
| @@ -39,6 +40,12 @@ if linux: | ||||
| def time(): | ||||
|     return int(t.time()) | ||||
|  | ||||
| def kill(pid): | ||||
|     setup_child() | ||||
|     fprint("Killing PID " + str(pid)) | ||||
|     os.kill(pid, 9) | ||||
|     fprint("Signal 9 sent to PID " + str(pid)) | ||||
|  | ||||
| def fprint(msg): | ||||
|     #if not getattr(sys, "frozen", False): | ||||
|     setup_child() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user