Penetration Test - Using_Scripting_in_Pen_Testing(4)

时间:2020-12-10 10:45:47   收藏:0   阅读:6

PowerShell scripts

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

Set-ExecutionPolicy Unrestricted

技术图片

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()
      }
  }
}

技术图片

QUICK REVIEW
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!