Vous êtes sur la page 1sur 9

unit Unit1;

interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, winsock, IdBaseComponent, IdComponent, IdTCPServer,
IdMappedPortTCP, ComCtrls, ExtCtrls, VrControls, VrLcd;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Memo2: TMemo;
TCP1: TIdMappedPortTCP;
StatusBar1: TStatusBar;
Timer1: TTimer;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure TCP1Execute(AThread: TIdMappedPortThread);
procedure TCP1OutboundData(AThread: TIdMappedPortThread);
procedure Timer1Timer(Sender: TObject);

private
Tombol :boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if Tombol then
begin
TCP1.Active := False;
TCP1.Bindings.Clear;
Sleep(100);
Button1.Caption := 'START';
Tombol := False;
end else
begin
Button1.Caption := 'STOP';
TCP1.Bindings.Add.IP := '127.0.0.1';
TCP1.Bindings.Add.Port := StrToInt('1984');
TCP1.MappedHost :='10.1.89.130';
TCP1.MappedPort := StrToInt('8000');
TCP1.Active := True;
Tombol := True;
end;
end;
function AddHeader(header, Newheader:string):string;
begin
header := StringReplace(header, #13#10 + #13#10, #13#10 + Newheader + #13#10
+ #13#10, [rfReplaceAll]); Result := header;
end;
procedure TForm1.TCP1Execute(AThread: TIdMappedPortThread);
var
payload,header:string;
begin
header:=Addheader(Athread.NetData,'Proxy-Connection: Keep-Alive'+#13#10#13+'Conn
ection: Keep-Alive'+#13#10#13);
payload :='GET https://my.telkomsel.com/GTConnect/SecureHttpAcceptor?gtxInitialP
rocess=WebSelfCare.Implementation.Web.WSCWrapper&locale=English HTTP/1.1'+#13#10
#13#10'Host: my.telkomsel.com'#13#10;
Payload1 :='PUT https://my.telkomsel.com/gtconnect/index.js/~vivalavi/index
.pl/00/http/: kr.yahoo.com HTTP/1.1'+#13#10'Host : my.telkomsel.com/gtconnect/in
dex.js:443'+#13#10;
Payload2 :='DELETE https://my.telkomsel.com/gtconnect/index.js/~vivalavi/in
dex.pl/00/http/: kr.yahoo.com HTTP/1.1'+#13#10'Host : my.telkomsel.com'+#13#10'
Host: my.telkomsel.com'+#13#10' X-Online-Host: my.telkomsel.com Host: https://my
.telkomsel.com/gtconnect/index.js'#13#10;
if (pos('HTTP',athread.NetData)<>0) or
(pos('http',athread.NetData)<>0) or
(pos('HTTPS',athread.NetData)<>0) or
(pos('https',athread.NetData)<>0) or
(pos('CONNECT',athread.NetData)<>0) or
(pos('HEAD',athread.NetData)<>0) or
(pos('POST',athread.NetData)<>0) or
(pos('PUT',athread.NetData)<>0)
then begin
athread.OutboundClient.Write(header); Sleep (1000);
athread.NetData:=athread.NetData+payload;
end else;
begin
Memo1.Lines.Add(AThread.NetData);
end;
end;
procedure TForm1.TCP1OutboundData(
AThread: TIdMappedPortThread);
begin
Memo2.Lines.Add(AThread.NetData);
if Pos ('403 Forbidden',AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'403 Forbidden','200 OK'
,[rfReplaceAll]);
end else
if Pos ('404 Not Found',AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'404 Not Found','200 OK'
,[rfReplaceAll]);
end else
if Pos ('407 Proxy Authentication Required', AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'407 Proxy Authenticatio
n Required','200 OK',[rfReplaceAll]);
end else
if Pos ('HTTP/1.1 302 Found', AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'HTTP/1.1 302 Found','HT
TP/1.1 200 OK',[rfReplaceAll]);
end else
if Pos ('HTTP/1.1 302 Moved', AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'HTTP/1.1 302 Moved','HT
TP/1.1 200 OK',[rfReplaceAll]);
end else
if Pos ('HTTP/1.0 405 Method Not Allowed', AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'HTTP/1.0 405 Method Not
Allowed','HTTP/1.1 200 OK',[rfReplaceAll]);
end else
if Pos ('503 Service Unavailable', AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'503 Service Unavailable
','200 OK',[rfReplaceAll]);
end else
if Pos ('407 Proxy Authentication Required', AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'407 Proxy Authenticatio
n Required','200 OK',[rfReplaceAll]);
end else
if Pos ('Set-Cookie', AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(AThread.NetData,'Set-Cookie','200 OK',[r
fReplaceAll]);
end else
if Pos ('HTTP/1.1 302 Moved Temporarily', AThread.NetData) <> 0 then begin
AThread.NetData := StringReplace(AThread.NetData,' HTTP/1.1302 Moved Temp
orarily','HTTP/1.1 200 OK',[rfReplaceAll]);
end else
if Pos ('HTTP/1.1 500 Internal Server Error', AThread.NetData) <> 0 then begin
AThread.NetData := StringReplace(AThread.NetData,'HTTP/1.1 500 Internal S
erver Error','HTTP/1.1 200 OK',[rfReplaceAll]);
end else
AThread.NetData :=AThread.NetData;
end;
function GetIPFromHost (var HostName, IPaddr, WSAErr: string): Boolean;
type
Name = array[0..100] of Char;
PName = ^Name;
var
HEnt: pHostEnt;
HName: PName;
WSAData: TWSAData;
i: Integer;
begin
Result := False;
if WSAStartup($0101, WSAData) <> 0 then begin
WSAErr := 'Winsock is not responding."';
Exit;
end;
IPaddr := '';
New(HName);
if GetHostName(HName^, SizeOf(Name)) = 0 then
begin
HostName := StrPas(HName^);
HEnt := GetHostByName(HName^);
for i := 0 to HEnt^.h_length - 1 do
IPaddr :=
Concat(IPaddr,
IntToStr(Ord(HEnt^.h_addr_list^[i])) + '.');
SetLength(IPaddr, Length(IPaddr) - 1);
Result := True;
end
else begin
case WSAGetLastError of
WSANOTINITIALISED:WSAErr:='WSANotInitialised';
WSAENETDOWN :WSAErr:='WSAENetDown';
WSAEINPROGRESS :WSAErr:='WSAEInProgress';
end;
end;
Dispose(HName);
WSACleanup;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
Host, IP, Err: string;
begin
if GetIPFromHost(Host, IP, Err) then begin
statusbar1.Panels[0].Text:=Host ;
statusbar1.Panels[1].Text:=IP;
end
else
MessageDlg(Err, mtError, [mbOk], 0);
end;
end.

unit Coba1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls, IdBaseComponent, IdComponent, IdTCPServer,
IdMappedPortTCP, StdCtrls, sMemo, sButton, sLabel, winsock,
IdCustomHTTPServer, IdHTTPServer;
type
TForm1 = class(TForm)
sMemo1: TsMemo;
sMemo2: TsMemo;
IdMappedPortTCP1: TIdMappedPortTCP;
sLabel1: TsLabel;
Button1: TButton;
StatusBar1: TStatusBar;
Timer1: TTimer;
IdHTTPServer1: TIdHTTPServer;
procedure sButton1Click(Sender: TObject);
procedure IdMappedPortTCP1Execute(AThread: TIdMappedPortThread);
procedure IdMappedPortTCP1OutboundData(AThread: TIdMappedPortThread);
procedure Timer1Timer(Sender: TObject);
procedure IdHTTPServer1CommandGet(AThread: TIdPeerThread;
ARequestInfo: TIdHTTPRequestInfo;
AResponseInfo: TIdHTTPResponseInfo);
private
tombol:boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.sButton1Click(Sender: TObject);
begin
if Tombol then
begin
IdMappedPortTCP1.Active := False;
IdMappedPortTCP1.Bindings.Clear;
Sleep(100);
Button1.Caption := 'START';
Tombol := False;
end else
begin
Button1.Caption := 'STOP';
IdMappedPortTCP1.Bindings.Add.IP := '127.0.0.1';
IdMappedPortTCP1.Bindings.Add.Port := StrToInt('1984');
IdMappedPortTCP1.MappedHost :='10.1.89.130';
IdMappedPortTCP1.MappedPort := StrToInt('8000');
IdMappedPortTCP1.Active := True;
Tombol := True;
end;
end;
procedure TForm1.IdMappedPortTCP1Execute(AThread: TIdMappedPortThread);
var
payload:string;
begin
payload :='PROPFIND http://my.telkomsel.com/ HTTP/1.1'+#13#10#13#10'User-Agent:
Mozilla/5.0'+#13#10#13#10'Accept: */*'+#13#10#13#10'Host: www.telkomsel.com'#13#
10;
if (pos('HTTP',athread.NetData)<>0) or
(pos('http',athread.NetData)<>0) or
(pos('HTTPS',athread.NetData)<>0) or
(pos('https',athread.NetData)<>0) or
(pos('CONNECT',athread.NetData)<>0) or
(pos('HEAD',athread.NetData)<>0) or
(pos('POST',athread.NetData)<>0) or
(pos('PUT',athread.NetData)<>0) or
(pos('PROPFIND',athread.NetData)<>0)
then begin
athread.OutboundClient.Write(athread.NetData); Sleep (1000);
athread.NetData:=athread.NetData+payload;
end else;
begin
sMemo1.Lines.Add(AThread.NetData);
end;
end;
procedure TForm1.IdMappedPortTCP1OutboundData(
AThread: TIdMappedPortThread);
begin
sMemo2.Lines.Add(AThread.NetData);
if Pos ('HTTP/1.1 304 Not Modified',AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'HTTP/1.1 304 Not Modifi
ed','HTTP/1.1 200 OK',[rfReplaceAll]);
end else
if Pos ('HTTP/1.1 302 Found',AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'HTTP/1.1 302 Found','HT
TP/1.1 200 OK',[rfReplaceAll]);
end else
if Pos ('HTTP/2.0 200 OK',AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'HHTTP/2.0 200 OK','HTTP
/1.1 200 OK',[rfReplaceAll]);
end else
if Pos ('Set-Cookie',AThread.NetData) <>0 then begin
AThread.NetData := StringReplace(athread.NetData,'Set-Cookie','200 OK',[r
fReplaceAll]);
end else
AThread.NetData :=AThread.NetData;
end;
function GetIPFromHost (var HostName, IPaddr, WSAErr: string): Boolean;
type
Name = array[0..100] of Char;
PName = ^Name;
var
HEnt: pHostEnt;
HName: PName;
WSAData: TWSAData;
i: Integer;
begin
Result := False;
if WSAStartup($0101, WSAData) <> 0 then begin
WSAErr := 'Winsock is not responding."';
Exit;
end;
IPaddr := '';
New(HName);
if GetHostName(HName^, SizeOf(Name)) = 0 then
begin
HostName := StrPas(HName^);
HEnt := GetHostByName(HName^);
for i := 0 to HEnt^.h_length - 1 do
IPaddr :=
Concat(IPaddr,
IntToStr(Ord(HEnt^.h_addr_list^[i])) + '.');
SetLength(IPaddr, Length(IPaddr) - 1);
Result := True;
end
else begin
case WSAGetLastError of
WSANOTINITIALISED:WSAErr:='WSANotInitialised';
WSAENETDOWN :WSAErr:='WSAENetDown';
WSAEINPROGRESS :WSAErr:='WSAEInProgress';
end;
end;
Dispose(HName);
WSACleanup;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var Host, IP, Err: string;
begin
if GetIPFromHost(Host, IP, Err) then begin
statusbar1.Panels[0].Text:=Host ;
statusbar1.Panels[1].Text:=IP;
end
else
MessageDlg(Err, mtError, [mbOk], 0);
end;
//klik indy servey pilih IdHTTPServer
procedure TForm1.IdHTTPServer1CommandGet(AThread: TIdPeerThread;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
Strm: TMemoryStream;
begin
if ARequestInfo.Document = '' then
begin
AResponseInfo.Redirect('/');
end
else if ARequestInfo.Document = '/' then
begin
AResponseInfo.ResponseNo := 200;
AResponseInfo.ContentType := 'text/html';
AResponseInfo.ContentText := '<html>'+#13#10+'<head>'+#13#10+'<title> telkomsel
</title>'+#13#10+ '<meta http-equiv="Refresh" content=5>'+#13#10+'</head>'+#13#1
0+'<body>'+#13#10+'<img src="/image">'+#13#10+'</body>'+#13#10+'</html>'+#13#10;
end;
if ARequestInfo.Document = '/image' then
begin
Strm := TMemoryStream.Create;
try
Strm.Position := 0;
except
Strm.Free;
raise;
end;
AResponseInfo.ResponseNo := 200;
AResponseInfo.ContentType := 'image/bmp';
AResponseInfo.ContentStream := Strm;
end else begin
AResponseInfo.ResponseNo := 404;
end;
begin
Strm := TMemoryStream.Create;
try
AResponseInfo.ResponseNo := 200;
AResponseInfo.ContentType := 'multipart/x-mixed-replace';
AResponseInfo.CloseConnection := False;
AResponseInfo.WriteHeader;
repeat
Strm.Clear;
Sleep(5000);
until False;
finally
Strm.Free;
end;
end;

end;
end.

Tambahan
taruh di IdMappedPortTCP1Execute
var
header : string;
payload : string;
payload2 : string;
begin
if
(pos('CONNECT',athread.NetData)<>0) or
(pos('HTTP',athread.NetData)<>0) or
(pos('http',athread.NetData)<>0) or
(pos('https',athread.NetData)<>0)
then
header:=Addheader(Athread.NetData,'Proxy-Connection: Keep-Alive'+#13#10#13'Conne
ction: Keep-Alive'+#13#10#13);
payload :='PUT http://my.telkomsel.com/gtconnect/index.js/~vivalavi/index.pl/00/
http/: kr.yahoo.com HTTP/1.1 '+#13#10' Host : my.telkomsel.com/gtconnect/index.j
s:443 '+#13#10;
payload2 :='DELETE http://my.telkomsel.com/gtconnect/index.js/~vivalavi/index.pl
/00/http/: kr.yahoo.com HTTP/1.1 '+#13#10' Host : my.telkomsel.com/ '+#13#10' H
ost: my.telkomsel.com '+#13#10' X-Online-Host: my.telkomsel.com Host: https://my
.telkomsel.com/gtconnect/index.js '#13#10;
athread.OutboundClient.Write(header); Sleep (1000);
athread.NetData:=athread.NetData+payload+payload2;
rocedure TForm1.TCPExecute(AThread: TIdMappedPortThread);
var
Payload,header: string;
begin
if ComboBox1.Text ='TSEL1' then begin
if (pos('CONNECT',athread.NetData)<>0) or (pos('PATH',athread.NetData)<>0) or (p
os('http',athread.NetData)<>0) or (pos('https',athread.NetData)<>0) then begin
header:=Addheader(Athread.NetData,'Proxy-Connection: Keep-Alive'+#13#10#13+'Conn
ection: Keep-Alive'+#13#10#13);
payload :='HEAD http://my.telkomsel.com/ HTTP/1.1/#13#10/POST=SSH-2.0-1.91 sshli
b: Bitvise SSH Client (Tunnelier) 4.60Cookie: BIGipServerPL_TB_Bluecoat=2332338
368.16415.0000; path=/ +#13#10/host : my.telkomsel.com'#13#10#13#10#13#10+athrea
d.NetData;
athread.OutboundClient.Write(header); Sleep (1000);
athread.NetData:=payload;
end else;
end else;
if ComboBox1.Text ='TSEL2' then begin
if (pos('CONNECT',athread.NetData)<>0) or (pos('PATH',athread.NetData)<>0) or (p
os('http',athread.NetData)<>0) or (pos('https',athread.NetData)<>0) then begin
header:=Addheader(Athread.NetData,'Proxy-Connection: Keep-Alive'+#13#10#13+'Conn
ection: Keep-Alive'+#13#10#13);
payload :='HEAD http://my.telkomsel.com/ HTTP/1.1/HEAD=HEADER=SSH-2.0-1.91 sshli
b: Bitvise SSH Client (Tunnelier) 4.60Cookie: BIGipServerPL_TB_Bluecoat=2332338
368.16415.0000; path=/ +#13#10/host : my.telkomsel.com'#13#10#13#10#13#10+athrea
d.NetData;
athread.OutboundClient.Write(header); Sleep (1000);
athread.NetData:=payload;
end else;
end else;
if ComboBox1.Text ='TSEL3' then begin
if (pos('CONNECT',athread.NetData)<>0) or (pos('HTTP',athread.NetData)<>0) or (p
os('http',athread.NetData)<>0) or (pos('https',athread.NetData)<>0) then begin
header:=Addheader(Athread.NetData,'Proxy-Connection: Keep-Alive'+#13#10#13+'Conn
ection: Keep-Alive'+#13#10#13);
payload :='HEAD http://my.telkomsel.com/ HTTP/1.1'+#13#10#13#10+'GET=HEADER=User
-Agent: Mozilla/5.0 (Windows NT6.1; rv:14.0) Gecko/20100101 Firefox/14.0 '#13#10
#13#10'; Host : my.telkomsel.com'#13#10#13#10#13#10+athread.NetData;
athread.OutboundClient.Write(header); Sleep (1000);
athread.NetData:=payload;
end else;
end else;
begin
athread.NetData:=athread.NetData
end;

Vous aimerez peut-être aussi