天天看點

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

文章目錄:

  • 一.Powershell操作符
  • 二.Powershell條件語句

    1.if條件判斷

    2.switch語句

  • 三.Powershell循環語句

    1.foreach循環

    2.while循環

    3.break和continue關鍵詞

    4.for循環

    5.switch循環

  • 四.Powershell數組

    1.數組定義

    2.通路數組

  • 五.Powershell函數

    1.自定義函數及調用

    2.函數傳回值

  • 六.Powershell字元串及互動

    1.定義文本及轉義字元

    2.使用者互動

    3.格式化字元串

    4.字元串操作

  • 七.Powershell系統資料庫操作

作者的github資源:

  • 逆向分析:https://github.com/eastmountyxz/

    SystemSecurity-ReverseAnalysis

  • 網絡安全:https://github.com/eastmountyxz/

    NetworkSecuritySelf-study

聲明:本人堅決反對利用教學方法進行犯罪的行為,一切犯罪行為必将受到嚴懲,綠色網絡需要我們共同維護,更推薦大家了解它們背後的原理,更好地進行防護。該樣本不會分享給大家,分析工具會分享。

一.Powershell操作符

常見的比較運算符包括:

  • -eq 等于
  • -ne 不等于
  • -gt 大于
  • -lt 小于
  • -le 小于等于
  • -contains 包含
  • -notcontains 不包含
67 -eq 50
50 -eq 50
1gb -gt 1tb
(1,2,3) -contains 1
(1,2,3) -contains 2
(1,2,3) -contains 4
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

求反運算符:

  • -not
$a=89 -gt 50
$a
-not $a
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

邏輯運算:

  • -and 與運算
  • -or 或運算
  • -not 非運算
  • -xor 異或運算
$true -and $true
$true -and $false
$true -or $false
$false -or $false
-not $true
$true -xor $true
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

比較數組和集合,從中篩選出不等于0的數字。

1,5,8,0,9 -ne 0
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

二.Powershell條件語句

1.if條件判斷

if-elseif-else條件判斷,執行操作用大括号表示。

$num=100
if($num -gt 90) {"大于90"} else {"小于等于90"}
if($num -gt 100) {"大于100"} else {"小于等于100"}
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

注意,if-else中間可以增加新的判斷elseif,如下所示:

if($num -gt 100) {"大于100"} elseif ($num -eq 100) {"等于100"} else {"小于100"}
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

2.switch語句

Switch語句主要用于多種情況的判斷,這裡在本地建立一個test01.ps1檔案,并執行該代碼。

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

傳統的if判斷如下:

$num=56
if($num -gt 50 -and $num -lt 60) 
{
    "大于50并且小于60"
} 
elseif ($num -eq 50) 
{
    "等于50"
}
else
{
    "小于50"
}
           

複制

去到桌面1019檔案夾,輸入“.\test01.ps1”執行代碼,再列印該檔案的源代碼。

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

switch語句如下:$_表示對變量取值。

$num=56
switch($num)
{
    {$_ -lt 50} {"此數值小于50"}
    {$_ -eq 50} {"此數值等于50"}
    {$_ -gt 50} {"此數值大于50"}
}
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

三.Powershell循環語句

1.foreach循環

這裡定義數組采用“$arr=1…10”實作,表示1到10的數字,在調用foreach循環輸出。

$arr=1..10
foreach ($n in $arr){ $n*$n }
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

定義檔案“test03.ps1”,隻輸出偶數内容。

$arr=1..10
foreach ($n in $arr)
{
    if (($n%2) -eq 0 )
    {
        $n
    }
}
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

接着利用foreach操作檔案目錄,将C槽python34檔案夾下的路徑全部提取出來,指派到file中輸出。

foreach ($file in dir c:\python34)
{
    if($file.length -gt 1kb)
    {
        $file.name
        $file.length
    }
}
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

原始檔案内容如下所示:

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

也可以定義變量來指定路徑

$path_value = dir c:\python34
foreach ($file in $path_value)
{
    if($file.length -gt 1kb)
    {
        $file.name
        $file.length
    }
}
           

複制

2.while循環

while循環需要注意循環的終止條件,防止出現死循環,而do_while循環是先執行一次循環體,再進行判斷。

下面這段代碼是經典運算:1+2+3+…+99,檔案名為“test05.ps1”。

$i=1
$s=0
while($i -lt 100)
{
    $s = $s + $i
    $i = $i + 1
}
$s
$i
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

do_whlie先執行循環體,再進行條件判斷,如下所示:

$num=15
do
{
    $num
    $num=$num-1
}
while($num -gt 10)
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

3.break和continue關鍵詞

break跳出整個循環,停止執行;continue跳出目前循環一次,繼續執行下一個判斷。

break:下面這個代碼當數值小于6繼續執行,當其等于4停止循環。

$i=1
while($i -lt 6)
{
    if($i -eq 4)
    {
        break
    }
    else
    {
        $i
        $i++
    }
}
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

continue:跳過了中間等于4的内容。

$i=1
while($i -lt 6)
{
    if($i -eq 4)
    {
        $i++
        continue
    }
    else
    {
        $i
        $i++
    }
}
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

4.for循環

利用for循環實作1+2+…+100的代碼如下(test09.ps1)。

$sum=0
for($i=1;$i -le 100;$i++)
{
    $sum=$sum+$i
}
$sum
           

複制

學習Powershell基礎文法之後,更重要的是解決實際問題,後續作者将繼續深入學習。

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

5.switch循環

使用switch循環實作輸出數組1到10,并進行奇數和偶數判斷。

$num=1..10
switch($num)
{
    default{"number=$_"}
}

$num=1..10
switch($num)
{
    {($_ % 2) -eq 0} {"$_ 數值是偶數"}
    {($_ % 2) -ne 0} {"$_ 數值是奇數"}
}
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

四.Powershell數組

1.數組定義

數組定義一種方法是逗号隔開不同的元素,另一種是通過兩個點來定義數組。

$arr=1,2,3,4,5
$arr=1..5
           

複制

判斷是否是一個數組,使用如下語句。

$arr -is [array]
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

數組可以接受不同的數值。

$arr=1,3.14,"yangxiuzhang"
$arr
$arr -is [array]
           

複制

空數組定義如下:

$arr=@()
$arr
$arr -is [array]
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

下面簡單比較隻有一個元素數組和變量的對比。

$arr=,"hello"
$arr
$arr -is [array]

$arr=1
$arr
$arr -is [array]
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

數組也可以是一個變量或指令,此時它仍然是一個數組。

$arr=ipconfig
$arr
$arr -is [array]
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

2.通路數組

首先定義一個多種類型的數組。

$arr=1,"hello world",(get-date)
$arr
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

通路數組特定元素,第一個元素,擷取兩個元素,擷取最後一個元素。

$arr[0]
$arr[0,1]
$arr[-1]

//提取部分元素
$arr[0..2]
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

擷取數組元素大小調用count實作。

$num = $arr[0..2]
$num.count
           

複制

如何将數組倒序輸出呢?如下所示。

$arr[($arr.count)..0]
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

數組添加一個元素代碼如下:

$arr=1,"hello world",(get-date)
$arr+="csdn"
$arr
$arr.count
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

更多數組操作,推薦讀者結合實際應用進行學習。

五.Powershell函數

1.自定義函數及調用

函數通常包括函數名、參數、函數體,下面是定義及調用一個myping函數的代碼(test11.ps1)。

function myping()
{
    ping www.baidu.com   
}

myping
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

同樣,上面的代碼可以修改為指定參數。

function myping($site)
{
    ping $site
}
myping www.baidu.com
           

複制

下面這個代碼是接收兩個參數并顯示的功能。

function myinfo($name,$age)
{
    $info="I am $name, and i am $age years old."
    write-host $info
}
myinfo yxz,28
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

2.函數傳回值

函數傳回值通過return實作,可以傳回多個值。下面是test13.ps1例子。

function add($num1,$num2)
{
   $sum=$num1+$num2
   return $sum
}
add 2 4

function fun($num1,$num2)
{
   $sum=$num1+$num2
   $sum.gettype()
   $sum.gettype().fullname
   return $sum
}
fun 2.2 4.3


//多個傳回值
function other($num1,$num2,$num3)
{
    $value=$num1,$num2,$num3
    return $value
}
other 2.2 4 6
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

六.Powershell字元串及互動

1.定義文本及轉義字元

表達式中可以定義隻,如下所示。同時,單引号和雙引号可以互相嵌套,這和JAVA、PHP、Python中的變量套接類似。

"hello world $(get-date)"
"hello world $(5*7)"
"hello, my name is 'yangxiuzhang'"
           

複制

輸出結果如下圖所示:

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

在Powershell中,轉義字元不再是斜杠(\)而是(`),如下所示。

  • `n 換行
  • `r 回車符
  • `t tab鍵
  • `b 倒退符
  • `’ 單引号
"hello,`n my name is `'yangxiuzhang`'"
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結
[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

2.使用者互動

read-host 讀取使用者的輸入。

$input = read-host "請輸入您的姓名"
"您好!您輸入的姓名是:$input"
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

3.格式化字元串

傳統的多個變量輸出方法:

$name="yangxiuzhang"
$age=25
$body="strong"
$height=1.72
"My name is $name, i am $age years old, and my body is $body, my height is $height"
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

格式化字元串輸出方法:

"My name is {0}, i am {1} years old, and my body is {2}, my height is {3}" -f            

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

4.字元串操作

任何程式設計語言,都繞不過字元串操作,在網絡安全領域,擷取ip位址、URL拼接、圖檔或腳本檔案擷取等都涉及字元串操作,下面進行簡單分享。

字元串分割

$str="c:\windows\system32\demo.txt"
$str.split("\")
//數組類型,可以通過數組下标通路
$str.split("\").gettype()
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

擷取圖檔名稱

$str="https://blog.csdn.net/Eastmount/102781411/logo.png"
$str.split("/")[-1]
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

是否以某個字元結尾和是否包含某個字元。

$str.endswith("png")
$str.contains("csdn")
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

字元串比較,-1表示兩個字元串不一樣,相等輸出0。

$str="https://blog.csdn.net/Eastmount/102781411/logo.png"
$str.compareto("window")
$str.compareto("https://blog.csdn.net/Eastmount/102781411/logo.png")
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

其他操作如下:

//擷取下标
$str.indexof("s")

//字元插入
$str.insert(4,"yxz")

//字元串替換
$str.replace("n","N")
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

七.Powershell系統資料庫操作

系統資料庫(Registry,繁體中文版Windows作業系統稱之為登入檔)是Microsoft Windows中的一個重要的資料庫,用于存儲系統和應用程式的設定資訊。

早在Windows 3.0推出OLE技術的時候,系統資料庫就已經出現。随後推出的Windows NT是第一個從系統級别廣泛使用系統資料庫的作業系統。但是,從Microsoft Windows 95作業系統開始,系統資料庫才真正成為Windows使用者經常接觸的内容,并在其後的作業系統中繼續沿用至今。

在CMD中輸入regedit即可打開系統資料庫,如下圖所示。

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結
[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

系統資料庫圖形化界面顯示如下,包括各種程式的配置資訊,不能随便修改它,很容易造成系統故障。

  • HKEY_CLASSES_ROOT

    定義文檔的類型\類以及與類型關聯的資訊以及COM元件的配置資料

  • HKEY_CURRENT_USER

    包含目前登入到Windows的使用者的配置資訊

  • HKEY_LOCAL_MACHINE

    包含與計算機相關的配置資訊,不管使用者是否登入

  • HKEY_USERS

    包含有關預設使用者配置的資訊

  • HKEY_CURRENT_CONFIG

    包含有關非使用者特定的硬體的配置資訊

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

在Powershell中顯示系統資料庫指令如下:

cd hkcu:
dir
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

對應系統資料庫圖形界面。

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結
cd system
dir
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

對應圖形界面。

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

其他通路也類似。

cd HKLM:
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

對應圖形界面:

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

讀取鍵值

get-itemproperty
           

複制

[網絡安全] 二十三.Powershell基礎入門之常見文法及系統資料庫操作-2一.Powershell操作符二.Powershell條件語句三.Powershell循環語句四.Powershell數組五.Powershell函數六.Powershell字元串及互動七.Powershell系統資料庫操作八.總結

設定鍵值

set-itemproperty
           

複制

由于系統資料庫不能随便修改,很容易造成系統故障,後續随着作者深入學習,了解更多網絡安全中Powershell及系統資料庫工作再來分享,希望讀者喜歡該系列文章。

八.總結

寫到這裡,這篇文章介紹結束,主要内容:

  • 一.Powershell操作符
  • 二.Powershell條件語句
  • 三.Powershell循環語句
  • 四.Powershell數組
  • 五.Powershell函數
  • 六.Powershell字元串及互動
  • 七.Powershell系統資料庫操作

如果你是一名新人,一定要踏踏實實親自動手去完成這些基礎的逆向和滲透分析,相信會讓你逐漸提升,過程确實很痛苦,但做什麼事又不辛苦呢?加油!希望你能成長為一名厲害的安全工程師或病毒分析師,到時候記得回到這篇文章的起點,告訴你的好友。

學安全一年,認識了很多安全大佬和朋友,希望大家一起進步。這篇文章中如果存在一些不足,還請海涵。作者作為網絡安全和系統安全初學者的慢慢成長路吧!希望未來能更透徹撰寫相關文章。同時非常感謝參考文獻中的安全大佬們的文章分享,深知自己很菜,得努力前行。程式設計沒有捷徑,逆向也沒有捷徑,它們都是搬磚活,少琢磨技巧,幹就對了。什麼時候你把攻擊對手按在地上摩擦,你就赢了,也會慢慢形成了自己的安全經驗和技巧。加油吧,少年希望這個路線對你有所幫助,共勉。

參考文獻:

  • https://www.bilibili.com/video/av66327436 [推薦B站老師視訊]
  • 《安全之路Web滲透技術及實戰案例解析》陳小兵老師
  • https://baike.baidu.com/item/Windows Power Shell/693789
  • https://www.pstips.net/powershell-piping-and-routing.html
  • https://www.pstips.net/using-the-powershell-pipeline.html