Advertisement
Guest User

PSN ACC creator enjoy

a guest
Jan 16th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Net;
  4. using Newtonsoft.Json;
  5. using System.Threading.Tasks;
  6. using System.Text;
  7. using System.Net.Http;
  8. using System.Net.Http.Headers;
  9.  
  10. namespace SuccADick
  11. {
  12.     class Playstation
  13.     {
  14.         #region New Method
  15.         #region General Declarations
  16.         private Database Database = new Database();
  17.         private HttpClientHandler handler;
  18.         private List<ProxyList> ProxyList = new List<ProxyList>();
  19.         private TimeSpan timeOut = new TimeSpan(0, 0, 30);
  20.         public static List<psStatus> StaticStatus = new List<psStatus>();
  21.         private string userId = "";
  22.         #endregion
  23.         #region Sony Uri's
  24.         private Uri accessTokenUri = new Uri("https://auth.api.sonyentertainmentnetwork.com/2.0/oauth/token");
  25.         private Uri onlineIdUri = new Uri("https://accounts.api.playstation.com/api/v1/accounts/onlineIds");
  26.         private Uri accountCreationUri = new Uri("https://accounts.api.playstation.com/api/v1/s2s/accounts");
  27.         private Uri sonyMessageUri = new Uri("https://us-gmsg.np.community.playstation.net/groupMessaging/v1/messageGroups");
  28.         #endregion
  29.         #region Sony Account Creation Classes
  30.         private class CommunicationName
  31.         {
  32.             public string first { get; set; }
  33.             public string last { get; set; }
  34.         }
  35.         private class Address
  36.         {
  37.             public string qualifier { get; set; }
  38.             public string city { get; set; }
  39.             public string countrySubdivision { get; set; }
  40.             public string postalCode { get; set; }
  41.         }
  42.         private class EmailAddress
  43.         {
  44.             public string address { get; set; }
  45.         }
  46.         private class CommunicationPreferences
  47.         {
  48.             public List<AvailableNotification> availableNotifications { get; set; }
  49.         }
  50.         private class AvailableNotification
  51.         {
  52.             public string code { get; set; }
  53.             public bool optedIn { get; set; }
  54.         }
  55.         private class SonyPostData
  56.         {
  57.             public CommunicationName communicationName { get; set; }
  58.             public List<Address> addresses { get; set; }
  59.             public List<EmailAddress> emailAddresses { get; set; }
  60.             public string language { get; set; }
  61.             public string legalCountry { get; set; }
  62.             public string dateOfBirth { get; set; }
  63.             public string onlineId { get; set; }
  64.             public string signinId { get; set; }
  65.             public string password { get; set; }
  66.             public string onlineIdReservation { get; set; }
  67.             public int toSUAVersion { get; set; }
  68.             public CommunicationPreferences communicationPreferences { get; set; }
  69.         }
  70.         #endregion
  71.         #region Sony Reserve Online Id Class
  72.         private class ReserveOnlineId
  73.         {
  74.             public string onlineId { get; set; }
  75.             public bool reserveIfAvailable { get; set; }
  76.         }
  77.         #endregion
  78.         #region General Post Data
  79.         private Dictionary<string, string> accessTokenPostData = new Dictionary<string, string>()
  80.         {
  81.             { "grant_type", "captcha" },
  82.             { "captcha_provider", "google:recaptcha-v2" },
  83.             { "scope", "user:account.create" },
  84.             { "valid_for", null },
  85.             { "client_id", "7e309afa-8d09-40d2-8e24-5029642f2c3c" },
  86.             { "client_secret", "8aCv07DXTHJ1T2nA" },
  87.             { "response_token", null },
  88.         };
  89.         private SonyPostData createAccountPostData = new SonyPostData
  90.         {
  91.             communicationName = new CommunicationName
  92.             {
  93.                 first = "Succ",
  94.                 last = "Fucc"
  95.             },
  96.             addresses = new List<Address>()
  97.                 {
  98.                     new Address
  99.                     {
  100.                         qualifier = "residence",
  101.                         city = "Los Angeles",
  102.                         countrySubdivision = "CA",
  103.                         postalCode = "90017"
  104.                     }
  105.                 },
  106.             emailAddresses = new List<EmailAddress>(),
  107.             language = "en-US",
  108.             legalCountry = "US",
  109.             dateOfBirth = "1990-1-1",
  110.             onlineId = null,
  111.             signinId = null,
  112.             password = null,
  113.             onlineIdReservation = null,
  114.             toSUAVersion = 6,
  115.             communicationPreferences = new CommunicationPreferences
  116.             {
  117.                 availableNotifications = new List<AvailableNotification>()
  118.                     {
  119.                         new AvailableNotification
  120.                         {
  121.                             code = "sonyCommunications",
  122.                             optedIn = false
  123.                         },
  124.                         new AvailableNotification
  125.                         {
  126.                             code = "partnerCommunications",
  127.                             optedIn = false
  128.                         }
  129.                     }
  130.             }
  131.         };
  132.         private ReserveOnlineId reserverOnlineIdPostData = new ReserveOnlineId()
  133.         {
  134.             onlineId = null,
  135.             reserveIfAvailable = true
  136.         };
  137.         #endregion
  138.         private async Task<bool> checkForIPBan()
  139.         {
  140.             try
  141.             {
  142.                 int randomProxy = Security.random.Next(ProxyList.Count);
  143.  
  144.                 if (Global.useProxyPSN)
  145.                     handler = new HttpClientHandler() { UseProxy = true, Proxy = new WebProxy($"{ProxyList[randomProxy].IP}:{ProxyList[randomProxy].Port}", false), CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
  146.                 else
  147.                     handler = new HttpClientHandler() { CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
  148.  
  149.                 using (HttpClient client = new HttpClient(handler) { Timeout = timeOut })
  150.                 using (HttpRequestMessage retrieveReservationToken = new HttpRequestMessage() { Method = HttpMethod.Get, RequestUri = onlineIdUri })
  151.                 {
  152.                     HttpResponseMessage Response = await client.SendAsync(retrieveReservationToken);
  153.                     string ResponseString = await Response.Content.ReadAsStringAsync();
  154.                     if (Response.StatusCode == HttpStatusCode.Forbidden)
  155.                         return true;
  156.                     else
  157.                         return false;
  158.                 }
  159.             }
  160.             catch (Exception ex)
  161.             {
  162.                 return true;
  163.             }
  164.         }
  165.         private async Task<string> reserveOnlineId(string onlineId)
  166.         {
  167.             try
  168.             {
  169.                 int randomProxy = Security.random.Next(ProxyList.Count);
  170.  
  171.                 if (Global.useProxyPSN)
  172.                     handler = new HttpClientHandler() { UseProxy = true, Proxy = new WebProxy($"{ProxyList[randomProxy].IP}:{ProxyList[randomProxy].Port}", false), CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
  173.                 else
  174.                     handler = new HttpClientHandler() { CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
  175.  
  176.                 using (HttpClient client = new HttpClient(handler) { Timeout = timeOut })
  177.                 using (HttpRequestMessage retrieveReservationToken = new HttpRequestMessage() { Method = HttpMethod.Post, RequestUri = onlineIdUri, Content = new StringContent(JsonConvert.SerializeObject(new ReserveOnlineId() { onlineId = onlineId, reserveIfAvailable = true }), Encoding.UTF8, "application/json") })
  178.                 {
  179.                     HttpResponseMessage Response = await client.SendAsync(retrieveReservationToken);
  180.                     string ResponseString = await Response.Content.ReadAsStringAsync();
  181.                     if (Response.StatusCode == HttpStatusCode.Created)
  182.                     {
  183.                         dynamic JsonConverter = JsonConvert.DeserializeObject(ResponseString);
  184.                         string resvToken = JsonConverter.reservationId;
  185.                         string resvExp = JsonConverter.expirationDate;
  186.                         Database.addReservedPSID(userId, onlineId, resvToken, resvExp);
  187.                         return resvToken;
  188.                     }
  189.                     else if (Response.StatusCode == HttpStatusCode.Forbidden)
  190.                         return "ip";
  191.                     else
  192.                         return null;
  193.                 }
  194.             }
  195.             catch (Exception ex)
  196.             {
  197.                 return "error";
  198.             }
  199.         }
  200.         private async Task<string> retrieveSonyAccessToken(string Email, string Captcha)
  201.         {
  202.             try
  203.             {
  204.                 accessTokenPostData["valid_for"] = Email;
  205.                 accessTokenPostData["response_token"] = Captcha;
  206.  
  207.                 int randomProxy = Security.random.Next(ProxyList.Count);
  208.  
  209.                 if (Global.useProxyPSN)
  210.                     handler = new HttpClientHandler() { UseProxy = true, Proxy = new WebProxy($"{ProxyList[randomProxy].IP}:{ProxyList[randomProxy].Port}", false), CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
  211.                 else
  212.                     handler = new HttpClientHandler() { CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
  213.  
  214.                 using (HttpClient client = new HttpClient(handler) { Timeout = timeOut })
  215.                 using (HttpRequestMessage retrieveAccessToken = new HttpRequestMessage() { Method = HttpMethod.Post, RequestUri = accessTokenUri, Content = new FormUrlEncodedContent(accessTokenPostData) })
  216.                 {
  217.                     HttpResponseMessage Response = await client.SendAsync(retrieveAccessToken);
  218.                     string ResponseString = await Response.Content.ReadAsStringAsync();
  219.                     if (Response.StatusCode == HttpStatusCode.OK)
  220.                     {
  221.                         dynamic JsonConverter = JsonConvert.DeserializeObject(ResponseString);
  222.                         string accessToken = JsonConverter.access_token;
  223.                         return accessToken;
  224.                     }
  225.                     else if (Response.StatusCode == HttpStatusCode.Forbidden)
  226.                         return "ip";
  227.                     else
  228.                         return null;
  229.                 }
  230.             }
  231.             catch (Exception ex)
  232.             {
  233.                 return "error";
  234.             }
  235.         }
  236.         public async void createPlaystationAccount(string UserID, string onlineId, string Email, string Password)
  237.         {
  238.             StaticStatus.Add(new psStatus { userId = UserID });
  239.             var Status = StaticStatus.Find(x => x.userId == UserID);
  240.             var startTime = DateTime.UtcNow;
  241.             userId = UserID;
  242.             try
  243.             {
  244.                 ProxyList.Clear();
  245.                 ProxyList = Database.FillProxyList();
  246.  
  247.                 Status.taskPercentage = 20;
  248.                 Status.taskStatus = "Checking proxy";
  249.                 if (await checkForIPBan())
  250.                 {
  251.                     Status.taskPercentage = 100;
  252.                     Status.taskStatus = $"Current proxy IP is banned it will rotate in about 3 minutes try again then.";
  253.                 }
  254.  
  255.                 Status.taskPercentage = 40;
  256.                 Status.taskStatus = "Reserving Online ID";
  257.                 string onlineIdReservationToken = Database.retrieveReservedPSIDResvToken(userId, onlineId);
  258.  
  259.                 if (onlineIdReservationToken == "")
  260.                 {
  261.                     onlineIdReservationToken = await reserveOnlineId(onlineId);
  262.                     int onlineIdRetry = 0;
  263.                     if (onlineIdReservationToken == null || onlineIdReservationToken == string.Empty)
  264.                     {
  265.                         Status.taskPercentage = 100;
  266.                         Status.taskStatus = $"Could not reserve Online Id it's already in use or reserved";
  267.                         return;
  268.                     }
  269.                     if(onlineIdReservationToken == "ip")
  270.                     {
  271.                         Status.taskPercentage = 100;
  272.                         Status.taskStatus = $"Possible IP ban please wait 5 minutes for the proxy to rotate";
  273.                         return;
  274.                     }
  275.                     while (onlineIdReservationToken == "error" || onlineIdRetry > 3)
  276.                     {
  277.                         Status.taskStatus = $"Reserving Online ID - Retry attempt {onlineIdRetry} / 3";
  278.                         onlineIdReservationToken = await reserveOnlineId(onlineId);
  279.                         onlineIdRetry++;
  280.                     }
  281.                     if (onlineIdReservationToken == "error")
  282.                     {
  283.                         Status.taskPercentage = 100;
  284.                         Status.taskStatus = $"Could not reserve Online Id";
  285.                         return;
  286.                     }
  287.                 }
  288.  
  289.                 Status.taskPercentage = 50;
  290.                 Status.taskStatus = "Retrieiving Captcha";
  291.                 string Captcha = await Security.solveCaptcha();
  292.  
  293.                 Status.taskPercentage = 70;
  294.                 Status.taskStatus = "Retrieving Access Token";
  295.                 string accessToken = await retrieveSonyAccessToken(Email, Captcha);
  296.                 int accessRetry = 0;
  297.                 if (accessToken == null)
  298.                 {
  299.                     Status.taskPercentage = 100;
  300.                     Status.taskStatus = $"Could not retrieve access token, possible IP ban try again in 5 minutes when IP rotates";
  301.                     return;
  302.                 }
  303.                 while (accessToken == "error" || accessRetry > 3)
  304.                 {
  305.                     Status.taskStatus = $"Retrieving Access Token - Retry attempt {accessRetry} / 3";
  306.                     accessToken = await retrieveSonyAccessToken(Email, Captcha);
  307.                     accessRetry++;
  308.                 }
  309.                 if (accessToken == "ip")
  310.                 {
  311.                     Status.taskPercentage = 100;
  312.                     Status.taskStatus = $"Possible IP ban please wait 5 minutes for the proxy to rotate";
  313.                     return;
  314.                 }
  315.                 if (accessToken == "error")
  316.                 {
  317.                     Status.taskPercentage = 100;
  318.                     Status.taskStatus = $"Could not retrieve access token, try again later";
  319.                     return;
  320.                 }
  321.  
  322.                 createAccountPostData.onlineId = onlineId;
  323.                 createAccountPostData.onlineIdReservation = onlineIdReservationToken;
  324.                 createAccountPostData.signinId = Email;
  325.                 createAccountPostData.emailAddresses.Add(new EmailAddress { address = Email });
  326.                 createAccountPostData.password = Password;
  327.  
  328.                 int randomProxy = Security.random.Next(ProxyList.Count);
  329.  
  330.                 if (Global.useProxyPSN)
  331.                     handler = new HttpClientHandler() { UseProxy = true, Proxy = new WebProxy($"{ProxyList[randomProxy].IP}:{ProxyList[randomProxy].Port}", false), CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
  332.                 else
  333.                     handler = new HttpClientHandler() { CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
  334.  
  335.                 using (HttpClient client = new HttpClient(handler) { Timeout = timeOut })
  336.                 using (HttpRequestMessage createPlaystationAccount = new HttpRequestMessage() { Method = HttpMethod.Post, RequestUri = accountCreationUri, Content = new StringContent(JsonConvert.SerializeObject(createAccountPostData), Encoding.UTF8, "application/json") })
  337.                 {
  338.                     Status.taskPercentage = 90;
  339.                     Status.taskStatus = "Creating playstation account";
  340.                     createPlaystationAccount.Headers.Add("Authorization", $"Bearer {accessToken}");
  341.                     HttpResponseMessage Response = await client.SendAsync(createPlaystationAccount);
  342.                     string ResponseString = await Response.Content.ReadAsStringAsync();
  343.                     if (Response.StatusCode == HttpStatusCode.Created)
  344.                     {
  345.                         var seconds = Math.Round((DateTime.UtcNow - startTime).TotalSeconds, 2);
  346.                         Database.addNewPSNAccount(userId, onlineId, Email, Password, string.Format("{0:M/d/yyyy - HH:mm:ss tt} UTC", DateTime.UtcNow), seconds.ToString());
  347.                         Status.taskPercentage = 100;
  348.                         Status.taskStatus = $"Playstation account: {onlineId} successfully created";
  349.                         Database.removeReservedPSID(onlineIdReservationToken);
  350.                         return;
  351.                     }
  352.                     else
  353.                     {
  354.                         Status.taskPercentage = 100;
  355.                         Status.taskStatus = $"Playstation account: {onlineId} failed to create, remember the password cannot be similar to the Online ID if this persists wait 5 - 10 minutes";
  356.                         return;
  357.                     }
  358.                 }
  359.             }
  360.             catch (Exception ex)
  361.             {
  362.                 Status.taskPercentage = 100;
  363.                 Status.taskStatus = $"Playstation account: {onlineId} failed to create, please try again if this persists wait 5 - 10 minutes";
  364.                 return;
  365.             }
  366.         }
  367.         public async Task SendPSNMessage(psBomberAccountList bomb, string Recipient, string Message)
  368.         {
  369.             ProxyList.Clear();
  370.             ProxyList = Database.FillProxyList();
  371.             Random r = new Random();
  372.             int rn = r.Next(ProxyList.Count);
  373.             try
  374.             {
  375.                 List<string> recpients = new List<string>() { Recipient };
  376.                 Message messageContent = new Message(recpients, Message);
  377.                 MessageRequest messageRequest = new MessageRequest(messageContent.UsersToInvite, new MessageData(messageContent.MessageText, 1));
  378.                 var message = messageRequest.BuildTextMessage();
  379.  
  380.                 using (HttpClientHandler handler = new HttpClientHandler() { UseProxy = true, Proxy = new WebProxy($"{ProxyList[rn].IP}:{ProxyList[rn].Port}"), CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate })
  381.                 using (HttpClient client = new HttpClient(handler))
  382.                 using (HttpRequestMessage request = new HttpRequestMessage() { Method = HttpMethod.Post, RequestUri = sonyMessageUri, Content = message })
  383.                 {
  384.                     client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bomb.Oauth);
  385.                     var response = await client.SendAsync(request);
  386.                     var responseString = await response.Content.ReadAsStringAsync();
  387.                     dynamic Json = JsonConvert.DeserializeObject(responseString);
  388.                     //if (Json.sentMessageId == null || Json.error != null)
  389.                     //    return Tuple.Create(false, responseString);
  390.                     //return Tuple.Create(true, responseString);
  391.                 }
  392.             }
  393.             catch (Exception ex) { }
  394.         }
  395.         public class psStatus
  396.         {
  397.             public string userId { get; set; }
  398.             public int taskPercentage { get; set; }
  399.             public string taskStatus { get; set; }
  400.         }
  401.         #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement