[Tutor] Some Python difficulties ..

Chan Cheuk B150612244 at outlook.com
Sat Jul 9 22:23:23 EDT 2016


Dear all,


I would like to know whether my designed Python program below for Linux route command could not run and show the output onto the textarea that I planned originally.


The source code is:


#!/usr/bin/python
# lb        => Label
# btn       => button
# tb        => textbox / entry
# txtarea   => multiline text
# cb        => Checkbox
# rb        => radiobutton
# e.g. lb_ipaddress, btn_start, tb_output

from Tkinter import *

root = Tk()
root.title("netcat(nc) GUI")

option_a = IntVar()
option_b = IntVar()
option_c = IntVar()
option_d = IntVar()

def startfping():
    print "Start nc button clicked!"
    fpingcommand = command_gen()
    print "\tnetcat command: " + nccommand
    commandresult = runcommand()
    print "\tCommand output: " + commandresult

def command_gen():
    print "Generate the netcat command details!"
    command = "netcat "

    print "option a: " + str(option_a.get())
    if option_a.get():
        command = command + "-a "

    print "option b: " + str(option_b.get())
    if option_b.get():
        command = command + "-c 1 "

    print "option c: " + str(option_c.get())
    if option_c.get():
        command = command + "-q "

    command = command + tb_ipaddress.get()

    print "option d: " + str(option_d.get())
    if option_d.get():
        command = "netcat -h"

    result = command
    return result

def runcommand():
    print "Run command and get return!"
    result = "Get it"
    return result

lb_ipaddress = Label(root, text="IP Address(s):", fg="orange", justify=LEFT)
lb_ipaddress.grid(row=0, column=0, padx=2, pady=5, sticky=W)

tb_ipaddress = Entry(root, width=40, bd=5)
tb_ipaddress.grid(row=0, column=1, columnspan=3, padx=5, pady=5)

cb_option_a = Checkbutton(root, text = "Telnet details",variable=option_a, justify=LEFT)
cb_option_a.grid(row=1, column=0, columnspan=2, padx=5, pady=5, sticky=W)
# option a => -a

cb_option_b = Checkbutton(root, text="Port scanning", variable=option_b, justify=LEFT)
cb_option_b.grid(row=1, column=2, columnspan=2, padx=5, pady=5, sticky=W)
# option b => -c 1

cb_option_c = Checkbutton(root, text="Remote Shell/Backdoor", variable=option_c, justify=LEFT)
cb_option_c.grid(row=2, column=0, columnspan=2, padx=5, pady=5, sticky=W)
# option c => -q

cb_option_d = Checkbutton(root, text="Reverse Shells", variable=option_d, justify=LEFT)
cb_option_d.grid(row=2, column=2, columnspan=2, padx=5 , pady=5, sticky=W)
# option d => -h (but exclude all other options and IP address)

btn_run = Button(root, width = 10, text="Run!",justify=RIGHT, command=startfping)
btn_run.grid(row=3, column=3, padx=5, pady=5, stick=E)

lb_commandoutput = Label(root, text="Command Output:", fg="red", justify=LEFT)
lb_commandoutput.grid(row=4, column=0, padx=2, pady=0)

txtarea_output = Text(root, height=10, width=60)
txtarea_output.grid(row=5, column=0, columnspan=4, padx=10, pady=10)

root.mainloop()


Thank you for your kindly attention if you tell me how to fix it :'(



More information about the Tutor mailing list