-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPoSHWords.ps1
More file actions
88 lines (79 loc) · 2.43 KB
/
PoSHWords.ps1
File metadata and controls
88 lines (79 loc) · 2.43 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
###########################################################################
#
# NAME: PoSHWords
#
# AUTHOR: RichRoc
#
# COMMENT: Powershell Script to spider a website and generate a unique
# wordlist.
#
# VERSION HISTORY:
# 0.1 5/28/2014 - Initial release
#
###########################################################################
#Parameters#
[CmdletBinding()]
Param(
[Parameter(Mandatory=$False,Position=1)]
[string]$Action,
[Parameter(Mandatory=$True,Position=2)]
[string]$URL,
[Parameter(Mandatory=$True,Position=3)]
[int]$MinLength,
[Parameter(Mandatory=$False,Position=4)]
[int]$MaxLength
)
#Main#
#Initialize an array for PoSHWords
$WordListArray = @()
$Regex = "(\b(\w{$MinLength,$MaxLength})\b)"
#Get Web Page
$WebSite = Invoke-WebRequest -UseBasicParsing -Uri $URL
#Parse website content to word list array
$TempArray = $WebSite.RawContent.ToString() | Select-String -Pattern $Regex -AllMatches | ForEach-Object {$_.Matches} | ForEach-Object {$_.Value}
$WordListArray = $WordListArray + $TempArray
foreach ($Link in $WebSite.Links)
{
if ($Link.href.ToLower().Contains("$URL"))
{
#Write-Output $Link.href
$SubLink = Invoke-WebRequest -UseBasicParsing -Uri ($link.href)
if ($SubLink.StatusCode -eq 200)
{
$TempArray = $SubLink.RawContent.ToString() | Select-String -Pattern $Regex -AllMatches | ForEach-Object {$_.Matches} | ForEach-Object {$_.Value}
$WordListArray = $WordListArray + $TempArray
}
}
elseif ($Link.href.ToLower().StartsWith("/"))
{
#Write-Output ("http://" + "$URL" + $Link.href)
$SubLink = Invoke-WebRequest -UseBasicParsing -Uri ("http://" + "$URL" + $link.href)
if ($SubLink.StatusCode -eq 200)
{
$TempArray = $SubLink.RawContent.ToString() | Select-String -Pattern $Regex -AllMatches | ForEach-Object {$_.Matches} | ForEach-Object {$_.Value}
$WordListArray = $WordListArray + $TempArray
}
}
}
#Write the WordListArray to a text file
$WordListArray | ForEach-Object {$_.ToLower()} | Select-Object -unique > wordlist_$URL.txt
<#--Invoke-WebRequest Object reference
$WebSite.StatusCode
$WebSite.StatusDescription
$WebSite.Content
$WebSite.RawContent
$WebSite.Forms
$WebSite.Headers
$WebSite.Headers.Pragma
$WebSite.Headers.Keep-Alive
$Website.Headers.Transfer-Encoding
$Website.Headers.Cache-Control
$Website.Headers.Content-Type
$Website.Headers.Date
$Website.Headers.Server
$WebSite.Images
$WebSite.InputFields
$WebSite.Links
$WebSite.ParsedHTML
$WebSite.RawContentLength
--#>