The use of the = command from the radare shell can be done from
the shell using the connect:// URI. Maybe we will have to rename
or to make the remote io plugin handle connect:// and rap:// to
be conceptually more consistent.

I have been working on the refactoring of the python implementation
of the radare protocol, so now it is possible to create a radare server
or client in pure python (without any dependency) and it is also possible
to use the analysis and standard api locally or remotely by just changing
the r.cmd() provider. I have pushed some examples of use in the repository,
but here there are some copypastas of the not-yet finished API.

import radapy
from string import *

PORT = 8888

def fun_system(str):
       print "CURRENT SEEK IS %d"%radapy.offset
       return str

def fun_open(file,flags):
       return str

def fun_seek(off,type):
       return str

def fun_write(buf):
       print "WRITING %d bytes (%s)"%(len(buf),buf)
       return 6

def fun_read(len):
       global rs
       print "READ %d bytes from %d\n"% (len, rs.offset)
       str = "patata"
       str = str[rs.offset:]
       return str


# main

#radapy.handle_cmd_open = fun_open
#radapy.handle_cmd_close = fun_close
rs = radapy.RapServer()
rs.handle_cmd_system = fun_system
rs.handle_cmd_read = fun_read
rs.handle_cmd_write = fun_write
rs.size = 10
rs.listen_tcp (PORT)


[panc...@dazo radare]$ cat scripts/radapy_client.py
import sys
sys.path.append('.')
import radapy

c = radapy.RapClient('localhost', 9999)
#c = RapClient('localhost', 9999)
fd = c.open("/bin/ls", 0)
print c.cmd("px")
#c.system("x")
c.close(fd)
c.disconnect()



[panc...@dazo radare]$ cat scripts/standalone.py
hijack=1

import radare
import ranal
import radapy

# r.cmd() hijacking
if hijack:
       class Food:
               def cmd(str):
                       global c
                       print "Command to run is (%s)"%str
                       return c.cmd(str)
               cmd = staticmethod(cmd)
       global r
       radare.r = Food


c = radapy.RapClient("localhost", 9999)

fd = c.open("/bin/ls", 0)
print c.cmd("px")
#r = Food
#r.cmd("#test")
print radare.r.cmd("pd 20")
radare.seek(33)
print radare.disasm(0, 10)

# close
c.close(fd)
c.disconnect()


Nibble wrote:
Hi,

I've been playing a little with the remote protocol in radare and added
a new command called '='. It allows to establish connections with
several remote radares and interact with them.

You can access to the help, as usual, through '=?':

  ]> =?
   =                  ; List hosts
   =[fd] cmd          ; Exec cmd in host n
   =+ [proto://]host  ; Add host (default protocol is rap://)
   =-[fd]             ; Remove all hosts or host 'fd'
   ==[fd]             ; Open remote session with host 'fd'
   NOTE: Last used host comes to be default
         Use 'q' to quit session

But, lets introduce the command with a little example :) A typical
remote session could be:

- At remote <host1>:
  $ radare listen://:1234
- At remote <host2>:
  $ radare listen://:1234
- At localhost:
  $ radare <bin>
  ; Add hosts
  ]> =+ rap://<host1>:1234//bin/ls
  Connected to: <host1> at port 1234
  waiting... ok
  5 - rap://<host1>:1234//bin/ls
  ; Of course, you can open remote files in debug mode (or using any io
; plugin) specifying the uri when adding hosts: ]> =+ rap://<host2>:1234/dbg:///bin/ls
  Connected to: <host2> at port 1234
  waiting... ok
  5 - rap://<host1>:1234//bin/ls
  6 - rap://<host2>:1234/dbg:///bin/ls
  ; Exec commands in host1
  ]> =5 px
  ]> = s 0x666
  ...
  ; Open a session with host2
  ]> ==6
  fd:6> !cont entrypoint
  ...
  fd:6> q
  ; Remove hosts (and close connections)
  ]> =-

Enjoy!

Regards,
Nibble
_______________________________________________
radare mailing list
[email protected]
http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org


_______________________________________________
radare mailing list
[email protected]
http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org

Reply via email to