Skip to content

Commit

Permalink
service: Split set service
Browse files Browse the repository at this point in the history
```
from service.set import Sys as SetSys
setsys = SetSys(c, sm.get_service('set:sys')
setsys.get_mii_author_id()
```
  • Loading branch information
d3m3vilurr committed Jan 7, 2018
1 parent 52d40e0 commit 8772172
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
31 changes: 0 additions & 31 deletions client.py
Expand Up @@ -451,37 +451,6 @@ def write_rop(self, rop_addr, rop):
if n != 0:
self.execute(writer)

def get_service(self, name):
ptr = self.malloc(8)
if ptr == 0:
print('[-] malloc failed')
return
ret = self.srv_cmd1(ptr, name)
if ret != 0:
print('[-] sm:GetService failed (0x%X)' % ret)
self.free(ptr)
return
handle = self.r32(ptr)
print('[+] Handle', handle)
self.free(ptr)
return handle

def setsys_get_mii_author_id(self):
handle = self.get_service('set:sys')
if not handle:
return
try:
out = self.cmd(handle, 90)
except Exception as e:
print('[-] set:sys:GetMiiAuthorId failed')
print('[-] ', e.message)
self.svcCloseHandle(handle)
return
ids = struct.unpack('>QQ', out['data'])
ret = (ids[0] << 64) | ids[1]
self.svcCloseHandle(handle)
return '%X' % ret

## Service playground
def srv_cmd0(self, unk_zero):
# srv::Initialize
Expand Down
16 changes: 16 additions & 0 deletions service/set.py
@@ -0,0 +1,16 @@
from __future__ import print_function
from service import Service
from rop import Rop, data_base, main_base, wk_base, F, G, D, Ret
from ipc import *

class Sys(Service):
def get_mii_author_id(self):
try:
out = self.client.cmd(self.handle, 90)
except Exception as e:
print('[-] set:sys:GetMiiAuthorId failed')
print('[-] ', e.message)
return
ids = struct.unpack('>QQ', out['data'])
ret = (ids[0] << 64) | ids[1]
return '%X' % ret

0 comments on commit 8772172

Please sign in to comment.