cegy Posted March 12, 2008 Posted March 12, 2008 Hi, is it possible to make a patch in vb.net am using 2008 of it atm. i do know how a patch works in vb6 but not in .net so i thought to ask.could somone show me a simple example please.many thanks :biggrin:
Ufo-Pu55y Posted March 12, 2008 Posted March 12, 2008 Imports System.IOPublic Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Patch("C:\Grandma's_Online_Banking.exe", 666, &H90) End Sub Private Sub Patch(ByVal TargetFile As String, ByVal FileOffset As Long, ByVal NewValue As Byte) Dim br As BinaryReader = New BinaryReader(File.Open(TargetFile, FileMode.Open)) br.BaseStream.Position = FileOffset br.BaseStream.WriteByte(NewValue) br.Close() End SubEnd ClassGood luck with the rest :biggrin:
cegy Posted March 13, 2008 Author Posted March 13, 2008 (edited) i could userstand soem of it but not all erm..Patch("C:\Grandma's_Online_Banking.exe", 666, &H90) is to open the file and patch it with the offset of &H90Dim br As BinaryReader = New BinaryReader(File.Open(TargetFile, FileMode.Open)) br.BaseStream.Position = FileOffset br.BaseStream.WriteByte(NewValue) br.Close()mean that its gonna open the file and write the file offset patch to it and then close it.could u tell me abit more about this bit?Patch("C:\Grandma's_Online_Banking.exe", 666, &H90) and also to show like a 4 byte patching if it possible than just 1 bye patching?many thanks Edited March 13, 2008 by cegy
Ufo-Pu55y Posted March 13, 2008 Posted March 13, 2008 could u tell me abit more about this bit?Patch("C:\Grandma's_Online_Banking.exe", 666, &H90) and also to show like a 4 byte patching if it possible than just 1 bye patching? Ofc it's a simple and useless example.. written in a min. I dunno what you expected. U're really asking about the utter basics ! Do at least 'something', show it and get help. Sry, but pls don't be that lazy and expect full projects
cegy Posted March 13, 2008 Author Posted March 13, 2008 ok then i'll find simpel something with a 1 byte to patch and i'll upload the project for ya to show that am not lazy
evlncrn8 Posted March 13, 2008 Posted March 13, 2008 (edited) Patch("C:\Grandma's_Online_Banking.exe", 666, &H90)that IS 1 byte patch at offset 666, patching a nop into the executable.... jesus, if you cant figure that out from the code, im worried about any potential code you make... Edited March 13, 2008 by evlncrn8
hmi222 Posted March 13, 2008 Posted March 13, 2008 (edited) could u tell me abit more about this bit?Patch("C:\Grandma's_Online_Banking.exe", 666, &H90) and also to show like a 4 byte patching if it possible than just 1 bye patching?Perhaps: (no specific language!)global nrPatches.l=4dim Offset.l (global nrPatches)Dim Patchdata.b(global nrPatches)Offset(0)=666Offset(1)=766Offset(2)=866Offset(3)=966Patchdata(0)=$43Patchdata(1)=$4fPatchdata(2)=$4fPatchdata(3)=$4cfor i=0 to NrPatches-1Patch("C:\Grandma's_Online_Banking.exe", Offset(i), Patchdata(i)) nextyu can all do dynamically, its just a fast idea to given answer! Edited March 13, 2008 by hmi222
cegy Posted March 13, 2008 Author Posted March 13, 2008 not sure how to use ur code as i don't understand not like ufo-pu55y, and yes i know &H90 is NOP aka nothing
Loki Posted March 13, 2008 Posted March 13, 2008 He's suggesting you use a loop for patching multiple offsets.Perhaps you should start by coding some simple projects first - this is the absolute basic of programming in any language.
evlncrn8 Posted March 13, 2008 Posted March 13, 2008 yup, its simple binary file access... it should be one of the first things you learn apart from hello world...running before you can run isn't good... you'll trip, land on your head and get bloody... though you do have the vb/.net 'bandage' of it hiding things from you...
Xylitol Posted March 18, 2008 Posted March 18, 2008 vb.net sucki have the source code of the shmeitcorp patcher in asm if you want
Unbekannt1 Posted March 18, 2008 Posted March 18, 2008 (edited) This is a module I created a long time ago...Public Class PatchModule Public Structure PEPatch 'Public Variables - Vital Public eFilePath As String 'Prvate Variables - NotVital Private eBytes As Array 'Use Functions Public Function FileExistance() As Boolean If IO.File.Exists(eFilePath) = True Then Return (True) Else Return (False) End If End Function Public Function CompareFileSize(ByRef TotalBytes As Integer) As Boolean eBytes = IO.File.ReadAllBytes(eFilePath) If eBytes.Length = TotalBytes Then Return (True) Else Return (False) End If End Function Public Function GetFileSize() As Long eBytes = IO.File.ReadAllBytes(eFilePath) Return (eBytes.Length) End Function Public Function ReadBytes(ByRef pOffset As Long, Optional ByRef pLength As Integer = 4) As String Dim BR As IO.BinaryReader = New IO.BinaryReader(New IO.FileStream(eFilePath, IO.FileMode.OpenOrCreate)) BR.BaseStream.Position = pOffset eBytes = BR.ReadBytes(pLength) ReadBytes = BitConverter.ToString(eBytes, 0, pLength) BR.Close() End Function Public Sub WriteBytes(ByRef pOffset As Long, ByRef pBytes As Byte) Dim BW As IO.BinaryWriter = New IO.BinaryWriter(New IO.FileStream(eFilePath, IO.FileMode.OpenOrCreate)) BW.BaseStream.Position = pOffset BW.Write(pBytes) BW.Close() End Sub Public Function CheckPatched(ByRef pOffset As Long, ByRef pOriginalByte As Byte) As Boolean Dim BR As IO.BinaryReader = New IO.BinaryReader(New IO.FileStream(eFilePath, IO.FileMode.OpenOrCreate)) BR.BaseStream.Position = pOffset eBytes = BR.ReadBytes(1) BR.Close() If BitConverter.ToString(eBytes, 0, 1) = BitConverter.ToString(BitConverter.GetBytes(pOriginalByte), 0, 1) Then Return (False) 'Not Patched Else Return (True) 'Patched End If End Function End StructureEnd ClassPut that inside a new class then....Declare to use the new classPublic Patcher As PatchModule.PEPatchThen do whatever you want....this example NOPs out 2 jumps (each 2 bytes) to bypass an ASCII check:Patcher.eFilePath = FilePath'ASCII Overwrites For i = 0 To 1 Patcher.WriteBytes(&HCDF79 + i, &H90) Patcher.WriteBytes(&HCDF8B + i, &H90) Next TextBox2.Paste("Patching ASCII Overwrite...DONE!" & vbNewLine) Edited March 18, 2008 by Patrickssj6
Departure Posted April 8, 2008 Posted April 8, 2008 (edited) I think he means write multiple bytes to 1 address instead of single byte to multiple address's, im not 100% sure how vb.net works but can you make an array of bytes to patch to single address like you would with other programming languages?maybe this type of example he is looking forUf0 -Pu55y example code:Imports System.IOPublic Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Patch("C:\Grandma's_Online_Banking.exe", 666, &H90) End Subnow im not sure the following would work but give it a try for multiple bytes on single address, I have no idea how vb.net works but I going by how vb.net might declare an array of bytes.Imports System.IOPublic Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Patch() as Byte = {&H90,&H90,&H90,&H90} Patch("C:\Grandma's_Online_Banking.exe", 666, Patch) End SubAnd the anwser to your question about " Patch("C:\Grandma's_Online_Banking.exe", 666, &H90) " Patch = Call the Sub that writes the bytes to address"C:\Grandma's_Online_Banking.exe" = the Path to application 666 = the offset address&H90 = the byte, Now you might not relize that &H mean that its a byte, and ofcause you already know that 90 = nop so to tell vb.net that its an actuall byte you need &H then 90 so it will be &H90I hope this helps you with understanding what &H is... and im not 100% sure that "Dim Patch() as Byte = {&H90,&H90,&H90,&H90}" will work but if it does it it could be used to nop out 4 bytes from a single starting address.Good luck Edited April 8, 2008 by Departure
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now