-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-CookieFromZap.ps1
51 lines (49 loc) · 1.93 KB
/
Get-CookieFromZap.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<#
.Synopsis
This Script will get ZAP messages and will filter out cookies from messages
.Example
.\Get-CookiesFromZap
.Notes
Author: Mrityunjaya Pathak
Date : Feb 2015
#>
param(
#Url on which ZAP operation will be performed(only http url)
$URL=$(throw "Missing filepath value"),
#ZAP Proxy URI
$PROXY="http://localhost:8080"
)
$lastWritten= get-date
$here=split-path $myinvocation.mycommand.definition
$MessageCount =&$here\Get-MessageCount $SITEURL $PROXY
$TotalMessages=&$here\Get-MessageFromZap $SITEURL $PROXY $MessageCount
$TotalMessages | foreach{
$url=($_.requestHeader -split "`n" -replace "`r" |where {$_ -match '^GET '}) -replace '^GET ' -replace '\shttp/\d\.\d$'
$SetCookieObject=($_.responseHeader -split "`n" -replace "`r"| where{$_ -match 'Set-Cookie:'}) -replace '^Set-Cookie: '
$SetCookieObject| foreach {
$line=$_
$elements=$line -split ";" -replace '^ +'
$properties=@{}
$here=split-path $myinvocation.mycommand.definition
$properties.CookieKey= $url| &$here\ConvertTo-LEGOSiteName
$properties.lastSeen=$lastWritten
$properties.URL=$url
$elements |
foreach {$c=0} {
$name,$value=$_ -split "=",2
if ($c -eq 0) {
$properties.name=$name
$properties.value=$value
}
elseif ($name -eq "expires") {
$properties.$name=[datetime]$value
}
else {
$properties.$name=$value
}
$c++
}
new-object psobject -Property $properties
}
} |select CookieKey,lastSeen,URL,name,value,expires,path,domain,httponly,secure|Sort-Object name |sv cookies
$cookies