Пример #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Structures.TCPCommandSimple com = new Structures.TCPCommandSimple();
            com.command = 2805;
            com.param   = Convert.ToUInt16(this.SelectedPID);

            byte[] tmp2 = Structures.getBytesFromStruct(com);
            tmp2 = Network.SendCommand64(tmp2, false, "", this.Client, true);

            if (tmp2 != null)
            {
                Int32 attachResult = Commands.ps4ninja_attach(Convert.ToInt16(this.SelectedPID), 0, this.Client);

                if (attachResult == 0)
                {
                    frmVMEntries FRMVMEntries = new frmVMEntries();
                    FRMVMEntries.VMData = tmp2;
                    FRMVMEntries.Client = this.Client;
                    FRMVMEntries.PID    = Convert.ToInt16(this.SelectedPID);
                    FRMVMEntries.Text   = string.Format("Debug - PID {0} - {1}", this.SelectedPID, this.SelectedCommand);
                    FRMVMEntries.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("There was an error! Maybe the process is not active anymore.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }
Пример #2
0
        public static void ps4ninja_kill_pid(short pid, TcpClient Client)
        {
            Structures.TCPCommandSimple com = new Structures.TCPCommandSimple();
            com.command = 9999;
            com.param   = Convert.ToUInt16(pid);

            byte[] tmp2 = Structures.getBytesFromStruct(com);
            Network.SendCommand(tmp2, false, "", Client);
        }
Пример #3
0
        public static byte[] ps4ninja_read_regs(short pid, TcpClient Client)
        {
            // Send ptrace read regs command
            Structures.TCPCommandSimple com = new Structures.TCPCommandSimple();
            com.command = 2812;
            com.param   = Convert.ToUInt16(pid);

            byte[] tmp2 = Structures.getBytesFromStruct(com);
            return(Network.SendCommand64(tmp2, false, "", Client, true));
        }
Пример #4
0
        public static Int32 ps4ninja_detach(short pid, TcpClient Client)
        {
            // Send ptrace detach command
            Structures.TCPCommandSimple com = new Structures.TCPCommandSimple();
            com.command = 2807;
            com.param   = Convert.ToUInt16(pid);

            byte[] tmp2 = Structures.getBytesFromStruct(com);
            tmp2 = Network.SendCommand(tmp2, false, "", Client);

            if (tmp2 != null)
            {
                return(BitConverter.ToInt32(tmp2, 0));
            }
            else
            {
                return(-1);
            }
        }
Пример #5
0
        public static byte[] SendCommand64(byte[] command, bool withDialog, string LocalFile, TcpClient Client, bool Response64Bit)
        {
            if (Client.Client.Available > 0)
            {
                byte[] tmp2 = new byte[Client.Client.Available];
                Client.Client.Receive(tmp2);
            }

            // Send data length and wait for OK
            Network.WriteU32((UInt32)command.Length, Client.Client);
            byte res = Network.ReadByte(Client.Client);

            if (res != 0x4f)
            {
                return(null);
            }

            // Send command and wait for OK
            Network.WriteBytes(command, Client.Client);
            res = Network.ReadByte(Client.Client);

            if (res != 0x4f)
            {
                return(null);
            }

            // Read answer length and send OK
            byte[] tmp = null;

            UInt64 rdata = 0;

            if (!withDialog)
            {
                if (!Response64Bit)
                {
                    rdata = Network.ReadU32(Client.Client);
                }
                else
                {
                    rdata = Network.ReadU64(Client.Client);
                }

                tmp = new byte[rdata];
            }
            else
            {
                rdata = Network.ReadU64(Client.Client);
            }
            // Reading answer...
            if (rdata != 0)
            {
                if (!withDialog)
                {
                    Network.WriteByte(Convert.ToByte(0x4f), Client.Client);
                    tmp = Network.ReadBytes((UInt32)rdata, Client.Client);
                }
                else
                {
                    frmTransfer trans = new frmTransfer(Client, rdata);
                    trans.LocalFile = LocalFile;
                    if (trans.ShowDialog() == DialogResult.Cancel)
                    {
                        if (trans.ClientPID != 0)
                        {
                            Structures.TCPCommandSimple com = new Structures.TCPCommandSimple();
                            com.command = 9999;
                            com.param   = Convert.ToUInt16(trans.ClientPID);

                            byte[] tmp2 = Structures.getBytesFromStruct(com);

                            SendCommand(tmp2, false, "", Client);
                            return(null);
                        }
                    }
                    else
                    {
                        tmp = new byte[1]; // Return one dummy byte
                    }
                }
            }
            else
            {
                if (!withDialog)
                {
                    tmp = null;
                }
                else
                {
                    // If the filesize was zero, create an empty local file
                    if (File.Exists(LocalFile))
                    {
                        File.Delete(LocalFile);
                    }

                    FileStream fs = new FileStream(LocalFile, FileMode.CreateNew, FileAccess.ReadWrite);
                    fs.Close();

                    tmp    = new byte[1];
                    tmp[0] = 0x4f;
                }
            }

            return(tmp);
        }