Jump to content



Photo

Help Creating a Patch

vb.net c++ c# patch

  • Please log in to reply
29 replies to this topic

#16 OP nouser

nouser

    Neowinian

  • Joined: 22-September 12

Posted 22 September 2012 - 20:54

i need these resources to be editable by the user via an other exe... :/

i have seen what i am asking in trojans in the looong past. user could put his ip/dns and create an exe..i think it was being done with patching.. i was too young..i just remember that..i want something similar..basically i want that thing but not for trojan lol thanks


#17 articuno1au

articuno1au

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 20-March 11
  • Location: Brisbane, Australia

Posted 22 September 2012 - 20:55

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Settings>
	<ServerPath>C:\Server\whatever.exe</ServerPath>
	<PortNumber>8420</PortNumber>
	<PortCheck>true</PortCheck>
	<AutoStart>true</AutoStart>
  </Settings>
</ArrayOfSettings>
That's how I do it. Simply create a structure (or class) containing your settings.
public struct Settings
	{
		public string ServerPath;
		public int PortNumber;
		public bool PortCheck;
		public bool AutoStart;
	}
Then:
var xmlSerializer = new XmlSerializer(typeof (Settings[]));
			var sWriter = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "Settings.xml", false);
			xmlSerializer.Serialize(sWriter, settingsArray);
			sWriter.Close();
to write the settings out of the program, or the deserialize method to read the settings into the program.

This way the .exe is distributed all on it's own, but your program can create a settings file to work off of.

If the user needs to make changes, they can simply make a change in the .xml file (or in your application, or in a separate application that only makes the file etc etc etc)

You can embed this file as a resource and read it out of the resource instead of as a filesystem request. Then you just make the executable take the values and save them.. Might defy the point though >.>

EDIT::
I consulted with an expert on the subject, and he said it's possible, but it's a butt load of pain to do. He said that once values are changed in the initial compile, it becomes next to impossible to find in C++, and only marginally better in CLI language.

#18 OP nouser

nouser

    Neowinian

  • Joined: 22-September 12

Posted 22 September 2012 - 21:06

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Settings>
	<ServerPath>C:\Server\whatever.exe</ServerPath>
	<PortNumber>8420</PortNumber>
	<PortCheck>true</PortCheck>
	<AutoStart>true</AutoStart>
  </Settings>
</ArrayOfSettings>
That's how I do it. Simply create a structure (or class) containing your settings.
public struct Settings
	{
		public string ServerPath;
		public int PortNumber;
		public bool PortCheck;
		public bool AutoStart;
	}
Then:
var xmlSerializer = new XmlSerializer(typeof (Settings[]));
			var sWriter = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "Settings.xml", false);
			xmlSerializer.Serialize(sWriter, settingsArray);
			sWriter.Close();
to write the settings out of the program, or the deserialize method to read the settings into the program.

This way the .exe is distributed all on it's own, but your program can create a settings file to work off of.

If the user needs to make changes, they can simply make a change in the .xml file (or in your application, or in a separate application that only makes the file etc etc etc)

You can embed this file as a resource and read it out of the resource instead of as a filesystem request. Then you just make the executable take the values and save them.. Might defy the point though >.>

EDIT::
I consulted with an expert on the subject, and he said it's possible, but it's a butt load of pain to do. He said that once values are changed in the initial compile, it becomes next to impossible to find in C++, and only marginally better in CLI language.

thanks for your reply,that way is not standalone..the xml file HAS to be in the same folder with the exe..right? correct me if im wrong

#19 +Karl L.

Karl L.

    xorangekiller

  • Tech Issues Solved: 15
  • Joined: 24-January 09
  • Location: Virginia, USA
  • OS: Debian Testing

Posted 22 September 2012 - 21:07

In case you're interested in embedding the settings as a resource, this MSDN article is a good place to start. It explains resources in executables very thoroughly and has a few examples in VB.

#20 articuno1au

articuno1au

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 20-March 11
  • Location: Brisbane, Australia

Posted 22 September 2012 - 21:10

thanks for your reply,that way is not standalone..the xml file HAS to be in the same folder with the exe..right? correct me if im wrong

Yep.

Once you embed a resource, you can't access it easily as a user.

Hell, you can't access it easily outside of the application even if you wrote the application.

There really isn't a good way to do this :\

Best bet sounds like settings the values pre compile and just using constants >.>

#21 OP nouser

nouser

    Neowinian

  • Joined: 22-September 12

Posted 22 September 2012 - 21:13

check here: http://www.neowin.ne...-a-patch-vbnet/
this guy asks how to patch an exe.. so this is enough heplfull..also someone else there posted a project about patching an other exe.. BUT in my exe i cannot find what is the offset address that need to be patched.. a vb6 exe shows the strings in w32dams.. vb.net exe file wont show the strings in w32dasm so i cannot get the address.. i tried other than w32dasm(as you mentioned w32dasm is old..) but still i cannot see the strings in order to get their address and change them...

#22 articuno1au

articuno1au

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 20-March 11
  • Location: Brisbane, Australia

Posted 22 September 2012 - 21:18

Yeah, but if the user has custom settings per compile (that are defined prior to compile) the offset isn't going to be the same..

Also, It's not that simple in CLI languages..

I'm out. I can't help you with this I'm sorry.

#23 +Karl L.

Karl L.

    xorangekiller

  • Tech Issues Solved: 15
  • Joined: 24-January 09
  • Location: Virginia, USA
  • OS: Debian Testing

Posted 22 September 2012 - 21:22

I still think that modifying the resource table is the easiest way to go about accomplishing this, but I really don't have any more experience with it so I can't advise you more. I'm with articuno1au; I'm out too. Good luck!

#24 OP nouser

nouser

    Neowinian

  • Joined: 22-September 12

Posted 22 September 2012 - 21:24

there will be only 1 compile..mine.. so offset will be the same.. thanks for your time..anyone else?

#25 articuno1au

articuno1au

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 20-March 11
  • Location: Brisbane, Australia

Posted 22 September 2012 - 21:30

Compile with null values.

Compile a new exe with a different value.

Compare the two exes in binary (Google it), that should identify where the variables are stored in CLI.

Write a binary editor to insert the values.

Waste 5+ hours perfecting the above >.>

#26 OP nouser

nouser

    Neowinian

  • Joined: 22-September 12

Posted 22 September 2012 - 21:47

Compile with null values.

Compile a new exe with a different value.

Compare the two exes in binary (Google it), that should identify where the variables are stored in CLI.

Write a binary editor to insert the values.

Waste 5+ hours perfecting the above >.>

in the past i used to patch some exe's from other people to change the program title(window title) just for fun.. the thing is that from old exes you could be able to read the string's offset address using w32dasm..but with new exes i cannot do that.. thats what im looking for..a program that will give me the address of the strings!

#27 OP nouser

nouser

    Neowinian

  • Joined: 22-September 12

Posted 22 September 2012 - 22:41

guys..winhex will do the work..it says where a string is and the offset and the byte..now im ready to patch my exe :) allright so im just saying it to you so you can see how to do it if you want to do it in the future.. :)

#28 +Karl L.

Karl L.

    xorangekiller

  • Tech Issues Solved: 15
  • Joined: 24-January 09
  • Location: Virginia, USA
  • OS: Debian Testing

Posted 22 September 2012 - 22:41

I think what articuno1au is trying to say is that you should compile two versions of the executable, one with the strings as NULL and one with them set to something else, and use a utility like diff (in binary mode) to compare the two to determine the offsets.

#29 Eric

Eric

    Neowinian Senior

  • Tech Issues Solved: 13
  • Joined: 02-August 06
  • Location: Greenville, SC

Posted 22 September 2012 - 22:46

Can the exe not write to the registry or appdata folders? It would be easiest to put defaults in and a dialog to change and save them after the application has been run.

#30 OP nouser

nouser

    Neowinian

  • Joined: 22-September 12

Posted 22 September 2012 - 23:21

thanks for your suggestions..winhex shows where the string is..offset address and byte..now i can patch the exe :) i was looking for a program like this because w32dasm couldnt do the work(show the string..) :) now i have the offest and the byte(s) and i can easily patch them :) thanks everyone!!!
example:
1.exe has a messagebox which says "hello world"
2.exe has a textbox and i write there "hi space" and then i click PATCH 1.exe!
now everytime you run 1.exe it will say Hi space and NOT hello world..thats what i wanted to do and now i am able to do it..

:) THANKS everyone for your time!!!!