CMD
Basics
Located at C:\Windows\System32\cmd.exe
.
General
cls
Clear the screen
doskey /history
Prints the session's command history.
page up
Places the first command in our session history to the prompt.
page down
Places the last command in history to the prompt.
⇧
View previously run commands.
⇩
View most recent commands run.
⇨
Types the previous command to prompt one character at a time.
⇦
N/A
F3
Will retype the entire previous entry to our prompt.
F5
Pressing F5 multiple times will allow you to cycle through previous commands.
F7
Opens an interactive list of previous commands.
F9
Enters a command to our prompt based on the number specified. The number corresponds to the commands place in our history.
Navigation
Directories
Files
Copy
xcopy
has been deprecated for robocopy
(robust file copy). The former resets any file attributes by default which can be useful from an attacker's perspective. The latter is a combination of copy
, xcopy
, and move
. It is made for large directories and drive syncing.
Operations
Searching
Sorting
Comparing
Environment Variables
Global not case-sensitive variables, format -> %ENV_VAR%
. They are 2 major scopes:
System -> OS-defined, globally-accessible
User -> user-defined, user-accessible
Managing Env Vars
set
-> temp, i.e., current session, setx
-> permanent, i.e., registry changes.
Interesting Env Vars
%PATH%
Specifies a set of directories where executable programs are located.
%OS%
The current operating system on the user's workstation.
%SYSTEMROOT%
Expands to C:\Windows
. A system-defined read-only variable containing the Windows system folder. Anything Windows considers important to its core functionality is found here, including important data, core system binaries, and configuration files.
%LOGONSERVER%
Provides us with the login server for the currently active user followed by the machine's hostname. We can use this information to know if a machine is joined to a domain or workgroup.
%USERPROFILE%
Provides us with the location of the currently active user's home directory. Expands to C:\Users\{username}
.
%ProgramFiles%
Equivalent of C:\Program Files
. This location is where all the programs are installed on an x64
based system.
%ProgramFiles(x86)%
Equivalent of C:\Program Files (x86)
. This location is where all 32-bit programs running under WOW64
are installed. Note that this variable is only accessible on a 64-bit host. It can be used to indicate what kind of host we are interacting with. (x86
vs. x64
architecture)
Services
Note that not all services will respond to a
stop
request, regardless of our permissions, if other running programs/services depend on them.When modifying a service, the changes will come into effect after the service is restarted. All changes made are reflected in the Windows registry and will persist on reboot, so services can be taken out permanently.
Scheduled Tasks
Create Syntax
/sc
Sets the schedule type. It can be by the minute, hourly, weekly, and much more. Be sure to check the options parameters.
/tn
Sets the name for the task we are building. Each task must have a unique name.
/tr
Sets the trigger and task that should be run. This can be an executable, script, or batch file.
/s
Specify the host to run on, much like in Query.
/u
Specifies the local user or domain user to utilize
/p
Sets the Password of the user-specified.
/mo
Allows us to set a modifier to run within our set schedule. For example, every 5 hours every other day.
/rl
Allows us to limit the privileges of the task. Options here are limited
access and Highest
. Limited is the default value.
/z
Will set the task to be deleted after completion of its actions.
For creating a new scheduled task we must specify, at a minimum, the following:
/create
: to tell it what we are doing/sc
: we must set a schedule/tn
: we must set the name/tr
: we must give it an action to take
Change Syntax
/tn
Designates the task to change
/tr
Modifies the program or action that the task runs.
/ENABLE
Change the state of the task to Enabled.
/DISABLE
Change the state of the task to Disabled.
Delete Syntax
/tn
Identifies the task to delete.
/s
Specifies the name or IP address to delete the task from.
/u
Specifies the user to run the task as.
/p
Specifies the password to run the task as.
/f
Stops the confirmation warning.
Help
Last updated
Was this helpful?