Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Net;
- using Newtonsoft.Json;
- using System.Threading.Tasks;
- using System.Text;
- using System.Net.Http;
- using System.Net.Http.Headers;
- namespace SuccADick
- {
- class Playstation
- {
- #region New Method
- #region General Declarations
- private Database Database = new Database();
- private HttpClientHandler handler;
- private List<ProxyList> ProxyList = new List<ProxyList>();
- private TimeSpan timeOut = new TimeSpan(0, 0, 30);
- public static List<psStatus> StaticStatus = new List<psStatus>();
- private string userId = "";
- #endregion
- #region Sony Uri's
- private Uri accessTokenUri = new Uri("https://auth.api.sonyentertainmentnetwork.com/2.0/oauth/token");
- private Uri onlineIdUri = new Uri("https://accounts.api.playstation.com/api/v1/accounts/onlineIds");
- private Uri accountCreationUri = new Uri("https://accounts.api.playstation.com/api/v1/s2s/accounts");
- private Uri sonyMessageUri = new Uri("https://us-gmsg.np.community.playstation.net/groupMessaging/v1/messageGroups");
- #endregion
- #region Sony Account Creation Classes
- private class CommunicationName
- {
- public string first { get; set; }
- public string last { get; set; }
- }
- private class Address
- {
- public string qualifier { get; set; }
- public string city { get; set; }
- public string countrySubdivision { get; set; }
- public string postalCode { get; set; }
- }
- private class EmailAddress
- {
- public string address { get; set; }
- }
- private class CommunicationPreferences
- {
- public List<AvailableNotification> availableNotifications { get; set; }
- }
- private class AvailableNotification
- {
- public string code { get; set; }
- public bool optedIn { get; set; }
- }
- private class SonyPostData
- {
- public CommunicationName communicationName { get; set; }
- public List<Address> addresses { get; set; }
- public List<EmailAddress> emailAddresses { get; set; }
- public string language { get; set; }
- public string legalCountry { get; set; }
- public string dateOfBirth { get; set; }
- public string onlineId { get; set; }
- public string signinId { get; set; }
- public string password { get; set; }
- public string onlineIdReservation { get; set; }
- public int toSUAVersion { get; set; }
- public CommunicationPreferences communicationPreferences { get; set; }
- }
- #endregion
- #region Sony Reserve Online Id Class
- private class ReserveOnlineId
- {
- public string onlineId { get; set; }
- public bool reserveIfAvailable { get; set; }
- }
- #endregion
- #region General Post Data
- private Dictionary<string, string> accessTokenPostData = new Dictionary<string, string>()
- {
- { "grant_type", "captcha" },
- { "captcha_provider", "google:recaptcha-v2" },
- { "scope", "user:account.create" },
- { "valid_for", null },
- { "client_id", "7e309afa-8d09-40d2-8e24-5029642f2c3c" },
- { "client_secret", "8aCv07DXTHJ1T2nA" },
- { "response_token", null },
- };
- private SonyPostData createAccountPostData = new SonyPostData
- {
- communicationName = new CommunicationName
- {
- first = "Succ",
- last = "Fucc"
- },
- addresses = new List<Address>()
- {
- new Address
- {
- qualifier = "residence",
- city = "Los Angeles",
- countrySubdivision = "CA",
- postalCode = "90017"
- }
- },
- emailAddresses = new List<EmailAddress>(),
- language = "en-US",
- legalCountry = "US",
- dateOfBirth = "1990-1-1",
- onlineId = null,
- signinId = null,
- password = null,
- onlineIdReservation = null,
- toSUAVersion = 6,
- communicationPreferences = new CommunicationPreferences
- {
- availableNotifications = new List<AvailableNotification>()
- {
- new AvailableNotification
- {
- code = "sonyCommunications",
- optedIn = false
- },
- new AvailableNotification
- {
- code = "partnerCommunications",
- optedIn = false
- }
- }
- }
- };
- private ReserveOnlineId reserverOnlineIdPostData = new ReserveOnlineId()
- {
- onlineId = null,
- reserveIfAvailable = true
- };
- #endregion
- private async Task<bool> checkForIPBan()
- {
- try
- {
- int randomProxy = Security.random.Next(ProxyList.Count);
- if (Global.useProxyPSN)
- 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 };
- else
- handler = new HttpClientHandler() { CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
- using (HttpClient client = new HttpClient(handler) { Timeout = timeOut })
- using (HttpRequestMessage retrieveReservationToken = new HttpRequestMessage() { Method = HttpMethod.Get, RequestUri = onlineIdUri })
- {
- HttpResponseMessage Response = await client.SendAsync(retrieveReservationToken);
- string ResponseString = await Response.Content.ReadAsStringAsync();
- if (Response.StatusCode == HttpStatusCode.Forbidden)
- return true;
- else
- return false;
- }
- }
- catch (Exception ex)
- {
- return true;
- }
- }
- private async Task<string> reserveOnlineId(string onlineId)
- {
- try
- {
- int randomProxy = Security.random.Next(ProxyList.Count);
- if (Global.useProxyPSN)
- 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 };
- else
- handler = new HttpClientHandler() { CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
- using (HttpClient client = new HttpClient(handler) { Timeout = timeOut })
- 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") })
- {
- HttpResponseMessage Response = await client.SendAsync(retrieveReservationToken);
- string ResponseString = await Response.Content.ReadAsStringAsync();
- if (Response.StatusCode == HttpStatusCode.Created)
- {
- dynamic JsonConverter = JsonConvert.DeserializeObject(ResponseString);
- string resvToken = JsonConverter.reservationId;
- string resvExp = JsonConverter.expirationDate;
- Database.addReservedPSID(userId, onlineId, resvToken, resvExp);
- return resvToken;
- }
- else if (Response.StatusCode == HttpStatusCode.Forbidden)
- return "ip";
- else
- return null;
- }
- }
- catch (Exception ex)
- {
- return "error";
- }
- }
- private async Task<string> retrieveSonyAccessToken(string Email, string Captcha)
- {
- try
- {
- accessTokenPostData["valid_for"] = Email;
- accessTokenPostData["response_token"] = Captcha;
- int randomProxy = Security.random.Next(ProxyList.Count);
- if (Global.useProxyPSN)
- 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 };
- else
- handler = new HttpClientHandler() { CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
- using (HttpClient client = new HttpClient(handler) { Timeout = timeOut })
- using (HttpRequestMessage retrieveAccessToken = new HttpRequestMessage() { Method = HttpMethod.Post, RequestUri = accessTokenUri, Content = new FormUrlEncodedContent(accessTokenPostData) })
- {
- HttpResponseMessage Response = await client.SendAsync(retrieveAccessToken);
- string ResponseString = await Response.Content.ReadAsStringAsync();
- if (Response.StatusCode == HttpStatusCode.OK)
- {
- dynamic JsonConverter = JsonConvert.DeserializeObject(ResponseString);
- string accessToken = JsonConverter.access_token;
- return accessToken;
- }
- else if (Response.StatusCode == HttpStatusCode.Forbidden)
- return "ip";
- else
- return null;
- }
- }
- catch (Exception ex)
- {
- return "error";
- }
- }
- public async void createPlaystationAccount(string UserID, string onlineId, string Email, string Password)
- {
- StaticStatus.Add(new psStatus { userId = UserID });
- var Status = StaticStatus.Find(x => x.userId == UserID);
- var startTime = DateTime.UtcNow;
- userId = UserID;
- try
- {
- ProxyList.Clear();
- ProxyList = Database.FillProxyList();
- Status.taskPercentage = 20;
- Status.taskStatus = "Checking proxy";
- if (await checkForIPBan())
- {
- Status.taskPercentage = 100;
- Status.taskStatus = $"Current proxy IP is banned it will rotate in about 3 minutes try again then.";
- }
- Status.taskPercentage = 40;
- Status.taskStatus = "Reserving Online ID";
- string onlineIdReservationToken = Database.retrieveReservedPSIDResvToken(userId, onlineId);
- if (onlineIdReservationToken == "")
- {
- onlineIdReservationToken = await reserveOnlineId(onlineId);
- int onlineIdRetry = 0;
- if (onlineIdReservationToken == null || onlineIdReservationToken == string.Empty)
- {
- Status.taskPercentage = 100;
- Status.taskStatus = $"Could not reserve Online Id it's already in use or reserved";
- return;
- }
- if(onlineIdReservationToken == "ip")
- {
- Status.taskPercentage = 100;
- Status.taskStatus = $"Possible IP ban please wait 5 minutes for the proxy to rotate";
- return;
- }
- while (onlineIdReservationToken == "error" || onlineIdRetry > 3)
- {
- Status.taskStatus = $"Reserving Online ID - Retry attempt {onlineIdRetry} / 3";
- onlineIdReservationToken = await reserveOnlineId(onlineId);
- onlineIdRetry++;
- }
- if (onlineIdReservationToken == "error")
- {
- Status.taskPercentage = 100;
- Status.taskStatus = $"Could not reserve Online Id";
- return;
- }
- }
- Status.taskPercentage = 50;
- Status.taskStatus = "Retrieiving Captcha";
- string Captcha = await Security.solveCaptcha();
- Status.taskPercentage = 70;
- Status.taskStatus = "Retrieving Access Token";
- string accessToken = await retrieveSonyAccessToken(Email, Captcha);
- int accessRetry = 0;
- if (accessToken == null)
- {
- Status.taskPercentage = 100;
- Status.taskStatus = $"Could not retrieve access token, possible IP ban try again in 5 minutes when IP rotates";
- return;
- }
- while (accessToken == "error" || accessRetry > 3)
- {
- Status.taskStatus = $"Retrieving Access Token - Retry attempt {accessRetry} / 3";
- accessToken = await retrieveSonyAccessToken(Email, Captcha);
- accessRetry++;
- }
- if (accessToken == "ip")
- {
- Status.taskPercentage = 100;
- Status.taskStatus = $"Possible IP ban please wait 5 minutes for the proxy to rotate";
- return;
- }
- if (accessToken == "error")
- {
- Status.taskPercentage = 100;
- Status.taskStatus = $"Could not retrieve access token, try again later";
- return;
- }
- createAccountPostData.onlineId = onlineId;
- createAccountPostData.onlineIdReservation = onlineIdReservationToken;
- createAccountPostData.signinId = Email;
- createAccountPostData.emailAddresses.Add(new EmailAddress { address = Email });
- createAccountPostData.password = Password;
- int randomProxy = Security.random.Next(ProxyList.Count);
- if (Global.useProxyPSN)
- 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 };
- else
- handler = new HttpClientHandler() { CookieContainer = new CookieContainer(), UseCookies = true, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate };
- using (HttpClient client = new HttpClient(handler) { Timeout = timeOut })
- using (HttpRequestMessage createPlaystationAccount = new HttpRequestMessage() { Method = HttpMethod.Post, RequestUri = accountCreationUri, Content = new StringContent(JsonConvert.SerializeObject(createAccountPostData), Encoding.UTF8, "application/json") })
- {
- Status.taskPercentage = 90;
- Status.taskStatus = "Creating playstation account";
- createPlaystationAccount.Headers.Add("Authorization", $"Bearer {accessToken}");
- HttpResponseMessage Response = await client.SendAsync(createPlaystationAccount);
- string ResponseString = await Response.Content.ReadAsStringAsync();
- if (Response.StatusCode == HttpStatusCode.Created)
- {
- var seconds = Math.Round((DateTime.UtcNow - startTime).TotalSeconds, 2);
- Database.addNewPSNAccount(userId, onlineId, Email, Password, string.Format("{0:M/d/yyyy - HH:mm:ss tt} UTC", DateTime.UtcNow), seconds.ToString());
- Status.taskPercentage = 100;
- Status.taskStatus = $"Playstation account: {onlineId} successfully created";
- Database.removeReservedPSID(onlineIdReservationToken);
- return;
- }
- else
- {
- Status.taskPercentage = 100;
- 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";
- return;
- }
- }
- }
- catch (Exception ex)
- {
- Status.taskPercentage = 100;
- Status.taskStatus = $"Playstation account: {onlineId} failed to create, please try again if this persists wait 5 - 10 minutes";
- return;
- }
- }
- public async Task SendPSNMessage(psBomberAccountList bomb, string Recipient, string Message)
- {
- ProxyList.Clear();
- ProxyList = Database.FillProxyList();
- Random r = new Random();
- int rn = r.Next(ProxyList.Count);
- try
- {
- List<string> recpients = new List<string>() { Recipient };
- Message messageContent = new Message(recpients, Message);
- MessageRequest messageRequest = new MessageRequest(messageContent.UsersToInvite, new MessageData(messageContent.MessageText, 1));
- var message = messageRequest.BuildTextMessage();
- 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 })
- using (HttpClient client = new HttpClient(handler))
- using (HttpRequestMessage request = new HttpRequestMessage() { Method = HttpMethod.Post, RequestUri = sonyMessageUri, Content = message })
- {
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", bomb.Oauth);
- var response = await client.SendAsync(request);
- var responseString = await response.Content.ReadAsStringAsync();
- dynamic Json = JsonConvert.DeserializeObject(responseString);
- //if (Json.sentMessageId == null || Json.error != null)
- // return Tuple.Create(false, responseString);
- //return Tuple.Create(true, responseString);
- }
- }
- catch (Exception ex) { }
- }
- public class psStatus
- {
- public string userId { get; set; }
- public int taskPercentage { get; set; }
- public string taskStatus { get; set; }
- }
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement