Skip to content

Commit

Permalink
Code cleanup!
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b0 authored Jul 16, 2018
1 parent e733510 commit 39ec5c5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions graphical.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Add-Type -AssemblyName PresentationFramework, System.Drawing, System.Windows.For
[System.Windows.Forms.Application]::EnableVisualStyles()

Clear-Host
$reportdir = "C:\Users\$env:UserName\snipenet\"
$reportdir = "C:\Users\$env:UserName\snipenet"
$reportfile = "C:\Users\$env:UserName\snipenet\malicious-ip-history.txt"
$todaysreport = "$reportdir$date.txt"
$todaysreport = "$reportdir\$date.txt"
$date = Get-Date -format "yyyyMMdd"
$iconloc = "C:\Users\$env:UserName\AppData\Local\snipehunt\snipe.ico"
$iconfold = "C:\Users\$env:UserName\AppData\Local\snipehunt"
Expand Down Expand Up @@ -117,15 +117,15 @@ $clearButton.Add_Click({$result.Clear()})

function hunter()
{
$stringArray = $result.Text.Split("`n") | % {$_.trim()}
$stringArray = $result.Text.Split("`n") | ForEach-Object{$_.trim()}
$result.Clear()
foreach($potentiallydangerousip in $stringArray)
{
if(Invoke-WebRequest https://www.abuseipdb.com/check/$potentiallydangerousip | Select-Object -ExpandProperty RawContent | select-string "was found in our database!")
{
if(Get-Content $reportfile | Select-String $potentiallydangerousip)
{
$reportdate = Get-Content $reportfile | Select-String $potentiallydangerousip | cut -d " " -f 2
$reportdate = Get-Content $reportfile | Select-String $potentiallydangerousip | Out-String | ForEach-Object{$_.split(' ')[1]}
$result.text += "`r`n" + "$potentiallydangerousip was reported on $reportdate"
}
if( -not (Get-Content $reportfile | Select-String $potentiallydangerousip))
Expand All @@ -139,13 +139,17 @@ function hunter()
$result.text += "`r`n" + "$potentiallydangerousip is clean."
}
}
$a = new-object -comobject wscript.shell
$intAnswer = $a.popup("Do you want to hunt?",0,"Proceed with hunt?",4)
$a = new-object -comobject wscript.shell
$intAnswer = $a.popup("Do you want to hunt?",0,"Proceed with hunt?",4)
If ($intAnswer -eq 6)
{
Get-Content $reportfile | grep $date | cut -d " " -f 1 > $todaysreport
Remove-Item -Path "$reportdir\temp.txt"
Get-Content $reportfile | select-string $date | Out-String | ForEach-Object{$_.split(' ')} >> "$reportdir\temp.txt"
Get-Content "$reportdir\temp.txt" | select-string $date -NotMatch | Out-String | ForEach-Object{$_.trim()} > $todaysreport

foreach($maliciousip in Get-Content $todaysreport)
{
Write-Host $maliciousip
& 'C:\Program Files\Mozilla Firefox\firefox.exe' -new-tab -url https://www.abuseipdb.com/check/$maliciousip
}
}
Expand Down

0 comments on commit 39ec5c5

Please sign in to comment.