Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
netanelc305 committed Nov 14, 2023
1 parent 70d94ad commit 7ba5509
Show file tree
Hide file tree
Showing 14 changed files with 1,294 additions and 701 deletions.
185 changes: 185 additions & 0 deletions src/protos/gpt_construct_rpc.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
syntax = "proto3";

// Enum for cmd_type_t
enum CmdType {
CMD_EXEC = 0;
CMD_DLOPEN = 1;
CMD_DLCLOSE = 2;
CMD_DLSYM = 3;
CMD_CALL = 4;
CMD_PEEK = 5;
CMD_POKE = 6;
CMD_REPLY_ERROR = 7;
CMD_REPLY_PEEK = 8;
CMD_GET_DUMMY_BLOCK = 9;
CMD_CLOSE = 10;
CMD_REPLY_POKE = 11;
CMD_LISTDIR = 12;
CMD_SHOWOBJECT = 13;
CMD_SHOWCLASS = 14;
CMD_GET_CLASS_LIST = 15;
}

// Enum for arch_t
enum ArchType {
ARCH_UNKNOWN = 0;
ARCH_ARM64 = 1;
}

// Struct for protocol_handshake_t
message ProtocolHandshake {
int32 magic = 1;
ArchType arch = 2;
string sysname = 3;
string machine = 4;
}

// Struct for cmd_exec_t
message CmdExec {
int32 background = 1;
repeated string argv = 2;
repeated string envp = 3;
}

// Struct for cmd_dlopen_t
message CmdDlopen {
string filename = 1;
int32 mode = 2;
}

// Struct for cmd_dlclose_t
message CmdDlclose {
int64 lib = 1;
}

// Struct for cmd_dlsym_t
message CmdDlsym {
int64 lib = 1;
string symbol_name = 2;
}

// Enum for argument_type_t
enum ArgumentType {
INTEGER = 0;
DOUBLE = 1;
}

// Struct for argument_t
message Argument {
ArgumentType type = 1;
oneof value {
int64 int_value = 2;
double double_value = 3;
}
}

// Struct for cmd_call_t
message CmdCall {
int64 address = 1;
int64 va_list_index = 2;
repeated Argument argv = 3;
}

// Struct for cmd_peek_t
message CmdPeek {
int64 address = 1;
int64 size = 2;
}

// Struct for cmd_poke_t
message CmdPoke {
int64 address = 1;
int64 size = 2;
bytes data = 3;
}

// Struct for cmd_dirlist_t
message CmdDirlist {
string filename = 1;
}

// Struct for cmd_showobject_t
message CmdShowobject {
int64 address = 1;
}

// Struct for cmd_showclass_t
message CmdShowclass {
int64 address = 1;
}

// Struct for listdir_entry_stat_t
message ListdirEntryStat {
int64 errno = 1;
int64 st_dev = 2;
int64 st_mode = 3;
int64 st_nlink = 4;
int64 st_ino = 5;
int64 st_uid = 6;
int64 st_gid = 7;
int64 st_rdev = 8;
int64 st_size = 9;
int64 st_blocks = 10;
int64 st_blksize = 11;
int64 st_atime = 12;
int64 st_mtime = 13;
int64 st_ctime = 14;
}

// Struct for listdir_entry_t
message ListdirEntry {
int64 d_type = 1;
int64 d_namlen = 2;
ListdirEntryStat lstat = 3;
ListdirEntryStat stat = 4;
}

// Struct for protocol_message_t
message ProtocolMessage {
int32 magic = 1;
CmdType cmd_type = 2;
oneof data {
CmdExec cmd_exec = 3;
CmdDlopen cmd_dlopen = 4;
CmdDlclose cmd_dlclose = 5;
CmdDlsym cmd_dlsym = 6;
CmdCall cmd_call = 7;
CmdPeek cmd_peek = 8;
CmdPoke cmd_poke = 9;
CmdDirlist cmd_dirlist = 10;
CmdShowobject cmd_showobject = 11;
CmdShowclass cmd_showclass = 12;
}
}

// Struct for reply_protocol_message_t
message ReplyProtocolMessage {
int32 magic = 1;
CmdType cmd_type = 2;
}

// Enum for exec_chunk_type_t
enum ExecChunkType {
CMD_EXEC_CHUNK_TYPE_STDOUT = 0;
CMD_EXEC_CHUNK_TYPE_ERRORCODE = 1;
}

// Struct for exec_chunk_t
message ExecChunk {
ExecChunkType chunk_type = 1;
int32 size = 2;
}

// Struct for return_registers_arm_t
message ReturnRegistersArm {
repeated int64 x = 1;
repeated double d = 2;
}

// Struct for call_response_t
message CallResponse {
oneof return_values {
ReturnRegistersArm arm_registers = 1;
int64 return_value
}
}
110 changes: 79 additions & 31 deletions src/protos/rpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,67 @@ syntax = "proto3";

package rpc;

enum CmdType {
CMD_EXEC = 0;
CMD_DLOPEN = 1;
CMD_DLCLOSE = 2;
CMD_DLSYM = 3;
CMD_CALL = 4;
CMD_PEEK = 5;
CMD_POKE = 6;
CMD_REPLY_ERROR = 7;
CMD_REPLY_PEEK = 8;
CMD_GET_DUMMY_BLOCK = 9;
CMD_CLOSE = 10;
CMD_REPLY_POKE = 11;
CMD_LISTDIR = 12;
CMD_SHOWOBJECT = 13;
CMD_SHOWCLASS = 14;
CMD_GET_CLASS_LIST = 15;

message Command {
int32 magic = 1;
oneof type {
CmdExec exec = 2;
CmdDlopen dlopen = 3;
CmdDlclose dlclose = 4;
CmdDlsym dlsym = 5;
CmdCall call = 6;
CmdPeek peek = 7;
CmdPoke poke = 8;
CmdListDir listdir = 9;
CmdShowObject showobject = 10;
CmdShowClass showclass = 11;
CmdDummyBlock dummy_block = 12;
CmdClose close = 13;
CmdGetClassList class_list = 14;
}
}
message CmdDummyBlock{}

// Todo
message CmdExec{
bool background=1;
repeated string argv=2;
repeated string envp=3;
}
message CmdClose{}
message CmdGetClassList{}
message ResponsePoke{
uint64 result = 1;
}

message Response {
oneof type {
ResponseCmdExec exec = 1;
ResponseCmdExecChunk exec_chunk = 2;
ResponseDlopen dlopen = 3;
ResponseDlclose dlclose = 4;
ResponseDlsym dlsym = 5;
ResponsePeek peek = 6;
ResponsePoke poke = 7;
ResponseCall call = 8;
ResponseError error = 9;
ResponseDummyBlock dummy_block = 10;
ResponseShowObject show_object = 11;
ResponseGetClassList class_list = 12;
ResponseShowClass show_class = 13;
}
}

message ResponseShowClass{
string description = 1;
}
message ResponseDummyBlock{
uint64 address = 1;
uint64 size = 2;
}
message ResponseError{
string func_name = 1;
uint64 error_num=2;
}

enum CmdExecChunkType {
Expand All @@ -45,32 +89,32 @@ message CmdExecChunk {

message CmdDlopen {
string filename = 1;
uint32 mode = 2;
int32 mode = 2;
}

message CmdDlclose {
uint64 lib = 1;
uint64 handle = 1;
}

message CmdDlsym {
uint64 lib = 1;
uint64 handle = 1;
string symbol_name = 2;
}

message Argument {
uint64 type = 1;
uint64 value = 2;
oneof type{
uint64 value=1;
string value=2;
double value=3;
}
}

message CmdCall {
uint64 address = 1;
uint64 va_list_index = 2;
uint64 argc = 3;
repeated Argument argv = 4;
repeated Argument argv = 3;
}



message ReturnRegistersArm {
repeated uint64 x = 1;
repeated uint64 d = 2;
Expand All @@ -80,10 +124,13 @@ message CmdPeek {
uint64 address = 1;
uint64 size = 2;
}
message ResponsePeek{
bytes data =1;
}


message CmdPoke {
uint64 address = 1;
uint64 size = 2;
bytes data = 3;
}

Expand Down Expand Up @@ -121,6 +168,9 @@ message CmdShowObject {
uint64 address = 1;
}

message ResponseShowObject {
string description = 1;
}
message CmdShowClass {
uint64 address = 1;
}
Expand All @@ -136,19 +186,17 @@ message ResponseCmdExecChunk {
}

message ResponseDlopen {
uint32 err = 1;
uint64 handle = 1;
}

message ResponseDlclose {
uint32 err = 1;
uint32 res = 1;
}

message ResponseDlsym {
uint64 ptr = 1;
}

message ResponsePeek{}

message ResponseCall {
oneof return_values {
ReturnRegistersArm arm_registers = 1;
Expand Down
Loading

0 comments on commit 7ba5509

Please sign in to comment.