Advertisement
kolya5544

Untitled

Dec 11th, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Net.Http;
  6. using System.Net.Http.Headers;
  7. using System.Text;
  8.  
  9. namespace Test1111
  10. {
  11.     class Program
  12.     {
  13.         public static string key = "";
  14.         public static async System.Threading.Tasks.Task ReportAsync(string hostname, string comment, bool hacking, bool brute, bool webapp_h, bool scanning, bool ddos)
  15.         {
  16.  
  17.             string bad = "";
  18.             if (hacking)
  19.             {
  20.                 bad += "15,";
  21.             }
  22.             if (brute)
  23.             {
  24.                 bad += "18,5,";
  25.             }
  26.             if (webapp_h)
  27.             {
  28.                 bad += "21,";
  29.             }
  30.             if (scanning)
  31.             {
  32.                 bad += "14,";
  33.             }
  34.             if (ddos)
  35.             {
  36.                 bad += "4,";
  37.             }
  38.             bad = bad.Substring(0, bad.Length - 1);
  39.             try
  40.             {
  41.                 using (var httpClient = new HttpClient())
  42.                 {
  43.                     using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.abuseipdb.com/api/v2/report"))
  44.                     {
  45.                         request.Headers.TryAddWithoutValidation("Key", key);
  46.                         request.Headers.TryAddWithoutValidation("Accept", "application/json");
  47.  
  48.                         var contentList = new List<string>();
  49.                         contentList.Add($"ip={Uri.EscapeDataString(hostname)}");
  50.                         contentList.Add("categories=" + bad);
  51.                         contentList.Add($"comment={Uri.EscapeDataString(comment)}");
  52.                         request.Content = new StringContent(string.Join("&", contentList));
  53.                         request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
  54.                         Console.WriteLine("=== REPORTING IP.... " + hostname);
  55.                         var response = await httpClient.SendAsync(request);
  56.                         if (response.StatusCode == HttpStatusCode.OK)
  57.                         {
  58.                             Console.WriteLine("=== REPORTED IP " + hostname);
  59.                         }
  60.                         else
  61.                         {
  62.                             Console.WriteLine("=== ERROR WHILE REPORTING: " + response.StatusCode.ToString());
  63.                             Console.WriteLine("=== " + response.Content.ToString());
  64.                         }
  65.                     }
  66.                 }
  67.             }
  68.             catch (Exception e)
  69.             {
  70.                 Console.WriteLine(e.StackTrace);
  71.             }
  72.         }
  73.         static void Main(string[] args)
  74.         {
  75.             var a = ReportAsync("127.0.0.1", "IP Spoofing attempt using CONNECT/GET requests", true, false, true, false, false);
  76.             Console.ReadLine();
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement