· 8 years ago · Jul 12, 2017, 10:26 PM
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text.RegularExpressions;
5
6using System.Net;
7using System.Net.Http;
8using System.Text;
9using System.Threading.Tasks;
10using System.IO;
11
12
13namespace 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/*
270using System;
271using System.Net;
272using System.Net.Http;
273using System.Collections.Generic;
274using System.Linq;
275using System.Text;
276using System.Threading.Tasks;
277using System.IO;
278Â
279namespace 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*/