Re: Help with putty code



On 26 Jul, 17:06, j...@xxxxxxxxxxx (Jens Thoms Toerring) wrote:
Pvt Ryan <ryan1...@xxxxxxxxxxx> wrote:
Background:
Due to the large number of bots attempting to ssh to my server, I
implemented portknocking (as the logs were just filled with crap).
So to access port 2222 for ssh I would first need to connect on port
3333 which opens port 2222 for 60secs.
(obv I just made those ports up)
I wanted to continue to use putty under windows to connect to my
server. However its a bit of hassle to connect manually to 1 port 1st
and then do the real connection.
The devs at putty have said they won't implement port knocking which
is fine, so i decided to build putty from source and add the port
knocking to my copy.
Problem:
I implemented it and it works, sort of.
Unfortunately (under windows) the 1st attempted connection (the knock)
times out (within 30secs) and in doing so kills my active putty
window.

That's a problem you will have to take up to a windows group
since it is nothing related to C but to networking under Windows.

The network code is independent of what I changed, My knock function
is basically an exact copy of his connect_to_host function, with all
the extras striped out. His connect_to_host function handles the error
(which is what I am assuming causes the terminal to quit) whereas in
my knock function I am trying to just drop/ignore that error.


Under linux due to the -Werror flag my build fails with the following:
--------------------------------------------------------------------
cc1: warnings being treated as errors
../ssh.c:2829: warning: function definition has qualified void return
type

I guess it's this line:

static const void knock(Ssh ssh, char *host, int port, char **realhost)

The function is defined to return void, i.e. nothing. Can you come
up with any idea what a 'constant nothing' is supposed to be? Just
throw out the 'const' and this warning should go awway.

../ssh.c: In function ‘knock’:
../ssh.c:2845: warning: statement with no effect

Again I can only guess, but it looks as if this line is the culprit:

    ssh->cfg.addressfamily == ADDRTYPE_IPV4 ? " (IPv4)" :                    
              (ssh->cfg.addressfamily == ADDRTYPE_IPV6 ? " (IPv6)" : "");    

Here nothing really happens - there's no assignment or anything
with a side effect. All it results in is a pointer to a string
literal which isn't used. So this line has, as the error message
tells you, no effect. Throwing it out wouldn't change anything
about the behaviour of your program.

As I stated above I copied & pasted a lot of his connection code in
order to avoid rewriting/adding to his connection functions at an OS
level. Also his code handles proxies and I am not good enough to be
able to handle them myself. I don't know why that code does nothing in
my function and yet it does something in his, as I pass the same Ssh
struct as him.

Now if i edit the makefile and remove the -Werror flag and then run
make again it will build fine.
It times out after about 5min.

Unless it's due to the rather likely not correct line 2845. this
again is nothing related to C but a networking issue, this time
under Linux. A good place to ask would be one of the groups
comp.unix.programmer or comp.os.linux.development.apps.

The timeout I was talking about was the network timeout (which is to
be expected as the server silently drops the packets) however I can't
work out why the 1st connection is being handled, and passing the
error to the front end and causing the terminal to become inactive.

The const was a copy/paste mistake I hadn't noticed, thanks for
pointing it out. I'll have to reread line 2845 and see why it does
nothing.

The reason behind giving a diff was I figured that his whole current
svn tree is only 10Mb so it would be trivial to download it and also I
thought it would be more relevant for people to follow the whole code
due to a lot of the code being abstracted.
.



Relevant Pages

  • Re: AS4.2/WM5/OUTLOOK2K3 suddenly not syncing, please help
    ... there is a connection EXIST between the device because I ... connection on port 26675 but on the PPC the port number keeps ... Outlook, countless times of reinstalling Activesync, removing Windows ... Firewall set to NO). ...
    (microsoft.public.pocketpc.activesync)
  • tunneling ftp connection: connection to wu-ftpd fails
    ... i have wu-ftpd running on a redhat server. ... i'm trying to login to the wu-ftpd from my windows machine using the ... The program uses ftp so i setup an ftp tunnel from port 6006 to 21 on the ... Establishing this connection and tunnel works ok. ...
    (comp.security.ssh)
  • UPDATE: Re: Question regarding SSH via Lantronix SCS100
    ... to do SSH and to authenticate the SSH connection with a local ... unexpectedly closed connection'. ... CONSOLE or AUX port on the router, or does it matter, and what ...
    (comp.dcom.sys.cisco)
  • Re: tightvnc & ssh
    ... > I can ssh to my mandrake box. ... I got a connection error (I forget the exact error ... Which seems to mean that I can't just use tightvnc on the windows ... There is a product called putty. ...
    (comp.os.linux.networking)
  • Re: SSH options re: NAT
    ... No, SSH is two-fold, a call to it on the client side results in a call ... port, meaning that any connections that come into that port are answered ... programming practice for daemons) Once the connection is established, ... don't want to execute a command on the remote side and you use -N. ...
    (comp.security.ssh)