Create a RAT in Java (Part 1: Method Resolve() )

Method Resolve() )

How to Create a RAT in Java (Part 1: Method Resolve() )

DISCLAIMER: This tutorial is for learning/educational purposes only. What you do with this information is your own decision, and if any consequences should occur, the authors of this tutorial are not to be held accountable.

Basically: Learn at your own risk, the authors (MendaxV2 and I) are not to be held responsible if anyone uses these tutorials to make a malicious r.a.t. program

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

Introduction

This mini series is a collab between Mendax v2 and I are designed to teach how to create a RAT (Remote Access Tool) using Java (Programming Language)

We have broken it up into 2 parts because of the size of the code.

  • I will be writing part one (aka this tutorial, about what the Resolve() Method does in the file)
  • Mendax v2 will be writing about the Main Method, and the Connect() Method

Code credits: Mendax v2
-------------------------

About Method: Resolve()
This method is used to grab the IP address of the host and return it as a string (a sentence, so to speak)

Lets start off by creating the method (We are going to assume the Class-wrapping code and the imports are already written)

To do this, we start off with this format:
[Java Access Modifier] [static] [Return Type] [Method name] [(Variable Type and the name] { }

So lets write:
public static String resolve(String host){
}

In Java, we need brackets between code segments to indicate which lines are in the method.

Next, lets create our variable:
InetAddress ip;

"InetAddress" is an object, "ip" is that object's name
We haven't set it to anything yet, as it will be set later in the method.

The While Loop
Next, we'll need to add a while( condition == true ){ statements } to the code

It says, while this statement is still true, we'll keep doing what is written in the statements within the brackets of this loop until a break/continue is called, or until the condition is false.

The TryCatch

Inside the while loop, we need to make sure that the next few lines of code work, and how to properly handle the error if the code doesn't work.

Hence, we need a try{}catch(Exception err){} in the code.

Its saying we'll first try this portion of code, and if something doesn't work, we will catch the error, and figure out what to do next.

Without it, the program will crash because it is given an error and does not know how to handle it.

So now that we got this part down, lets write the actual statements within the try{} portion of the code.

A lot is going on here.
It first instantiates what the variable "ip" from earlier is equal to.

It is instantiated here because InetAddress.getByName(host); , itself, can raise an Error. Which is why it was left as "InetAddress ip;" earlier.

The next line says:
host = ip.getHostAddress().toString();

the variable "host" was already defined when the method was created
in where it said "...resolve(String host){}"

The host variable is equal to the IP address of the host, and is in the format of a String (hence what the toString() method is there for)

Without the toString(), Java will raise an error saying that there is a type mismatch between the "host" variable, which is a String, and the "ip.getHostAddress()" which will return it in the form of an InetAddress object.

In the next line, we have:
return host;

Which tells the method to return the IP of the host/target in the form of a string.

The Catch statement
The Catch statement is to catch whatever error may occur while trying the statements.

Error err instantiates the Error object, called "err"

Though it is not used inside the Catch statement's brackets, it is still needed. (because you can't put nothing in parentheses, when it requires something)

Next, we write:
continue;
inside of the brackets to tell the WhileLoop to end its looping.

Finally, we use closing brackets to close the loop, the catch, and the resolve method

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

Mendax v2 will be explaining keywords more in detail in his part of the tutorial on the RAT main method

Thanks for reading
Any questions, let us know

4 Comments

Quick question, is there actually a law that says you need to post a disclaimer?

It's an unwritten rule of society, I assume. So that he doesn't get 'shouted' at and blamed for whatever happens to people when they follow his instructions. But I guess you already knew that.

TRT

Well, I dunno if such a law exists, but I like to live by the saying of "better safe than sorry"

Hello Mendax,

I am a Computer Science Student and I chose to do a extended essay on this subject and i got interested on creating a virus, and i want to know if you can help me with this, i also want to know how to run this trojan, and how it work in detail.

Thank you in advance

Share Your Thoughts

  • Hot
  • Latest