The Code:
from tkinter import *
from tkinter import messagebox
import tkinter as tk
from csv import *
import os
#This is the gui
gui = tk.Tk()
gui.title("IP-Stalker.v2")
gui.geometry("510x300")
ipList=[]
def Add():
lst=[IP1.get()]
ipList.append(lst)
lst=[IP2.get()]
ipList.append(lst)
lst=[IP3.get()]
ipList.append(lst)
lst=[IP4.get()]
ipList.append(lst)
lst=[IP5.get()]
ipList.append(lst)
lst=[IP6.get()]
ipList.append(lst)
messagebox.showinfo("Information","The data has been added successfully")
def Save():
with open("targets.txt","w") as file:
Writer=writer(file)
Writer.writerows(ipList)
messagebox.showinfo("Information","Saved succesfully")
def Scanner():
master = Tk()
master.title("Monitor")
master.geometry("510x400")
master.option_add('*Font', '19')
master.configure(bg="black")
master.resizable(False,False)
master.attributes("-topmost", True)
targs=open('targets.txt','r')
list=targs.readlines()
displayRow=0
for ip in list:
on=ip+'Online'
off=ip+'Offline'
print ('Scanning',ip)
response = os.system('ping -c 1 ' + ip)
if response == 0:
print('IP:',ip,'is up!')
ONLabel = tk.Label(master, text=on, bg="black", fg="green", padx=70, pady=10)
ONLabel.grid(row=displayRow, column=1)
else:
print (ip,' is down!')
ONLabel = tk.Label(master, text=off, bg="black", fg="red", padx=70, pady=10)
ONLabel.grid(row=displayRow, column=1)
displayRow+=1
label1=Label(gui,text="IP Address: ",padx=20,pady=10)
label2=Label(gui,text="IP Address: ",padx=20,pady=10)
label3=Label(gui,text="IP Address: ",padx=20,pady=10)
label4=Label(gui,text="IP Address: ",padx=20,pady=10)
label5=Label(gui,text="IP Address: ",padx=20,pady=10)
label6=Label(gui,text="IP Address: ",padx=20,pady=10)
IP1 = Entry(gui, width=30,borderwidth=3)
IP2 = Entry(gui, width=30,borderwidth=3)
IP3 = Entry(gui, width=30,borderwidth=3)
IP4 = Entry(gui, width=30,borderwidth=3)
IP5 = Entry(gui, width=30,borderwidth=3)
IP6 = Entry(gui, width=30,borderwidth=3)
#Select User inputs and submit and scan button positioning
label1.grid(row=0, column=0)
label2.grid(row=1, column=0)
label3.grid(row=2, column=0)
label4.grid(row=3, column=0)
label5.grid(row=4, column=0)
label6.grid(row=5, column=0)
IP1.grid(row=0, column=1)
IP2.grid(row=1, column=1)
IP3.grid(row=2, column=1)
IP4.grid(row=3, column=1)
IP5.grid(row=4, column=1)
IP6.grid(row=5, column=1)
save=Button(gui,text="Save New IP List",padx=20,pady=10,command=Save)
add=Button(gui,text="Add New IP List",padx=20,pady=10,command=Add)
scan=Button(gui,text="Scan",padx=20,pady=10,command=Scanner)
add.place(x=50,y=250)
save.place(x=210, y=250)
scan.place(x=380,y=250)
#save.grid(row=6,column=1)
#add.grid(row=6,column=0)
#scan.grid(row=6,column=2)
gui.mainloop()