Skip to content

Commit

Permalink
Added cleaning up the allocated memory. not for shellcodeinject
Browse files Browse the repository at this point in the history
  • Loading branch information
psychomario committed May 30, 2012
1 parent 992a441 commit 9d38151
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dllinject.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def inject(self, dllpath): #inject dllpath into our process
len(loaddll),
None
)
self.kernel32.CreateRemoteThread(
thread = self.kernel32.CreateRemoteThread(
self.handle,
None,
0,
Expand All @@ -212,6 +212,16 @@ def inject(self, dllpath): #inject dllpath into our process
0,
None
)
self.kernel32.WaitForSingleObject(
thread,
-1
)
self.kernel32.VirtualFreeEx(
self.handle,
shellcodeaddress,
len(loaddll),
0x8000
)

def injectshellcode(self, shellcode):
"""This function merely executes what it is given"""
Expand All @@ -229,7 +239,7 @@ def injectshellcode(self, shellcode):
len(shellcode),
None
)
self.kernel32.CreateRemoteThread(
thread = self.kernel32.CreateRemoteThread(
self.handle,
None,
0,
Expand All @@ -240,6 +250,7 @@ def injectshellcode(self, shellcode):
)

def injectshellcodefromfile(self, file):
"""This function merely executes what it is given as a raw file"""
fh=open(file,'rb')
shellcode=fh.read()
fh.close()
Expand Down

0 comments on commit 9d38151

Please sign in to comment.