I write lil telnet program ...

Actually that telnet doesn't show what I am typing was kinda bothering me so I programed telnet that shows what I am typing

It worked ok but has one serious bug ....

------------------------------------------------------------------------------------

invoke send,sock,addr bufferSent,100,0
.if eax==100
invoke SendMessage,hwndStatus2,SB_SETTEXT,0,addr SentSuccess
.else
invoke ErrorProc,addr SentFail
jmp comehere
.endif
invoke CleanBuffer,addr bufferSent ;cleaning buffer

-----------------------------------------------------------------------------------
CleanBuffer proc lpBuffer:DWORD
mov eax,lpBuffer
xor ecx,ecx
happyloop:
mov byte ptr ,0
inc ecx
inc eax
cmp ecx,100
jne happyloop
ret
CleanBuffer endp
------------------------------------------------------------------------------------
ErrorProc proc Message:DWORD
invoke MessageBox,0,Message,0,MB_OK
ret
ErrorProc endp
------------------------------------------------------------------------------------
After send I cleaned buffer with cleanbuffer function ....

And also clean buffer after recv ...

It always works fine with first command ... But I got always what I didn't expect after first command

for example I sent helo command to smtp server it reponds with
Syntax: helo Hostname
but if I send helo again it says wrong command ...

I think cleaning buffer has problem or something ....

I need help with this I tried to debug but really can't find why

Here is my source code
Posted on 2002-05-16 00:28:30 by Gandalf
I debugged ...

Problem was

-----------------------------------------------------------------------------------
invoke send,sock,addr bufferSent,100,0

I sent always 100 bytes ....
That's means if I typed "helo"
bufferSent will be
"helo",13,10,0,0,0,,,,,,,,,,,,,,,,,,,0

with a lot of zero .....

-----------------------------------------------------------------------------------
So I debugged

-----------------------------------------------------------------------------------
lea ebx,bufferSent
xor eax,eax
countloop:
inc ebx
inc eax
cmp byte ptr ,0
jne countloop


invoke send,sock,addr bufferSent,eax,0

-----------------------------------------------------------------------------------
So this will send no 0 any more ....
I attached debugged source here
And I will add some more things ....

Not completed yet....
Posted on 2002-05-16 02:50:30 by Gandalf
You can enable "Local echo" in telnet, and it will show you what you type :).
Posted on 2002-05-16 06:53:35 by f0dder

You can enable "Local echo" in telnet, and it will show you what you type :).


but why ruin the fun? :)
Posted on 2002-05-16 13:38:22 by jademtech