PowerShell ile IP Scan islemi (tr-TR)

%3CLINGO-SUB%20id%3D%22lingo-sub-1440334%22%20slang%3D%22en-US%22%3EPowerShell%20ile%20IP%20Scan%20islemi%20(tr-TR)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1440334%22%20slang%3D%22en-US%22%3E%3CP%3EPowerShell%20ile%20bu%20makalemizde%20de%20network%20adminleri%20i%C3%A7in%20basit%20bir%20komut%20ile%20belirledi%C4%9Finiz%20aral%C4%B1kda%20IPleri%20taray%C4%B1p%20hangi%20IPlerin%20aktif%20kullan%C4%B1ld%C4%B1%C4%9F%C4%B1n%C4%B1%20belirleyebilirsiniz.%20Ping%20komutunun%20geli%C5%9Fmi%C5%9F%20bir%20hali%20olarak%20d%C3%BC%C5%9F%C3%BCnebilirsiniz.%20Komut%20b%C3%BCt%C3%BCn%C3%BC%20temelinde%20kullanm%C4%B1%C5%9F%20oldu%C4%9Fu%20ping%20komutunun%20reply%20from%20cevab%C4%B1%20veren%20IPleri%20belirleyerek%20komut%20sat%C4%B1r%C4%B1nda%20g%C3%B6r%C3%BCnt%C3%BClemenizi%20sa%C4%9Flar.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%3CIP%20aral%C4%B1gi%3D%22%22%3E%20%7C%20%25%7Bping%20-n%201%20-w%2015%20Network%20IP.%24_%20%7C%20select-string%20%22reply%20from%22%7D%3C%2FIP%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EBasit%20bir%20%C3%B6rnek%20ile%20a%C3%A7%C4%B1klamak%20gerekirse%20IP%20aral%C4%B1%C4%9F%C4%B1%20i%C3%A7in%201%20den%20254%20de%20kadar%20bir%20aral%C4%B1k%20belirleyip%20bu%20aral%C4%B1k%20aras%C4%B1nda%20IP%20taramas%C4%B1%20yapmas%C4%B1n%C4%B1%20isteyebilirsiniz.%20Network%20IP%20adresi%20i%C3%A7in%20de%20Network%20adresiniz%20i%C3%A7in%20192.168.1.%24%26nbsp%3B%20%C5%9Feklinde%20tan%C4%B1mlama%20yapman%C4%B1z%20yeterli%20olacakt%C4%B1r.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E1..254%20%7C%20%25%7Bping%20-n%201%20-w%2015%20192.168.1.%24_%20%7C%20select-string%20%22reply%20from%22%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%C3%96rnek%20uygulama%20%C3%A7%C4%B1kt%C4%B1s%C4%B1%20a%C5%9Fa%C4%9F%C4%B1daki%20gibidir.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EPowerShell%206.2.3%0ACopyright%20(c)%20Microsoft%20Corporation.%20All%20rights%20reserved.%0A%0Ahttps%3A%2F%2Faka.ms%2Fpscore6-docs%0AType%20'help'%20to%20get%20help.%0A%0APS%20C%3A%5CUsers%5Coadmin%26gt%3B%201..254%20%7C%20%25%7Bping%20-n%201%20-w%2015%20192.168.1.%24_%20%7C%20select-string%20%22reply%20from%22%7D%0A%0AReply%20from%20192.168.1.1%3A%20bytes%3D32%20time%26lt%3B1ms%20TTL%3D64%0AReply%20from%20192.168.1.33%3A%20bytes%3D32%20time%3D42ms%20TTL%3D64%0AReply%20from%20192.168.1.34%3A%20bytes%3D32%20time%26lt%3B1ms%20TTL%3D128%0AReply%20from%20192.168.1.42%3A%20bytes%3D32%20time%3D2ms%20TTL%3D64%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%C4%B0%C5%9Fi%20biraz%20daha%20yukar%C4%B1ya%20ta%C5%9F%C4%B1mak%20istersek%20cevap%20veren%20IP%20adrelerini%20listelemek%20istersek%20de%20a%C5%9Fa%C4%9F%C4%B1daki%20%C3%B6rnek%20scripti%20kullanabilirsiniz.%20%C4%B0%C5%9Flemin%20sonu%C3%A7lanmas%C4%B1%20ve%20kullan%C4%B1lan%20IPlerin%20listelenmesi%20zaman%20alabilir.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E1..255%20%7C%20foreach-object%20%7B%20(new-objectsystem.net.networkinformation.ping).Send(%22192.168.1.%24_%22)%20%7D%20%7C%20where-object%20%7B%24_.Status%20-eq%20%22Success%22%7D%20%7C%20select%20Address%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EUygulama%20%C3%A7%C4%B1kt%C4%B1s%C4%B1%20a%C5%9Fa%C4%9F%C4%B1daki%20gibidir.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EPowerShell%206.2.3%0ACopyright%20(c)%20Microsoft%20Corporation.%20All%20rights%20reserved.%0A%0Ahttps%3A%2F%2Faka.ms%2Fpscore6-docs%0AType%20'help'%20to%20get%20help.%0A%0APS%20C%3A%5CUsers%5Coadmin%26gt%3B%201..255%20%7C%20foreach-object%20%7B%20(new-object%20system.net.networkinformation.ping).Send(%22192.168.1.%24_%22)%20%7D%20%7C%20where-object%20%7B%24_.Status%20-eq%20%22Success%22%7D%20%7C%20select%20Address%0A%0AAddress%0A-------%0A192.168.1.1%0A192.168.1.33%0A192.168.1.34%0A192.168.1.42%0A192.168.1.62%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1440334%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Contributor

PowerShell ile bu makalemizde de network adminleri için basit bir komut ile belirlediğiniz aralıkda IPleri tarayıp hangi IPlerin aktif kullanıldığını belirleyebilirsiniz. Ping komutunun gelişmiş bir hali olarak düşünebilirsiniz. Komut bütünü temelinde kullanmış olduğu ping komutunun reply from cevabı veren IPleri belirleyerek komut satırında görüntülemenizi sağlar.

<IP aralıgi> | %{ping -n 1 -w 15 Network IP.$_ | select-string "reply from"}

Basit bir örnek ile açıklamak gerekirse IP aralığı için 1 den 254 de kadar bir aralık belirleyip bu aralık arasında IP taraması yapmasını isteyebilirsiniz. Network IP adresi için de Network adresiniz için 192.168.1.$  şeklinde tanımlama yapmanız yeterli olacaktır.

1..254 | %{ping -n 1 -w 15 192.168.1.$_ | select-string "reply from"}

 Örnek uygulama çıktısı aşağıdaki gibidir.

PowerShell 6.2.3
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS C:\Users\oadmin> 1..254 | %{ping -n 1 -w 15 192.168.1.$_ | select-string "reply from"}

Reply from 192.168.1.1: bytes=32 time<1ms TTL=64
Reply from 192.168.1.33: bytes=32 time=42ms TTL=64
Reply from 192.168.1.34: bytes=32 time<1ms TTL=128
Reply from 192.168.1.42: bytes=32 time=2ms TTL=64

 

İşi biraz daha yukarıya taşımak istersek cevap veren IP adrelerini listelemek istersek de aşağıdaki örnek scripti kullanabilirsiniz. İşlemin sonuçlanması ve kullanılan IPlerin listelenmesi zaman alabilir.

 

1..255 | foreach-object { (new-objectsystem.net.networkinformation.ping).Send("192.168.1.$_") } | where-object {$_.Status -eq "Success"} | select Address

Uygulama çıktısı aşağıdaki gibidir.

PowerShell 6.2.3
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/pscore6-docs
Type 'help' to get help.

PS C:\Users\oadmin> 1..255 | foreach-object { (new-object system.net.networkinformation.ping).Send("192.168.1.$_") } | where-object {$_.Status -eq "Success"} | select Address

Address
-------
192.168.1.1
192.168.1.33
192.168.1.34
192.168.1.42
192.168.1.62

 

0 Replies