Advertisement
Guest User

PS4-C#SendingPayloads

a guest
Mar 1st, 2017
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. public static Socket _psocket;
  2. public static bool pDConnected;
  3. public static string IP = "192.168.0.8";//Temporary.
  4.  
  5. public static void Connect2PS4(string ip)
  6. {
  7.            try
  8.             {
  9.                 _psocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  10.                 _psocket.ReceiveTimeout = 3000;
  11.                 _psocket.SendTimeout = 3000;
  12.                 _psocket.Connect(new IPEndPoint(IPAddress.Parse(IP), 9023));
  13.                 pDConnected = true;
  14.                 return true;
  15.             }
  16.             catch
  17.             {
  18.                 pDConnected = false;
  19.                 return false;
  20.             }
  21. }
  22.  
  23. public static bool SendPayload(string filename)
  24. {
  25.     _psocket.SendFile(filename);
  26.     return true;
  27. }
  28.  
  29.  public static bool DisconnectPayload()
  30. {
  31.     pDConnected = false;
  32.     _psocket.Close();
  33.     return true;
  34. }
  35.  
  36.  
  37. //Below is a simple example using the above to send the payload to ps4.
  38.  
  39. Connect2PS4(IP);
  40. if(_pConnected)
  41. {
  42.     OpenFileDialog FileO = new OpenFileDialog();
  43.     FileO.FileName = "payload.bin";
  44.     FileO.InitialDirectory = "C:\\";
  45.     FileO.Filter = "bin files|*.bin|All Files|*.*";
  46.     DialogResult result = FileO.ShowDialog();
  47.     if(result == DialogResult.OK)
  48.      SendPayload(FileO.FileName);
  49.     DisconnectPayload();
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement