Sign in to follow this  
Followers 0
Manko

ProDLLer: Unknown code running? Befriend or Kill!

100 posts in this topic

#1 ·  Posted (edited)

post-28581-0-99756400-1317831005_thumb.j

Know your system!

Prod your system for unwanted code! (virus/malware)

Please report bugs/requests/criticism or whatever!

ProDLLer v0.503

Update: 23rd of October 2011

ProDLLer.rar

Earlier versions downloaded: 2726 times.

Most Recent changes...
 
; 0.503
; Fixed: Don't leave icon in tray when leaving, XP/7.
; Fixed: Don't leave them after crash either.
; Added: Don't allow shutdown or standby while ProDLLing in XP, Thanks to Prog@ndy. Vista/7, dont alow shutdown.
; Added: Don't let ProDLLer be put to sleep by idletimers in xp/vista/7.
; Fixed: Lockup when returning from sleep in vista/7, . (if "Noprocs" running then disable "noprocs" and resume all procs.)
; Change: No suspending of "theme"-service in XP. On crash, just resume all processes... like we have to in vista/7...
 
; 0.502
; Fixed: Gui-problem fixed by BeginPaint/endpaint... tested on win7
; Fixed: "Crashnet" and SuspendAll. In the unlikely event that this happens. All procs will be resumed on vist and win7.
; Fixed: Fixed false positives in SSDTshadow on vista/win7.
 
; 0.501
; Added: SSDTshadow - not complete, but fully functional. = lacking names. (Logic is painful; need to guard against faults...)
; Fixed: Lockup in crashnet if "Services.exe" and "System" is suspended. Just resume them... You can suspend again...
; Fixed: Further lockups, same, to do with themes and "lsass.exe"...
 
; 0.500
; Added: Startup-killing... to take a load off the GUI... it will ask...
; Fixed: Slowdown because I accidentaly changed ProDLLer to itterate processes every second...
; Fixed: Process-CPU-utilization. Movement of abandoned children... I cheat. Just load up new list...
; Fixed: Got rid of the Adlib. There were too many possible problems...
; Fixed: CPU-load. Is again aligned...
 
; 0.499
; Added: If over 16 procs start from 1 sec to another or if a total of 40 procs have started; "NoProcsAllowed" is activated.
; Added: Crash-recovery... Just start a new instance of ProDLLer... :)
; Change: No loading of moduleinfo at start.
; Added: Refresh moduleinfo when we need it. KINDA CLUNKY SINCE I ITERATE ALL OF THEM, RIGHT NOW....
; Added: On start of app. Disallow new procs. "NoProcsAllowed" is activated.
; Fixed: A number of bugs that crash Prodller if insane amounts of processes start and stop...
 
; 0.498
; Fixed: "KernelNot.". When disabling callbacks; adjacent CBs of same type would sometimes vanish. Famous anti-rootkit had same faulty behavior.
 
; 0.497
; Fixed: Lockup when suspending some procs during modules-itteration. Context-menu disabled during itteration.
; Fixed: Lockup after thread-view due to excessive killing of already terminated security-threads... Now checking IF it needs killing...
; Fixed: Lockup when trying to change state of services while it is already working with your earlier request. Disable display.

Thanks for functions:

Thanks to "Smoke_N" for his "_ProcessListModules()"! Apparently i borrowed it a looooong time ago. :)

Thanks to "Engine" for his GREAT "Windows Services UDF"!!!

Thanks to JScript, Larry, SmOke_N, mrRevoked for _ProcessGetPath. I used this because I'm too lazy to do one myself. :)

Special thanks to:

Thanks to wraithdu for help and support!

Thanks to Ascend4nt for support and friendship!

Thanks to trancexx for good talks and friendship!

Thanks also to this great community! I really feel empowered!

/Manko [EDIT: New version.]

Edited by Manko

Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Nice idea. However, if you want people to be able to compile / play with it, you'll have to provide the "service.au3" and "skeleton.sys" files. Of course that's totally up to you :)

Edited by wraithdu

Share this post


Link to post
Share on other sites

Nice idea. However, if you want people to be able to compile / play with it, you'll have to provide the "service.au3" and "skeleton.sys" files. Of course that's totally up to you :)

Thanks! Files now included in first post! I will however not be ferreting out all files for compiling driver in masm32. :)

They are all standard/unmodified but you need the update and the DDK and maybe something else...?

Well if a need arises and it's impossible to find some masm_includefile or other... maybe... PM me...

But driver is included, so it should not be necessary for most.

/Manko


Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites

I do like it. It's something I've never thought to do before. But I can't see where/how I would really use it.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

I took your ColdBoot code out of here, and why doesn't it work just standalone?

#include <service.au3>

FileInstall("c:\skeleton.sys","c:\")
_StopService(".","skeleton")
_DeleteService(".","skeleton")
My_Service_Create("skeleton","Skeleton Driver","c:\skeleton.sys",$SERVICE_KERNEL_DRIVER,$SERVICE_DEMAND_START,$SERVICE_ERROR_IGNORE,0)
_StartService("skeleton")
_DeleteService(".","skeleton")
$test=DllStructCreate("char a[128]")
DllStructSetData($test,1,"\\.\skeleton")


$hColdBoot=DllCall("kernel32.dll", "int", "CreateFile", "ptr", DllStructGetPtr($test), "dword", 0xc0000000, "dword", 0, "dword", 0, "dword", 3, "dword", 0, "dword", 0)
DllCall("kernel32.dll", "int", "DeviceIoControl", "dword", $hColdBoot,"dword", 0x00226000, "ptr", 0, "dword", 0, "ptr", 0, "dword", 4, "dword*", 0, "ptr", 0)

Func My_Service_Create($sServiceName, _
                    $sDisplayName, _
                    $sBinaryPath, _
                    $nServiceType = 0x00000010, _
                    $nStartType = 0x00000002, _
                    $nErrorType = 0x00000001, _
                    $nDesiredAccess = 0x000f01ff)
   Local $hAdvapi32
   Local $hKernel32
   Local $arRet
   Local $hSC
   Local $lError = -1   

   $hAdvapi32 = DllOpen("advapi32.dll")
   If $hAdvapi32 = -1 Then Return 0
   $hKernel32 = DllOpen("kernel32.dll")
   If $hKernel32 = -1 Then Return 0
   $arRet = DllCall($hAdvapi32, "long", "OpenSCManager", _
                    "str", ".", _
                    "str", "ServicesActive", _
                    "long", $SC_MANAGER_ALL_ACCESS)
   If $arRet[0] = 0 Then
      $arRet = DllCall($hKernel32, "long", "GetLastError")
      $lError = $arRet[0]
   Else
      $hSC = $arRet[0]
      $arRet = DllCall($hAdvapi32, "long", "OpenService", _
                       "long", $hSC, _
                       "str", $sServiceName, _
                       "long", $SERVICE_INTERROGATE)
      If $arRet[0] = 0 Then
         $arRet = DllCall($hAdvapi32, "long", "CreateService", _
                          "long", $hSC, _
                          "str", $sServiceName, _
                          "str", $sDisplayName, _
                          "long", $nDesiredAccess, _
                          "long", $nServiceType, _
                          "long", $nStartType, _
                          "long", $nErrorType, _
                          "str", $sBinaryPath, _
                          "int", 0, _
                          "ptr", 0, _
                          "int", 0, _
                          "int", 0, _
                          "int", 0)
         If $arRet[0] = 0 Then          
            $arRet = DllCall($hKernel32, "long", "GetLastError")
            $lError = $arRet[0]
         Else
            DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $arRet[0])
         EndIf
      Else
         DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $arRet[0])
      EndIf   
      DllCall($hAdvapi32, "int", "CloseServiceHandle", "long", $hSC)
   EndIf
   DllClose($hAdvapi32)
   DllClose($hKernel32)   
   If $lError <> -1 Then 
      SetError($lError)
      Return 0
   EndIf
   Return 1
EndFunc

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

1. I took your ColdBoot code out of here, and why doesn't it work just standalone?

2. I do like it. It's something I've never thought to do before. But I can't see where/how I would really use it.

Hi!

1. Because a DllCall returns an array and you took out this part:

if $hColdBoot[0] = -1 Then 
    msgbox(0,"","Could not aquire cold boot handle!",5)
    $hColdboot=0
Else
    $hColdboot=$hColdBoot[0] ; ###### - Gets the result from the first arrayparameter into the single variable... - ####### 
EndIfoÝ÷ Øò¢çhmÁ©íjYm«r¢çȦ¦©àzÚ-+ºÚ"µÍØ[
    ][ÝÚÙ[Ì ][ÝË  ][ÝÚ[ ][ÝË  ][ÝÑ]XÙR[ÐÛÛÛ    ][ÝË  ][ÝÙÛÜ  ][ÝË  ÌÍÚÛÛÛÝÌK   ][ÝÙÛÜ  ][ÝË  ][ÝÜ][ÝË    ][ÝÙÛÜ  ][ÝË  ][ÝÜ][ÝË    ][ÝÙÛÜ  ][ÝË
    ][ÝÙÛÜ
][ÝË  ][ÝÜ][ÝË
oÝ÷ ÛeX­ßÛ¶%~Ýz׶)àjwkzj/x&j­çeÌ!Èkz¨Ê&zIèÂWçë¢kaz^­«h®ÊZ®Óµéæj­è§}ç-³*.®Ì¬µéÊ)ãyËbe)í£*.®Úî²×¦ºz˱©Ý²Ö²¶«xZ½êÞrÞ­çfj|¬ÊË^ÆòiÊ&n)Ú¶*'¡ûh¢[ºÚ/z¹h¢F§uæ¬zî±èZ±·ªk¡¹^«¶'.ªåÉú+¶¬¥ªí¡ûaz·¦¢ö¥¦ºzË·ljȦ¦WiËm«Zد»¬jlv÷öÖ¥Á¬¬vaz*ã¡´¨!Ú'ßÛkz¨Ø^»p!Øm¶§-Yai×(uè§~ì¶b§u×¥zاǫ¾'ANDG+y«b§vËZ®Ø§pjÈî²Û(ëax¦ëb«hëbëhëk¢éݶiËm«HÁ«©àz)ථ+Þ¬­Ø½é¦ºé¬Z²²­¶)ජajwex"[Zè­¢ëpéÈìm«Þj{©u«^÷öÙ'£!z{ajÜ"VÞ6m«_ºYh~'^jÆ®¶­sdfÆTç7FÆÂgV÷C¶3¢b3#·6¶VÆWFöâç72gV÷C²ÂgV÷C¶3¢b3#²gV÷C²¥õ7F÷6W'f6RgV÷C²âgV÷C²ÂgV÷C·6¶VÆWFöâgV÷C²²222222222ÒDTÄUDRD2ÄäRÒ2222222220¥ôFVÆWFU6W'f6RgV÷C²âgV÷C²ÂgV÷C·6¶VÆWFöâgV÷C²²222222222ÒDTÄUDRD2ÄäRÒ2222222220¤×õ6W'f6Uô7&VFRgV÷C·6¶VÆWFöâgV÷C²ÂgV÷Cµ6¶VÆWFöâG&fW"gV÷C²ÂgV÷C¶3¢b3#·6¶VÆWFöâç72gV÷C²Âb33cµ4U%d4Uô´U$äTÅôE$dU"Âb33cµ4U%d4UôDTÔäEõ5D%BÂb33cµ4U%d4UôU%$õ%ôtäõ$RÃ¥õ7F'E6W'f6RgV÷C·6¶VÆWFöâgV÷C²¥ôFVÆWFU6W'f6RgV÷C²âgV÷C²ÂgV÷C·6¶VÆWFöâgV÷C²¢b33c·FW7CÔFÆÅ7G'V7D7&VFRgV÷C¶6"³#ÒgV÷C²¤FÆÅ7G'V7E6WDFFb33c·FW7BÃÂgV÷C²b3#²b3#²âb3#·6¶VÆWFöâgV÷C²

/Manko


Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites

AWESOME and UNBELIEVABLE ! When i first saw the title , i thought that it'll never be possible but ..

*Loss of words*..

Thanks for sharing !

Share this post


Link to post
Share on other sites

Thanks for sharing !

Thanks for the high praise! Hope it will be useful for you!

Have updated app in first post.

Now it lists processes in parent/child order with indentation. Now you can see what proc started which proc. +it gets easier to read.

(On the downside, it sortof broke sorting of that column... but I wanted to release now and maybe fix later.)

Added info on Company/description/priority/full path

Proclistwindow is larger and it is resizeable!

/Manko


Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites

way cool! It's not like I'll be using it daily but there are situations when I really need this sort of app...

Bug thing: when resizing the window or moving the lists separator the whole thing flickers and the left list goes over the right one until i release the mouse button... not sure if this is because my cpu has only 1500 mhz

thx for sharing

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

way cool! It's not like I'll be using it daily but there are situations when I really need this sort of app...

Bug thing: when resizing the window or moving the lists separator the whole thing flickers and the left list goes over the right one until i release the mouse button... not sure if this is because my cpu has only 1500 mhz

thx for sharing

Hi!

It's more like, I'm a crappy programmer. I actually don't know how to make it resize prettily... Ie tracking the mouse, making changes...

App worked in other respects, so I didn't bother. *blush*

Thanks for taking time and effort to comment!

/Manko

[EDIT: Have fixed much prettier resizing... (both listviews follow mouse like they should) Will not release and bump thread now though...]

Edited by Manko

Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Problem resolved with new function!

A WARNING to potential users. Since I have a very clean system. I have not realised just how REALLY dangerous suspending threads can be. I just thought that if I kept updating lists of exceptions like for:

"csrss.exe" - NEVER supend on winXP, as this handles keyboard and mouse, and you would not be able to do anything else.

"ctfmon.exe" - App would be unresponsive, and might lock...

"fsgk.exe" - F-Secure antivirus. App would lock. This is used at work. BLODY SLOW AND USELESS...

...all would be good... But then I discovered lots more on laptops and readyinstalled package - brand name - systems... These procs all locked the system... They were too many!!! I had to find the cause.... And discovered it in Global message hooks. (SetWindowsHookEx)

So I started researching a way to warn the user of which processes had set these hooks. A possible way was to set a hook one self that would monitor hooks. WH_DEBUG which would return among others what sort of hook would be called and which process had installed it.

LRESULT CALLBACK DebugProc(   
    int nCode,
    WPARAM wParam,; Returns what sort of hook will be called
    LPARAM lParam   ; Returns below struct...
);

The lParam would return a pointer to the below struct.

typedef struct {
    DWORD idThread;
    DWORD idThreadInstaller;    THIS would return what I wanted. But always return 0. !!!! :( 
    LPARAM lParam;
    WPARAM wParam;
    int code;
} DEBUGHOOKINFO, *PDEBUGHOOKINFO;

Problem resolved with new function!

No matter what I did... It did not work. All the other fields in the struct is filled, but NOT the one I needed. (Of course I had put it in dll... And fiddled with security descriptors and such... no game!)I googled for days, only to find that noone could solve this and all had the same problem. :) I have continued to google and am on the track of a solution involving kernel drivers and undocumented structures deep in kernelspace... My Leads are:

http://www.experts-exchange.com/Programmin...Q_22405364.html

http://zairon.wordpress.com/2006/12/06/any...-on-my-machine/

http://www.woodmann.com/forum/archive/index.php/t-11537.html

This won't be fixed soon, so now you know, and have been warned. And I have no experience with kernel drivers... (The one I have is form a skeleton source, which I have shoves my two line code for rebooting into...)

I have to continue searching...

/Manko [EDIT:Problem resolved with new function!]

Edited by Manko

Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

the code gives me unendless errors

Have you downloaded extras? (The includes must ofcourse be in the INCLUDEs directory.) :)

Are you using Windows XP? (Prefered, maybe required...)

Are you administrator? (Required!)

Are you using AutoIt v3.3.0.0?

If that doesn't help, what are the errors? first error?

Thanks for replying! Don't see that often... :lmao:

/Manko

Edited by Manko

Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

yes at all but the errors r code related like endswitch and missing separators as i remember

Edit : line 80 _service_start("Skeleton") in correct number of parameters

i guess the services.au3 that i have is out dated or maybe urs

Edited by yehia

Share this post


Link to post
Share on other sites

yes at all but the errors r code related like endswitch and missing separators as i remember

Edit : line 80 _service_start("Skeleton") in correct number of parameters

i guess the services.au3 that i have is out dated or maybe urs

I'm guessing, if you switch to the provided services.au3, errors will go away. Make a copy of yours so you can switch back.

If that doesn't help, maybe you can give me more info...

/Manko


Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites

how can i just list all the loaded dlls in an array?

Here you go!

Apparently I borrowed the module_func from Smoke_N a loooong time ago. Credits to him!!!

I just put it in my originally SMALL script and quickly forgot about it... :)

Never thought about publishing own code, back then...

I have used these APIs before, but AM lazy, so since I wasn't accustomed to Autoit-coding I just took it when I found one readymade.

#AutoIt3Wrapper_outfile=C:\TEST1.exe
#include <WinAPI.au3>   ; _GetPrivilege_SEDEBUG() - by wraithdu - uses this include. My function needs none.
#include <array.au3>    ; Needed to display array in example. Not needed by Func.

; ############ Example code #######################
#RequireAdmin

Global $avArray[100000][7], $iAdd = 0, $i
_GetPrivilege_SEDEBUG() ; I need this for tricky processes. Not needed for most...
Global $procs=ProcessList()
$avArray[0][0] = "ProcessName"
$avArray[0][1] = "th32ProcessID"
$avArray[0][4] = "ProccntUsage"
$avArray[0][5] = "modBaseSize"
$avArray[0][2] = "hModule"
$avArray[0][3] = "szModuleName"
$avArray[0][6] = "szExePath"
for $i= 3 to ubound($procs,1)-1
$iAdd+=1
_ProcessListModules($procs[$i][1])
Next
ReDim $avArray[$iAdd+1][7]
_arraydisplay($avArray, "Credits to Smoke_N for func... I just slightly modified it.")
; ###############################################


; ############ Here be func! #################### Credits to Smoke_N (Just searched for it...)
Func _ProcessListModules($dwPID)
    Local Const $TH32CS_SNAPMODULE = 0x08
    Local $aDLLCall, $tagMODULEENTRY32, $hModuleSnap
    $aDLLCall = DllCall("Kernel32.dll", "ptr", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPMODULE, "dword", $dwPID)
    $hModuleSnap = $aDLLCall[0]
    $tagMODULEENTRY32 = DllStructCreate("dword;dword;dword;dword;dword;byte;dword;ptr;char[256];char[257]")
    DllStructSetData($tagMODULEENTRY32, 1, DllStructGetSize($tagMODULEENTRY32))
    $aDLLCall = DllCall("Kernel32.dll", "int", "Module32First", "ptr", $hModuleSnap, "long", DllStructGetPtr($tagMODULEENTRY32))
    While 1
;~      typedef struct tagMODULEENTRY32 {
        ;$avArray[$iAdd][0] = DllStructGetData($tagMODULEENTRY32, 1) ;~             DWORD   dwSize;
        $avArray[$iAdd][0] = $procs[$i][0]
        ;$avArray[$iAdd][1] = DllStructGetData($tagMODULEENTRY32, 2) ;~             DWORD   th32ModuleID;
        $avArray[$iAdd][1] = DllStructGetData($tagMODULEENTRY32, 3) ;~          DWORD   th32ProcessID;
        ;$avArray[$iAdd][3] = DllStructGetData($tagMODULEENTRY32, 4) ;~             DWORD   GlblcntUsage;
        $avArray[$iAdd][4] = DllStructGetData($tagMODULEENTRY32, 5) ;~          DWORD   ProccntUsage;
        ;$avArray[$iAdd][5] = DllStructGetData($tagMODULEENTRY32, 6) ;~             BYTE  * modBaseAddr;
        $avArray[$iAdd][5] = DllStructGetData($tagMODULEENTRY32, 7) ;~          DWORD   modBaseSize;
        $avArray[$iAdd][2] = DllStructGetData($tagMODULEENTRY32, 8) ;~          HMODULE hModule;
        $avArray[$iAdd][3] = DllStructGetData($tagMODULEENTRY32, 9) ;~          char    szModule[MAX_MODULE_NAME32 + 1];
        $avArray[$iAdd][6] = DllStructGetData($tagMODULEENTRY32, 10);~          char    szExePath[MAX_PATH];
;~      } MODULEENTRY32;
        $aDLLCall = DllCall("kernel32", "int", "Module32Next", "ptr", $hModuleSnap, "long", DllStructGetPtr($tagMODULEENTRY32))
        If Not $aDLLCall[0] Then ExitLoop
        $iAdd += 1
    WEnd
    DllCall("Kernel32.dll", "int", "CloseHandle", "ptr", $hModuleSnap)
    Return
EndFunc   ;==>_ProcessListModules

; ####################### Below Func is Part of example - Needed to get commandline from more processes.
; ####################### Thanks to wraithdu!
Func _GetPrivilege_SEDEBUG()
    Local $tagLUIDANDATTRIB = "int64 Luid;dword Attributes"
    Local $count = 1
    Local $tagTOKENPRIVILEGES = "dword PrivilegeCount;byte LUIDandATTRIB[" & $count * 12 & "]" ; count of LUID structs * sizeof LUID struct
    Local $TOKEN_ADJUST_PRIVILEGES = 0x20
    Local $call = DllCall("advapi32.dll", "int", "OpenProcessToken", "ptr", _WinAPI_GetCurrentProcess(), "dword", $TOKEN_ADJUST_PRIVILEGES, "ptr*", "")
    Local $hToken = $call[3]
    $call = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", Chr(0), "str", "SeDebugPrivilege", "int64*", "")
    ;msgbox(0,"",$call[3] & " " & _WinAPI_GetLastErrorMessage())
    Local $iLuid = $call[3]
    Local $TP = DllStructCreate($tagTOKENPRIVILEGES)
    Local $LUID = DllStructCreate($tagLUIDANDATTRIB, DllStructGetPtr($TP, "LUIDandATTRIB"))
    DllStructSetData($TP, "PrivilegeCount", $count)
    DllStructSetData($LUID, "Luid", $iLuid)
    DllStructSetData($LUID, "Attributes", $SE_PRIVILEGE_ENABLED)
    $call = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "ptr", $hToken, "int", 0, "ptr", DllStructGetPtr($TP), "dword", 0, "ptr", Chr(0), "ptr", Chr(0))
    Return ($call[0] <> 0) ; $call[0] <> 0 is success
EndFunc   ;==>_GetPrivilege_SEDEBUG

/Manko


Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites

thanks alot man

What i'm going to do with it is a "dll scanner that would point out a spy or trojan threads injected to windows services"

thanks

Share this post


Link to post
Share on other sites

Great Program Manko :)

and i used some function of it in my Task Manager


1 £0\\/3 |-|3® $0 |\\/|µ(|-|

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • Luigi
      By Luigi
      Greetings, someone can give a exemple, how send a error from a C#'s dll to AutoIt?
      I use this line, to send an error... but, I want get a error code In AutoIt with macro @error, it's possible?
       
      throw new ArgumentException("arquivo map não existe", "value" ); In this way, work, I know ther are error, but, @errror always is zero.
      I don't want this, I want a number as error code.
      Can you help me?
       
      Best regards
    • nss
      By nss
      Hi all,
       
      I am making a program in which I use Bass audio library (with the wrapper for autoit that I found here on forums I think) because of its support for dx effects.
      My problem, though, is that when effects as reverb or echo/delay are added, the channel length is not extended as to fit the tail of the effect, so if the file was really short, you wouldn't even hear the reverb at all.
      I've tried setting the  buffer parameter even to 60k ms, updating the channel length to 60k ms, but nothing makes it so that the effects aren't being cut off.
      I've heard that I could add silence manually to wave files by adding the chr(0) characters, but haven't had any luck doing that, either.
      What I'm doing:
      initialize bass use streamCreateFile to load the wave file with the fx flag and length parameter set to 60000 set the config buffer to 60000 use channel set fx to add dx8 reverb use channel play to play the sound use bass update to update the length to 60000  
      I even tried having only silence in one wave file and tried joining two wave files together, but that didn't work either.
       
      Any help would be very much appreciated.
    • Nareshm
      By Nareshm
      If Process exits then end process and ;Some code here {1}
       
      If Process does not exits then ; My {1} Code
    • junkew
      By junkew
      Since W8.1 (actually IE 11 with W7 will work also) microsoft has a Javascript runtime that can be called from scripting languages
      As shown in this example from C++: https://iobservable.net/blog/2013/11/12/introduction-to-jsrt/
      By loading either JSCRIPT9.DLL or CHAKRA.DLL you can embed ECMA JavaScript in your application
      And implemented here in AutoHotKey https://autohotkey.com/boards/viewtopic.php?f=6&t=5739
      Triggered by other threads: 
      https://www.autoitscript.com/forum/topic/185883-accessing-autoit-variables/ https://iobservable.net/blog/2013/11/12/introduction-to-jsrt/ https://www.autoitscript.com/forum/topic/184824-chakracore-udf-executing-javascript-in-autoit/ http://eclipsesource.com/blogs/2016/04/06/getting-started-with-microsoft-chakracore/
        This code is almost working but unfortunately not with the expected output. Someone seeing what is wrong? 
      It runs completely after fixes of DanyFirex 
       
      ;~ https://iobservable.net/blog/2013/11/ ;~ Should work on all windows versions with IE11 #AutoIt3Wrapper_UseX64=N #Region enum JsErrorCode : unsigned int Enum $JsNoError = 0, _ $JsErrorCategoryUsage = 0x10000, _ $JsErrorInvalidArgument, _ $JsErrorNullArgument, _ $JsErrorNoCurrentContext, _ $JsErrorInExceptionState, _ $JsErrorNotImplemented, _ $JsErrorWrongThread, _ $JsErrorRuntimeInUse, _ $JsErrorBadSerializedScript, _ $JsErrorInDisabledState, _ $JsErrorCannotDisableExecution, _ $JsErrorHeapEnumInProgress, _ $JsErrorArgumentNotObject, _ $JsErrorInProfileCallback, _ $JsErrorInThreadServiceCallback, _ $JsErrorCannotSerializeDebugScript, _ $JsErrorAlreadyDebuggingContext, _ $JsErrorAlreadyProfilingContext, _ $JsErrorIdleNotEnabled, _ $JsErrorCategoryEngine = 0x20000, _ $JsErrorOutOfMemory, _ $JsErrorCategoryScript = 0x30000, _ $JsErrorScriptException, _ $JsErrorScriptCompile, _ $JsErrorScriptTerminated, _ $JsErrorScriptEvalDisabled, _ $JsErrorCategoryFatal = 0x40000, _ $JsErrorFatal ;~ }JsErrorCode; #EndRegion enum JsErrorCode : unsigned int #Region typedef enum JsRuntimeVersion Enum $JsRuntimeVersion10 = 0, $JsRuntimeVersion11 = 1 #EndRegion typedef enum JsRuntimeVersion ; Create callback function. Local $hPrintf = DllCallbackRegister("_printf", "long", "ptr;bool;ptr;ushort;ptr") Local $hJSRuntime = DllOpen("c:\windows\system32\jscript9.dll") $JsRuntimeAttributeNone = 0x00000000 ;~ #RequireAdmin Example() Func Example() Local $script = "native.printf('hello world')" ;~ Local $script = "native.printf('number=%#x string=%s\n', 255, 'test')" ;~ Local $script = "(()=>{return 'Hello world!';})()" ;~ Local $script = "var x='helloworld'; return x;" ;~ Local $script = "var x=10;" & @CRLF & "var y=11;" ;~ Local $script = "(42);" ;~ Local $script = "(" & @CRLF ;~ $script=$script & "host.echo(JSON.stringify({foo:'bar'}));)" & @CRLF ;~ $script=$script & "42 // The script's result :) "& @CRLF ;~ $script=$script & ")"& @CRLF ;~ $script=$script & "class Host {"& @CRLF ;~ $script=$script & " echo(s) {"& @CRLF ;~ $script=$script & " MsgBox %s%"& @CRLF ;~ $script=$script & " }"& @CRLF ;~ $script=$script & "}"& @CRLF Local $aResult Local $runtime Local $context ;~ // Create a runtime ;~ JsCreateRuntime(JsRuntimeAttributeNone, nullptr, &runtime); $runtime = _JsCreateRuntime($JsRuntimeAttributeNone, 0, $runtime) ; ;~ // Create an execution context. ;~ JsCreateContext(runtime, &context); $context = _JsCreateContext($runtime, $context) ;~ // Now set the current execution context. ;~ JsSetCurrentContext(context); _JsSetCurrentContext($context) ; ; Get the Global object for adding stuff ;~ JsGetGlobalObject(&global); Local $global $global = _JsGetGlobalObject($global) ;~ JsPropertyIdRef nativeProp; ;~ JsGetPropertyIdFromName(L"native", &nativeProp); Local $nativeProp $nativeProp = _JsGetPropertyIdFromName("native", $nativeProp) ;~ JsValueRef nativeObj; ;~ JsCreateObject(&nativeObj); Local $nativeObj $nativeObj = _JsCreateObject($nativeObj) ;~ JsPropertyIdRef printfProp; ;~ JsGetPropertyIdFromName(L"printf", &printfProp); Local $printfProp $printfProp = _JsGetPropertyIdFromName("printf", $printfProp) ;~ JsValueRef printfFunc; ;~ JsCreateFunction(PrintFormat, nullptr, &printfFunc); Local $printfFunc $printfFunc = _JsCreateFunction(DllCallbackGetPtr($hPrintf), 0, $printfFunc) ;~ JsSetProperty(nativeObj, printfProp, printfFunc, true); _JsSetProperty($nativeObj, $printfProp, $printfFunc, True) ;~ JsSetProperty(global, nativeProp, nativeObj, true); _JsSetProperty($global, $nativeProp, $nativeObj, True) ;~ STDAPI_(JsErrorCode) JsCreateFunction( ;~ _In_ JsNativeFunction nativeFunction, ;~ _In_opt_ void *callbackState, ;~ _Out_ JsValueRef *function ;~ ); ; Get a JsValueRef for our Host object ;~ hostRef := ToJsValue(Host) ;~ $aResult=DllCall($hJSRuntime, "int","JsVariantToValue", "ptr", &variant, "ptr*", valref) ; Pass our Host object to the script engine ;~ DllCall("jscript9\JsSetProperty", "ptr", globalObject, "ptr", hostPropertyId, "ptr", hostRef, "int", true) ;~ // Run the script. ;~ STDAPI_(JsErrorCode) JsRunScript( ;~ _In_z_ const wchar_t *script, ;~ _In_ JsSourceContext sourceContext, ;~ _In_z_ const wchar_t *sourceUrl, ;~ _Out_ JsValueRef *result ;~ ); Local $currentSourceContext = 1 ;~ JsRunScript(script.c_str(), currentSourceContext++, L"", &result); Local $result = "" Local $sourceURL = "" $aResult = DllCall($hJSRuntime, "int", "JsRunScript", "WSTR", $script, "UINT*", $currentSourceContext, "wstr", "dummysource.js", "WSTR*", $result) ConsoleWrite("Error 11: " & @error & @CRLF) If @error = 0 Then ConsoleWrite($aResult[0] & ";" & $aResult[1] & ";" & $aResult[2] & ";" & $aResult[3] & ";" & $aResult[4] & @CRLF) EndIf ;~ // Convert your script result to String in JavaScript redundant if your script returns a String ;~ JsValueRef resultJSString; ;~ STDAPI_(JsErrorCode) JsConvertValueToString( ;~ _In_ JsValueRef value, ;~ _Out_ JsValueRef *stringValue ;~ ); ;~ JsConvertValueToString(result, &resultJSString); ;~ $aResult=DllCall($hJSRuntime, "int", "JsConvertValueToString", "WSTR", $script, "long", 1, "WSTR*",0, "WSTR*", $result) ;~ consolewrite("Error 4: " & @error & @CRLF) ;~ if @error=0 Then ;~ consolewrite($aResult[0] & ";" & $aResult[1] & ";" & $aResult[2] & ";" & $aResult[3] & ";" & $aResult[4] & @CRLF) ;~ EndIf ;~ ;~ // Project script result back to C++. ;~ const wchar_t *resultWC; ;~ size_t stringLength; ;~ JsStringToPointer(resultJSString, &resultWC, &stringLength); ;~ wstring resultW(resultWC); ;~ cout << string(resultW.begin(), resultW.end()) << endl; ;~ system("pause"); ;~ // Dispose runtime ;~ JsSetCurrentContext(JS_INVALID_REFERENCE); ;~ JsDisposeRuntime(runtime); Return 0 ; EndFunc ;==>Example ; Create callback function. ;~ JsValueRef CALLBACK PrintFormat(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) ;~ { ;~ const wchar_t *format; ;~ size_t length; ;~ JsStringToPointer(arguments[1], &format, &length); ;~ VARIANT variant; ;~ JsValueToVariant(arguments[2], &variant); ;~ const wchar_t *str; ;~ JsStringToPointer(arguments[3], &str, &length); ;~ wprintf(format, variant.intVal, str); ;~ return JS_INVALID_REFERENCE; ;~ } ;~ typedef _Ret_maybenull_ JsValueRef (CALLBACK * JsNativeFunction)( ;~ _In_ JsValueRef callee, ;~ _In_ bool isConstructCall, ;~ _In_ JsValueRef *arguments, ;~ _In_ unsigned short argumentCount ;~ ); Func _printf($callee, $isConstructCall, $arguments, $argumentCount, $callbackState) ConsoleWrite("there we are with " & $argumentCount & " arguments" & @CRLF) Local $tArgs = DllStructCreate("ptr JsValues[" & $argumentCount & "]", $arguments) ;~ STDAPI_(JsErrorCode) JsConvertValueToString( ;~ _In_ JsValueRef value, ;~ _Out_ JsValueRef *stringValue ;~ ); ;~ JsConvertValueToString(result, &resultJSString); local $tresult $aResult=DllCall($hJSRuntime, "int", "JsConvertValueToString", "ptr", DllStructGetData($tArgs,1,2), "ptr*", $tresult) consolewrite("Error 4: " & @error & @CRLF) if @error=0 Then consolewrite( $aResult[0] & ";" & $aResult[1] & ";" & $aResult[2] & @CRLF) $tresult=$aresult[2] EndIf ;~ STDAPI_(JsErrorCode) JsValueToVariant( ;~ _In_ JsValueRef object, ;~ _Out_ VARIANT *variant ;~ ); ;~ Local $aResult = DllCall($hJSRuntime, "dword", "JsValueToVariant", "ptr", $arguments[0], "ptr*", 0) ;~ If @error Then Return SetError(3, 0, @error) ;~ If $aResult[0] <> 0 Then Return SetError(4, 0, $aResult[0]) ;~ consolewrite($aResult[2]) Local $aResult = DllCall($hJSRuntime, "dword", "JsStringToPointer", "ptr", $tResult, "ptr*", 0, "int*", 0) If @error Then Return SetError(3, 0, @error) If $aResult[0] <> 0 Then Return SetError(4, 0, $aResult[0]) Local $tString = DllStructCreate("wchar string["&$aResult[3]&"]", $aResult[2]) consolewrite("+Parameter: " & $tString.string & @CRLF) Return 0 EndFunc ;==>_printf ;~ typedef void *JsRuntimeHandle; ;~ // Create a runtime. ;~ Edge mode signature STDAPI_(JsErrorCode) JsCreateRuntime( ;~ _In_ JsRuntimeAttributes attributes, ;~ _In_opt_ JsThreadServiceCallback threadService, ;~ _Out_ JsRuntimeHandle *runtime); ;~ Legacy mode signature ;~ STDAPI_(JsErrorCode) JsCreateRuntime( ;~ _In_ JsRuntimeAttributes attributes, ;~ _In_ JsRuntimeVersion version, ;~ _In_opt_ JsThreadServiceCallback threadService, ;~ _Out_ JsRuntimeHandle *runtime ;~ ); ;~ $runtime=_JsCreateRuntime(JsRuntimeAttributeNone, 0, $runtime); Func _JsCreateRuntime($JsRuntimeAttributeNone, $JSRuntimeVersion, $runtime) $aResult = DllCall($hJSRuntime, "int", "JsCreateRuntime", "int", $JsRuntimeAttributeNone, "int", $JSRuntimeVersion, "ptr", 0, "ptr*", $runtime) If @error Then Return SetError(1, @error, 0) Return $aResult[4] EndFunc ;==>_JsCreateRuntime ;~ // Edge mode signature ;~ STDAPI_(JsErrorCode) JsCreateContext( ;~ _In_ JsRuntimeHandle runtime, ;~ _Out_ JsContextRef *newContext); ;~ // Legacy mode signature ;~ STDAPI_(JsErrorCode) JsCreateContext( ;~ _In_ JsRuntimeHandle runtime, ;~ _In_ IDebugApplication *debugApplication, ;~ _Out_ JsContextRef *newContext ;~ ); ;~ JsCreateContext(runtime, &context); Func _JsCreateContext($runtime, $context) $aResult = DllCall($hJSRuntime, "int", "JsCreateContext", "ptr", $runtime, "ptr", 0, "ptr*", $context) If @error Then Return SetError(1, @error, 0) Return $aResult[3] EndFunc ;==>_JsCreateContext ;~ STDAPI_(JsErrorCode) JsSetCurrentContext( ;~ _In_ JsContextRef context ;~ ); ;~ JsSetCurrentContext(context); Func _JsSetCurrentContext($context) $aResult = DllCall($hJSRuntime, "int", "JsSetCurrentContext", "ptr", $context) If @error Then Return SetError(1, @error, 0) Return $JsNoError EndFunc ;==>_JsSetCurrentContext ; Get the Global object for adding stuff ;~ STDAPI_(JsErrorCode) JsGetGlobalObject( ;~ _Out_ JsValueRef *globalObject ;~ ); ;~ JsValueRef global; ;~ JsGetGlobalObject(&global); Func _JsGetGlobalObject($global) $aResult = DllCall($hJSRuntime, "int", "JsGetGlobalObject", "ptr*", $global) If @error Then Return SetError(1, @error, 0) Return $aResult[1] EndFunc ;==>_JsGetGlobalObject ; Get a property ID for the name "host" ;~ STDAPI_(JsErrorCode) JsGetPropertyIdFromName( ;~ _In_z_ const wchar_t *name, ;~ _Out_ JsPropertyIdRef *propertyId ;~ ); ;~ DllCall("jscript9\JsGetPropertyIdFromName", "wstr", "host", "ptr*", hostPropertyId) ;~ local $hostPropertyID ;~ $aResult=DllCall($hJSRuntime, "int","JsGetPropertyIdFromName", "wstr", "host", "ptr*", $hostPropertyId) ;~ consolewrite("Error 5: " & @error & @CRLF) ;~ if @error=0 Then ;~ consolewrite($aResult[0] & ";" & $aResult[1] & ";" & $aResult[2] & @CRLF) ;~ EndIf ;~ JsPropertyIdRef nativeProp; ;~ JsGetPropertyIdFromName(L"native", &nativeProp); Func _JsGetPropertyIdFromName($propname, $nativeProp) $aResult = DllCall($hJSRuntime, "int", "JsGetPropertyIdFromName", "wstr", $propname, "ptr*", $nativeProp) If @error Then Return SetError(1, @error, 0) Return $aResult[2] EndFunc ;==>_JsGetPropertyIdFromName ;~ STDAPI_(JsErrorCode) JsCreateObject( ;~ _Out_ JsValueRef *object ;~ ); ;~ JsValueRef nativeObj; ;~ JsCreateObject(&nativeObj); Local $nativeObj Func _JsCreateObject($JSRTobject) $aResult = DllCall($hJSRuntime, "int", "JsCreateObject", "ptr*", $JSRTobject) If @error Then Return SetError(1, @error, 0) Return $aResult[1] EndFunc ;==>_JsCreateObject ;~ STDAPI_(JsErrorCode) JsCreateFunction( ;~ _In_ JsNativeFunction nativeFunction, ;~ _In_opt_ void *callbackState, ;~ _Out_ JsValueRef *function ;~ ); Func _JsCreateFunction($fncCallBackPtr, $callbackState, $fncVar) $aResult = DllCall($hJSRuntime, "int", "JsCreateFunction", "ptr", $fncCallBackPtr, "ptr*", $callbackState, "ptr*", $fncVar) If @error Then Return SetError(1, @error, 0) Return $aResult[3] EndFunc ;==>_JsCreateFunction ;~ JsSetProperty(nativeObj, printfProp, printfFunc, true); ;~ STDAPI_(JsErrorCode) JsSetProperty( ;~ _In_ JsValueRef object, ;~ _In_ JsPropertyIdRef propertyId, ;~ _In_ JsValueRef value, ;~ _In_ bool useStrictRules ;~ ); Func _JsSetProperty($Obj, $Prop, $Func, $val) ; $aResult = DllCall($hJSRuntime, "int", "JsSetProperty", "ptr", $Obj, "ptr", $Prop, "ptr", $Func, "int", $val) If @error Then Return SetError(1, @error, 0) EndFunc ;==>_JsSetProperty  
    • ur
      By ur
      How to retrieve the target executable path from a process.
      My system is effected with IMG001.exe virus and I remove the folders created by it daily but still it is creating the folders everytime I login to my PC.
      My Antivirus is not detecting it.

       
      So I thought to create a process in AutoIT to check for the process name IMG001.exe and retrieve the process target exe to a log file, so that I can track where it is putting these files.
      With  ProcessExists ( "process" ) , i can get the process ID.
      But how to get the target location of the executable of the process.??