Merge pull request #49 from rasta-mouse/ni_numbers

Add UK National Insurance Numbers to Datatypes
master
ChrisTruncer 2017-07-30 19:52:16 -07:00 committed by GitHub
commit b31ba839fa
2 changed files with 143 additions and 0 deletions

View File

@ -250,6 +250,49 @@ function Invoke-EgressAssess
$script:AllSSN = $list.ToArray() $script:AllSSN = $list.ToArray()
} }
function Generate-NI
{
$script:AllNI = @()
#determine the number of NI based on 9 bytes per NI
$num = [math]::Round(($Size * 1MB)/9)
Write-Verbose "Generating $Size MB of National Insurance Numbers ($num)..."
$list = New-Object System.Collections.Generic.List[System.String]
for ($i = 0; $i -lt $num; $i++)
{
if ($Fast)
{
$randString = -join ((65..90) | Get-Random -Count 3 | % {[char]$_})
$randNum = Get-Random -minimum 100 -maximum 1000
$randNumString = [string][int64]$randNum
$randNiBase = "$($randString.substring(0,2))$($randNum)"
$randNiEnd = Get-Random -minimum 100 -maximum 500
for ($i2 = $randNiEnd; $i2 -lt $($randNiEnd+500); $i2++)
{
$randNI = "$randNiBase$i2$($randString.substring(2))"
$list.Add($randNI)
$i++
}
}
else
{
$randString = -join ((65..90) | Get-Random -Count 3 | % {[char]$_})
$randNum = Get-Random -minimum 100000000000 -maximum 1000000000000
$randNumString = [string][int64]$randNum
$r = "$($randString.substring(0,2))$($randNumString.substring(0,6))$($randString.substring(2))"
$list.Add($r)
$r = "$($randString.substring(0,2))$($randNumString.substring(6,6))$($randString.substring(2))"
$list.Add($r)
$i++
}
}
$script:AllNI = $list.ToArray()
}
function Generate-CreditCards function Generate-CreditCards
{ {
@ -471,6 +514,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
$Data = $AllSSN $Data = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
$Data = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -618,6 +666,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
$Data = $AllSSN $Data = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
$Data = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -907,6 +960,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
$Data = $AllSSN $Data = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
$Data = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -1013,6 +1071,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
$Data = $AllSSN $Data = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
$Data = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -1153,6 +1216,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
$Data = $AllSSN $Data = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
$Data = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -1260,6 +1328,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
$FTPData = $AllSSN $FTPData = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
$FTPData = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -1351,6 +1424,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
$FTPData = $AllSSN $FTPData = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
$FTPData = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -1473,6 +1551,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
$SMTPData = $AllSSN $SMTPData = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
$SMTPData = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -1531,6 +1614,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
[string]$ICMPData = $AllSSN [string]$ICMPData = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
[string]$ICMPData = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -1651,6 +1739,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
[string]$DNSData = $AllSSN [string]$DNSData = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
[string]$DNSData = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -1734,6 +1827,11 @@ function Invoke-EgressAssess
Generate-SSN Generate-SSN
[string]$DNSData = $AllSSN [string]$DNSData = $AllSSN
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
[string]$DNSData = $AllNI
}
elseif ($Datatype -eq "cc") elseif ($Datatype -eq "cc")
{ {
Generate-CreditCards Generate-CreditCards
@ -1793,6 +1891,11 @@ function Invoke-EgressAssess
Generate-CreditCards Generate-CreditCards
[string]$SMBData = $AllCC [string]$SMBData = $AllCC
} }
elseif ($Datatype -eq "ni")
{
Generate-NI
[string]$SMBData = $AllNI
}
elseif ($Datatype -eq "ssn") elseif ($Datatype -eq "ssn")
{ {
Generate-SSN Generate-SSN

40
datatypes/ni_numbers.py Normal file
View File

@ -0,0 +1,40 @@
'''
This module generates UK National Insurance Numbers.
Format is 2 prefix letters, 6 digits, 1 suffix letter:
AB123456C
They are sometimes printed with spaces:
AB 12 34 56 C
This modules doesn't take correct letter prefixing into account,
it just generates them randomly. But this is probably good
enough for basic regex-type filters to detect.
'''
from common import helpers
class Datatype:
def __init__(self, cli_object):
self.cli = "ni"
self.description = "UK National Insurance Numbers"
self.filetype = "text"
self.datasize = int(cli_object.data_size)
def create_ni(self):
ni_n = helpers.randomNumbers(6)
ni_s = (helpers.randomString(3)).upper()
ni = ni_s[0:2] + ni_n[0:6] + ni_s[2:3]
return ni
def generate_data(self):
print "[*] Generating data..."
nis = ''
# This is approx 1 meg of ni's (not including ", ")
for single_ni in range(0, 100000 * self.datasize):
nis += self.create_ni() + ', '
return nis