Audoit code to Run RDP on only a Single monitor using the TopMost method
Category Archives: Uncategorized
Install and running Handwriting-Synthesis on Windows.
install Python 3.6.2 and Git Add “C:\Users\User\AppData\Local\Programs\Python\Python36” to your path and remove any Windows Store Path’s as needed to prevent Windows store from popping up while executing python commandline execute python get-pip.py from command line -> https://bootstrap.pypa.io/get-pip.py dir into a new folder. Know that using the latest version of python can cause issues with TensorFlow …
Continue reading “Install and running Handwriting-Synthesis on Windows.”
Ready a Stream of Data into Calendar Appointments
|
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
Remove-Variable * -ErrorAction SilentlyContinue; Remove-Module *; $error.Clear(); Clear-Host #This will Break the Webcall scripts #https://stackoverflow.com/questions/47542628/cannot-convert-argument-second-time-in-powershell #https://www.slipstick.com/developer/change-programmatic-access-options/ #$proxy = New-WebServiceProxy -uri "http://localhost:8080/API.asmx?WSDL" -namespace "com.api" -class "MyProxyClass" #$proxy = New-WebServiceProxy -uri "http://localhost:8080/API.asmx?WSDL" -namespace "MyPortal" -class "MyProxyClass" # load the required .NET types Add-Type -AssemblyName 'Microsoft.Office.Interop.Outlook' $GCalenderItems = $null #Makes global Car $End = (Get-Date).AddDays(14).ToShortDateString() $Start = (Get-Date).AddDays(-14).ToShortDateString() Function Get-OutlookCalendar { # access Outlook object model $outlook = New-Object -ComObject outlook.application # connect to the appropriate location $namespace = $outlook.GetNameSpace('MAPI') $Calendar = [Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderCalendar $Filter = "[MessageClass]='IPM.Appointment' and [IsRecurring] = '$False' AND [Start] > '$Start' AND [Start] < '$End'" # AND [End] < '$End'" #AND [Start] > '$Start' AND [End] < '$End'" $CalenderItems = $namespace.getDefaultFolder($Calendar).Items.Restrict($Filter) $CalenderItems | Select-Object -Property Start, Subject write-host "There are $($CalenderItems.Count) calendar entries. Fetching between $($start) and $($end)" #write-host "There are $($CalenderItems.Items.Count) calendar entries. Fetching between $($start) and $($end)" #$folder #$CalenderItems | Select-Object -Property Start, End, Categories, Subject, IsRecurring, Organizer #$folder | gm return $CalenderItems #$dataToReturn = $folder.Items.Restrict($Filter) # | Select-Object -Property Start, End, Categories, Subject, IsRecurring, Organizer $folder.items | Select-Object -Property Start, Categories, Subject, IsRecurring, Organizer $data = $folder.items | Select-Object -Property Start, Categories, Subject, IsRecurring, Organizer $data | Where-Object ($_.Subject -ne "!@#!#!$") $cal = $data | Where-Object ($_Subject -CContains "paceart") write-host "Completed" } $GCalenderItems = Get-OutlookCalendar function add-appointment(){ <# .SYNOPSIS Creates and appointment in outlook .DESCRIPTION Creates an appointment in outlook in the default calendar folder .PARAMETER TimeDate Time and Date of the appointment. Multiple formats are accepted. Please use the one common to your region. It will create the appointment for today if no date is specified. .PARAMETER Location The message to be send. .PARAMETER ReminderMinutesBeforeStart Sets when to send reminder for appointment. Default is 15 minutes. 1440 minutes are in a day and 10080 minutes in a week. Set it to 0 for no reminders. .PARAMETER Subject The subject of the appointment. .EXAMPLE add-appointment -TimeDate "1/4/2015 4:30 pm" -Subject "Little Mermaid" -location "Cameo Theater" -ReminderMinutesBeforeStart 0 This example adds a appointment on 1/4/2015 at 4:30 PM with subject Little mermaid and no reminder. .NOTES Requires Windows PowerShell v2 or later and Microsoft Office Outlook 2010 or later. Outlook cannot be running when running this script.Some versions of Outlook will not close the session. Please go to taskbar and close manually in that case. #> [CmdletBinding()] param ( [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] $TimeDate, [parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] $Subject , $location, [int]$ReminderMinutesBeforeStart = "15" ) $AppointmentTime = get-date $Timedate #Check whether Outlook is installed if (-not (Test-Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE")) { Write-Warning "Outlook is not installed. You need to install Outlook 2010 or later to use this Script." break } #Check if Outlook is running. $OutlookState = Get-Process | Where-Object {$_.Name -eq "outlook"} if ($OutlookState) { Write-Warning "Outlook is running. Please close outlook to run this script" break } $outlook = new-object -com Outlook.Application $calendar = $outlook.Session.GetDefaultFolder(9) # == olFolderCalendar $appt = $calendar.Items.Add(1) # == olAppointmentItem $appt.Start = [datetime]$AppointmentTime $appt.Subject = $subject $appt.Location = $location $appt.ReminderSet = $true $appt.ReminderMinutesBeforeStart =$ReminderMinutesBeforeStart $appt.Save() $outlook.Quit() } if ( !(Test-Path variable:proxy) ) { $proxy = New-WebServiceProxy -uri "https://MyPortal/API.asmx?WSDL" -namespace "MyPortal" -UseDefaultCredential #$proxy = New-WebServiceProxy -uri "http://localhost:8080/API.asmx" -namespace "MyPortal" -UseDefaultCredential } function AdvanceSearch-appointment(){ $Outlook = New-Object -ComObject Outlook.Application Unregister-Event * Register-ObjectEvent -InputObject $Outlook -EventName "AdvancedSearchComplete" -Action { Write-Host "ADVANCED SEARCH COMPLETE" $Args.Scope "Results: " $Args.Results if ($Args.Results) { foreach ($result in $Args.Results) { write-host "==================================================" write-host $result.Subject write-host $result.ReceivedTime write-host $result.SenderName write-host "==================================================" } } } #$olFolders = “Microsoft.Office.Interop.Outlook.OlDefaultFolders” -as [type] $olFolders = [Microsoft.Office.Interop.Outlook.OlDefaultFolders]::olFolderCalendar $NameSpace = $Outlook.GetNameSpace(“MAPI”) #$Scope = $NameSpace.getDefaultFolder($olFolders::olFolderCalendar) #'Inbox' $Scope = 'Inbox' #$NameSpace.getDefaultFolder($olFolders) #'Inbox' #'Calendar' $Emails = $Outlook.AdvancedSearch( $Scope, "", $true ) #urn:schemas:calendar:subject != '%' #$Emails } $person = New-Object "MyPortal.ThePerson"; $person.FirstName = "Frederick"; $person.LastName = "DebYouSee"; $Command = New-Object "MyPortal.SystemChange"; $Command = $proxy.Jira_QueryAllOpenChangeControlsThisWeek(50); $ol = New-Object -ComObject Outlook.Application; $meeting = $ol.CreateItem('olAppointmentItem'); $calendar = $ol.Session.GetDefaultFolder(9) # == olFolderCalendar :nextCalendarItem foreach($file in $Command) { [string]$MyTitle = " CC" + $file.Ticket + ": " + $file.summary; Write-Host $MyTitle; #$file.Ticket.ToString().Trim() ": " $file.summary.ToString().Trim(); #$GCalenderItems | Select-Object -Property Start, Subject foreach ($result in $GCalenderItems) { if ($result.Subject -like $MyTitle) { write-host "==================================================" write-host $result.Start write-host $result.End write-host $result.Subject write-host "==================================================" continue nextCalendarItem; } } Write-Host $file.PlannedStartDate; Write-Host $file.PlannedEndDate; $meeting.Subject = "$MyTitle"; $meeting.Body = $file.description; $meeting.Categories = "ChangeControlReminder"; $meeting.Location = 'Change Control Reminder'; $meeting.ReminderSet = $true; $meeting.Importance = 1; $meeting.MeetingStatus = [Microsoft.Office.Interop.Outlook.OlMeetingStatus]::olMeeting #$meeting.Recipients.Add('mjones@contoso.net') $meeting.ReminderMinutesBeforeStart = 15 $StartDate = [DateTime]::Parse($file.PlannedStartDate, [System.Globalization.CultureInfo]::InvariantCulture); #$file.PlannedStartDate#DateTime.Parse() #System.Globalization.CultureInfo.InvariantCulture $EndDate = [DateTime]::Parse($file.PlannedEndDate, [System.Globalization.CultureInfo]::InvariantCulture); #$file.PlannedStartDate#DateTime.Parse() #System.Globalization.CultureInfo.InvariantCulture $duration = $EndDate - $StartDate $meeting.Start = $StartDate if ($duration.TotalHours -gt 8) { $meeting.Duration = 30 } else { $meeting.Duration = $duration.TotalMinutes } #$meeting.Send() $appt = $calendar.Items.Add(1) # == olAppointmentItem $appt.Start = $StartDate; if ($duration.TotalHours -gt 8) { $appt.Duration = 30 } else { $appt.Duration = $duration.TotalMinutes } $appt.Subject = "$MyTitle"; $appt.Body = $file.description; $appt.Location = $location; $appt.Categories = "ChangeControlReminder"; $appt.Location = 'Change Control Reminder'; $appt | gm $appt.ReminderSet = $false; $appt.Importance = 1; $appt.BusyStatus = [Microsoft.Office.Interop.Outlook.OlBusyStatus]::olFree; $appt.ReminderMinutesBeforeStart = $ReminderMinutesBeforeStart; $appt.Save(); } #Invoke-Expression $Command; #$proxy.Dispose(); #You must dispose of the proxy IN YOUR SCRIPT, powershell will not do it for you! |
Soapcalls from PHP to .NET Web services
|
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
#!/usr/bin/php -q <?php //Creates a check for HTTP and HTTPS services. Also creates a SSL cert check. //Every host is scanned for the ports listed below, and if an web service is found, a service check is created for it. $database_folder = "/etc/nagios/scripts/auto_generate_database/"; //Folder of the SQLLite databases to use for host lookup. $outputfile = "autoconfig_Custom-services.cfg"; #$outputfile = "/etc/nagios/conf.d/auto_generated/autoconfig_http-services.cfg"; $check_http = "/etc/nagios/plugins/check_http"; //Location of Nagios check_http command. This command does all the work and the config is bases on what this command returns. $servicehttps_ports_array = array("443","8443","9443","18200","18201","18202","18203","18204","18205","18206","18207","18208","18209","18210");// array of ports for SSL/TLS checks. Also creates a cert check for each ones of these. $servicehttp_ports_array = array("80","8080","8888");// array of ports for normal HTTP checks $httpcodes = "200,301,302,403,404"; //HTTP codes that are OK //////////////////////////// MAIN //////////////////////////// #var_dump($argv); #exit(); include_once("/etc/nagios/scripts/lib/check_for_custom_config_lib.php"); //Load check for custom config library. $servicegroups_array = array();// Servicegroup array $servicehttp_array = array();// http service array $servicehttps_array = array();// https service array //Open the database with a list of servers. $dbh = new PDO("sqlite:$database_folder/servers.sqlite3") or die("cannot open the database"); //Build the arrays foreach($servicehttps_ports_array as $port) { $servicehttps_array["$port"] = array(); } foreach($servicehttp_ports_array as $port) { $servicehttp_array["$port"] = array(); } $stmt = $dbh->query("SELECT * FROM servers;"); $debug_count = 0; if($argc>1) { echo "Pinging $argv[1] \r\n"; //ping to see if the host is up. exec("ping -c 1 $argv[1]", $null, $result); if (!($result == 0)){ continue;} echo "Checking $argv[1] with ISPortal \r"; $Output = NagiosServiceCheck($argv[1]); echo $Output; $fh= fopen($argv[1],'w'); fwrite($fh, $Output); fclose($fh); } else { //Loop over the list of servers. foreach ($stmt as $row) { $host = $row["hostname"]; $ip = $row["ip"]; echo "Pinging $host \r\n"; //ping to see if the host is up. exec("ping -c 1 $ip", $null, $result); if (!($result == 0)){ continue;} echo "Checking $host with ISPortal \r"; #httpChecks($host,$ip); //Check for HTTP and HTTPS ports $Output = NagiosServiceCheck($host); echo $Output; $fh= fopen($host,'w'); fwrite($fh, $Output); fclose($fh); $debug_count++; # if ($debug_count > 50) {break 1;} //Stop after X servers for testing } } exit(); function ServiceCheck($ServiceName) { switch ($i) { case 0: echo "i equals 0"; break; case 1: echo "i equals 1"; break; case 2: echo "i equals 2"; break; } } function NagiosServiceCheck($host) { try { #$client = new SoapClient("https://IsPortal/API.asmx?WSDL", array('login' => "EID@FQDN.COM", 'password' => "MyPasswordGoesHere", 'user_agent' => 'PHPSoapClient')); $client = new SoapClient("https://IsPortal/API.asmx?WSDL", array('user_agent' => 'PHPSoapClient', 'cache_wsdl' => WSDL_CACHE_NONE)); #var_dump($client->__getFunctions()); #$result = $client->HelloWorld()->HelloWorldResult; #$result = $client->Testing_HelloWorld()->Testing_HelloWorldResult; #$result = $client->Nagios_GenerateCustomServices($host, "true")->Nagios_GenerateCustomServicesResult; #$result = $client->__soapCall(Nagios_GenerateCustomServices, 'Hostname' => '$host', 'MustBeSetToAutomatic', => 'True')->Nagios_GenerateCustomServicesResult; #$result = $client->Nagios_GenerateCustomServices(new SoapParam('Hostname', $Hostname), new SoapParam("True", $MustBeSetToAutomatic))->Nagios_GenerateCustomServicesResult; #$result = $client->Nagios_GenerateCustomServices(array('parameters' => $params))->Nagios_GenerateCustomServicesResult; $params = array('Hostname' => $host, 'MustBeSetToAutomatic' => 'True'); $result = $client->__soapCall('Nagios_GenerateCustomServices', array('parameters' => $params))->Nagios_GenerateCustomServicesResult; #echo $result; return $result; } catch (Exception $e) { echo 'caught execption: ', $e->getMessage(), "\n"; } } function httpChecks($host,$ip) { global $httpcodes,$check_http,$servicehttp_array,$servicehttps_array,$servicehttps_ports_array,$servicehttp_ports_array; //Check for an active HTTP service on an array of ports. foreach($servicehttp_ports_array as $port) { ///Check for an active HTTP service on an array of ports. $output_array = array(); exec ($check_http." -p $port -H $ip --expect=$httpcodes -t 2", $output_array); //Use the Nagios check_http to probe the ports. if( preg_match("/HTTP OK:/",$output_array[0]) ) { echo "HTTP $port found for $host \n"; array_push($servicehttp_array["$port"], $host); //dump found host and port into array //var_dump($servicehttps_array); } } //Check for an active HTTPS service on an array of ports. foreach($servicehttps_ports_array as $port) { $output_array = array(); exec ($check_http." -p $port -H $ip -S --expect=$httpcodes -t 2", $output_array); //Use the Nagios check_http to probe the ports. if( preg_match("/HTTP OK:/",$output_array[0]) ) { echo "HTTPS $port found for $host \n"; array_push($servicehttps_array["$port"], $host); //dump found host and port into array //var_dump($servicehttps_array); } } } function generateServiceGroups($servicegroups_array) { //Create a service group for each new service monitored. $output_group = ""; $servicegroups_array = array_unique($servicegroups_array); foreach($servicegroups_array as $name) { echo "servicegroup:$name\n"; $output_group .= "define servicegroup{\n"; $output_group .= " servicegroup_name $name\n"; $output_group .= " alias\n"; $output_group .= "}\n"; } return($output_group); } function generateServiceHTTP($servicehttp_array,$servicehttp_ports_array){ $service_list = ""; $service = ""; global $servicegroups_array,$httpcodes; //loop over each port. foreach($servicehttp_ports_array as $port) { $service_list = ""; if (count($servicehttp_array[$port]) > 0) { //loop over the array foreach($servicehttp_array[$port] as $host) { //skip if there is a custom config. if (checkForCustomConfig($host,"HTTP $port")) { continue; } //Put additional check here. //Service is good, add it to the list. $service_list .= $host . ","; } $service_list=substr_replace($service_list,"",-1); //remove ending comma $service .="define service{\n"; $service .=" use generic-service\n"; $service .=" host_name $service_list\n"; $service .=" service_description HTTP $port\n"; $service .=" check_command check_web! --expect=$httpcodes -p $port -w 8 -c 9\n"; $service .=" check_interval 5\n"; $service .=" flap_detection_enabled 0\n"; $service .=" retry_interval 1\n"; $service .=" notifications_enabled 0\n"; $service .=" servicegroups http-checks-$port\n"; $service .=" contact_groups OpsSysadmin\n"; $service .=" notes HTTP $port Website checks\n"; $service .="}\n"; array_push($servicegroups_array,"http-checks-$port"); } } return($service); } function generateServiceHTTPS($servicehttps_array,$servicehttps_ports_array){ $service_list = ""; $service = ""; global $servicegroups_array,$httpcodes;; //loop over each port. foreach($servicehttps_ports_array as $port) { $service_list = ""; if (count($servicehttps_array[$port]) > 0) { //loop over the array foreach($servicehttps_array[$port] as $host) { //skip if there is a custom config. if (checkForCustomConfig($host,"HTTPS $port")) { continue; } //Put additional check here. //Service is good, add it to the list. $service_list .= $host . ","; } $service_list=substr_replace($service_list,"",-1); //remove ending comma $service .="define service{\n"; $service .=" use generic-service\n"; $service .=" host_name $service_list\n"; $service .=" service_description HTTPS $port\n"; $service .=" check_command check_web! --expect=$httpcodes -p $port -w 8 -c 9 --ssl\n"; $service .=" check_interval 5\n"; $service .=" flap_detection_enabled 0\n"; $service .=" retry_interval 1\n"; $service .=" notifications_enabled 0\n"; $service .=" servicegroups https-checks-$port\n"; $service .=" contact_groups OpsSysadmin\n"; $service .=" notes HTTPS $port Website checks\n"; $service .="}\n"; array_push($servicegroups_array,"https-checks-$port"); } } return($service); } function generateServiceHTTPSCert($servicehttps_array,$servicehttps_ports_array){ $service_list = ""; $service = ""; global $servicegroups_array,$httpcodes; //loop over each port. foreach($servicehttps_ports_array as $port) { $service_list = ""; if (count($servicehttps_array[$port]) > 0) { //loop over the array foreach($servicehttps_array[$port] as $host) { //skip if there is a custom config. if (checkForCustomConfig($host,"HTTPS $port SSL Cert Expiration")) { continue; } //Put additional check here. //Service is good, add it to the list. $service_list .= $host . ","; } $service_list=substr_replace($service_list,"",-1); //remove ending comma $service .="define service{\n"; $service .=" use generic-service\n"; $service .=" host_name $service_list\n"; $service .=" service_description HTTPS $port SSL Cert Expiration\n"; $service .=" check_command check_web!--expect=$httpcodes -p $port -w 8 -c 9 --ssl -C 20\n"; $service .=" check_interval 5\n"; $service .=" flap_detection_enabled 0\n"; $service .=" retry_interval 1\n"; $service .=" notifications_enabled 0\n"; $service .=" servicegroups https-cert-checks-$port\n"; $service .=" contact_groups OpsSysadmin\n"; $service .=" notes HTTPS $port SSL Cert Expiration checks\n"; $service .="}\n"; array_push($servicegroups_array,"https-cert-checks-$port"); } } return($service); } //------------------------------End of script. Functions below ------------------------- |
VB.NET
|
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 |
<WebMethod()> Public Function Nagios_GenerateCustomServices(ByVal Hostname As String, ByVal MustBeSetToAutomatic As Boolean) Dim ReturnedArray As ArrayList If MustBeSetToAutomatic Then ReturnedArray = MyModule.DetectServerServices(Hostname, ServiceProcess.ServiceStartMode.Automatic) Else ReturnedArray = MyModule.DetectServerServices(Hostname, -1) End If Dim Host As String = "define host{ use linux-server host_name " & Hostname & " alias " & Hostname & " address " & System.Net.Dns.GetHostByName(Hostname).AddressList(0).ToString & " notes Ex. vBlock - VCE PowerPath hostgroups Ex. vBlock_linux_appliance } " Dim Data As String = Nothing Data = Host If MustBeSetToAutomatic Then For I = 0 To ReturnedArray.Count - 1 If (ReturnedArray(I).ToString.StartsWith("!")) Then Continue For End If Data &= "define service{ use generic-service host_name " & Hostname & " service_description " & ReturnedArray(I).ToString.Replace("\(", "(").Replace("\)", ")") & " check_command CheckServiceSNMP!" & ReturnedArray(I) & " check_interval 60 retry_interval 1 notification_interval 60 contact_groups nicholas event_handler start_service!start_" & ReturnedArray(I) & " max_check_attempts 2 notifications_enabled 1 } " 'root@Hostname[Nagios]:/usr/lib64/nagios/plugins# ./check_SNMP_service_displayname_emc MySnmpCommunity IsPortal "Power" Next Else For I = 0 To ReturnedArray.Count - 1 If Not (ReturnedArray(I).ToString.StartsWith("!")) Then Continue For End If Data &= "define service{ use generic-service host_name " & Hostname & " service_description " & ReturnedArray(I).ToString.Substring(1).Replace("\(", "(").Replace("\)", ")") & " check_command CheckServiceSNMP!" & ReturnedArray(I) & " check_interval 60 retry_interval 1 notification_interval 60 contact_groups TheGrouup event_handler start_service!start_" & ReturnedArray(I) & " max_check_attempts 2 notifications_enabled 1 } " Next End If Return Data End Function |
simple VB Form Web Fuzzer
|
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
Public Class Form1 Dim NewLetter As Char Dim MyWebRequest As New Net.WebClient() Dim Extention As String = ".cfm" Dim FileLen As Integer = 0 Dim SleepTime As Integer = 1000 Const WebSite As String = "http://MyWebsite.com/" Private Sub ExplorePath(ByVal RequestString As String, Optional ByVal LastAscii As Integer = 0) Application.DoEvents() Dim Data As Byte() = Nothing Dim NumberOfFilesFound As Integer = 0 Dim DataLength As Integer = 0 NumberOfFilesFound = 0 Debug.WriteLine("Trying: " & WebSite & RequestString & "<" & Extention) Try If LastAscii = 0 Then Data = MyWebRequest.DownloadData(WebSite & RequestString & "<" & Extention) Else Data = MyWebRequest.DownloadData(WebSite & RequestString & Chr(LastAscii) & "<" & Extention) End If If DataLength <> Data.Length Then If LastAscii = 0 Then ListBox1.Items.Add(RequestString & "<" & Extention) Else ListBox1.Items.Add(RequestString & Chr(LastAscii) & "<" & Extention) Try MyWebRequest.DownloadData(WebSite & RequestString & Chr(LastAscii) & Extention) ListBox1.Items.Add("--[" & RequestString & Chr(LastAscii) & Extention & "]--") Catch ex As Exception End Try ExplorePath(RequestString & ChrW(LastAscii), 48) End If End If Catch ex As Exception DataLength = 0 End Try Select Case LastAscii Case 0 LastAscii = 48 Case 58 LastAscii = 65 'A Case 91 LastAscii = 48 'Zero Return Case Else LastAscii += 1 End Select Threading.Thread.Sleep(SleepTime) ExplorePath(RequestString, LastAscii) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'THIS CAN DOS THE SYSTEM 'Add a Sleep Command 'Exit Sub Dim MyThread(25) As Threading.Thread Dim MyThreadClass(25) As ThreadClassAction If TextBox2.Text = "" Then For i = 0 To 25 MyThreadClass(i) = New ThreadClassAction MyThreadClass(i).CallBack = Me MyThread(i) = New Threading.Thread(AddressOf MyThreadClass(i).Launch) MyThread(i).Name = Chr(Asc("A") + i) MyThread(i).IsBackground = True MyThread(i).Start() Next Else Extention = TextBox1.Text ExplorePath(TextBox2.Text) MsgBox("Done!") End If End Sub End Class Public Class ThreadClass Public CallBack As Form Public Data As String Public Sub AddListItem1() Form1.ListBox1.Items.Add(Data) End Sub Public Sub AddListItem2() Form1.ListBox2.Items.Add(Data) End Sub End Class Public Class ThreadClassAction Public CallBack As Form Dim MyWebRequest As New Net.WebClient() Private Delegate Sub MyDelPtr() Public Extention As String = ".cfm" Const WebSite As String = "http://MyWebsite.com/" Public Sub Launch() ExplorePathThread(Threading.Thread.CurrentThread.Name) End Sub Private Sub ExplorePathThread(ByVal RequestString As String, Optional ByVal LastAscii As Integer = 0) Debug.WriteLine("Starting Thread: " & Threading.Thread.CurrentThread.Name) Application.DoEvents() Dim MyThreadClass As New ThreadClass MyThreadClass.CallBack = CallBack Dim MyDel1 = New MyDelPtr(AddressOf MyThreadClass.AddListItem1) Dim MyDel2 = New MyDelPtr(AddressOf MyThreadClass.AddListItem2) Dim Data As Byte() = Nothing Dim NumberOfFilesFound As Integer = 0 Dim DataLength As Integer = 0 NumberOfFilesFound = 0 Debug.WriteLine("Trying: " & WebSite & RequestString & "<" & Extention) Try If LastAscii = 0 Then Data = MyWebRequest.DownloadData(WebSite & RequestString & "<" & Extention) Else Data = MyWebRequest.DownloadData(WebSite & RequestString & Chr(LastAscii) & "<" & Extention) End If If DataLength <> Data.Length Then If LastAscii = 0 Then MyThreadClass.Data = (RequestString & "<" & Extention) CallBack.Invoke(MyDel1) Else MyThreadClass.Data = (RequestString & Chr(LastAscii) & "<" & Extention) CallBack.Invoke(MyDel1) Try MyWebRequest.DownloadData(WebSite & RequestString & Chr(LastAscii) & Extention) MyThreadClass.Data = ("--[" & RequestString & Chr(LastAscii) & Extention & "]--") CallBack.Invoke(MyDel2) Catch ex As Exception End Try ExplorePathThread(RequestString & ChrW(LastAscii), 48) End If End If Catch ex As Exception DataLength = 0 End Try Select Case LastAscii Case 0 LastAscii = 48 Case 58 LastAscii = 65 'A Case 91 LastAscii = 48 'Zero Return Case Else LastAscii += 1 End Select ExplorePathThread(RequestString, LastAscii) End Sub End Class |