Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Activator;
- {$R RSRC.RES}
- {$R manifest.res}
- uses
- Winapi.Windows,
- Winapi.Messages,
- System.RegularExpressions,
- System.Classes,
- System.SysUtils,
- IdContext,
- IdCustomHTTPServer,
- IdHTTPServer,
- System.Win.Registry;
- const
- ORIGINAL_PCRADIO_EXE = 'PCRadioOrig.exe';
- SubKey = 'SOFTWARE\PCRadio\PCR';
- StrKey = 'keybill';
- var
- steps: Integer = 0;
- Reg: TRegistry;
- str: string;
- procedure ProcessMessages;
- var
- Msg: TMsg;
- function ProcessMsg(var Msg: TMsg): Boolean;
- begin
- Result := False;
- if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then
- begin
- Result := True;
- if Msg.Message <> WM_QUIT then
- begin
- TranslateMessage(Msg);
- DispatchMessage(Msg);
- end
- else
- DispatchMessage(Msg);
- end;
- end;
- begin
- while ProcessMsg(Msg) do
- ;
- end;
- function Execute(FileName: string): boolean;
- var
- StartupInfo: TStartupInfo;
- ProcessInfo: TProcessInformation;
- exitc: cardinal;
- begin
- FillChar(StartupInfo, sizeof(StartupInfo), 0);
- with StartupInfo do
- begin
- cb := Sizeof(StartupInfo);
- dwFlags := STARTF_USESHOWWINDOW;
- wShowWindow := SW_SHOW;
- end;
- Result := CreateProcess(nil, PChar(FileName), nil, nil, false, CREATE_NEW_CONSOLE or
- NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
- end;
- function PatchHosts(const Patch: Boolean = True): Boolean;
- const
- subdir = '\drivers\etc\hosts';
- regex0 = '^\s*127\.0\.0\.1\s+bill\.pcradi0\.ru\s*$';
- site0 = '127.0.0.1 bill.pcradi0.ru';
- var
- sysdir: array[0..MAX_PATH] of WideChar;
- i: Integer;
- hosts: TStringList;
- r0: Boolean;
- begin
- r0 := False;
- GetSystemDirectoryW(@sysdir, Length(sysdir));
- hosts := TStringList.Create;
- with hosts do
- try
- LoadFromFile(StrPas(sysdir) + subdir);
- i := 0;
- while i < Count do
- begin
- if TRegEx.IsMatch(Strings[i], regex0) then
- begin
- if not Patch then
- Delete(i);
- r0 := True;
- end;
- Inc(i);
- end;
- if (not r0) and (Patch) then
- Add(site0);
- Result := (r0);
- SaveToFile(StrPas(sysdir) + subdir);
- except
- Result := False;
- end;
- FreeAndNil(hosts);
- end;
- type
- TFakeServer = class
- private
- HttpServer: TIdHTTPServer;
- public
- constructor Create;
- destructor Destroy; override;
- procedure HttpServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo;
- AResponseInfo: TIdHTTPResponseInfo);
- end;
- constructor TFakeServer.Create;
- begin
- HttpServer := TIdHTTPServer.Create(nil);
- HttpServer.OnCommandGet := HttpServerCommandGet;
- HttpServer.Active := True;
- end;
- destructor TFakeServer.Destroy;
- begin
- HttpServer.Active := False;
- FreeAndNil(HttpServer);
- inherited;
- end;
- procedure TFakeServer.HttpServerCommandGet(AContext: TIdContext; ARequestInfo:
- TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
- begin
- if (UpperCase(ARequestInfo.Command) = 'POST') and (LowerCase(ARequestInfo.URI) =
- '/player/paywin/activation.php') then
- begin
- AResponseInfo.ContentText := str;
- Inc(steps);
- end;
- if (UpperCase(ARequestInfo.Command) = 'POST') and (LowerCase(ARequestInfo.URI) =
- '/player/paywin/lastdate.php') then
- begin
- AResponseInfo.ContentText := '0';
- Inc(steps);
- end;
- end;
- function RandStr(): string;
- var
- i: Integer;
- begin
- Randomize;
- SetLength(Result, Random(20) + 5);
- for i := 1 to Length(Result) do
- repeat
- Result[i] := Chr(Random(256));
- until CharInSet(Result[i], ['A'..'Z', 'a'..'z', '0'..'9']);
- end;
- var
- FakeServer: TFakeServer;
- begin
- PatchHosts(True);
- Reg := TRegistry.Create;
- Reg.OpenKey(SubKey, True);
- str := RandStr();
- Reg.WriteString(StrKey, str);
- Reg.CloseKey;
- FakeServer := TFakeServer.Create;
- Sleep(1000);
- try
- Execute(ExtractFilePath(ParamStr(0)) + ORIGINAL_PCRADIO_EXE);
- repeat
- ProcessMessages;
- Sleep(10);
- until (steps = 1);
- finally
- FreeAndNil(FakeServer);
- FreeAndNil(Reg);
- end;
- PatchHosts(False);
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement