2

I am creating a GUI for networking recon for a school project and trying to get the run button to activate whatever is toggled on as a checkbutton. Currently, I am having a problem getting the value of the checkbuttons and kind of stuck. please let me know what I am doing wrong here. Seen a lot using classes with tkinter but mine seems to work so far, but that could be why im running into problems. Hope to get a quick response, here is my code dump:

from tkinter import *
import subprocess
#from tkinter.filedialog import asksaveasfilename

#save file
#saveFile = asksaveasfilename()
#print("You can write data to " + saveFile)

startup = Tk()

names = ["about","accounts","admin","administrador","administrator","ads","adserver","adsl","agent","blog","channel","client","dmz","dns","dns0","dns1","dns2","dns3","external","file","forum","forums","ftp","ftpserver","host","http",
"https","ids","intern","intranet","irc","linux","log","mail","map","member","members","name","nc","ns","ntp","ntserver","office","pop","pptp","print","printer","pub","public","root","route","router","server","smtp","sql","ssh","telnet",
"voip","webaccess","webadmin","webserver","website","win","windows","www","xml"]
nslookup= IntVar()

def cmdnslookup():
        domain='microsoft.com'
        process = "dig "+domain+" ns > NameServerLookup.txt"
        subprocess.Popen(process, shell=True)

def cmdmxlookup():
        domain='microsoft.com'
        process = "dig "+domain+" mx > MailServerLookup.txt"
        subprocess.Popen(process, shell=True)

def cmdipForward():
        for name in names:
                domain='www.stcloudstate.edu'
                process = "host "+name+"."+domain+" | grep 'has address' >> ForwardIPLookup.txt"
                subprocess.Popen(process, shell=True)


##def cmdipReverse():
##        
##def cmdipAdditional():
##        
##def cmdzoneTransfer():
##        
##def cmdoneSixtyOne():
##        
##def cmdsnmp():
##        
##def cmdrpc():
##        
##def cmdip():
##        


def close():
        startup.destroy()

def menu():
        startup.title("Wilson Recon Tool")

        menubar = Menu(startup)
        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label="Close", command=close)
        menubar.add_cascade(label="file", menu=filemenu)
        startup.config(menu=menubar)

        topFrame = Frame(startup)
        topFrame.pack()

        bottomFrame = Frame(startup)
        bottomFrame.pack(side=BOTTOM)

        about = Label(topFrame, text="Application Description", font="ariel 10 bold").grid(row=0, column=0, sticky=W)
        description = StringVar()
        description.set("This is a network recon tool. It's designed to help make reconassiance easier for those not familar with terminal based tools." )
        message = Message(topFrame, textvariable=description, width=250)
        message.grid(row=1,column=0)


        recon = Label(bottomFrame, text="Recon Information", font="ariel 10 bold")
        recon.grid(row=0,column=0,pady=5,sticky=W)
        global nslookup
        nslookup = Checkbutton(bottomFrame, text="Name Server Lookup",variable=nslookup)
        nslookup.grid(row=1,column=0,sticky=W)
        mxlookup= IntVar()
        mxlookup = Checkbutton(bottomFrame, text="Mail Server Lookup",variable=mxlookup)
        mxlookup.grid(row=2,column=0,sticky=W)
        ipForward= IntVar()
        ipForward = Checkbutton(bottomFrame, text="Forward Domain Lookup",variable=ipForward)
        ipForward.grid(row=3,column=0,sticky=W)
        ipReverse= IntVar()
        ipReverse = Checkbutton(bottomFrame, text="Reverse Domain Lookup",variable=ipReverse)
        ipReverse.grid(row=4,column=0,sticky=W)
        ipAdditional= IntVar()
        ipAdditional = Checkbutton(bottomFrame, text="Additional IPs Check",variable=ipAdditional, state=DISABLED)
        ipAdditional.grid(row=5,column=0,sticky=W)
        zoneTransfer= IntVar()
        zoneTransfer = Checkbutton(bottomFrame, text="Zone Transfer Check",variable=zoneTransfer, state=DISABLED)
        zoneTransfer.grid(row=6,column=0,sticky=W)
        oneSixtyOne= IntVar()
        oneSixtyOne = Checkbutton(bottomFrame, text="Onesixtyone",variable=oneSixtyOne)
        oneSixtyOne.grid(row=7,column=0,sticky=W)
        snmp= IntVar()
        snmp = Checkbutton(bottomFrame, text="SNMPWalk",variable=snmp)
        snmp.grid(row=8,column=0,sticky=W)
        rpc= IntVar()
        rpc = Checkbutton(bottomFrame, text="RPC Client using NETBIOS",variable=rpc, state=DISABLED)
        rpc.grid(row=9,column=0,sticky=W)
        otherNetwork = Label(bottomFrame, text="Other Network Information", font="ariel 10 bold")
        otherNetwork.grid(row=10,column=0,pady=5,sticky=W)
        ip= IntVar()
        ip = Checkbutton(bottomFrame, text="Local Machine",variable=ip)
        ip.grid(row=11,column=0,sticky=W)

##        nslookup.pack()
##        mxlookup.pack()
##        ipForward.pack()
##        ipReverse.pack()
##        ipAdditional.pack()
##        zoneTransfer.pack()
##        oneSixtyOne.pack()
##        snmp.pack()
##        rpc.pack()
##        ip.pack()



        def cmdrunButton():
                global nslookup
                nslookup.get()
                mxlookup.get()
                ipForward.get()
                ipReverse.get()
                ipAdditional.get()
                zoneTransfer.get()
                oneSixtyOne.get()
                snmp.get()
                rpc.get()
                ip.get()
                print(nslookup)

        runButton = Button(bottomFrame, text="Run", command=cmdrunButton)
        runButton.grid(row=12, padx=3,pady=3,column=0,sticky=W)
        quitButton = Button(bottomFrame, text="Quit",command=close)
        quitButton.grid(row=12, padx=3,pady=3,column=1,sticky=E)

##        runButton.pack()
##        quitButton.pack()



        startup.mainloop()
menu()

because of the error i tried moving one of the variables to a global to see if that work help and does not seem to be working.

2
  • pardon my lack of comments Commented May 1, 2017 at 3:44
  • Like the error message says, CheckButton instances have no method (or attribute of any kind named get. What is your question Commented May 1, 2017 at 3:48

1 Answer 1

1

Let's look at just one Checkbutton variable to see what is happening

mxlookup = IntVar()

Here, mxlookup is an IntVar, a representation of the Tcl variable you will bind to the Checkbutton from the next line.

mxlookup = Checkbutton(bottomFrame, text="Mail Server Lookup",variable=mxlookup)

In this line, you create a Checkbutton using the IntVar you created in the previous line, then assign it to the mxlookup name.

mxlookup.get()

Finally, when you get to this bit, mxlookup refers to the Checkbutton instance, not the IntVar instance it used to be. A Checkbutton instance doesn't have a get() method, so when you try calling mxlookup.get(), Python raises an AttributeError. To solve this issue, you can use a different name for the IntVar, the Checkbutton or both.

Sign up to request clarification or add additional context in comments.

1 Comment

ahh, thank you, been mulling for a while. been a long day.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.