Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. using System.Net;
  7. using System.Net.Http;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.IO;
  11.  
  12.  
  13. namespace Rextester
  14. {
  15. public class Program
  16. {
  17. //------------------------------------------------------------------------------------------------------------------------------------Collection Finder
  18. static void CollectionFinder(string accessKey, string secretKey)
  19. {
  20. string URL = "https://visagecloud.com/rest/v1.1/collection/all?" + "accessKey=" + accessKey + "&secretKey=" + secretKey;
  21. HttpWebRequest WebReq =
  22. (HttpWebRequest)WebRequest.Create(URL);
  23.  
  24. WebReq.Method = "GET";
  25. WebReq.ContentType = "application/json";
  26. Console.WriteLine("looking for collections");
  27. //WebReq.ContentLength = buffer.Length;
  28.  
  29.  
  30. //HttpWebResponse response = (HttpWebResponse)WebReq.GetResponse();
  31. //Stream stream = response.GetResponseStream(); <----------------We tried this, but no luck
  32. //StreamReader myreader = new StreamReader(stream);
  33. //Stream PostData = WebReq.GetRequestStream(); //<=========================== Cannot send a content-body with this verb-type
  34. //PostData.Write(buffer, 0, buffer.Length);
  35. //PostData.Close();
  36. //HttpWebResponse WebResp = null;
  37.  
  38.  
  39.  
  40. try
  41. {
  42.  
  43.  
  44.  
  45. var WebResp = (HttpWebResponse)WebReq.GetResponse();
  46. //Let's show some information about the response
  47. Console.WriteLine(WebResp.StatusCode);
  48. Console.WriteLine(WebResp.Server);
  49. using (var mystream = WebResp.GetResponseStream())
  50. {
  51. //Stream Answer = WebResp.GetResponseStream();
  52. using (var RDR = new StreamReader(mystream))
  53. {
  54. Console.WriteLine(RDR.ReadToEnd());
  55. }
  56. }
  57.  
  58. //Now, we read the response (the string), and output it.
  59.  
  60. //string[] lines = new[] { _Answer.ReadToEnd() };
  61. //System.IO.File.WriteAllLines(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\Cdefault.txt", lines);
  62.  
  63. //StreamReader reader = File.OpenText(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\Cdefault.txt");
  64.  
  65.  
  66. }
  67. catch (WebException webex)
  68. {
  69. WebResponse errResp = webex.Response;
  70. using (Stream respStream = errResp.GetResponseStream())
  71. {
  72. StreamReader reader = new StreamReader(respStream);
  73. string text = reader.ReadToEnd();
  74. Console.WriteLine(text);
  75. }
  76. }
  77.  
  78. }
  79. //---------------------------------------------------------------------------------------------------------------------------------- Collection Maker
  80. static void CollectionMaker(string accessKey, string secretKey)
  81. {
  82. string userCollection;
  83. Console.WriteLine("Please enter a collection name");
  84. userCollection = Console.ReadLine();
  85.  
  86. byte[] buffer = Encoding.ASCII.GetBytes("accessKey=" + accessKey + "&secretKey=" + secretKey + "&collectionName=" + userCollection);
  87. HttpWebRequest WebReq =
  88. (HttpWebRequest)WebRequest.Create("https://visagecloud.com/rest/v1.1/collection/collection");
  89. WebReq.Method = "POST";
  90. WebReq.ContentType = "application/x-www-form-urlencoded";
  91. Console.WriteLine("creating collection named " + userCollection);
  92. WebReq.ContentLength = buffer.Length;
  93. Stream PostData = WebReq.GetRequestStream();
  94. PostData.Write(buffer, 0, buffer.Length);
  95. PostData.Close();
  96. HttpWebResponse WebResp = null;
  97. if (!File.Exists(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\Cdefault.txt"))
  98. {
  99. var CdefaultTxt = File.Create(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\Cdefault.txt");
  100. CdefaultTxt.Close();
  101. }
  102.  
  103.  
  104. try
  105. {
  106.  
  107. WebResp = (HttpWebResponse)WebReq.GetResponse();
  108. //Let's show some information about the response
  109. Console.WriteLine(WebResp.StatusCode);
  110. Console.WriteLine(WebResp.Server);
  111. Console.WriteLine(WebResp.GetResponseStream());
  112.  
  113. //Now, we read the response (the string), and output it.
  114. Stream Answer = WebResp.GetResponseStream();
  115. StreamReader _Answer = new StreamReader(Answer);
  116.  
  117. string[] lines = new[] { _Answer.ReadToEnd() };
  118. System.IO.File.WriteAllLines(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\Cdefault.txt", lines);
  119.  
  120. StreamReader reader = File.OpenText(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\Cdefault.txt");
  121.  
  122.  
  123. }
  124. catch (WebException webex)
  125. {
  126. WebResponse errResp = webex.Response;
  127. using (Stream respStream = errResp.GetResponseStream())
  128. {
  129. StreamReader reader = new StreamReader(respStream);
  130. string text = reader.ReadToEnd();
  131. Console.WriteLine(text);
  132. }
  133. }
  134.  
  135. }
  136. //-------------------------------------------------------------------------------------------------------------------------------------------------------------------Face hash finder
  137. static void FaceHashFinder(string accessKey, string secretKey)
  138.             {
  139. //Our postvars
  140. string URL = "https%3A%2F%2Fscontent-amt2-1.xx.fbcdn.net%2Fv%2Ft1.0-9%2F19511355_10209597279392017_7285589497372752431_n.jpg%3Foh%3D800858c4be404d03d33e5425d469369c%26oe%3D59D47AEC";
  141.  
  142.  
  143. byte[] buffer = Encoding.ASCII.GetBytes("accessKey=" + accessKey + "&secretKey=" + secretKey + "&pictureURL=" + URL);
  144.             //Initialization, we use localhost, change if applicable
  145.             HttpWebRequest WebReq =
  146. (HttpWebRequest)WebRequest.Create("https://visagecloud.com/rest/v1.1/analysis/detection");
  147.             //Our method is post, otherwise the buffer (postvars) would be useless
  148.             WebReq.Method = "POST";
  149.             //We use form contentType, for the postvars.
  150.             WebReq.ContentType = "application/x-www-form-urlencoded";
  151. Console.WriteLine("end here plox");
  152.             //The length of the buffer (postvars) is used as contentlength.
  153.             WebReq.ContentLength = buffer.Length;
  154.             //We open a stream for writing the postvars
  155.             Stream PostData = WebReq.GetRequestStream();
  156.             //Now we write, and afterwards, we close. Closing is always important!
  157.             PostData.Write(buffer, 0, buffer.Length);
  158. PostData.Close();
  159.             //Get the response handle, we have no true response yet!
  160.             HttpWebResponse WebResp = null;
  161. try
  162. {
  163.  
  164. WebResp = (HttpWebResponse)WebReq.GetResponse();
  165. //Let's show some information about the response
  166. Console.WriteLine(WebResp.StatusCode);
  167. Console.WriteLine(WebResp.Server);
  168. Console.WriteLine(WebResp.GetResponseStream());
  169.  
  170. //Now, we read the response (the string), and output it.
  171. Stream Answer = WebResp.GetResponseStream();
  172. StreamReader _Answer = new StreamReader(Answer);
  173. //Console.WriteLine(_Answer.ReadToEnd());
  174. //-----------------------------------------------------------------------------------------------
  175.  
  176. //FILE CREATION AND CHECKS
  177.  
  178. if(!File.Exists(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\default.txt"))
  179. {
  180. var defaultTxt = File.Create(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\default.txt");
  181. defaultTxt.Close();
  182. }
  183.  
  184. if (!File.Exists(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\hash.txt"))
  185. {
  186. var hashTxt = File.Create(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\hash.txt");
  187. hashTxt.Close();
  188. }
  189.  
  190.  
  191.  
  192.  
  193. //makes system wait for 2 seconds
  194. Console.WriteLine("Waiting for 2 seconds");
  195. System.Threading.Thread.Sleep(2000);
  196.  
  197. //-----------------------------------------------------------------------------------------------------
  198. string[] lines = new[] { _Answer.ReadToEnd() };
  199. System.IO.File.WriteAllLines(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\default.txt", lines);
  200.  
  201. StreamReader reader = File.OpenText(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\default.txt");
  202. string readerLine;
  203. int val;
  204. string hash = "poop";
  205. while ((readerLine = reader.ReadLine()) != null)
  206. {
  207. val = readerLine.IndexOf("hash\":\"");
  208. hash = readerLine.Substring(val + 7, 64);
  209. }
  210. string[] cHash = new[] { hash };
  211. System.IO.File.WriteAllLines(@"C:\Users\coled\Desktop\DrowningFlounderv0.1\hash.txt", cHash);
  212. //-----------------------------------------------------------------------------------------------
  213. Console.WriteLine("end of code");
  214.  
  215. }
  216.  
  217. catch (WebException webex)
  218. {
  219. WebResponse errResp = webex.Response;
  220. using (Stream respStream = errResp.GetResponseStream())
  221. {
  222. StreamReader reader = new StreamReader(respStream);
  223. string text = reader.ReadToEnd();
  224. Console.WriteLine(text);
  225. }
  226. }
  227. return;
  228.             } //----------------End of Function "FaceHashFinder"----------------------//
  229.  
  230. //-------------------------------------------------------------------------------------------------------------------------------------Main
  231.            
  232. public static void Main(string[] args)
  233. {
  234. string accessKey = "5ho8s6ukulohb5ermcl08ibgj2i4rph9ukjsteb8afuc2dia";
  235. string secretKey = "tjhjjkbqeo743smsgqc59k2gsl1j0icb4itriuk28opo20fm9vac9ck5cbu71st5b93gk44pitg6g4i2erhtaedau6d4unno";
  236. string CollUserInput;
  237. Program.CollectionFinder(accessKey, secretKey);
  238. // calling for program FaceHashFinder
  239. //Program first = new Program();
  240. do
  241. {
  242.  
  243. Console.WriteLine("Using Collection Cole");
  244. Console.WriteLine("Collection ID: 2ajjmstnj3io4srt0eolrka52lvihbgsumndudulngj8i2dvcf75b186je6q95t5");
  245. CollUserInput = Console.ReadLine();
  246. Console.WriteLine(CollUserInput);
  247. } while (!CollUserInput.Equals("Y") && !CollUserInput.Equals("N"));
  248.  
  249. if (CollUserInput == "Y")
  250. {
  251. Console.WriteLine("creating collection");
  252. //Program.CollectionMaker(accessKey, secretKey);
  253. }
  254. else if (CollUserInput == "N")
  255. {
  256. Console.WriteLine("Fine, fuck you then.");
  257. }
  258. Program.FaceHashFinder(accessKey, secretKey);
  259. Console.WriteLine("end of main");
  260.  
  261.  
  262. }
  263. }
  264. }
  265.  
  266.  
  267.  
  268.  
  269. /*
  270. using System;
  271. using System.Net;
  272. using System.Net.Http;
  273. using System.Collections.Generic;
  274. using System.Linq;
  275. using System.Text;
  276. using System.Threading.Tasks;
  277. using System.IO;
  278.  
  279. namespace ConsoleApplication1
  280. {
  281.     class Program
  282.     {
  283.         static void Main(string[] args)
  284.         {
  285.             //Our postvars
  286.             byte[] buffer = Encoding.ASCII.GetBytes("faceHash=5738de51cb8325c385dd41e0eb169adcca9498dbb68bb33e4592f4a6795f15eb&accessKey=5ho8s6ukulohb5ermcl08ibgj2i4rph9ukjsteb8afuc2dia&secretKey=tjhjjkbqeo743smsgqc59k2gsl1j0icb4itriuk28opo20fm9vac9ck5cbu71st5b93gk44pitg6g4i2erhtaedau6d4unno&collectionId=ulqemhvcf0c6is65p9h0lsmtprc8nl83d6411o075td1cetaidt3a8urmbtvcr3j&profileId=opu12q8sjgvib9pe3g0fanh73ohietjdgltn1t6j76kvfuv8je5an14ai9a05gtg&=");
  287.             //Initialization, we use localhost, change if applicable
  288.             HttpWebRequest WebReq =
  289.             (HttpWebRequest)WebRequest.Create("https://visagecloud.com/rest/v1.1/profile/map");
  290.             //Our method is post, otherwise the buffer (postvars) would be useless
  291.             WebReq.Method = "POST";
  292.             //We use form contentType, for the postvars.
  293.             WebReq.ContentType = "application/x-www-form-urlencoded";
  294.             Console.WriteLine("end here plox");
  295.             //The length of the buffer (postvars) is used as contentlength.
  296.             WebReq.ContentLength = buffer.Length;
  297.             //We open a stream for writing the postvars
  298.             Stream PostData = WebReq.GetRequestStream();
  299.             //Now we write, and afterwards, we close. Closing is always important!
  300.             PostData.Write(buffer, 0, buffer.Length);
  301.             PostData.Close();
  302.             //Get the response handle, we have no true response yet!
  303.             HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();
  304.             //Let's show some information about the response
  305.             Console.WriteLine(WebResp.StatusCode);
  306.             Console.WriteLine(WebResp.Server);
  307.  
  308.             //Now, we read the response (the string), and output it.
  309.             Stream Answer = WebResp.GetResponseStream();
  310.             StreamReader _Answer = new StreamReader(Answer);
  311.             Console.WriteLine(_Answer.ReadToEnd());
  312.             Console.WriteLine("end of code");
  313.             //Congratulations, you just requested your first POST page, you
  314.             //can now start logging into most login forms, with your application
  315.             //Or other examples.
  316.         }
  317.     }
  318. }
  319. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement