Advertisement
LaPanthere

No-Distribute Scanner Class

Oct 1st, 2013
1,344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using System.Net;
  6. using System.Text.RegularExpressions;
  7. using System.Drawing;
  8. using System.IO;
  9. namespace noDistributeScanner
  10. {
  11. class noDistribute
  12. {
  13. //CREDITS MUST BE GIVEN IF USED, LaPanthere is the author
  14. List<string> prox;
  15. Random r = new Random();
  16.  
  17. public string resp = "";
  18.  
  19. public void Initialize()
  20. {
  21. prox = methodHMA();
  22. }
  23.  
  24. public List<ListViewItem> getResults(string filename, bool useproxy = false)
  25. {
  26. List<ListViewItem> lvis = new List<ListViewItem>();
  27. try
  28. {
  29. WebClient wc = new WebClient();
  30.  
  31. if (useproxy)
  32. {
  33. wc.Proxy = getProxy();
  34. }
  35.  
  36. wc.Headers.Add("Content-Type", "application/octet-stream");
  37. byte[] result = wc.UploadFile("http://nodistribute.com/scan/", filename);
  38.  
  39. string response = Encoding.UTF8.GetString(result);
  40.  
  41. resp = response;
  42.  
  43. Regex reg = new Regex("<img class='.*?' src='../images/.*?.png'>.(.*)(?=<br)");
  44.  
  45. foreach (Match m in reg.Matches(response))
  46. {
  47. string match = m.Groups[1].Value;
  48. string[] match2 = null;
  49. if (match.Contains(": "))
  50. {
  51. match2 = match.Split(new[] { ": " }, StringSplitOptions.None);
  52. }
  53. else
  54. {
  55. match2 = match.Split(new[] { ":" }, StringSplitOptions.None);
  56. }
  57.  
  58. ListViewItem lvi = new ListViewItem(match2[0]);
  59. switch (match2[1])
  60. {
  61. case "Clean":
  62. lvi.ForeColor = Color.Green;
  63. break;
  64. default:
  65. lvi.ForeColor = Color.Red;
  66. break;
  67. }
  68. lvi.SubItems.Add(match2[1]);
  69. lvis.Add(lvi);
  70. }
  71. }
  72. catch (Exception ex)
  73. {
  74. ListViewItem lvix = new ListViewItem();
  75. if (ex.Message.Contains("remote server"))
  76. {
  77. lvix.ForeColor = Color.Red;
  78. lvix.Text = "Error";
  79. lvix.SubItems.Add("Couldn't connect to proxy, retrying with new proxy...");
  80. lvis.Add(lvix);
  81. lvis = getResults(filename, useproxy);
  82. }
  83. else
  84. {
  85. lvix.ForeColor = Color.Red;
  86. lvix.Text = "Error";
  87. lvix.SubItems.Add(ex.Message);
  88. lvis.Add(lvix);
  89. }
  90. }
  91. return lvis;
  92. }
  93.  
  94. public string getDetections(string response)
  95. {
  96. string ret = "ERROR";
  97. try
  98. {
  99. Regex reg2 = new Regex("<strong>Result:</strong>.*");
  100. string[] splitting = null;
  101. foreach (Match m in reg2.Matches(response))
  102. {
  103. string match = HtmlRemoval.StripTagsRegex(m.Value);
  104. splitting = match.Split(new[] { "Result: " }, StringSplitOptions.None);
  105. ret = splitting[1];
  106. }
  107. }
  108. catch { }
  109. return ret;
  110. }
  111.  
  112. public string getFilename(string response)
  113. {
  114. string ret = "ERROR";
  115. try
  116. {
  117. Regex reg2 = new Regex("<strong>Filename:</strong>.*");
  118. string[] splitting = null;
  119. foreach (Match m in reg2.Matches(response))
  120. {
  121. string match = HtmlRemoval.StripTagsRegex(m.Value);
  122. splitting = match.Split(new[] { "Filename: " }, StringSplitOptions.None);
  123. ret = splitting[1];
  124. }
  125. }
  126. catch { }
  127. return ret;
  128. }
  129.  
  130. public string getMD5(string response)
  131. {
  132. string ret = "ERROR";
  133. try
  134. {
  135. Regex reg2 = new Regex("<strong>MD5:</strong>.*");
  136. string[] splitting = null;
  137. foreach (Match m in reg2.Matches(response))
  138. {
  139. string match = HtmlRemoval.StripTagsRegex(m.Value);
  140. splitting = match.Split(new[] { "MD5: " }, StringSplitOptions.None);
  141. ret = splitting[1];
  142. }
  143. }
  144. catch { }
  145. return ret;
  146. }
  147.  
  148. public string getLink(string response)
  149. {
  150. string ret = "ERROR";
  151. try
  152. {
  153. Regex reg2 = new Regex("http://nodistribute.com/share/.*?(?=\")");
  154. string[] splitting = null;
  155. foreach (Match m in reg2.Matches(response))
  156. {
  157. //string match = HtmlRemoval.StripTagsRegex(m.Value);
  158. //splitting = match.Split(new[] { "Filename: " }, StringSplitOptions.None);
  159. ret = m.Value.Replace("share", "result");
  160. }
  161. }
  162. catch { }
  163. return ret;
  164. }
  165. public WebProxy getProxy()
  166. {
  167. if (prox.Count != 0)
  168. {
  169. int index = r.Next(prox.Count);
  170. string[] proxyport = prox[index].Split(':');
  171. //throw new Exception(proxyport[0]);
  172. return new WebProxy(proxyport[0], Convert.ToInt32(proxyport[1]));
  173. }
  174. return null;
  175. }
  176.  
  177. public List<string> methodHMA()
  178. {
  179. List<string> buffer = new List<string>();
  180. for (int i = 1; i < 3; i++)
  181. {
  182. string html = doRequest("http://www.hidemyass.com/proxy-list/" + i);
  183. foreach (Match tr in new Regex("<tr.*?</tr>", RegexOptions.Singleline).Matches(html))
  184. {
  185. MatchCollection tdCollection = new Regex("<td.*?</td>", RegexOptions.Singleline).Matches(tr.Value);
  186. if (tdCollection.Count > 2 && tdCollection[1].Value.Length > 100)
  187. {
  188. List<string> noneStyle = new List<string>();
  189. string ip = tdCollection[1].Value.Replace("<td><span>", "").Replace("</span></td>", "");
  190. foreach (Match inline in new Regex(@"\..+?\{display:none\}").Matches(ip))
  191. {
  192. noneStyle.Add(inline.Value.Replace(".", "").Replace("{display:none}", ""));
  193. }
  194. ip = new Regex("<style>.*?</style>", RegexOptions.Singleline).Replace(ip, "");
  195. ip = new Regex("<span style=\"display:none\">.+?</span>", RegexOptions.Singleline).Replace(ip, "");
  196. ip = new Regex("<div style=\"display:none\">.+?</div>", RegexOptions.Singleline).Replace(ip, "");
  197. foreach (string s in noneStyle)
  198. {
  199. ip = new Regex("<span class=\"" + s + "\">.+?</span>").Replace(ip, "");
  200. ip = new Regex("<div class=\"" + s + "\">.+?</div>").Replace(ip, "");
  201. }
  202. ip = new Regex("<(span|div).+?>").Replace(ip, "");
  203. ip = new Regex("</(span|div)>").Replace(ip, "");
  204. buffer.Add(ip + ":" + tdCollection[2].Value.Replace("<td>", "").Replace("</td>", "").Replace("\r", "").Replace("\n", ""));
  205. }
  206. }
  207. }
  208. return buffer;
  209. }
  210.  
  211. public string doRequest(string url, string cookie = "PHPSESSID=cvtr5gt9glfcc7d7eqa1svlsl4;")
  212. {
  213. HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
  214. req.Method = "GET";
  215. req.KeepAlive = true;
  216. req.Accept = "*/*";
  217. req.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36";
  218. req.ContentType = "application/x-www-form-urlencoded";
  219. req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
  220. req.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
  221. req.Headers.Add("Accept-Language", "en-US,en;q=0.8");
  222. req.Headers.Add("Cookie", cookie);
  223. req.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
  224. req.Timeout = 5000;
  225. HttpWebResponse res = (HttpWebResponse)req.GetResponse();
  226. StreamReader sr = new StreamReader(res.GetResponseStream());
  227. string pageReturn = sr.ReadToEnd();
  228. return pageReturn;
  229. }
  230. }
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement