Guest User

Untitled

a guest
Jul 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. "@
  2.  
  3. Add-Type -TypeDefinition @"
  4. using System;
  5. using System.Diagnostics;
  6. using System.Runtime.InteropServices;
  7.  
  8. public static class GetAddress
  9. {
  10. [DllImport("kernel32", SetLastError=true, CharSet = CharSet.Ansi)]
  11. public static extern IntPtr LoadLibrary(
  12. [MarshalAs(UnmanagedType.LPStr)]string lpFileName);
  13.  
  14. [DllImport("kernel32", CharSet=CharSet.Ansi, ExactSpelling=true, SetLastError=true)]
  15. public static extern IntPtr GetProcAddress(
  16. IntPtr hModule,
  17. string procName);
  18. }
  19.  
  20. "@
  21.  
  22. $library = [GetAddress]::LoadLibrary("c:\windows\system32\kernel32")
  23. $address = [GetAddress]::GetProcAddress($library, "WinExec")
  24. "0x$("{0:X16}" -f $address.ToInt64())"
Add Comment
Please, Sign In to add comment