Пример #1
0
        public void request(Session session, Channel channel)
        {
            Buffer buf    = new Buffer();
            Packet packet = new Packet(buf);

            bool reply = waitForReply();

            if (reply)
            {
                channel.reply = -1;
            }

            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(new String("subsystem").getBytes());
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putString(subsystem.getBytes());
            session.write(packet);

            if (reply)
            {
                while (channel.reply == -1)
                {
                    try{ Thread.sleep(10); }
                    catch                    //(System.Exception ee)
                    {
                    }
                }
                if (channel.reply == 0)
                {
                    throw new JSchException("failed to send subsystem request");
                }
            }
        }
Пример #2
0
        public void request(Session session, Channel channel)
        {
            Buffer buf=new Buffer();
            Packet packet=new Packet(buf);

            bool reply=waitForReply();
            if(reply)
            {
                channel.reply=-1;
            }

            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(Util.getBytes("subsystem"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putString(Util.getBytes("sftp"));
            session.write(packet);

            if(reply)
            {
                while(channel.reply==-1)
                {
                    try{System.Threading.Thread.Sleep(10);}
                    catch//(Exception ee)
                    {
                    }
                }
                if(channel.reply==0)
                {
                    throw new JSchException("failed to send sftp request");
                }
            }
        }
Пример #3
0
        public void request(Session session, Channel channel)
        {
            Buffer buf    = new Buffer();
            Packet packet = new Packet(buf);

            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(Util.getBytes("signal"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putString(Util.getBytes(signal));
            session.write(packet);
        }
Пример #4
0
        public void request(Session session, Channel channel)
        {
            Buffer buf=new Buffer();
            Packet packet=new Packet(buf);

            packet.reset();
            buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString( Util.getBytes("signal"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putString(Util.getBytes(signal));
            session.write(packet);
        }
Пример #5
0
        public void request(Session session, Channel channel)
        {
            Buffer buf=new Buffer();
            Packet packet=new Packet(buf);

            // send
            // byte     SSH_MSG_CHANNEL_REQUEST(98)
            // uint32 recipient channel
            // string request type       // "shell"
            // boolean want reply        // 0
            packet.reset();
            buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(Util.getBytes("shell"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            session.write(packet);
        }
Пример #6
0
        public void request(Session session, Channel channel)
        {
            Buffer buf    = new Buffer();
            Packet packet = new Packet(buf);

            // send
            // byte     SSH_MSG_CHANNEL_REQUEST(98)
            // uint32 recipient channel
            // string request type       // "shell"
            // boolean want reply        // 0
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(Util.getBytes("shell"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            session.write(packet);
        }
Пример #7
0
		public void request(Session session, Channel channel)
		{
			Packet packet=session.packet;
			Buffer buf=session.buf;
			// send
			// byte     SSH_MSG_CHANNEL_REQUEST(98)
			// uint32 recipient channel
			// string request type       // "exec"
			// boolean want reply        // 0
			// string command
			packet.reset();
			buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
			buf.putInt(channel.getRecipient());
			buf.putString(new Str("exec").getBytes());
			buf.putByte((byte)(waitForReply() ? 1 : 0));
			buf.putString(new Str(command).getBytes());
			session.write(packet);
		}
Пример #8
0
        public void request(Session session, Channel channel)
        {
            Packet packet = session.packet;
            Buffer buf    = session.buf;

            // send
            // byte     SSH_MSG_CHANNEL_REQUEST(98)
            // uint32 recipient channel
            // string request type       // "exec"
            // boolean want reply        // 0
            // string command
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(new Str("exec").getBytes());
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putString(new Str(command).getBytes());
            session.write(packet);
        }
Пример #9
0
		public void request(Session session, Channel channel) 
		{
			Buffer buf=new Buffer();
			Packet packet=new Packet(buf);

			// byte      SSH_MSG_CHANNEL_REQUEST(98)
			// uint32 recipient channel
			// string request type        // "x11-req"
			// boolean want reply         // 0
			// boolean   single connection
			// string    x11 authentication protocol // "MIT-MAGIC-COOKIE-1".
			// string    x11 authentication cookie
			// uint32    x11 screen number
			packet.reset();
			buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
			buf.putInt(channel.getRecipient());
			buf.putString(Util.getBytes("x11-req"));
			buf.putByte((byte)(waitForReply() ? 1 : 0));
			buf.putByte((byte)0);
			buf.putString(Util.getBytes("MIT-MAGIC-COOKIE-1"));
			buf.putString(ChannelX11.getFakedCookie(session));
			buf.putInt(0);
			session.write(packet);
		}
Пример #10
0
        public void request(Session session, Channel channel)
        {
            Buffer buf=new Buffer();
            Packet packet=new Packet(buf);

            //byte      SSH_MSG_CHANNEL_REQUEST
            //uint32    recipient_channel
            //string    "window-change"
            //boolean   FALSE
            //uint32    terminal width, columns
            //uint32    terminal height, rows
            //uint32    terminal width, pixels
            //uint32    terminal height, pixels
            packet.reset();
            buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(Util.getBytes("window-change"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putInt(width_columns);
            buf.putInt(height_rows);
            buf.putInt(width_pixels);
            buf.putInt(height_pixels);
            session.write(packet);
        }
Пример #11
0
        public void request(Session session, Channel channel)
        {
            Buffer buf    = new Buffer();
            Packet packet = new Packet(buf);

            //byte      SSH_MSG_CHANNEL_REQUEST
            //uint32    recipient_channel
            //string    "window-change"
            //boolean   FALSE
            //uint32    terminal width, columns
            //uint32    terminal height, rows
            //uint32    terminal width, pixels
            //uint32    terminal height, pixels
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(Util.getBytes("window-change"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putInt(width_columns);
            buf.putInt(height_rows);
            buf.putInt(width_pixels);
            buf.putInt(height_pixels);
            session.write(packet);
        }
Пример #12
0
        public void request(Session session, Channel channel)
        {
            Buffer buf    = new Buffer();
            Packet packet = new Packet(buf);

            // byte      SSH_MSG_CHANNEL_REQUEST(98)
            // uint32 recipient channel
            // string request type        // "x11-req"
            // boolean want reply         // 0
            // boolean   single connection
            // string    x11 authentication protocol // "MIT-MAGIC-COOKIE-1".
            // string    x11 authentication cookie
            // uint32    x11 screen number
            packet.reset();
            buf.putByte((byte)Session.SSH_MSG_CHANNEL_REQUEST);
            buf.putInt(channel.getRecipient());
            buf.putString(Util.getBytes("x11-req"));
            buf.putByte((byte)(waitForReply() ? 1 : 0));
            buf.putByte((byte)0);
            buf.putString(Util.getBytes("MIT-MAGIC-COOKIE-1"));
            buf.putString(ChannelX11.getFakedCookie(session));
            buf.putInt(0);
            session.write(packet);
        }
Пример #13
0
        /*public*/
        /*lock*/
        public void write(Packet packet, Channel c, int length)
        {
            while(true)
                               {
                                   if(in_kex)
                                   {
                                       try{Thread.Sleep(10);}
                                       catch(ThreadInterruptedException e){};
                                       continue;
                                   }
                                   lock(c)
                                   {
                                       if(c.rwsize>=length)
                                       {
                                           c.rwsize-=length;
                                           break;
                                       }
                                   }
                                   if(c._close || !c.isConnected())
                                   {
                                       throw new IOException("channel is broken");
                                   }

                                   bool sendit=false;
                                   int s=0;
                                   byte command=0;
                                   int recipient=-1;
                                   lock(c)
                                   {
                                       if(c.rwsize>0)
                                       {
                                           int len=c.rwsize;
                                           s=packet.shift(len, (c2smac!=null ? c2smac.getBlockSize() : 0));
                                           command=packet.buffer.buffer[5];
                                           recipient=c.getRecipient();
                                           length-=len;
                                           c.rwsize-=len;
                                           sendit=true;
                                       }
                                   }
                                   if(sendit)
                                   {
                                       _write(packet);
                                       packet.unshift(command, recipient, s, length);
                                   }

                                   try{Thread.Sleep(10);}
                                   catch(ThreadInterruptedException e){};
                               }
                               _write(packet);
        }