C++ DLL Injector!

C++ DLL Injector!

Post by Fl0urite on Fri Mar 07, 2014 3:44 am
([msg=79769]see C++ DLL Injector![/msg])

Made by yours truly! (kindof) Here is the code, anyone got the code for some good DLLs? eg. privilege escalation?
anyway here is the code:
Code: Select all
#include <windows.h>
#include <stdio.h>
#include <iostream>
//simple dll injector
//coded by Th3_M4d_h4tt3r
//Usage: dllinjector.exe [PID] [DLL]
int main(int argc, char* argv[]){
   using namespace std;
   int PID=atoi(argv[1]);
   char *buffer=argv[2];
   printf("[+] Welcome to Fl0urites DLL injector!\n");
   HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);
   if(!process){
      printf("[-] Cannot open process (PID %i).\n")%PID;
      exit(1);
   } else {
      printf("[+] Opened process (PID %i).\n")%PID;
   }
   LPVOID addr = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
   if (addr==NULL) {
      printf("[-] Could not load library from kernel32.dll.\n");
      exit(1);
   } else {
      printf("[+] Loaded library from kernel32.dll.\n");
   }
   LPVOID arg = (LPVOID)VirtualAllocEx(process, NULL, strlen(buffer), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
   if(arg==NULL) {
      printf("[-] The memory could not be allocated inside the chosen process.\n");
      exit(1);
   } else {
      printf("[+] Successfully allocated memory for chosen process.\n");
   }
   int n = WriteProcessMemory(process, arg, buffer, strlen(buffer), NULL);
   if(n == 0) {
      printf("[-] There were no bytes written to the process's address space.\n");
      exit(1);
   }
   HANDLE threadID = CreateRemoteThread(process, NULL, 0, (LPTHREAD_START_ROUTINE)addr, arg, NULL, NULL);
   if(threadID == NULL) {
      printf("[-] The remote thread could not be created.\n");
      exit(1);
   } else {
      printf("[+] The remote thread was successfully created!\n");
      exit(0);
   }
   return 0;
}
Fl0urite
New User
New User
 
Posts: 7
Joined: Wed Feb 12, 2014 5:01 am
Blog: View Blog (0)


Re: C++ DLL Injector!

Post by Goatboy on Sat Mar 08, 2014 7:03 pm
([msg=79779]see Re: C++ DLL Injector![/msg])

Fl0urite wrote:Made by yours truly!

Code: Select all
//coded by Th3_M4d_h4tt3r

I had a sensible chuckle at that.

Either you are Th3_Bu77hur7_h4t3r or you are stealing his code. I'm leaning towards the former based upon your join date and previous posts. In this case, I'm not sure whether to pity you or laugh at you. I can do both though, so no worries.

And in the case that you are stealing his code, you could do a lot better. Like stealing from someone who knows his shit. Or from someone who doesn't steal blatantly from other sources without changing any of the identifying strings or variable names.

Fucking idiot.
Assume that everything I say is or could be a lie.
1UHQ15HqBRZFykqx7mKHpYroxanLjJcUk
User avatar
Goatboy
Expert
Expert
 
Posts: 2823
Joined: Mon Jul 07, 2008 9:35 pm
Blog: View Blog (0)


Re: C++ DLL Injector!

Post by Fl0urite on Wed Mar 12, 2014 3:12 pm
([msg=79889]see Re: C++ DLL Injector![/msg])

Goatboy wrote:
Fl0urite wrote:Made by yours truly!

Code: Select all
//coded by Th3_M4d_h4tt3r

I had a sensible chuckle at that.

Either you are Th3_Bu77hur7_h4t3r or you are stealing his code. I'm leaning towards the former based upon your join date and previous posts. In this case, I'm not sure whether to pity you or laugh at you. I can do both though, so no worries.

And in the case that you are stealing his code, you could do a lot better. Like stealing from someone who knows his shit. Or from someone who doesn't steal blatantly from other sources without changing any of the identifying strings or variable names.

Fucking idiot.

I took some of his code from a different forum, I made some modifications to the code like naturally adding arguments, I was unaware that it was already stolen

I think I make sure the code I see on forums IS NOT copied, I made a huge mistake. Kudos for pointing that out. I would like to add that you shouldn't scold members until you fully understand the situation ;)

I am not Th3_Bu77hur7_h4t3r XD
Fl0urite
New User
New User
 
Posts: 7
Joined: Wed Feb 12, 2014 5:01 am
Blog: View Blog (0)


Re: C++ DLL Injector!

Post by Goatboy on Wed Mar 12, 2014 6:26 pm
([msg=79891]see Re: C++ DLL Injector![/msg])

Pretty sure I understood what was going on. I've been here a long time, and I have seen just about every type of post you can imagine. From "Help me hack 'my own' website" to "plz help B h4x0r" it's all pretty obvious after a while. It's my job to scold. Makes people better.

You stole code, claimed it was your own, let's all just move on.
Assume that everything I say is or could be a lie.
1UHQ15HqBRZFykqx7mKHpYroxanLjJcUk
User avatar
Goatboy
Expert
Expert
 
Posts: 2823
Joined: Mon Jul 07, 2008 9:35 pm
Blog: View Blog (0)


Re: C++ DLL Injector!

Post by A200K on Tue Apr 22, 2014 9:29 pm
([msg=80340]see Re: C++ DLL Injector![/msg])

This code will leave some memory leaks...

Wait until the thread exited, free the reserved memory and close the handle to the process after you inject the dll, e.g. with WaitForSingleObjectEx, VirtualFreeEx, CloseHandle.
A200K
New User
New User
 
Posts: 4
Joined: Tue Apr 22, 2014 9:26 pm
Blog: View Blog (0)



Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests