[Help] Need help with vb hack hooking onto the wrong process.

Posts 1–7 of 7 · Page 1 of 1
[Help] Need help with vb hack hooking onto the wrong process.
Hey guys, i have a problem with my hack hooking onto the wrong process. Sometimes i will run two of the same process for testing purposes but my hack will sometimes write it on the wrong process. How can i tell the hack which process to hook on to from a certain directory? Thanks.
You could use Process.Start("C:\file_location.exe") which will return a newly created "process" object.
This way you don't have to loop over all the running processes: you already have a reference to the one you want.
Code:
Dim myProcess as Process

myProcess = Process.Start("C:\windows\system32\calc.exe")

How can i tell the hack which process to hook on to from a certain directory?
I assume you're running 2 copies of the .exe from the same place? Not sure if knowing that directory would help, since they both ran from it?
Please explain a little more.
Well the process name is the same but the directory is different because one is the server exe and the other is the client exe.
Process.MainModule.FileName includes the full filepath to the exe.
or Process.Modules(o).FileName I think.


edit: to remove the filename and just give you the folder's path
http://stackoverflow.com/questions/4...ialog-filename
Pass the full path (the one including the file name) to the System. IO .Path.GetDirectoryName method. This will strip out the file name and return the full path to the directory containing that file.

For example:

Dim filePath As String = "C:\MyDir\MySubDir\myfile.ext"
Dim directoryPath As String = Path.GetDirectoryName(filePath)

Places the following string in the directoryPath variable:

C:\MyDir\MySubDir


answered Feb 4 '11 at 8:26
Cody Gray
Code:
Dim theFolderPath as String = Path.GetDirectoryName(myProcess.MainModule.FileName)
'' or do some simple string manipulation on MainModule.FileName (..like SubString(LastIndexOf("\"))
Looks solid, but im not at my computer right now so i cant test it. Would you know of a way to check the MD5 of the exe also?
Negative, but a quick google yields: https://www.google.com/search?q=Md5+in+.net

MD5 Class (System.Security.Cryptography)

Code:
Shared Sub Main(ByVal args() As String)
        Dim [source] As String = "Hello World!" 
        Using md5Hash As MD5 = MD5.Create()

            Dim hash As String = GetMd5Hash(md5Hash, source)

            Console.WriteLine("The MD5 hash of " + source + " is: " + hash + ".")

            Console.WriteLine("Verifying the hash...")

            If VerifyMd5Hash(md5Hash, [source], hash) Then
                Console.WriteLine("The hashes are the same.")
            Else
                Console.WriteLine("The hashes are not same.")
            End If 
        End Using 
    End Sub 'Main



    Shared Function GetMd5Hash(ByVal md5Hash As MD5, ByVal input As String) As String 

        ' Convert the input string to a byte array and compute the hash. 
        Dim data As Byte() = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input))

        ' Create a new Stringbuilder to collect the bytes 
        ' and create a string. 
        Dim sBuilder As New StringBuilder()

        ' Loop through each byte of the hashed data  
        ' and format each one as a hexadecimal string. 
        Dim i As Integer 
        For i = 0 To data.Length - 1
            sBuilder.Append(data(i).ToString("x2"))
        Next i

        ' Return the hexadecimal string. 
        Return sBuilder.ToString()

    End Function 'GetMd5Hash
System. Security. Cryptography namespace

edit:
 
another search + code specific to your question

https://www.google.com/search?q=Md5+of+a+file+vb.net

1st result: http://social.msdn.microsoft.com/For...in-a-directory
Code:
 Private Shared Function CreateMD5StringFromFile(ByVal Filename As String) As String

      Dim MD5 = System.Security.Cryptography.MD5.Create
      Dim Hash As Byte()
      Dim sb As New System.Text.StringBuilder

      Using st As New IO.FileStream(Filename, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
         Hash = MD5.ComputeHash(st)
      End Using

      For Each b In Hash
         sb.Append(b.ToString("X2"))
      Next

      Return sb.ToString
End Function
Thanks for this, and im going to rephrase what i originally said for anybody that doesnt understand what i said up top. I would like to have something that will be able to tell what directory the process is running from if this can be done.
For example:

if process(processname, runs from this directory) then
do this
elseif process(processname, runs from this other directory) then
do something else
end if
Hopefully i cleared it up for anyone else reading this.
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us