My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
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
#----------------------------------------------------------------------------------------
#
# Sample usage:
#
# Download the WebClient with Cookies
# PS> download-webclient-with-cookies
#
# Send me spam
# PS> spam-adamdotcom
#
# Adam Kahtava - http://adam.kahtava.com/ - MIT Licensed
#
#-----Maintained by Adam Kahtava---------------------------------------------------------

function global:download-webclient-with-cookies(){
download-file 'http://adamdotcom-services.googlecode.com/svn/trunk/AdamDotCom.Common.Service/Final-Assemblies/AdamDotCom.WebClientWithCookies.dll'
}

function global:spam-adamdotcom(){
trap [Exception]{
write-host $_.Exception.Message
break;
}

# Load the assembly containing WebClientWithCookies and RegexUtilities
[Reflection.Assembly]::LoadFile((Resolve-Path "AdamDotCom.WebClientWithCookies.dll")) | out-null

# Load the assembly containing System.Web.HttpUtilitiy
[void][Reflection.Assembly]::LoadWithPartialName("System.Web") | out-null

# create a new instance of the HTTP Web Client that supports cookies
$webClient = New-Object AdamDotCom.Common.Service.Utilities.WebClientWithCookies

# download Adam's contact page that contains the Anti CRSF Token
[void] $webClient.DownloadData("http://adam.kahtava.com/contact")

# create a new regular expression to grab the Anti CRSF Token - since this is an MVC site our token is named "__RequestVerificationToken_Lw__"
$regex = "__RequestVerificationToken_Lw__=(?<CRSF_Token>[^;]+)"
$match = [regex]::matches($webClient.ResponseHeaders["Set-Cookie"], $regex)[0]
$antiCrsfToken = $match.Groups["CRSF_Token"].Captures[0].Value

write-host "`nYour Anti CRSF Token is: " $antiCrsfToken

# construct the message including the Anti CSRF Token
$message = "__RequestVerificationToken=" + [System.Web.HttpUtility]::UrlEncode($antiCrsfToken) +
"&fromName=Johnathon Fink" +
"&fromAddress=prancesw@rmcres.com" +
"&subject=Call for your diploma now" +
"&body=Is your lack of a degree..."

# drown Adam in spam-spam-spam
$webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
[void] $webClient.UploadData("http://adam.kahtava.com/contact/send", "POST", ([System.Text.Encoding]::UTF8.GetBytes($message)));

write-host "`nSuccess!!! Your spam has been sent.`n"

$webClient = $null
}

# My curl equivelent method poached from http://adamdotcom-script.googlecode.com/svn/trunk/Scripts/PowerShell/Development-Utilities.ps1
function global:download-file([string] $urlPath) {
$urlSplit = $urlPath.split('/')
$filename = (Resolve-Path .\).ToString() + '\' + $urlSplit[$urlSplit.length - 1]
$webclient = New-Object "System.Net.WebClient"
$webclient.DownloadFile($urlPath, $filename)
return $filename
}

Change log

r62 by kahtava on Mar 8, 2010   Diff
Changed regex manipulation to use more
PowerShell and rely less on my assembly
Go to: 
Sign in to write a code review

Older revisions

r51 by kahtava on Dec 18, 2009   Diff
Patched a bug that required
URLEncoding
r49 by kahtava on Dec 14, 2009   Diff
Capitalized my name. :)
r48 by kahtava on Dec 14, 2009   Diff
Cleanup
All revisions of this file

File info

Size: 2909 bytes, 67 lines
Powered by Google Project Hosting