DevNull Notes
  • README
  • windows-privilege-escalation
    • Basic Windows Commands
    • Managing Files and Folder Permissions
    • Understanding the ACL Entries
    • Booting Files
    • User Management Commands
    • Network Enumeration
Powered by GitBook
On this page
  • Change Directory
  • System Information (systeminfo)
  • Windows Version
  • Show Current User
  • Print a message
  • Display Enviornment Variables
  • Display System PATH
  • Create a file ( > Redirection Operator)
  • View File Contents
  • Define a enviornment variables
  • dir command
  • Create a New folder
  • Delete Files and Folders
  • Rename a File or folder(ren or rename)
  • Display or set date and time
  • Get MAC Address of the system
  • Exit Command prompt
  • Change command prmpt title
  • Displays " Press any key to continue ..." and waits for user input
  • change command prompt Display
  • Call Another Batch File (call)
  • Copying files and folders in Windows
  • Changing File and Folder Attributes Using ATTRIB
  • Restarting a Windows System immediately without any delay
  1. windows-privilege-escalation

Basic Windows Commands

Change Directory

 cd \
cd devnull
 cd ..\
  • Change the drive:

 D:
  • To see current location:

 cd
  • Change Directory to SystemRoot

cd %SystemRoot%

System Information (systeminfo)

  Displays detailed information about the system including OS version, hardware specs, network configuration andf uptime

systeminfo

Windows Version

ver

Show Current User

whoami
  • detailed info

whoami /all

Print a message

echo Welcome to Devnull notes

Display Enviornment Variables

List all system enviornment variables and their values

set 

Display System PATH

shows the directories where executables files are searched when running cmmmands.

echo %PATH%
echo %SystemRoot%
echo %Username%
echo %cd%

Create a file ( > Redirection Operator)

echo "DevNull" > welcome.txt

View File Contents

type welcome.txt

Define a enviornment variables

set DEMO=DevNull
  • Retrieve the value of an enviornment variable

echo %DEMO%

dir command

  • Display help for dir command.

dir /?
  • Listing file and folder

dir
  • Display Short File Names (8.3 format)

dir /x
  • Display file and folder in Bare format

dir  /s /b
  • /a = Displays all files, including hidden and system files

  • /a:hs = Lists only hidden and system files

  • /b = shows filesnames only, without additional details

  • /p = Stops output after each screenfull

  • /s = List all files in all subdirectives recursively

  • /l = Converts filenames to lowercase

  • /o:gn = sorts files with directories first, then alphabatically

  • /v = shows extra information like file attributes and last access time

  • /x = Displays the short (8.3) filename format

  • List Only Hidden and System Files (recursive)

dir /A:SH /b /S
  • List only hidden files (Recursive)

dir /A:H /S /b

Create a New folder

md NewFolder
mkdir NewFolder
  • Create folder in specific path

md C:\Users\DevNull\Documents\Project
  • Create multiple folder at once

mkdir Folder1 Folder2 Folder3
  • Create Nested Directories (Subdirectories in One Command)

md Parent\Child\GrandChild

Delete Files and Folders

  • Delete Folder (rd or rmdir)

rd data
rmdir data
  • Delete a folder without confirmation(/q)

rmdir folder /q
  • Delete a folder and its content (/s /q)

rmdir folder1 /s /q
  • /s = deletes the specified folder and all files and subfolders inside it.

  • /q = Quiet mode, deletes without confirmation

  • Delete a file (del)

del hello.txt
  • Delete a specific file with confirmation (/p)

del d:\temp\filename.txt /p
  • Delete files recursively (/s /f /q)

 del /s /f /q data
  • /s - Deletes all matching files in subdirectories

  • /f - force delete read-only files.

  • /q - Quiet mode (no confirmation)

Rename a File or folder(ren or rename)

ren oldname newname
rename oldname newname

Display or set date and time

date
time

Get MAC Address of the system

getmac

Exit Command prompt

exit

Change command prmpt title

title DevNull

Displays " Press any key to continue ..." and waits for user input

pasue

change command prompt Display

prompt MyPrompt$

Call Another Batch File (call)

runs runme.bat without stopping the current

call c:\runme.bat

Copying files and folders in Windows

  1. Basic Copying with Copy

 copy /a c:\data\file.txt e:\data /v /y
  • /a - specifies the source file (ASCII mode).

  • /v - verifies the copied file for accuracy.

  • /y - suppresses confirmation prompts when overwriting existing files.

  1. Advanced copy with XCOPY

it is more powerfull alternative to COPY for copying directories, files and subdirectories. It can copy multiple files at once

xcopy.exe d:\data*.* c:\test\ /a /d /p /s /v /w
  • /a - Copies only files with archieve attribute.

  • /d - Copies files modified after a specific dates

  • /p - Prompts before copying each file.

  • /s - copies directories and subdirectories, except empty ones.

  • /v - verifies copyied files

  • /w - waits for confirmation before starting

xcopy c:\inetpub\ /s /y c:\data\

copies everything from c:\inetpub (including subdirectoreis) to c:\data\

xcopy C:\inetpub\*.htm C:\htmfiles\ /s /v /y
  1. Robust copying with ROBOCOPY (Recommeded) ROBOCOPY (robusty file copy) is a more powerfull tool introduced in later windows versions

  • Copies all files form c:\data to C:\data1 including subdirectories.

    robocopy c:\data c:\data1 /s
  • Copies a specific files

    robocopy C:\data c:\data1 img.jpg /S
    robocopy <source> <destination> <file to copy>
  • Copy specific file types, Copies all .js, .css and .html files from C:\data to their respective folders

    robocopy c:\data c:\js *.js /s    
  • Copy Multiples File types

    robocopy c:\data\ c:\allfiles *.jpg *.png *.html *.txt /s
  • Additional options

    • /r:1 - Retries once if a file fails to copy

    • /w:1 - Waits one second between Retries

    • /ndl - Prevents directories from being listed in the output.

    • /xjd - Excludes junction points (to avoid infinite loops).

Changing File and Folder Attributes Using ATTRIB

The ATTRIB command in windows allows users to modify file and folder such as hidden, system, Read-only and archieve

  • Basic Syntax, Displays the attributes of a file

attrib [filename/foldername]
  • Displays help information for the attrib command.

attrib /?
  • +H/-H - Adds/Removes the Hidden Attributes

  • +S/-S - Adds/Removes the System Attributes

  • +R/-R - Adds/Removes the Read-Only attribute

  • +A/-A - Adds/Removes the Archieve attribute

  • /S - Applies changes to all subdirectories

  • /D - Applies changes to directories

  • Modifying File Attributes, make a file Hidden, System and Read-Only

attrib +s +r +h test.txt
attrib +s +r +h shell.exe
  • Remove System, Hidden and Read-Only attributes

attrib -s -r -h test.txt
attrib -s -r -h shell.exe
  • Applying attributes to all files in a Directory

attrib +s +h +r c:\data\* /s
attrib +s +h +r e:\* /S /D
  • Remove Hidden, System and Read-Only attributes from all files

attrib -s -h -r c:\data\* /s
  • Unhiding all files on a drive

attrib -h -s -r *.* /s /d
  • protecting a file from accidential deletion

attrib +r important.docx

Restarting a Windows System immediately without any delay

shutdown /r /t 0 /f
  • /s - shutdown the computer

  • /r - Restart the computer

  • /t 0 - set the time delay to 0 seconds(immediate restart)

  • /f - force close all running applications without warning

  • Allow user to cancel shutdown

shutdown /a
Previouswindows-privilege-escalationNextManaging Files and Folder Permissions

Last updated 1 month ago