Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Requesterinfo requesterinfo = new Requesterinfo
            {
                contactEmail = "*****@*****.**",
                contactName  = "yourName",
                contactPhone = "yourPhoneNumber"
            };
            Subscriptioninfo subscriptioninfo = new Subscriptioninfo
            {
                subscriptionId         = "yourSubscriptionID ex(00000000-0000-0000-0000-000000000000)",
                subscriptionAdminEmail = "yourSubscriptionAdminEmail"
            };
            Testinfo testinfo = new Testinfo
            {
                startDate       = "PenTest Starting Date",
                endDate         = "PenTest Ending Date",
                testerIps       = new[] { "First IP", "Second IP" },
                testerDnsNames  = new[] { "First DNS Name", "Second DNS Name" },
                testDescription = "Description of PenTest"
            };
            Pentestacks pentestacks = new Pentestacks
            {
                standardTests = true,
                agreeToTerms  = true,
                noProhibTests = true
            };
            Azureasset1 azureasset1 = new Azureasset1
            {
                assetType          = "Azure Asset Type",
                dnsName            = "Azure Asset DNS Name",
                testDescription    = "Description of PenTest",
                toolingDescription = "Description of tools used"
            };
            Azureasset azureasset = new Azureasset
            {
                azureAsset = azureasset1
            };
            PentestReportObject pentestReport = new PentestReportObject
            {
                requesterInfo    = requesterinfo,
                subscriptionInfo = subscriptioninfo,
                testInfo         = testinfo,
                azureAssets      = new[] { azureasset },
                pentestAcks      = pentestacks
            };

            MakeRequest(pentestReport).GetAwaiter().GetResult();
            Console.WriteLine("Hit ENTER to exit...");
            Console.ReadLine();
        }
Exemplo n.º 2
0
        static async Task MakeRequest(PentestReportObject pentestReport)
        {
            var client      = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("api-key", "62767bad6f034eaabde3ffa2c455bce7");

            var uri = "https://api.msrc.microsoft.com/engage/pentest?" + queryString;

            HttpResponseMessage response;

            // Request body
            string str = JsonConvert.SerializeObject(pentestReport);

            using (var content = new StringContent(str))
            {
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                response = await client.PostAsync(uri, content);
            }
        }