Thread: [MASM]Injector.

Results 1 to 15 of 15
  1. #1
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow

    [MASM]Injector.

    This is the ugliest injector you'll ever see.

    Try to prove me wrong.



    Here's the code, fools.

    Globals.inc
    [Highlight=ASM]

    ;'************************
    ;Main function globals
    ;***********************
    .data
    AppName db "Void's Ugly Injector",0
    ClassName db "Injector",0

    hwnd HWND ?
    msg MSG <>
    wnd WNDCLASSEX <>

    hInst HINSTANCE ?

    snapshot HANDLE ?
    pHandle HANDLE ?
    pEntry PROCESSENTRY32 <>

    allocMem dd 0

    processBuffer db 1024 DUP(0)

    kernel32dll db "kernel32.dll",0
    floadlibrary db "LoadLibraryA",0

    error db "Error",0
    error_1 db "Process not found!",0

    ;********************
    ;controls
    ;********************
    buttonClass db "button",0
    editClass db "edit",0
    staticClass db "static",0


    button1 HWND ?
    button1Text db "Inject",0

    button2 HWND ?
    button2Text db "Browse",0

    textbox1 HWND ?
    textbox1Text db 0

    textbox2 HWND ?
    textbox2Text db 0

    label1 HWND ?
    label1Text db "Process: ",0

    label2 HWND ?
    label2Text db "DLL: ",0

    fileDialog OPENFILENAME <>
    filter db "DLL",0,"*.DLL"
    buffer db 1024 DUP ( 0 )
    [/Highlight]

    Injector.asm
    [Highlight=ASM]
    .386
    .model flat,stdcall
    option casemap:none

    WinMain proto WORD,WORD,WORD,WORD
    Inject proto WORD,WORD

    include\masm32\include\windows.inc
    include\masm32\include\kernel32.inc
    include\masm32\include\user32.inc
    include\masm32\include\comdlg32.inc

    include Globals.inc

    includelib\masm32\lib\kernel32.lib
    includelib\masm32\lib\user32.lib
    includelib\masm32\lib\comdlg32.lib

    .data



    .code

    start:

    push NULL
    call GetModuleHandle

    mov hInst,eax
    invoke WinMain,eax,NULL,NULL,SW_SHOWDEFAULT
    invoke ExitProcess,0


    WinMain proc hInstance:HINSTANCE, hPrevInstance:HINSTANCE, cmdLine:LPSTR, cmdShowWORD

    mov wnd.cbSize,sizeof WNDCLASSEX

    mov ebx,CS_HREDRAW
    or ebx,CS_VREDRAW

    mov wnd.style, ebx
    mov wnd.lpfnWndProc, offset WndProc

    mov ebx,hInstance
    mov wnd.hInstance,ebx

    mov wnd.hbrBackground,COLOR_BTNSHADOW
    mov wnd.lpszClassName, offset ClassName

    push IDC_ARROW
    push NULL
    call LoadCursor

    mov wnd.hCursor,eax

    invoke RegisterClassEx,addr wnd
    invoke CreateWindowEx, NULL,addr ClassName,addr AppName,WS_OVERLAPPEDWINDOW,300,300,300,150,NULL,N ULL,hInstance,NULL

    mov hwnd,eax
    invoke ShowWindow,eax,cmdShow

    ;FILL OPENFILENAME STRUCT
    mov fileDialog.lStructSize,sizeof fileDialog

    push hwnd
    pop fileDialog.hwndOwner

    push hInstance
    pop fileDialog.hInstance
    mov fileDialog.lpstrFile,offset buffer
    mov fileDialog.lpstrFilter,offset filter
    mov fileDialog.nMaxFile,1024


    .while TRUE

    invoke GetMessage,addr msg,NULL,NULL,NULL

    .break .if eax==NULL


    invoke TranslateMessage, addr msg
    invoke DispatchMessage, addr msg

    .endw

    mov eax,msg.wParam

    Ret
    WinMain endp

    WndProc proc hWnd:HWND, Msg:UINT ,wParam:WPARAM, lParam:LPARAM

    .if Msg==WM_CREATE
    mov ebx,WS_CHILD
    or ebx,WS_VISIBLE
    or ebx, WS_BORDER
    or ebx,ES_AUTOHSCROLL
    invoke CreateWindowEx,NULL,addr editClass,NULL,ebx,70,30,100,20,hWnd,0,hInst,NULL ;DLL textbox
    mov textbox1,eax

    mov ebx,WS_CHILD
    or ebx,WS_VISIBLE
    or ebx, BS_DEFPUSHBUTTON
    invoke CreateWindowEx,NULL,addr buttonClass,addr button2Text,ebx,190,30,60,20,hWnd,1,hInst,NULL ;browse button

    mov ebx,WS_CHILD
    or ebx,WS_VISIBLE
    or ebx, WS_BORDER
    or ebx,ES_AUTOHSCROLL
    invoke CreateWindowEx,NULL,addr editClass,NULL,ebx,70,60,100,20,hWnd,0,hInst,NULL ;process textbox
    mov textbox2,eax

    mov ebx,WS_CHILD
    or ebx,WS_VISIBLE
    or ebx, BS_DEFPUSHBUTTON
    invoke CreateWindowEx,NULL,addr buttonClass,addr button1Text,ebx,190,60,60,20,hWnd,2,hInst,NULL ;inject button

    mov ebx,WS_CHILD
    or ebx,WS_VISIBLE
    invoke CreateWindowEx,NULL,addr staticClass,addr label1Text,ebx,5,60,60,20,hWnd,0,hInst,NULL ; process label

    mov ebx,WS_CHILD
    or ebx,WS_VISIBLE
    invoke CreateWindowEx,NULL,addr staticClass,addr label2Text,ebx,35,30,30,20,hWnd,0,hInst,NULL ; DLL label

    .endif

    .if Msg==WM_COMMAND
    mov eax,wParam
    .if eax==1
    invoke GetOpenFileName, addr fileDialog
    .if eax != NULL
    invoke SendMessage,textbox1,WM_SETTEXT,0,addr buffer
    .endif
    .endif

    .if eax==2
    invoke GetWindowText,textbox2,addr processBuffer,1024
    invoke Inject, addr buffer,addr processBuffer
    .endif
    .endif

    .if Msg==WM_CLOSE
    invoke PostQuitMessage,0
    .endif

    invoke DefWindowProc,hWnd,Msg,wParam,lParam
    Ret

    WndProc EndP

    Inject proc dllpathWORD,processNameWORD

    mov pEntry.dwSize,sizeof pEntry
    invoke CreateToolhelp32Snapshot,TH32CS_SNAPALL,0

    .if eax
    mov snapshot,eax

    invoke Process32First,snapshot,addr pEntry
    .while eax != NULL

    mov ebx,offset pEntry.szExeFile

    invoke lstrcmpi ,processName,ebx
    .if eax==0
    jmp processFound
    .endif

    invoke Process32Next,snapshot,addr pEntry
    .endw

    invoke MessageBox,NULL,addr error_1,addr error,MB_OK

    Ret

    processFound:
    mov ebx,pEntry.th32ProcessID

    invoke OpenProcess,PROCESS_ALL_ACCESS,0,ebx
    mov pHandle,eax
    .if eax != NULL
    invoke GetModuleHandle,addr kernel32dll
    invoke GetProcAddress,eax,addr floadlibrary
    .if eax != NULL
    mov ebx,eax

    invoke VirtualAllocEx,pHandle,0,sizeof dllpath,MEM_COMMIT,PAGE_EXECUTE_READWRITE
    mov allocMem,eax

    invoke lstrlen,dllpath
    mov edx,eax

    invoke WriteProcessMemory, pHandle,allocMem,dllpath,edx,0
    .if eax != NULL
    mov ecx,allocMem
    invoke CreateRemoteThread,pHandle,0,0,ebx,ecx,0,0
    .endif

    .endif
    .endif

    .endif

    Ret
    Inject EndP

    end start

    [/Highlight]

    I used macros this time 'cause I'm lazy..

  2. The Following 8 Users Say Thank You to Void For This Useful Post:

    .::SCHiM::. (02-13-2011),Auxilium (02-10-2011),Hassan (02-11-2011),Jason (02-10-2011),mookamoka3 (02-16-2011),Nightmare (11-28-2011),why06jz (02-10-2011),_Fk127_ (07-14-2011)

  3. #2
    cosconub's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    in the programming section MPGH Cash: $90,000,000,000
    Posts
    372
    Reputation
    -4
    Thanks
    39
    My Mood
    Psychedelic
    Not bad i like how it looks

    i like alota ugly gui's but ppl hate em

    A man is but the product of his thoughts what he thinks, he becomes.
    ~Mohandas Gandhi


    A Genius is nothing with out an idea, An idea is always an idea even without a genius.
    ~ Immortal

  4. #3
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    When I first assembled it and ran it, I almost cried.

  5. #4
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Noice. No exceptions.

  6. #5
    .::SCHiM::.'s Avatar
    Join Date
    Sep 2010
    Gender
    male
    Posts
    733
    Reputation
    180
    Thanks
    880
    My Mood
    Twisted
    Wow that's nice man!!
    I figure now it's my turn to go and release something tough

    I'm SCHiM

    Morals derive from the instinct to survive. Moral behavior is survival behavior above the individual level.

    Polymorphic engine
    Interprocess callback class
    SIN
    Infinite-precision arithmetic
    Hooking dynamic linkage
    (sloppy)Kernel mode Disassembler!!!

    Semi debugger




  7. #6
    TheCamels8's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    Israel :D
    Posts
    2,945
    Reputation
    174
    Thanks
    1,376
    My Mood
    Cheeky
    I like ASM so much
    It's awesome.
    Also you chose the best game: "WarRock.exe"
    Last edited by TheCamels8; 02-14-2011 at 12:14 PM.

  8. #7
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by .::SCHiM::. View Post
    Wow that's nice man!!
    I figure now it's my turn to go and release something tough
    I was hoping someone other than me would post code in this section.

    Can't wait for your release of whatever it is you're working on.

  9. #8
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,204
    My Mood
    Flirty
    Hey I post code in this section.

    Here:
    Code:
    Using System;
    public class Program
    {
    static void Main()
    {
    Console.WriteLine("Hello C#");
    }
    }

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  10. #9
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by why06 View Post
    Hey I post code in this section.

    Here:
    Code:
    Using System;
    public class Program
    {
    static void Main()
    {
    Console.WriteLine("Hello C#");
    }
    }
    yeah, sure you do. ):

  11. #10
    graysonmanolov's Avatar
    Join Date
    Jun 2010
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0
    My Mood
    Innocent
    Whoa. Thank you so much for posting this. I was always fascinated in low-level coding. I am, however, so confused about this memory management that you usually HAVE to use while coding in ASM. So, I have a couple of questions. Where did you start to accumulate such knowledge in memory management and Assembly? I would really love to start learning to develop low-level binaries so I can exploit hardware for piracy. ( PS3, iPhone ) Thank you so much for your time, Void!

  12. #11
    LEGiiTxCHAOTiiC's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Chicago
    Posts
    200
    Reputation
    39
    Thanks
    72
    Please organize into Code snippets, it's impossible to tell where it begins and ends. Thanks if you can.

  13. #12
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Quote Originally Posted by LEGiiTxCHAOTiiC View Post
    Please organize into Code snippets, it's impossible to tell where it begins and ends. Thanks if you can.
    Obviously random that don't know what happens/happened in this section.. /facepalm
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  14. #13
    LEGiiTxCHAOTiiC's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Chicago
    Posts
    200
    Reputation
    39
    Thanks
    72
    Quote Originally Posted by Brinuz View Post
    Obviously random that don't know what happens/happened in this section.. /facepalm
    You're right about me not knowing what happened, please explain. I'm not new to the forums however.

  15. #14
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Quote Originally Posted by LEGiiTxCHAOTiiC View Post
    You're right about me not knowing what happened, please explain. I'm not new to the forums however.
    check his post and you will find in there [Highlight=ASM]
    It was the old tags that this forum had.. for code.
    So, thats why the code looks so messy now..
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  16. The Following User Says Thank You to 'Bruno For This Useful Post:

    LEGiiTxCHAOTiiC (12-09-2011)

  17. #15
    LEGiiTxCHAOTiiC's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Chicago
    Posts
    200
    Reputation
    39
    Thanks
    72
    Quote Originally Posted by Brinuz View Post
    check his post and you will find in there [Highlight=ASM]
    It was the old tags that this forum had.. for code.
    So, thats why the code looks so messy now..
    Oh ok, I'm still getting used to the new look and everything, thanks for telling me.