SHARE
TWEET

Untitled

a guest Nov 6th, 2018 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import telnetlib
  2. import tkinter as tk
  3. from tkinter.scrolledtext import ScrolledText
  4.  
  5. session = telnetlib.Telnet()
  6.  
  7. # Root object
  8. root = tk.Tk()
  9. root.title("Telnet")
  10.  
  11. # KNAPPA - frame
  12. buttonFrame = tk.Frame(root)
  13. buttonFrame.grid(row=0, column=0)
  14.  
  15. # OUTPUT - Frame
  16. textFrame = tk.Frame(root)
  17. textFrame.grid(row=1, column=0)
  18.  
  19. # OUTPUT - text
  20. st = ScrolledText(root)
  21. st.grid(row=0, column=1)
  22. st.tag_config('in', foreground='red')
  23. st.tag_config('out', foreground='black')
  24.  
  25. # TEXT FIELDS - variables
  26. #..
  27.  
  28. def topen():
  29.     global session
  30.     session = telnetlib.Telnet("arnold", "25")
  31.     tRead("open arnold 25\n")
  32.  
  33. def thelo():
  34.     session.write(("helo domain.ru\n").encode('ascii'))
  35.     tRead("helo domain.ru\n")
  36.  
  37. def tauth():
  38.     session.write(("AUTH LOGIN\n").encode('ascii'))
  39.     tRead("AUTH LOGIN\n")
  40.  
  41. def tusername():
  42.     session.write(("MkBlbWlsZS5zZQ==\n").encode('ascii'))
  43.     tRead("MkBlbWlsZS5zZQ==\n")
  44.  
  45. def tpassword():
  46.     session.write(("cXdlcg==\n").encode('ascii'))
  47.     tRead("cXdlcg==\n")
  48.  
  49. def tmailfrom():
  50.     session.write(("mail from emile@domain.ru\n").encode('ascii'))
  51.     tRead("mail from emile@domain.dom\n")
  52.  
  53. def trcpt():
  54.     session.write(("rcpt to 1@emile.se\n").encode('ascii'))
  55.     tRead("rcpt to 1@emile.se\n")
  56.  
  57. def tdata():
  58.     session.write(("data\n").encode('ascii'))
  59.     tRead("data\n")
  60.  
  61. def tdataContent():
  62.     session.write(("From: emile@domain.ru\nSender: emile@domain.ru\nSubject telnet mejl\ncontent\n.\n").encode('ascii'))
  63.     tRead("From: emile@domain.ru\nSender: emile@domain.ru\nSubject telnet mejl\ncontent\n.\n")
  64.  
  65. def tquit():
  66.     session.write(("quit\n").encode('ascii'))
  67.     tRead("quit\n")
  68.  
  69. def tRead(sentMsg):
  70.     message = session.read_until(b'\n')
  71.     # sent
  72.     st.insert(tk.END, '--> ' + sentMsg, 'out')
  73.     # received
  74.     st.insert(tk.END, '<-- '.encode('ascii') + message, 'in')
  75.  
  76.  
  77. # KNAPPAR - funktioner
  78. bOpen = tk.Button(buttonFrame, text='open', command=topen)
  79. bHello = tk.Button(buttonFrame, text='HELO', command=thelo)
  80. bAuth = tk.Button(buttonFrame, text='Auth', command=tauth)
  81. bUsername = tk.Button(buttonFrame, text='Username', command=tusername)
  82. bPassword = tk.Button(buttonFrame, text='Password', command=tpassword)
  83. bMailfrom = tk.Button(buttonFrame, text='Mailfrom', command=tmailfrom)
  84. bRcpt = tk.Button(buttonFrame, text='Rcpt', command=trcpt)
  85. bData = tk.Button(buttonFrame, text='Data', command=tdata)
  86. bDataContent = tk.Button(buttonFrame, text='DataContent', command=tdataContent)
  87. bQuit = tk.Button(buttonFrame, text='QUIT', command=tquit)
  88. bExit = tk.Button(buttonFrame, text='Exit', command=root.destroy)
  89.  
  90. # KNAPPAR - pack
  91. bOpen.pack(fill='both')
  92. bHello.pack(fill='both')
  93. bAuth.pack(fill='both')
  94. bUsername.pack(fill='both')
  95. bPassword.pack(fill='both')
  96. bMailfrom.pack(fill='both')
  97. bRcpt.pack(fill='both')
  98. bData.pack(fill='both')
  99. bDataContent.pack(fill='both')
  100. bQuit.pack(fill='both')
  101. bExit.pack(fill='both')
  102.  
  103. # Show frame
  104. root.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top