Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 617 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java and SSH

#1
In The Name OF Allah
Al-Salam Alekum
Hello guys, Long time because of my exams I hadn't time to come online. Today I'm going to explain using JSch library in Java to connect with SSH server, executing commands and downloading files. I hope ye all like it...

Start your IDE I'm using NetBeans. Add JSch library

[To see links please register here]



In this example we will connect to our server(VPS) through SSH and run a command (cd /var/www && ls).

PHP Code:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ssh;

import java.io.InputStream;
import java.util.Properties;

import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

public class 
SSHConnectionJava {
    public static 
void main(String[] args) {

    
//Host IP    
        
String host "1.1.1.1";
    
//Host User
        
String user "root";
    
//Host Password
        
String password "12345678";
                
        try {
            
Properties config = new Properties();
            
config.put("StrictHostKeyChecking""no");
            
JSch jsch = new JSch();
            
// Create a JSch session to connect to the server
            
Session session jsch.getSession(userhost22);
            
session.setPassword(password);
            
session.setConfig(config);
            
// Establish the connection
            
session.connect();
            
System.out.println("Connected...");
            
ChannelExec channel = (ChannelExecsession.openChannel("exec");
            
//Executing a command
            
channel.setCommand("cd /var/www/ && ls");
            
channel.setErrStream(System.err);
            
            
InputStream in channel.getInputStream();
            
channel.connect();
            
byte[] tmp = new byte[1024];
            while (
true) {
                while (
in.available() > 0) {
                    
int i in.read(tmp01024);
                    if (
0) {
                        break;
                    }
                    
System.out.print(new String(tmp0i));
                }
                if (
channel.isClosed()) {
                    
System.out.println("Exit Status: "
                        
channel.getExitStatus());
                        break;
                    }
                    
Thread.sleep(1000);
            }
                        
            
channel.disconnect();
            
session.disconnect();
            
System.out.println("DONE!!!");
    } catch (
Exception e) {
            
e.printStackTrace();
            }
    }
    


As you see in this image, it shows us html as a commands result.

[To see links please register here]



Now all depend on you for Backing up both your website files and SQL database using two commands instead of the one above:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


This above will generate a zip files which include our files and the second command will generate a SQL file which include the whole databases data. Note: && separate the two commands.

Okay Let's download this files above:

Code:
zip -r /home/sinisterly.zip /var/www/ && mysqldump --all-databases > /home/all_databases.sql

I'm done if you need anything feel free PMing me or posting here down...
Thank you for reading ......


Wa Salam Alekum
Reply

#2
It's nice to have you back contributing quality tutorials.

Well done.
Reply

#3
Quote:(12-21-2018, 05:10 AM)mothered Wrote:

[To see links please register here]

It's nice to have you back contributing quality tutorials.

Well done.

Thank you mothered, glad yo see you again.
Reply

#4
Quote:(12-21-2018, 04:01 PM)Mr.Kurd Wrote:

[To see links please register here]

Quote: (12-21-2018, 05:10 AM)mothered Wrote:

[To see links please register here]

It's nice to have you back contributing quality tutorials.

Well done.

Thank you mothered, glad yo see you again.

Likewise.

Stay active.
Reply

#5
Quote:(12-20-2018, 10:29 PM)Mr.Kurd Wrote:

[To see links please register here]

In The Name OF Allah
Al-Salam Alekum
Hello guys, Long time because of my exams I hadn't time to come online. Today I'm going to explain using JSch library in Java to connect with SSH server, executing commands and downloading files. I hope ye all like it...

Start your IDE I'm using NetBeans. Add JSch library

[To see links please register here]



In this example we will connect to our server(VPS) through SSH and run a command (cd /var/www && ls).

PHP Code:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ssh;

import java.io.InputStream;
import java.util.Properties;

import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

public class 
SSHConnectionJava {
    public static 
void main(String[] args) {

 
//Host IP 
        
String host "1.1.1.1";
 
//Host User
        
String user "root";
 
//Host Password
        
String password "12345678";
                
        try {
            
Properties config = new Properties();
            
config.put("StrictHostKeyChecking""no");
            
JSch jsch = new JSch();
            
// Create a JSch session to connect to the server
            
Session session jsch.getSession(userhost22);
            
session.setPassword(password);
            
session.setConfig(config);
            
// Establish the connection
            
session.connect();
            
System.out.println("Connected...");
            
ChannelExec channel = (ChannelExecsession.openChannel("exec");
            
//Executing a command
            
channel.setCommand("cd /var/www/ && ls");
            
channel.setErrStream(System.err);
            
            
InputStream in channel.getInputStream();
            
channel.connect();
            
byte[] tmp = new byte[1024];
            while (
true) {
             while (
in.available() > 0) {
             
int i in.read(tmp01024);
             if (
0) {
             break;
             }
             
System.out.print(new String(tmp0i));
             }
             if (
channel.isClosed()) {
             
System.out.println("Exit Status: "
                 
channel.getExitStatus());
                     break;
                    }
                    
Thread.sleep(1000);
            }
                        
            
channel.disconnect();
            
session.disconnect();
            
System.out.println("DONE!!!");
 } catch (
Exception e) {
            
e.printStackTrace();
            }
 }
    


As you see in this image, it shows us html as a commands result.

[To see links please register here]



Now all depend on you for Backing up both your website files and SQL database using two commands instead of the one above:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


This above will generate a zip files which include our files and the second command will generate a SQL file which include the whole databases data. Note: && separate the two commands.

Okay Let's download this files above:

Code:
zip -r /home/sinisterly.zip /var/www/ && mysqldump --all-databases > /home/all_databases.sql

I'm done if you need anything feel free PMing me or posting here down...
Thank you for reading ......


Wa Salam Alekum
very nice guide. I enjoy reading. :smile: :cool:
Reply

#6
Quote:(01-28-2019, 06:33 AM)darkninja1980 Wrote:

[To see links please register here]

Quote: (12-20-2018, 10:29 PM)Mr.Kurd Wrote:

[To see links please register here]

In The Name OF Allah
Al-Salam Alekum
Hello guys, Long time because of my exams I hadn't time to come online. Today I'm going to explain using JSch library in Java to connect with SSH server, executing commands and downloading files. I hope ye all like it...

Start your IDE I'm using NetBeans. Add JSch library

[To see links please register here]



In this example we will connect to our server(VPS) through SSH and run a command (cd /var/www && ls).

PHP Code:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ssh;

import java.io.InputStream;
import java.util.Properties;

import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

public class 
SSHConnectionJava {
    public static 
void main(String[] args) {

 
//Host IP 
        
String host "1.1.1.1";
 
//Host User
        
String user "root";
 
//Host Password
        
String password "12345678";
                
        try {
            
Properties config = new Properties();
            
config.put("StrictHostKeyChecking""no");
            
JSch jsch = new JSch();
            
// Create a JSch session to connect to the server
            
Session session jsch.getSession(userhost22);
            
session.setPassword(password);
            
session.setConfig(config);
            
// Establish the connection
            
session.connect();
            
System.out.println("Connected...");
            
ChannelExec channel = (ChannelExecsession.openChannel("exec");
            
//Executing a command
            
channel.setCommand("cd /var/www/ && ls");
            
channel.setErrStream(System.err);
            
            
InputStream in channel.getInputStream();
            
channel.connect();
            
byte[] tmp = new byte[1024];
            while (
true) {
             while (
in.available() > 0) {
             
int i in.read(tmp01024);
             if (
0) {
             break;
             }
             
System.out.print(new String(tmp0i));
             }
             if (
channel.isClosed()) {
             
System.out.println("Exit Status: "
                 
channel.getExitStatus());
                     break;
                    }
                    
Thread.sleep(1000);
            }
                        
            
channel.disconnect();
            
session.disconnect();
            
System.out.println("DONE!!!");
 } catch (
Exception e) {
            
e.printStackTrace();
            }
 }
    


As you see in this image, it shows us html as a commands result.

[To see links please register here]



Now all depend on you for Backing up both your website files and SQL database using two commands instead of the one above:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


This above will generate a zip files which include our files and the second command will generate a SQL file which include the whole databases data. Note: && separate the two commands.

Okay Let's download this files above:

Code:
zip -r /home/sinisterly.zip /var/www/ && mysqldump --all-databases > /home/all_databases.sql

I'm done if you need anything feel free PMing me or posting here down...
Thank you for reading ......


Wa Salam Alekum
very nice guide. I enjoy reading. :smile: :cool:Welcome man :wink:
Reply

#7
Quote:(01-30-2019, 10:39 PM)Mr.Kurd Wrote:

[To see links please register here]

Quote: (01-28-2019, 06:33 AM)darkninja1980 Wrote:

[To see links please register here]

Quote: (12-20-2018, 10:29 PM)Mr.Kurd Wrote:

[To see links please register here]

In The Name OF Allah
Al-Salam Alekum
Hello guys, Long time because of my exams I hadn't time to come online. Today I'm going to explain using JSch library in Java to connect with SSH server, executing commands and downloading files. I hope ye all like it...

Start your IDE I'm using NetBeans. Add JSch library

[To see links please register here]



In this example we will connect to our server(VPS) through SSH and run a command (cd /var/www && ls).

PHP Code:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ssh;

import java.io.InputStream;
import java.util.Properties;

import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

public class 
SSHConnectionJava {
    public static 
void main(String[] args) {

 
//Host IP 
        
String host "1.1.1.1";
 
//Host User
        
String user "root";
 
//Host Password
        
String password "12345678";
                
        try {
            
Properties config = new Properties();
            
config.put("StrictHostKeyChecking""no");
            
JSch jsch = new JSch();
            
// Create a JSch session to connect to the server
            
Session session jsch.getSession(userhost22);
            
session.setPassword(password);
            
session.setConfig(config);
            
// Establish the connection
            
session.connect();
            
System.out.println("Connected...");
            
ChannelExec channel = (ChannelExecsession.openChannel("exec");
            
//Executing a command
            
channel.setCommand("cd /var/www/ && ls");
            
channel.setErrStream(System.err);
            
            
InputStream in channel.getInputStream();
            
channel.connect();
            
byte[] tmp = new byte[1024];
            while (
true) {
             while (
in.available() > 0) {
             
int i in.read(tmp01024);
             if (
0) {
             break;
             }
             
System.out.print(new String(tmp0i));
             }
             if (
channel.isClosed()) {
             
System.out.println("Exit Status: "
                 
channel.getExitStatus());
                     break;
                    }
                    
Thread.sleep(1000);
            }
                        
            
channel.disconnect();
            
session.disconnect();
            
System.out.println("DONE!!!");
 } catch (
Exception e) {
            
e.printStackTrace();
            }
 }
    


As you see in this image, it shows us html as a commands result.

[To see links please register here]



Now all depend on you for Backing up both your website files and SQL database using two commands instead of the one above:


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


This above will generate a zip files which include our files and the second command will generate a SQL file which include the whole databases data. Note: && separate the two commands.

Okay Let's download this files above:

Code:
zip -r /home/sinisterly.zip /var/www/ && mysqldump --all-databases > /home/all_databases.sql

I'm done if you need anything feel free PMing me or posting here down...
Thank you for reading ......


Wa Salam Alekum
very nice guide. I enjoy reading. :smile: :cool:Welcome man :wink:

No problem.
Reply

#8
@"Mr.Kurd", you did mention that you won't contribute anymore, but I hope to see more of your HQ tutorials.
Reply

#9
Quote:(01-31-2019, 02:51 AM)mothered Wrote:

[To see links please register here]

@"Mr.Kurd", you did mention that you won't contribute anymore, but I hope to see more of your HQ tutorials.

I like reading his guides as well.
Reply

#10
Quote:(01-31-2019, 02:51 AM)mothered Wrote:

[To see links please register here]

@"Mr.Kurd", you did mention that you won't contribute anymore, but I hope to see more of your HQ tutorials.
Actually, @"mothered" Java section here on SL is very inactive and members not showing interest. You see spending much time to write an HQ tutorial but members are not showing interest so it's pretty much tiring.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through