several changes made to speed up fake data generation

metadata
xan7r 2016-05-02 22:32:56 -04:00
parent ce2be66dc2
commit eb2bdbc812
1 changed files with 130 additions and 50 deletions

182
EgressAssess.ps1 Normal file → Executable file
View File

@ -1,3 +1,11 @@
# Updates Made:
# Drastically increased speed of SSN/CC number generation by genenerating a random value, then generating the next 500 sequentially instead of randomly.
# Also increased speed of Random SSN and CC number generation about 2-3x.
# For Credit Cards, several subfunction calls were removed and only generating 1 random number per credit card.
# For SSN, only generating 1 random number for 2 SSNs
# Note: by default script will now generate data in batches of 500 sequential values. For randomized values, use the -Randomize switch parameter
function Invoke-EgressAssess
{
@ -53,6 +61,10 @@ function Invoke-EgressAssess
This switch writes a report to console and disk.
Default report location "C:\Egress-Assess\report.txt".
.Parameter Randomize
This switch forces Egress-Assess to generate random numbers for fake data.
Performance is significantly slower with this switch.
.Example
Import-Module Egress-Assess.ps1
Invoke-EgressAssess -client http -ip 127.0.0.1 -Datatype cc -Verbose
@ -88,7 +100,9 @@ function Invoke-EgressAssess
[Parameter(Mandatory = $False)]
[int]$Loops = 1,
[Parameter(Mandatory = $False)]
[string]$Report
[string]$Report,
[Parameter(Mandatory = $False)]
[switch]$Randomize
)
begin
{
@ -210,19 +224,36 @@ function Invoke-EgressAssess
$num = [math]::Round(($Size * 1MB)/11)
Write-Verbose "Generating $Size MB of Social Security Numbers ($num)..."
$list = New-Object System.Collections.Generic.List[System.String]
$percentcount = 0
$quart = [math]::Round($num/4)
#$percentcount = 0
#$quart = [math]::Round($num/4)
for ($i = 0; $i -lt $num; $i++)
{
if ($i%$quart -eq 0)
if ($Randomize)
{
$percent = $percentcount * 25
Write-Verbose "$percent% Done! $i SSNs Generated"
$percentcount += 1
}
$r = "$(Get-Random -minimum 100 -maximum 999)-$(Get-Random -minimum 10 -maximum 99)-$(Get-Random -minimum 1000 -maximum 9999)"
$rOriginal = Get-Random -minimum 10000000000000 -maximum 100000000000000
$rOriginalString = [string][int64]$rOriginal
$r = "$($rOriginalString.substring(0,3))-$($rOriginalString.substring(3,2))-$($rOriginalString.substring(5,4))"
$list.Add($r)
$r = "$($rOriginalString.substring(9,3))-$($rOriginalString.substring(12,2))-$($rOriginalString.substring(2,4))"
$list.Add($r)
$i++
}
else {
$randNum = Get-Random -minimum 10000 -maximum 100000
$randNumString = [string][int64]$randNum
$randSsnBase = "$($randNumString.substring(0,3))-$($randNumString.substring(3,2))-"
$randSsnEnd = Get-Random -minimum 1000 -maximum 9500
for ($i2 = $randSsnEnd; $i2 -lt $($randSsnEnd+500); $i2++)
{
$randSSN = "$randSsnBase$i2"
$list.Add($randSSN)
$i++
}
}
}
$script:AllSSN = $list.ToArray()
}
@ -230,56 +261,104 @@ function Invoke-EgressAssess
{
$script:AllCC = @()
$stringBuilder = New-Object System.Text.StringBuilder
$script:list = New-Object System.Collections.Generic.List[System.String]
Write-Verbose "[*] Generating Credit Cards............."
function New-Visa
{
#generate a single random visa number, format 4xxx-xxxx-xxxx-xxxx
$r = "4$(Get-Random -minimum 100 -maximum 999)-$(Get-Random -minimum 1000 -maximum 9999)-$(Get-Random -minimum 1000 -maximum 9999)-$(Get-Random -minimum 1000 -maximum 9999)"
$script:list.Add($r)
}
function New-MasterCard
{
# generate a single random mastercard number
$r = "5$(Get-Random -minimum 100 -maximum 999)-$(Get-Random -minimum 1000 -maximum 9999)-$(Get-Random -minimum 1000 -maximum 9999)-$(Get-Random -minimum 1000 -maximum 9999)"
$script:list.Add($r)
}
function New-Discover
{
# generate a single random discover number
$r = "6011-$(Get-Random -minimum 1000 -maximum 9999)-$(Get-Random -minimum 1000 -maximum 9999)-$(Get-Random -minimum 1000 -maximum 9999)"
$script:list.Add($r)
}
function New-Amex
{
# generate a single random amex number
$script:AllCC += "3$(Get-Random -minimum 100 -maximum 999)-$(Get-Random -minimum 100000 -maximum 999999)-$(Get-Random -minimum 10000 -maximum 99999)"
$r = "3$(Get-Random -minimum 100 -maximum 999)-$(Get-Random -minimum 100000 -maximum 999999)-$(Get-Random -minimum 10000 -maximum 99999)"
$script:list.Add($r)
}
$num = [math]::Round($Size * 1MB)/19
$percentcount = 0
$quart = [math]::Round($num/4)
$intCardType = 0
for ($i = 0; $i -lt $num; $i++)
{
if ($i%$quart -eq 0)
if ($Randomize)
{
$percent = $percentcount * 25
Write-Verbose "$percent% Done! $i SSNs Generated"
$percentcount += 1
}
$r = Get-Random -Minimum 1 -Maximum 5
switch ($r) # Use switch statement to
$baseCC = $null
if ($intCardType -gt 3)
{
1 { New-Visa }
2 { New-MasterCard }
3 { New-Discover }
4 { New-Amex }
default { New-Visa }
$intCardType = 0
}
switch ($intCardType)
{
0 { # Generate Visa
$randNum = Get-Random -minimum 100000000000000 -maximum 1000000000000000
$randNumString = [string][int64]$randNum
$randCC = "4$($randNumString.substring(0,3))-$($randNumString.substring(3,4))-$($randNumString.substring(7,4))-$($randNumString.substring(11,4))"
$script:list.Add($randCC)
}
1 { # Generate MasterCard
$randNum = Get-Random -minimum 100000000000000 -maximum 1000000000000000
$randNumString = [string][int64]$randNum
$randCC = "5$($randNumString.substring(0,3))-$($randNumString.substring(3,4))-$($randNumString.substring(7,4))-$($randNumString.substring(11,4))"
$script:list.Add($randCC)
}
2 { # Generate Discover
$randNum = Get-Random -minimum 100000000000 -maximum 1000000000000
$randNumString = [string][int64]$randNum
$randCC = "6011-$($randNumString.substring(0,4))-$($randNumString.substring(4,4))-$($randNumString.substring(8,4))"
$script:list.Add($randCC)
}
3 { # Generate Amex
$randNum = Get-Random -minimum 100000000000000 -maximum 1000000000000000
$randNumString = [string][int64]$randNum
$randCC = "3$($randNumString.substring(0,3))-$($randNumString.substring(3,4))-$($randNumString.substring(7,4))-$($randNumString.substring(11,4))"
$script:list.Add($randCC)
}
}
$script:AllCC = $list.ToArray()
$intCardType++
}
else
{
switch ($(Get-Random -maximum 4))
{
0 { # Generate Visa
$randNum = Get-Random -minimum 100000000000000 -maximum 1000000000000000
$randNumString = [string][int64]$randNum
$randCCbase = "4$($randNumString.substring(0,3))-$($randNumString.substring(3,4))-$($randNumString.substring(7,4))-"
}
1 { # Generate MasterCard
$randNum = Get-Random -minimum 100000000000000 -maximum 1000000000000000
$randNumString = [string][int64]$randNum
$randCCbase = "5$($randNumString.substring(0,3))-$($randNumString.substring(3,4))-$($randNumString.substring(7,4))-"
}
2 { # Generate Discover
$randNum = Get-Random -minimum 10000000 -maximum 100000000
$randNumString = [string][int64]$randNum
$randCCbase = "6011-$($randNumString.substring(0,4))-$($randNumString.substring(4,4))-"
}
3 { # Generate Amex
$randNum = Get-Random -minimum 100000000000000 -maximum 1000000000000000
$randNumString = [string][int64]$randNum
$randCCbase = "3$($randNumString.substring(0,3))-$($randNumString.substring(3,4))-$($randNumString.substring(7,4))-"
}
}
$endCC = $(Get-Random -minimum 1000 -maximum 9500)
for ($i2 = $endCC; $i2 -lt $($endCC+500); $i2++)
{
$randCC = "$randCCbase$i2"
$list.Add($randCC)
$i++
}
}
}
$script:AllCC = $Script:list.ToArray()
#$script:AllCC = $list.ToArray()
}
function Generate-Identity
@ -1140,7 +1219,7 @@ function Invoke-EgressAssess
if ($proxy)
{
$proxy = [Slslsstem.Net.WebRequest]::GetSystemWebProxy()
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$wc.proxy = $proxy
}
@ -1219,6 +1298,7 @@ function Invoke-EgressAssess
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$webclient.proxy = $proxy
}
Write-Verbose "[*] Uploading data.."
$uri = New-Object System.Uri($Destination)
$webclient.UploadFile($uri, $SourceFilePath)
Write-Verbose "[*] File Transfer Complete."