⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 国外的远程控制源码,国内首发~~~我看到了就转过来了~
💻 PAS
字号:

unit main;

interface

uses
 Windows, WinSock;

var
 IRCPort:integer = 6667;
 IRCServer:string;
 IRCNick:string = 'bot';
 IRCChan:string = '#test';
 Sock1:TSocket;
 SockInfo:Sockaddr_in;
 WSAData:TWSAData;
 buff:array[0..1024] of char;
 Send01:string;
 StringList01:array of string;

       Procedure ReadSock;
       Procedure StartUp;
       Procedure ReStart;
       Procedure AddToList01(Text: string);
       procedure ParseContent(Content:string);
       Procedure SendPing;
       Procedure SendInfo;
       Procedure RandomNick;
       function StrToInt(S: string): integer;
       Function IntToStr(X: integer): string;
       function Trimit(const S: string): string; overload;

implementation

procedure ReadSock;
 var
  str01:string;
 begin
  str01:=buff;
 if pos('Nickname is already in use.',str01) > 0 then
  begin  //Incase nick already used. (duh!)
   WriteLn(str01);
   send01:='NICK ' + IRCNick + '[' + IntToStr(Random(10000)) + ']' + #13#10;
   send(Sock1,send01[1],Length(send01),0);
   ZeroMemory(@buff,sizeof(buff));
  end else
 if pos('PING :',str01) > 0 then
  begin  //Replys to 'Server' pings.
   WriteLn(str01);
   ZeroMemory(@buff,sizeof(buff));
   ParseContent(str01);
   SendPing;
   SetLength(StringList01,0);
  end else
 if pos('MOTD',str01) > 0 then
  begin  //Most servers will have this. Bot will join channel when this appears.
   WriteLn(str01);
   ZeroMemory(@buff,sizeof(buff));
   send01:='JOIN ' + IRCChan + #10#13;
   send(Sock1,send01[1],Length(send01),0);

   send01:='PRIVMSG Otis-programming :i am a wanker, spank me please' + #10#13;
   send(Sock1,send01[1],Length(send01),0);

  end else
  WriteLn(str01);
  ZeroMemory(@buff,sizeof(buff));
 end;

procedure Startup;
 begin    //Starts the socket and trys to connect.
  WSAStartup(257,WSAData);
  SockInfo.sin_family:=PF_INET;
  SockInfo.sin_port:=htons(IRCPort);
  SockInfo.sin_addr.S_addr:= inet_addr(PChar('216.122.249.75'));
  Sock1:= socket(PF_INET,SOCK_STREAM,0);
  Connect(Sock1,SockInfo,sizeof(SockInfo));
 end;

Procedure Restart;
 begin     //Hence the name, restarts if it cant connect, or gets disconnected.
  Shutdown(Sock1,2);
  CloseSocket(Sock1);
  Sleep(5000);
  StartUp;
  SendInfo;
 end;

procedure ParseContent(Content:string);
 var
  i: integer;
 begin
  i := Pos(' ', Content);
   while (i > 0) do
    begin AddToList01(Copy(Content, 1, i - 1));
     Delete(Content, 1, i); i := Pos(' ', Content);
    end;
     if Length(Content) > 0 then
      AddToList01(Content);
 end;

Procedure AddToList01(Text: string);
 var
  ListLen: integer;
  Listlen2:integer;
 begin
  ListLen:= Length(StringList01);
  ListLen2:= ListLen + 1;
  SetLength(StringList01, ListLen2);
  StringList01[ListLen]:= Text;
 end;

procedure SendPing;
 begin     //The PONG reply to the server.
  send01:='PONG ' + StringList01[High(StringList01)];
  send(Sock1,send01[1],Length(send01),0);
 end;

procedure sendinfo;
 begin     //Info to connect. has to be sent so the server can authorize your connection.
  Randomize;
  send01:='NICK ' + IRCNick + '[' + IntToStr(Random(10000)) + ']' + #13#10;
  send(Sock1,send01[1],Length(send01),0);
  send01:='USER ' + IRCNick + '[' + IntToStr(Random(10000)) + ']' + ' ' + #34 + 'win2kpro' + #34 + ' ' + #34 + '127.0.0.1' + #34 + ' ' + ':' + 'myrealcrapname' + #13#10;
  send(Sock1,send01[1],Length(send01),0);
 end;

function IntToStr(X: integer): string;
 var
  S: string;
 begin
  Str(X, S);
  Result := S;
 end;

function StrToInt(S: string): integer;
 var
  V, Code: integer;
 begin
  Val(S, V, Code);
  Result := V;
 end;

function Trimit(const S: string): string;
 var
  I, L: Integer;
 begin
  L := Length(S);
  I := 1;
  while (I <= L) and (S[I] <= ' ') do Inc(I);
  if I > L then Result := '' else
   begin
    while S[L] <= ' ' do Dec(L);
    Result := Copy(S, I, L - I + 1);
   end;
 end;

Procedure RandomNick;
 begin     // Duh!
  Randomize;
  send01:='NICK ' + IRCNick + '[' + IntToStr(Random(10000)) + ']' + #13#10;
  send(Sock1,send01[1],Length(send01),0);
 end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -