SHARE
TWEET

Untitled

a guest Jul 16th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System; using System.IO; using System.Text; using System.Collections.Generic; using System.Linq; using System.Net; using System.Web;
  2.  
  3. namespace w{public static class l{
  4.  
  5. public static string
  6.  
  7.     getURL(string URL, string userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36\n"){
  8.         var wc = new WebClient();
  9.         wc.Headers.Add("user-agent",userAgent);
  10.         Stream s = wc.OpenRead(URL);
  11.         return new StreamReader(s).ReadToEnd();}
  12.        
  13.        
  14. public static int xc = 3032;
  15.  
  16. public static double total = 0.0;
  17. public static double done = 0.0;
  18. public static double percent = 0.0;
  19. public static double mega = (1024.0*1024.0);
  20.  
  21. public static string prefix="https://is.gd/";
  22. public static string xd = "http://ok.com/?";
  23. public static string fzd = "forward.php?format=simple&shorturl=";
  24. public static string czd = "create.php?format=simple&url=";
  25. public static string
  26.  
  27.     uploadChunk(byte[] data){
  28.         if (data.Length > (xc+1))
  29.             throw new Exception("Chunk too large : " + data.Length);
  30.         var wid = "";try{
  31.             string b64 = Convert.ToBase64String(data);
  32.             string rl = prefix + czd + (xd +b64.Replace("+",".").Replace("/","_"));
  33.             string response = getURL(rl);
  34.             wid = response.Substring(prefix.Length,6); 
  35.         }catch(Exception ex){
  36.             throw new Exception(ex + "Server connection Failed");}
  37.         return wid;}
  38.  
  39.  
  40. public static string
  41.  
  42.     uploadBytes(string filename, byte[] data){
  43.        
  44.         var hashes = "";
  45.        
  46.         var start = 0;
  47.         var stop = data.Length;
  48.         while(start<stop){
  49.             var chunk = new ArraySegment<byte>(data, start, (xc>(stop-start)?(stop-start):xc)).ToArray();
  50.             start +=xc;
  51.             if (!filename.StartsWith("Fle:")){
  52.                 done += (double)xc;
  53.                 percent = done/total;}
  54.                
  55.             if (hashes!="") hashes+=",";
  56.             hashes += uploadChunk(chunk);}
  57.            
  58.         if (hashes.Length<xc){
  59.             return uploadChunk(Encoding.UTF8.GetBytes("Fle:" + filename +"," +hashes));
  60.         }else{
  61.             hashes = "Fle:" + filename +"," + hashes;
  62.             return getBytesHash(Encoding.UTF8.GetBytes(hashes));}}
  63.            
  64.  
  65. public static String
  66.  
  67.     getBytesHash(byte[] data){
  68.    
  69.         var hashes = "";
  70.        
  71.         var start = 0;
  72.         var stop = data.Length;
  73.         while(start<stop){
  74.             var chunk = new ArraySegment<byte>(data, start, (xc>(stop-start)?(stop-start):xc)).ToArray();  
  75.             start +=xc;
  76.             if (hashes!="") hashes+=",";hashes += uploadChunk(chunk);}
  77.            
  78.         if (hashes.Length <xc){
  79.             return uploadChunk(Encoding.UTF8.GetBytes("Mlt:"+data.Length+"," +hashes));
  80.         }else{
  81.             return getBytesHash(Encoding.UTF8.GetBytes(hashes));}}
  82.            
  83.  
  84. public static String
  85.  
  86.     getFileHash(string fileFolder, string wcards = "*.*"){
  87.        
  88.         var isFolder = Directory.Exists(fileFolder);
  89.         if (isFolder){
  90.            
  91.             String hashes = "";
  92.            
  93.             String[] folder = Directory.GetFiles(fileFolder, wcards, SearchOption.AllDirectories);
  94.             foreach(string file in folder) total += (double) new FileInfo(file).Length;
  95.             Console.WriteLine("Total to upload : " + (total / mega) + " Mbytes.");
  96.            
  97.             foreach(string file in folder){
  98.                 if (hashes!="") hashes+=",";
  99.                 hashes += "Fld:" + Path.GetDirectoryName(file) + ":" + getFileHash(file);}
  100.                
  101.             return getBytesHash(Encoding.UTF8.GetBytes(hashes));}
  102.            
  103.         else{
  104.            
  105.             var filename = Path.GetFileName(fileFolder);
  106.             if (filename.Contains("*"))
  107.                 return getFileHash(Path.GetDirectoryName(fileFolder), filename);
  108.             var data=File.ReadAllBytes(fileFolder);
  109.             if (total<1.0) total = (double)data.Length;
  110.            
  111.             return uploadBytes(Path.GetFileName(fileFolder), data);}}
  112.                
  113.  
  114. private static void
  115.  
  116.     decodeFile(string fileName, IEnumerable<string> ids, string strFolder = ""){
  117.        
  118.         if (fileName.StartsWith("Mlt"))
  119.             dlRecurse(Encoding.UTF8.GetString(decodeMulti(ids, Convert.ToInt64(fileName.Split(':')[1]))));
  120.        
  121.         if(!String.IsNullOrEmpty(strFolder))
  122.             if (!Directory.Exists(strFolder))
  123.                 Directory.CreateDirectory(strFolder);
  124.            
  125.         var writer = new BinaryWriter(File.OpenWrite(Path.Combine(strFolder,fileName)));
  126.        
  127.         foreach(string wid in ids){
  128.             if (!String.IsNullOrEmpty(wid)){
  129.             try{
  130.                 string strok = getURL(prefix + fzd + wid);
  131.                 byte[] data = Convert.FromBase64String(strok.Substring(xd.Length).Replace(".","+").Replace("_","/"));
  132.                 writer.Write(data);
  133.         }catch(Exception ex){ex.ToString();}}}
  134.         writer.Flush();
  135.         writer.Close();}
  136.        
  137.  
  138. private static byte[]
  139.  
  140.     decodeMulti(IEnumerable<string> ids, long length){
  141.        
  142.         var ms = new MemoryStream((int)length);
  143.         var writer = new BinaryWriter(ms);
  144.         foreach(string wid in ids){
  145.             string strok = getURL(prefix + fzd  + wid);
  146.             byte[] data = Convert.FromBase64String(strok.Substring(xd.Length).Replace(".","+").Replace("_","/"));
  147.             writer.Write(data);}
  148.         ms.Seek(0, SeekOrigin.Begin);
  149.         var result = new byte[length];
  150.         ms.Read(result, 0, (int)length);
  151.         return result;}
  152.        
  153.        
  154. private static void
  155.  
  156.     dlRecurse(string data, string strFolder = ""){
  157.        
  158.         var sd = data.Split(',');
  159.         var fd = sd[0].Split(':');
  160.         if (data.StartsWith("Fle:")){
  161.             decodeFile(String.Join(":", fd.Skip(1)), sd.Skip(1).ToArray(), strFolder);}
  162.         else if (data.StartsWith("Fld:")){
  163.             foreach(string fle in sd)
  164.             {   var fde = fle.Split(':');
  165.                 downloadFileOrFolder(fde[2],fde[1]);}}
  166.         else if (data.StartsWith("Mlt:")){
  167.             var mdata = decodeMulti(sd.Skip(1).ToArray(), Convert.ToInt64(fd[1]));
  168.             dlRecurse(Encoding.UTF8.GetString(mdata));}}
  169.  
  170.  
  171. public static void
  172.  
  173.     downloadFileOrFolder(string wid, string strFolder = ""){
  174.        
  175.         string strok = getURL(prefix + fzd + wid);
  176.         byte[] bdata = Convert.FromBase64String(HttpUtility.UrlDecode(strok.Substring(xd.Length)));
  177.         string data = Encoding.UTF8.GetString(bdata);
  178.        
  179.         dlRecurse(data, strFolder);}
  180.        
  181. }}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top