Ejemplo n.º 1
0
        static void Main()
        {
            var baseUrl = "http://localhost:12243/";
            var contentType = "application/json";
            var requester = new HttpRequester(baseUrl, contentType);

            // Test album Creation
            Album album = new Album { Producer = "Pesho", Title = "Testov album", ReleaseDate = DateTime.Now };
            requester.Post<Album>("api/album", album);
            Console.WriteLine("Simple Album added!");

            Song song = new Song { Genre = "RnB", Title = "Shake it!", Year = DateTime.Now.AddYears(-20) };
            Artist artist = new Artist { Name = "Pesho Zlia", BirthDate = new DateTime(1950, 1, 1), Country = "Germany" };
            album.Songs.Add(song);
            album.Artists.Add(artist);

            requester.Post<Album>("api/album", album);
            Console.WriteLine("Album added!");

            // Test albums Retrieving
            var retrievedAlbums = requester.Get<IList<Album>>("api/album/");
            foreach (var retrievedAlbum in retrievedAlbums)
            {
                Console.WriteLine("Album found! Title:" + retrievedAlbum.Title);
            }

            // Test one album Retrieving
            var getedAlbum = requester.Get<Album>("api/album/" + retrievedAlbums[0].AlbumId);

            Console.WriteLine("First Album found! Title:" + getedAlbum.Title);

            // Test album updating

            getedAlbum.Title = "Updated Title";
            requester.Put<Album>("api/album/" + getedAlbum.AlbumId, getedAlbum);
            Console.WriteLine("Title updated!");

            // Check new title
            getedAlbum = requester.Get<Album>("api/album/" + retrievedAlbums[0].AlbumId);
            Console.WriteLine("First Album found! Title:" + getedAlbum.Title);

            // Add
            Album newAlbum = new Album { Producer = "Pesho", Title = "Testov album", ReleaseDate = DateTime.Now };

            //Delete the album!
            requester.Delete<Album>("api/album/" + getedAlbum.AlbumId, getedAlbum);
            Console.WriteLine("Album deleted");
        }
Ejemplo n.º 2
0
        public static void Main()
        {
            var baseUrl = "http://localhost:37328/api/";
            var requester = new HttpRequester(baseUrl);

            var newStudent = new Student()
            {
                FirstName = "Vladimir",
                LastName = "Georgiev"
            };

            var createStudentTask = requester.PostAsync<Student>("students", newStudent);
            createStudentTask.GetAwaiter()
                             .OnCompleted(() =>
                             {
                                 Console.WriteLine("Student {0} created!", createStudentTask.Result.FullName);
                                 var students = requester.Get<IEnumerable<Student>>("students");
                                 foreach (var student in students)
                                 {
                                     Console.WriteLine(student.FullName);
                                 }
                             });
            while (true)
            {
                Console.ReadLine();
            }
        }
Ejemplo n.º 3
0
        public override Credencial Run(Camera cam)
        {
            try
            {
                //Try to connect, if we fail, because we do not get a response, the server is unreachable.
                //We wiil receive a JSON response, if it is not a JSON response, we will get an exception.
                var result = HttpRequester.Get(cam.UrlHttp + "/device.rsp?opt=user&cmd=list", new Dictionary<string, string> {{"uid", "admin"}});
                if (result == null)
                {
                    var notReachMsg = string.Format(Phrases.IP_Camera_Is_Not_Reachable, cam.Address, CommonName);
                    throw new ExploituUreachableTargetException(notReachMsg, cam, CommonName);
                }

                //We parse the JSON response to read the fields, if we get an error, is because the cam is not vulnerable, because the response is invalid
                dynamic json = result;
                string username = json.list[0].uid;
                string pass = json.list[0].pwd;
                if (username != null && pass != null)
                    return new Credencial(username, pass);
                
                return null;
            }
            catch (JsonParserErrorException ex)
            {
                //The server responds, but is not a JSON response.
                var error = string.Format("Error on parse JSON in the Cam: {0} for Exploit: {1}, Message: ", cam.Address, CommonName) + ex.Message;
                throw new ExploitFailException(error.Replace("\n", " "), cam, CommonName);
            }
            catch (RuntimeBinderException)
            {
                //The server responds, the JSON files are invalid.
                return null;
            }
        }
Ejemplo n.º 4
0
        static void Main()
        {
            Console.WriteLine("Enter search string:");
            string searched = Console.ReadLine();

            Console.WriteLine("Enter number of articles to show (less than 100):");
            int count = int.Parse(Console.ReadLine());


            string longurl    = "http://api.feedzilla.com/v1/articles/search.json";
            var    uriBuilder = new UriBuilder(longurl);
            var    query      = HttpUtility.ParseQueryString(uriBuilder.Query);

            query["q"]       = searched;
            query["count"]   = count.ToString();
            uriBuilder.Query = query.ToString();
            longurl          = uriBuilder.ToString();

            var requestedObjects = HttpRequester.Get <RequestedObject>(longurl);

            foreach (var article in requestedObjects.articles)
            {
                Console.WriteLine("Title: {0}\nURL: {1}\n\n", article.title, article.url);
            }
        }
Ejemplo n.º 5
0
        public async Task LoadGames()
        {
            _xhrRequester = new HttpRequester("game/get");
            var result = await _xhrRequester.Get <List <KeyValuePair <int, string> > >("", "get");

            cmbGames.ComboBox.ValueMember   = "key";
            cmbGames.ComboBox.DisplayMember = "value";
            cmbGames.ComboBox.DataSource    = result;
            btnLoadGame.PerformClick();
        }
Ejemplo n.º 6
0
        private async void btnLoadGame_Click(object sender, EventArgs e)
        {
            RemoveItems();
            var gameItem = (System.Collections.Generic.KeyValuePair <int, string>)cmbGames.SelectedItem;

            _xhrRequester = new HttpRequester($"game/{gameItem.Key}/map");
            var result = await _xhrRequester.Get <List <GameMap> >("");

            var name = "";

            foreach (var item in result)
            {
                UserControl ctrl;
                switch (item.ControllerType)
                {
                case Enums.ControllerType.VerticalLine:
                    ctrl = new UCVerticalLine();
                    name = "ucVerticalLine_";
                    break;

                case Enums.ControllerType.HorizontalLine:
                    ctrl = new UCHorizontalLine();
                    name = "ucHorizontalLine_";
                    break;

                case Enums.ControllerType.Charactor:
                    ctrl = new UCCharactor();
                    name = "ucChar_";
                    break;

                case Enums.ControllerType.Target:
                    ctrl = new UCTarget();
                    name = "ucTarget_";
                    break;

                default:
                    continue;
                }
                ctrl.Name        = $"{name}{index}";
                ctrl.MouseEnter += control_MouseEnter;
                ctrl.MouseLeave += control_MouseLeave;
                ctrl.MouseDown  += control_MouseDown;
                ctrl.MouseMove  += control_MouseMove;
                ctrl.MouseUp    += control_MouseUp;
                ctrl.KeyDown    += control_keyDown;
                ctrl.MouseClick += CtrlOnMouseClick;
                ctrl.Location    = new Point(item.PointX, item.PointY);
                ctrl.Size        = new Size(item.Width, item.Hight);
                Controls.Add(ctrl);
                index++;
            }
        }
Ejemplo n.º 7
0
        protected async void GetResult()
        {
            StringBuilder url = new StringBuilder();

            url.Append(this.BaseServiceUrl);
            url.Append(this.Amount.ToString());
            url.Append(this.FromCurrency.ToString().ToLower());
            url.Append("=?");
            url.Append(this.ToCurrency.ToString().ToLower());
            var test = await HttpRequester.Get <CurrencyModel>(url.ToString());

            this.Result = test.ToCurrency.ToString();
            this.OnPropertyChanged("Result");
        }
Ejemplo n.º 8
0
        static void Main()
        {
            //Dictionary<string, string> requestMap = new Dictionary<string, string>();
            //requestMap.Add("callback", "Payeezy.callback");
            //requestMap.Add("ta_token", "123");
            //requestMap.Add("auth", "false");
            //requestMap.Add("type", "FDToken");
            //requestMap.Add("credit_card.type", "visa");
            //requestMap.Add("credit_card.cardholder_name", "Kolev Iliya");
            //requestMap.Add("credit_card.card_number", "4788250000028291");
            //requestMap.Add("credit_card.exp_date", "1218");
            //requestMap.Add("credit_card.cvv", "123");
            //// billing address is optional
            //requestMap.Add("billing_address.city", "St.Louis");
            //requestMap.Add("billing_address.country", "US");
            //requestMap.Add("billing_address.email", "*****@*****.**");
            //requestMap.Add("billing_address.phone.type", "home");
            //requestMap.Add("billing_address.phone.number", "212-515-1212");
            //requestMap.Add("billing_address.street", "12115 LACKLAND");
            //requestMap.Add("billing_address.state_province", "MO");
            //requestMap.Add("billing_address.phone.number", "212-515-1212");
            //requestMap.Add("billing_address.zip_postal_code", "63146");

            // this picks the properties from the .payeezy.properties files
            // alternatively you can populate the properties and pass it to the constructor
            //PayeezyClientHelper clientHelper = new PayeezyClientHelper();
            //try
            //{
            //    PayeezyResponse payeezyResponse = clientHelper.doGetTokenCall(requestMap);
            //    Console.WriteLine(payeezyResponse.getResponseBody());
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine(e.StackTrace);
            //}
            var studentsServiceUrl = "https://api-cert.payeezy.com";

            var testUrl = "http://localhost:29863";

            //HttpRequester.Post(studentsServiceUrl + "students", newBook);

            //var card = new Card()
            //{
            //    Id = 1,
            //    Token = "465456464666",
            //    HolderName = "Ivan Ivanov"
            //};


            //var cards = HttpRequester.Get<IEnumerable<Card>>(studentsServiceUrl + "/v1/securitytokens");


            //var values = Hvar values = HttpRequester.Get<ValuesResponse>(testUrl + "/api/values");ttpRequester.Get<ValuesResponse>(testUrl + "/api/values");

            //var values = HttpRequester.Get<ValuesResponse>(testUrl + "/api/values");
            //var newVal = new ValuesResponse() { Name = "NovoJivotno" };
            //var responsePostValue = HttpRequester.Post<string>(testUrl + "/api/values", newVal);
            //Console.WriteLine(responsePostValue);
            ////HttpRequester.Get(testUrl + "/api/values");
            //Console.WriteLine(values.Name);
            //foreach (var item in values)
            //{
            //    Console.WriteLine(item);
            //}



            var values = HttpRequester.Get <Card>("https://api-cert.payeezy.com" + "/v1/securitytokens?apikey=y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a&js_security_key=js-6125e57ce5c46e10087a545b9e9d7354c23e1a1670d9e9c7&ta_token=NOIW&auth=true&callback=Payeezy.callback&type=FDToken&credit_card.type=visa&credit_card.cardholder_name=John%20Smith&credit_card.card_number=4788250000028291&credit_card.exp_date=1030&credit_card.cvv=123");

            Console.WriteLine(values.Status);
            Console.WriteLine(values.Result.Token.Value);


            var newVal = new ValuesResponse()
            {
                Name = "NovoJivotno"
            };

            var data = new Purchase()
            {
                MerchantRef     = "Astonishing-Sale",
                TransactionType = "purchase",
                Method          = "token",
                Amount          = "200",
                CurrencyCode    = "USD",
                Token           = new Token()
                {
                    TokenType = "FDToken",
                    TokenData = new TokenData()
                    {
                        Type           = "visa",
                        Value          = "2537446225198291",
                        CardholderName = "JohnSmith",
                        ExpDate        = "1030"
                    }
                }
            };

            Dictionary <string, string> requestHeaderMap = new Dictionary <string, string>();

            requestHeaderMap.Add(SecurityConstants.APIKEY, "y6pWAJNyJyjGv66IsVuWnklkKUPFbb0a");
            requestHeaderMap.Add(SecurityConstants.TOKEN, "fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6");
            requestHeaderMap.Add(SecurityConstants.AUTHORIZE, "YWI2MjFkMzVhOWVhMTkzZTZlYjExYzYxMGFhZWM1ZWY1NWQ3NDgwNTA1YmNhZTM0ZmNmM2Q1MjkxMzVmNDMzZA");
            requestHeaderMap.Add(SecurityConstants.TIMESTAMP, "1480621081859");

            var responsePostValue = HttpRequester.Post <PurchaseResponse>("https://api-cert.payeezy.com/v1/transactions", data, requestHeaderMap);

            Console.WriteLine(responsePostValue.Method);


            //var jsonHelper = new JSONHelperN<Card>();
            //var sss = jsonHelper.getJSONObject(card);
            //Console.WriteLine(sss);
            //var kkk = jsonHelper.fromJson(sss);
            //Console.WriteLine(kkk.Token);

            //var url = "http://www.abv.bg";
            //HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            //HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            //if (myHttpWebResponse.StatusCode == HttpStatusCode.OK)
            //    Console.WriteLine("\r\nResponse Status Code is OK and StatusDescription is: {0}",
            //                         myHttpWebResponse.StatusDescription);
            //// Releases the resources of the response.
            //Console.WriteLine(myHttpWebResponse.GetResponseStream());
            //Console.WriteLine("-------------------------------------");
            //Console.WriteLine(myHttpWebResponse.GetResponseStream());
            //myHttpWebResponse.Close();
        }