Jump to content

[Patcher] Argumento remoto


tierrilopes
 Share

Recommended Posts

Este tópico serve como complemento a

 

Ao contrário do tópico anterior em que o argumento está definido estaticamente, podendo assim ser descoberto e ultrapassado, desta forma o patcher faz download de um argumento gerado remotamente e atualiza-o, tanto no patcher como no binário.

 

Patcher:

Abrir o ficheiro Design.cs

Procurar por:

private void Form1_Load(object sender, EventArgs e)
        {

private void Form1_Load(object sender, EventArgs e)
        {

Adicionar acima:

private void down_arg()
        {
            var wc = new WebClient();
            wc.Headers.Add("user-agent",
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)");
            wc.DownloadFile("https://website.com/arg.txt", @"C:\ProgramData\arg.txt");
            string argument = File.ReadAllText(@"C:\ProgramData\arg.txt");
            Config.Launcher[1] = argument;
  			File.Delete("C:	\ProgramData\\arg.txt");
        }

Procurar por:

private void Form1_Load(object sender, EventArgs e)
        {

Adicionar debaixo:

down_arg();

 

 

 

Binário:

Procurar por:

void LocaleService_LoadConfig (const char *fileName)
{

Adicionar acima:

#include <iostream>
#include <fstream>
#include <string>
#include <string.h>
#include <tchar.h>
#include <urlmon.h>
#pragma comment(lib, "urlmon.lib")
#include "tmt.h"



//Argumento
void Argumento_remoto()
{
	HRESULT hr = URLDownloadToFile(NULL, _T("https://website.como/arg.txt"),
		_T("C:\\ProgramData\\arg2.txt"), 0, NULL);
	if (hr == 0)
	{
		//Ler ficheiro e guardar em variavel
		std::string txt;
		std::ifstream file("C:\\ProgramData\\arg2.txt");
		if (file.is_open())
			while (file.good())
				std::getline(file, txt);
		file.close();
		remove("C:\\ProgramData\\arg2.txt");
		//Executar argumento
		if (strstr(GetCommandLineA(), txt.c_str()) == nullptr) {
			exit(0);
		}
	}
	if (hr != 0)
	{
		MessageBoxA(NULL, "Erro ao conectar ao website", "Erro!", MB_ICONWARNING);
		exit(0);
	}
}
//Fim argumento

 

Explicação:

Faz download do ficheiro disponível em:

https://website.como/arg.txt

Guarda na localização:

C:\ProgramData\arg2.txt

arg2.txt é propositado e não arg.txt, para nome ser diferente do ficheiro utilizado pelo patcher, para prevenir algum erro de acesso ao mesmo. Desta maneira cada um trabalha com ficheiros separados, mas fazem download do mesmo ficheiro.

Link to comment
Share on other sites

  • 11 months later...
11 hours ago, Tierri Lopes said:

Sim esta, verifica se tens este include :

<fstream>

Agora aparece este erro:

Error    1    error C1189: #error :  Need to include strsafe.h after tchar.h    C:\Program Files\Microsoft Visual Studio 12.0\VC\include\tchar.h    24    1    UserInterface
Edited by Mhyper
Link to comment
Share on other sites

56 minutes ago, Tierri Lopes said:

https://pastebin.com/CxmaHwBt

 

Abre a localização C:\ProgramData e vê se tens um ficheiro chamado "arg2.txt" com o texto "teste".

 

Se sim, então podes prosseguir e descomentar a linha:


//remove("C:\\ProgramData\\arg2.txt"); //descomentar para versão final, apenas para testar

 

Continua com o mesmo erro.. Weird

Link to comment
Share on other sites

1 hour ago, Tierri Lopes said:

UserInterface/StdAfx.h

Adiciona:


#include <iterator>
#include <tchar.h>

 

Agora funciona..

Tenho outra questão, queria colocar esta função num ficheiro php, de modo a tornar isto mais útil e gerar o argumento automaticamente de x em x minutos, no entanto não consigo fazer com que seja feito o download do php e que o output seja colocado no txt..

 

function generateRandomString($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    }
    return $randomString;
}

Cumprimentos

Edited by Mhyper
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...