unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, Mask, StdCtrls, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdTelnet, XPMan, IdAntiFreezeBase,
IdAntiFreeze;
type
TForm1 = class(TForm)
XPManifest1: TXPManifest;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Label5: TLabel;
Edit3: TEdit;
Label4: TLabel;
Button1: TButton;
Edit2: TEdit;
Memo1: TMemo;
IdTelnet1: TIdTelnet;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure IdTelnet1Connect(Sender: TObject);
procedure IdTelnet1DataAvailable(Sender: TIdTelnet;
const Buffer: String);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
function RandomString(strlength: integer): string;
var
Form1: TForm1;
Pass: String;
implementation
{$R *.dfm}
function RandomString(strlength: integer): string;
var
temp : integer;
begin
randomize;
repeat
temp := random(122); //ggf. erhöhen
if temp in [0..127] then
begin//Kann um beliebige
ASCII-Zeichen erweitert werden,
//ggf. den Wert in Random hochsetzen
result := result + Chr(temp);
end;
until length(result) = strlength;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
IdTelnet1.Host:=Edit1.Text;
IdTelnet1.Port:=StrtoInt(Edit3.Text);
IdTelnet1.Connect();
if IdTelnet1.Connected then
memo1.Lines.Add('connected');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.Text:='127.0.0.1';
edit3.text:='3207';
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
IdTelnet1.Disconnect;
end;
procedure TForm1.IdTelnet1Connect(Sender: TObject);
begin
Label2.Font.Color:=clLime;
Label2.Caption:='Connected';
end;
procedure TForm1.IdTelnet1DataAvailable(Sender: TIdTelnet;
const Buffer: String);
begin
memo1.Lines.add(buffer);
if pos('',buffer) > 0 then
(sender as TidTelnet).SendCmd('');
if pos('Authenticated ok',buffer) > 0 then
(sender as TidTelnet).SendCmd('/?');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
try
idtelnet1.sendcmd(''); //Das ist im moemnt das passwort,also einfach leer, geht aber auch nicht mit normalen pw, an dieser stelle bleibt er hängen!
except
end;
end;
end.