Penetration Test - Using_Scripting_in_Pen_Testing(4)

PowerShell scripts

Run PowerShell on Windows as a administrator. And set the execution policy.

Set-ExecutionPolicy Unrestricted

image-20201205193010162

Following is a simple PowerShell script to scan ports.

$port = 80
$subnet = "10.0.0"
$range = 1..254
foreach ($r in $range)
{
$ip = "{0}.{1}" -F $subnet,$r
if(Test-Connection -BufferSize 32 -Count 1 -Quiet -ComputerName $ip)
  {
    $socket = new-object System.Net.Sockets.TcpClient($ip, $port)
    if($socket.Connected)
      {
        "$port open on $ip"
        $socket.Close()
      }
  }
}

image-20201205193241079

QUICK REVIEW
  • PowerShell is currently open source and available for multiple operating systems.
  • PowerShell scripts are disabled in Windows by default
posted @ 2020-12-05 19:34  晨风_Eric  阅读(53)  评论(0编辑  收藏  举报