Apr 4

PSExec

Welcome back kiddies for the second installment in our series. Today we are going to look at another easy to use tool for interfering in the productivity of those around you.  Today’s tool brought to us by the fantastic chums over at SysInternals, is psexec.  Psexec is a step up from last article, the general principle of psexec is that it allows you to run any command line application that is on your neighbor’s computer from your computer and pass in flags.  Ok so psexec does not come preinstalled here is a link to the site where you can get it.  Come right back after you have it.

Good now that we got that out of the way if we run psexec without any flags we get the help pasted here for your blessed convenience.

PsExec v1.72 - Execute processes remotely

Copyright (C) 2001-2006 Mark Russinovich

Sysinternals - www.sysinternals.com

 

PsExec executes a program on a remote system, where remotely executed console

applications execute interactively.

 

Usage: psexec [\\computer[,computer2[,...] | @file][-u user [-p psswd]][-n s][-

][-s|-e][-x][-i][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,...] cmd [aruments]

     -a         Separate processors on which the application can run with

                commas where 1 is the lowest numbered CPU. For example,

                to run the application on CPU 2 and CPU 4, enter:

                “-a 2,4″

     -c         Copy the specified program to the remote system for

                execution. If you omit this option the application

                must be in the system path on the remote system.

     -d         Don’t wait for process to terminate (non-interactive).

     -e         Loads the specified account’s profile.

     -f         Copy the specified program even if the file already

                exists on the remote system.

     -i         Run the program so that it interacts with the desktop on the

                remote system.

     -l         Run process as limited user (strips the Administrators group

                and allows only priviliges assigned to the Users group).

     -n         Specifies timeout in seconds connecting to remote computers.

     -p         Specifies optional password for user name. If you omit this

                you will be prompted to enter a hidden password.

     -s         Run the remote process in the System account.

     -u         Specifies optional user name for login to remote

                computer.

     -v         Copy the specified file only if it has a higher version number

                or is newer on than the one on the remote system.

     -w         Set the working directory of the process (relative to

                remote computer).

     -x         Display the UI on the Winlogon secure desktop (local system only).

     -priority  Specifies -low, -belownormal, -abovenormal, -high or

                -realtime to run the process at a different priority.

     computer   Direct PsExec to run the application on the remote

                computer or computers specified. If you omit the computer

                name PsExec runs the application on the local system,

                and if you specify a wildcard (\\*), PsExec runs the

                command on all computers in the current domain.

     @file      PsExec will execute the command on each of the computers listed

                in the file.

     program    Name of application to execute.

     arguments  Arguments to pass (note that file paths must be

                absolute paths on the target system).

 

You can enclose applications that have spaces in their name with

quotation marks e.g. psexec \\marklap “c:\long name app.exe”.

Input is only passed to the remote system when you press the enter

key, and typing Ctrl-C terminates the remote process.

 

If you omit a user name the process will run in the context of your

account on the remote system, but will not have access to network

resources (because it is impersonating). Specify a valid user name

in the Domain\User syntax if the remote process requires access

to network resources or to run in a different account. Note that

the password is transmitted in clear text to the remote system.

 

Error codes returned by PsExec are specific to the applications you

execute, not PsExec.

Ok now as I said this is a step up so bear with me.  The important command line switches (in order of appearance) are

/c as you can see (if you can read) /c copies the command in question over to the destination computer.  This is useful in case the program is not already stored on the destination.  However in most instances the command we are running will already be there so this will not be needed.

/f is related to /c and basically forces a copy even if the file already exists.  I recommend using this every time you use /c

/i is one of the most important switches.  This causes the application to show itself to the user that is currently logged in.  Why is this important you ask? Because one of the main ways we will use psexec is to pop up windows on the remote computer that annoy the user visually.

Those three switches make up the really important set; other ones can be used but are not necessary.  So let’s put it together and see about doing something annoying to our friends next door.  Lets run a RUNDLL32 command on a computer that will switch the mouse buttons.  Quick side note, rundll32 is basically a program that allows you to call functions in dlls. Anyways we will have a full article on rundll32 later down the road but for now lets try.

Psexec /i \\hr-JanetLee RunDll32.exe USER32.DLL,SwapMouseButton

So to break this one down, we are using psexec (obviously since the article is about psexec) and we want the command to run interactively. We are doing this to the imaginary remote computer hr-JannetLee and the command we want to run is RunDll32.exe USER32.DLL,SwapMouseButton.

The net effect is that Janet will have no idea that anything has happened until she tries to click on things and keeps getting context menus.  That about sums it up for psexec for this week, try to think of other great uses for this application and we will give you some more as we go along too.  Look forward to the rundll32 article as it will be chock full of fun toys we can use with psexec.

1 Comment so far

  1. Sharing Internet connection May 23rd, 2008 2:16 pm

    Sharing Internet connection…

    If you are shopping around for broadband services, taking a speedtest for that specific internet service provider is important. You want to find an internet service provider with the fastest internet connection for an affordable price. Since many inter…

Leave a comment

You must be logged in to post a comment.