As part of the program that I am making, I needed to make a program startup manager. This class allows the user to select a program from a listbox and then remove the program from startup. It will then refresh the listbox to show the program that remain in startup.
Imports Microsoft.Win32
Imports System.Security
Imports System.Security.AccessControl
Public Class StartupManager
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim regKey As RegistryKey 'new Reg key for each location within the registry
Dim newkey As RegistryKey
Dim subkey As RegistryKey
regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
'Using try and catch to avoid getting errors if there are no entries in the locations
Try
regKey.GetValueNames()
For i = 0 To UBound(regKey.GetValueNames())
Me.ListBox1.Items.Add(regKey.GetValueNames(i))
Next
Catch ex As Exception
End Try
newkey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
Try
newkey.GetValueNames()
For i = 0 To UBound(newkey.GetValueNames())
Me.ListBox1.Items.Add(newkey.GetValueNames(i))
Next
Catch ex As Exception
End Try
subkey = Registry.LocalMachine.OpenSubKey("Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Run", True)
Try
subkey.GetValueNames()
For i = 0 To UBound(subkey.GetValueNames())
Me.ListBox1.Items.Add(subkey.GetValueNames(i))
Next
Catch ex As Exception
End Try
End Sub
Private Sub KryptonButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KryptonButton1.Click
Dim selected As String = ListBox1.SelectedItem
Dim regKey As RegistryKey
Dim newkey As RegistryKey
Dim subkey As RegistryKey
regKey = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
newkey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True)
subkey = Registry.LocalMachine.OpenSubKey("Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Run", True)
'Using try and catch to avoid getting errors if the selected entry is not in this locaiton, it will then move to the next location until it find the entry
Try
regKey.DeleteValue(selected)
Catch ex As Exception
End Try
Try
newkey.DeleteValue(selected)
Catch ex As Exception
End Try
Try
subkey.DeleteValue(selected)
Catch ex As Exception
End Try
ListBox1.Items.Clear()
Try
regKey.GetValueNames()
For i = 0 To UBound(regKey.GetValueNames())
Me.ListBox1.Items.Add(regKey.GetValueNames(i))
Next
Catch ex As Exception
End Try
Try
newkey.GetValueNames()
For i = 0 To UBound(newkey.GetValueNames())
Me.ListBox1.Items.Add(newkey.GetValueNames(i))
Next
Catch ex As Exception
End Try
Try
subkey.GetValueNames()
For i = 0 To UBound(subkey.GetValueNames())
Me.ListBox1.Items.Add(subkey.GetValueNames(i))
Next
Catch ex As Exception
End Try
End Sub
End Class
Sunday, January 20, 2013
Wednesday, January 16, 2013
VB.Net - Delete Temp Files
I'm currently making a program for work, and one of the processes clears the temp folder for the current users. It took me a while to find out how to do this, so I figured I should share. It will skip files that are being used by a process without throwing an error. Don't forget to Imports System.IO at the top.
Code:
Dim tempfolder As String = System.IO.Path.GetTempPath
Dim tempfiles As String() = System.IO.Directory.GetFiles(tempfolder, "*.*", _
System.IO.SearchOption.AllDirectories)
For Each tempfile As String In tempfiles
Try
System.IO.File.Delete(tempfile)
Catch ex As Exception
End Try
Next
Code:
Dim tempfolder As String = System.IO.Path.GetTempPath
Dim tempfiles As String() = System.IO.Directory.GetFiles(tempfolder, "*.*", _
System.IO.SearchOption.AllDirectories)
For Each tempfile As String In tempfiles
Try
System.IO.File.Delete(tempfile)
Catch ex As Exception
End Try
Next
Thursday, November 8, 2012
Powershell fun
I wouldn't count it as software, but I did write a little script for
work that I made in PowerShell. It basically sets permissions for all accounts in C:\users that
have not been used in the last month, and are not local admin
accounts. Once the permissions have been set on accounts that do no
meet the criteria, it will then delete them. We are going to distribute
it to 5000+ computers using System Center Configuration Manager.
Update: While the script did work, it did not work well. I have posted the final code below.
Code:
$Today = Get-Date
$DaysToKeep = "30"
$hoursOlder= "2"
$LastTime = $Today.AddHours(-$hoursOlder)
$TargetFolder = "C:\Users"
$LastWrite = $Today.AddDays(-$DaysToKeep)
$FldrExclusion1 = "Techadmin"
$FldrExclusion2 = "Public"
$FldrExclusion3 = "Default"
$FldrExclusion4 = "Administrator"
$Folders = Get-ChildItem -path $TargetFolder |
Where {$_.psIsContainer -eq $true} |
Where {$_.LastWriteTime -le "$LastWrite"} |
Where {$_.name -ne $FldrExclusion1} |
Where {$_.name -ne $FldrExclusion2} |
Where {$_.name -ne $FldrExclusion3} |
Where {$_.name -ne $FldrExclusion4}
$Folders2 = Get-ChildItem -path $TargetFolder |
Where {$_.psIsContainer -eq $true} |
Where {$_.LastWriteTime -ge "$LastTime"} |
Where {$_.name -ne $FldrExclusion1} |
Where {$_.name -ne $FldrExclusion2} |
Where {$_.name -ne $FldrExclusion3} |
Where {$_.name -ne $FldrExclusion4}
function Take-Ownership {
param(
[String]$Folder
)
takeown.exe /A /F $Folder
$CurrentACL = Get-Acl $Folder
write-host ...Adding NT Authority\SYSTEM to $Folder -Fore Yellow
$SystemACLPermission = "NT AUTHORITY\SYSTEM","FullControl","ContainerInherit,ObjectInherit","None","Allow"
$SystemAccessRule = new-object System.Security.AccessControl.FileSystemAccessRule $SystemACLPermission
$CurrentACL.AddAccessRule($SystemAccessRule)
}
foreach ($Folder in $Folders)
{
if ($Folder -eq $null) {
write-host "No further folders to delete. Going to check for orphan folders." -forgroundcolor "Red"
}
else {
write-host "Deleting $Folder.FullName" -foregroundcolor "Green"
Take-Ownership ($Folder)
cmd.exe /c "rmdir /q /s $Folder"
}
}
foreach ($Folder in $Folders2)
{
if ($Folder -eq $null){
Write-host "All finished :)" -foregroundcolor "Black"
}
else {
write-host "Going back and deleting orphan folder $Folder" -foregroundcolor "Blue"
cmd.exe /c "del $Folder /s /f /q"
}
}
Update: While the script did work, it did not work well. I have posted the final code below.
Code:
$Today = Get-Date
$DaysToKeep = "30"
$hoursOlder= "2"
$LastTime = $Today.AddHours(-$hoursOlder)
$TargetFolder = "C:\Users"
$LastWrite = $Today.AddDays(-$DaysToKeep)
$FldrExclusion1 = "Techadmin"
$FldrExclusion2 = "Public"
$FldrExclusion3 = "Default"
$FldrExclusion4 = "Administrator"
$Folders = Get-ChildItem -path $TargetFolder |
Where {$_.psIsContainer -eq $true} |
Where {$_.LastWriteTime -le "$LastWrite"} |
Where {$_.name -ne $FldrExclusion1} |
Where {$_.name -ne $FldrExclusion2} |
Where {$_.name -ne $FldrExclusion3} |
Where {$_.name -ne $FldrExclusion4}
$Folders2 = Get-ChildItem -path $TargetFolder |
Where {$_.psIsContainer -eq $true} |
Where {$_.LastWriteTime -ge "$LastTime"} |
Where {$_.name -ne $FldrExclusion1} |
Where {$_.name -ne $FldrExclusion2} |
Where {$_.name -ne $FldrExclusion3} |
Where {$_.name -ne $FldrExclusion4}
function Take-Ownership {
param(
[String]$Folder
)
takeown.exe /A /F $Folder
$CurrentACL = Get-Acl $Folder
write-host ...Adding NT Authority\SYSTEM to $Folder -Fore Yellow
$SystemACLPermission = "NT AUTHORITY\SYSTEM","FullControl","ContainerInherit,ObjectInherit","None","Allow"
$SystemAccessRule = new-object System.Security.AccessControl.FileSystemAccessRule $SystemACLPermission
$CurrentACL.AddAccessRule($SystemAccessRule)
}
foreach ($Folder in $Folders)
{
if ($Folder -eq $null) {
write-host "No further folders to delete. Going to check for orphan folders." -forgroundcolor "Red"
}
else {
write-host "Deleting $Folder.FullName" -foregroundcolor "Green"
Take-Ownership ($Folder)
cmd.exe /c "rmdir /q /s $Folder"
}
}
foreach ($Folder in $Folders2)
{
if ($Folder -eq $null){
Write-host "All finished :)" -foregroundcolor "Black"
}
else {
write-host "Going back and deleting orphan folder $Folder" -foregroundcolor "Blue"
cmd.exe /c "del $Folder /s /f /q"
}
}
Sunday, October 7, 2012
WPA2
For my class I had to make another how to video. I did it over wpa2 cracking (again). I was going to do it over something I have not posted before, but we had a time limit that prevented me from doing so.
Sunday, September 9, 2012
Breaking Truecrpyt
I have gone over encryption before using the open source tool TrueCrypt. While encryption is a great way to keep your sensitive information a secret, it does have some vulnerabilities. Of course the biggest vulnerability is that password. TrueCrack exploits this weakness by brute forcing passwords used by TrueCrypt. Its an easy tool to use, and even has GPU support! You can check it out at http://code.google.com/p/truecrack/
Monday, April 9, 2012
Make Web Browsing Faster
There are multiple ways to make browsing faster, and usually they are very easy to do. You can switch browsers, Increase cache size, and change your DNS settings. All of these are easy to do, and can make a big difference.
With these changes you should see a noticeable difference.
- If you are still using Internet explorer then it's time to switch. I suggest using FireFox or chrome.
- Now that you are using a better browser it's time to increase your cache size. This can be done through Internet options. If you can't find Internet options just do a quick Google search on how to do this. Cache Is a form of temporary storage that stores web pages, documents, images, and so on. With local copies of the data less bandwidth is used thus increasing your web browsing speed.
- Next we are going to switch your DNS server to Google. DNS is what takes www.google.com and finds the ip address of the server to pull the page that you want. If you have time Warner then chances are you have been having problems going to web pages. This is caused by Time Warners crap DNS servers. To fix this go to (Windows) start > Control Panel > Network and Internet > Network and Sharing Center > Change adapter settings > right click interface > click IPv4 > properties > tick Use the following DNS server addresses: > for preferred put 8.8.8.8 and alternate 8.8.4.4
With these changes you should see a noticeable difference.
Tuesday, March 6, 2012
Cracking WPA (The Easy Way)
This is a follow up from the WEP video I did. Obviously its over cracking WPA/WPA2 using the brute forcing technique. This attack is simple to do, but can take a longgg time to get the key you are looking for.
Disclaimer: This is for learning purposes only and is to not be used for any purpose other than leaerning/testing .... ect. ect.
Disclaimer: This is for learning purposes only and is to not be used for any purpose other than leaerning/testing .... ect. ect.
Labels:
Security
Subscribe to:
Posts (Atom)
