# Y.A.W.N - Yet Another Windows Netstat # Coded by Luigi I. in August 2k3 (w/bare hands & IDLE for Windows and VI Improved) # Released under GNU GPL License. # This scripts puts in a small GUI the results of a normal netstat. # Should work on any Linux Box that has the Python Interpreter and the netstat,ping,and traceroute tools. # There's a Windows version, too! import os,string from Tkinter import * from time import sleep def creanetstat(): os.system("netstat -t > /tmp/YAWN") global f f = open("/tmp/YAWN",'r') def legginetstat(): global conn conn = 1 f.seek(0) if len(f.readlines()) <= 2: f.seek(0) Label(app,text="No Established Connection Detected").grid() else: f.seek(0) for linea in f.readlines()[2:]: getdata(string.strip(linea)) conn = conn + 1 def labelconnessione(host,porta,status,conn): conntext = " HOST: %s PORT: %s STATUS: %s " % (host,porta,status) tracetext = "Trace" pingtext = "Ping" Button(app,text=tracetext,command=lambda: tracehost(host)).grid(row=conn,column=1) Button(app,text=pingtext,command=lambda: ping(host)).grid(row=conn,column=2) Label(app,text=conntext).grid(row=conn,column=0) ## EXPERIMENTAL! Not Fully Workin'! def tracehost(host): tracecmd = "traceroute -m 4 %s > /tmp/tracert.txt" % (host) os.system("echo --- tracing " + host + " ---") os.system(tracecmd) sleep(2) os.system("cat /tmp/tracert.txt") os.system("echo --- traced " + host + " ---") def ping(host): pingcmd = "ping -c 5 %s > /tmp/ping.txt" % (host) os.system("echo --- pinging " + host + " ---") os.system(pingcmd) sleep(2) os.system("cat /tmp/ping.txt") os.system("echo --- pinged " + host + " ---") ## def getdata(linea): global host,port,status host = linea.split()[4][:string.find(linea.split()[4],":")] port = linea.split()[4][string.find(linea.split()[4],":")+1:] status = linea.split()[5] labelconnessione(host,port,status,conn) app = Tk() app.title("YAWN") Label(app,text="Yet Another Win Netstat(but it DOES work on GNU/Linux too!) ").grid(row=0,column=0) creanetstat() legginetstat() app.mainloop()