This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Hello. I am using a Python3.3 script that uses a telnet connection from telnetlib library.

Now, I am using the write(command) and read() functions of this connection.

So, after wiresharking this simple code:

import telnetlib
import sys
def func1(IP,user,passw):
    t=telnetlib.Telnet(IP)
    t.write(user.encode('ascii')+b'\n')
    t.write(passw.encode('ascii')+b'\n')
    return t

def func2(t,command):
    t.write(command.encode('ascii')+b'\n')
    print(command)

user=sys.argv[1]
passw=sys.argv[2]
IP=sys.argv[3]
t=func1(IP,user,passw)
for i in range(6):
   func2(t, "message "+str(i))

I saw a weird behavior on Wireshark. After submitting the username and password, it send to the server a packet which contains only 2 messages out of six (within the 'for loop'), and the next packet is also from my computer, resetting the telnet conection!

By adding a line to func2:

def func2(t,command):
    t.write(command.encode('ascii')+b'\n')
    t.read_eager()   #The new line
    print(command)

Somehow it works fine.

Now, it should not be like that. If I am using the write(command) 10 times one after each other, not the way I used here, It works fine without any need of read().

Any idea?

The last two packets:

  no.    time       source  destination  protocol  info

1501    11.754366   A.B.C.A *.*.*.113   TELNET  Telnet Data ...

1502    11.760757   A.B.C.A *.*.*.113   TCP esimport > telnet [RST, ACK] Seq=40 Ack=7 Win=0 Len=0

asked 30 Oct '13, 04:30

itay_user's gravatar image

itay_user
1223
accept rate: 0%

edited 30 Oct '13, 04:58


this sounds more like a question for the developer of telnetlib (and/or a Python network programming forum) than for the Wireshark community, especially as did not provide a capture file !?!

Anyway: Can you post a capture file somewhere (google docs, dropbox, cloudshark.org). Maybe we can see something that helps you to debug your code.

permanent link

answered 30 Oct '13, 06:02

Kurt%20Knochner's gravatar image

Kurt Knochner ♦
24.8k1039237
accept rate: 15%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×26
×20

question asked: 30 Oct '13, 04:30

question was seen: 1,725 times

last updated: 30 Oct '13, 07:20

p​o​w​e​r​e​d by O​S​Q​A