Advertisement
IAmXeClutch

[Project] PhantomRTM Java 1.0

Oct 29th, 2014
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.85 KB | None | 0 0
  1. import java.io.*;
  2. import java.net.*;
  3. import java.nio.*;
  4.  
  5. public class PhantomRTM
  6. {
  7.     private String int2uint(int i)
  8.     {
  9.         return "0x" + Integer.toHexString(i).toUpperCase();
  10.     }
  11.     private String byteArray2hexStr(byte[] byteArray)
  12.     {
  13.         return javax.xml.bind.DatatypeConverter.printHexBinary(byteArray);
  14.     }
  15.     private byte[] hexStr2ByteArray(String hexStr)
  16.     {
  17.         return javax.xml.bind.DatatypeConverter.parseHexBinary(hexStr);
  18.     }
  19.    
  20.     private String readerstring;
  21.     private String Console;
  22.     private Socket client;
  23.     private BufferedReader sreader;
  24.     private DataOutputStream swriter;
  25.    
  26.     public void Command_Launch(String Path)
  27.     {
  28.         String[] lines = Path.split("\\");
  29.         String Directory = "";
  30.         for (int i = 0; i < lines.length - 1; i++)
  31.             Directory += lines[i] + "\\";
  32.         Command_SendText("magicboot title=" + Path + " directory=" + Directory);
  33.     }
  34.     public void Command_OpenDVDDrive()
  35.     {
  36.         Command_SendText("dvdeject");
  37.     }
  38.     public String Command_SendText(String Text)
  39.     {
  40.         try
  41.         {
  42.             if (Connect(Console, false))
  43.             {
  44.                 swriter = new DataOutputStream(client.getOutputStream());
  45.                 swriter.writeChars(Text + "\r\n");
  46.                 readerstring = sreader.readLine();
  47.                 client.close();
  48.                 return readerstring;
  49.             }
  50.             return "";
  51.         }
  52.         catch (Exception ex)
  53.         {
  54.             return "";
  55.         }
  56.     }
  57.     public void Command_Shutdown()
  58.     {
  59.         Command_SendText("shutdown");
  60.     }
  61.  
  62.     public boolean Connect(String XboxIP)
  63.     {
  64.         return Connect(XboxIP, true);
  65.     }
  66.     private boolean Connect(String XboxIP, boolean close)
  67.     {
  68.         try
  69.         {
  70.             client = new Socket();
  71.             client.connect(new InetSocketAddress(XboxIP, 730), 0);
  72.             sreader = new BufferedReader(new InputStreamReader(client.getInputStream()));
  73.             Console = XboxIP;
  74.             readerstring = sreader.readLine().toLowerCase();
  75.             if (close)
  76.                 client.close();
  77.             return readerstring == "201- connected";
  78.         }
  79.         catch (Exception ex)
  80.         {
  81.             return false;
  82.         }
  83.     }
  84.    
  85.     public void Debug_Freeze()
  86.     {
  87.         Command_SendText("stop");
  88.     }
  89.     public void Debug_UnFreeze()
  90.     {
  91.         Command_SendText("go");
  92.     }
  93.    
  94.     public void File_DumpMemory(String Path, int Start, int Length)
  95.     {
  96.         try
  97.         {
  98.             FileOutputStream out = new FileOutputStream(Path);
  99.             out.write(Read_Byte(Start, Length));
  100.             out.close();
  101.         }
  102.         catch (Exception ex)
  103.         {
  104.            
  105.         }
  106.     }
  107.     public void File_SaveMemory(String Path, int Offset)
  108.     {
  109.         try
  110.         {
  111.             FileInputStream in = new FileInputStream(Path);
  112.             byte[] buffer = new byte[in.available()];
  113.             in.read(buffer);
  114.             in.close();
  115.             Write_Byte(Offset, buffer);
  116.         }
  117.         catch (Exception ex)
  118.         {
  119.            
  120.         }
  121.     }
  122.    
  123.     public String Get_ConsoleID()
  124.     {
  125.         return Command_SendText("getconsoleid").replace("200- consoleid=", "");
  126.     }
  127.     public String Get_CPUKey()
  128.     {
  129.         return Command_SendText("getcpukey").replace("200- ", "");
  130.     }
  131.     public String Get_ProcessID()
  132.     {
  133.         return "0x" + Command_SendText("getpid").replace("200- pid=", "").replace("0x", "").toUpperCase();
  134.     }
  135.    
  136.     public boolean Read_Boolean(int Offset)
  137.     {
  138.         return Read_Byte(Offset, 1)[0] == 1;
  139.     }
  140.     public byte Read_Byte(int Offset)
  141.     {
  142.         return Read_Byte(Offset, 1)[0];
  143.     }
  144.     public byte[] Read_Byte(int Offset, int Length)
  145.     {
  146.         try
  147.         {
  148.             if (Connect(Console, false))
  149.             {
  150.                 swriter = new DataOutputStream(client.getOutputStream());
  151.                 swriter.writeChars("getmem addr=" + int2uint(Offset) + " length=" + int2uint(Length) + "\r\n");
  152.                 sreader.readLine();
  153.                 String resp = sreader.readLine();
  154.                 client.close();
  155.                 return hexStr2ByteArray(resp);
  156.             }
  157.             return new byte[] { (byte)0xDE, (byte)0xAD, (byte)0xDE, (byte)0xAD };
  158.         }
  159.         catch (Exception ex)
  160.         {
  161.             return new byte[] { (byte)0xDE, (byte)0xAD, (byte)0xDE, (byte)0xAD };
  162.         }
  163.     }
  164.     public float Read_Float(int Offset)
  165.     {
  166.         return ByteBuffer.wrap(Read_Byte(Offset, 4)).order(ByteOrder.BIG_ENDIAN).getFloat();
  167.     }
  168.     public short Read_Int16(int Offset)
  169.     {
  170.         return ByteBuffer.wrap(Read_Byte(Offset, 2)).order(ByteOrder.BIG_ENDIAN).getShort();
  171.     }
  172.     public int Read_Int32(int Offset)
  173.     {
  174.         return ByteBuffer.wrap(Read_Byte(Offset, 2)).order(ByteOrder.BIG_ENDIAN).getInt();
  175.     }
  176.     public long Read_Int64(int Offset)
  177.     {
  178.         return ByteBuffer.wrap(Read_Byte(Offset, 2)).order(ByteOrder.BIG_ENDIAN).getLong();
  179.     }
  180.     public String Read_String(int Offset, int Length)
  181.     {
  182.         String str = "";
  183.         byte[] buffer = Read_Byte(Offset, Length);
  184.         for (int i = 0; i < Length; i++)
  185.             str += buffer.toString();
  186.         return str;
  187.     }
  188.    
  189.     public void Write_Boolean(int Offset, boolean Data)
  190.     {
  191.         Write_Byte(Offset, Data ? (byte)1 : (byte)0);
  192.     }
  193.     public void Write_Byte(int Offset, byte Data)
  194.     {
  195.         Write_Byte(Offset, new byte[] { Data });
  196.     }
  197.     public void Write_Byte(int Offset, byte[] Data)
  198.     {
  199.         Command_SendText("setmem addr=" + int2uint(Offset) + " data=" + byteArray2hexStr(Data));
  200.     }
  201.     public void Write_Float(int Offset, float Data)
  202.     {
  203.         Write_Byte(Offset, ByteBuffer.allocate(4).putFloat(Data).array());
  204.     }
  205.     public void Write_Int16(int Offset, short Data)
  206.     {
  207.         Write_Byte(Offset, ByteBuffer.allocate(2).putShort(Data).array());
  208.     }
  209.     public void Write_Int32(int Offset, int Data)
  210.     {
  211.         Write_Byte(Offset, ByteBuffer.allocate(4).putInt(Data).array());
  212.     }
  213.     public void Write_Int64(int Offset, long Data)
  214.     {
  215.         Write_Byte(Offset, ByteBuffer.allocate(8).putLong(Data).array());
  216.     }
  217.     public void Write_NOP(int Offset)
  218.     {
  219.         Write_Byte(Offset, new byte[] { (byte)0x60, (byte)0x00, (byte)0x00, (byte)0x00 });
  220.     }
  221.     public void Write_String(int Offset, String Data)
  222.     {
  223.         Write_Byte(Offset, Data.getBytes());
  224.     }
  225. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement