cncf / demo

Demo of CNCF technologies
https://cncf.io
Apache License 2.0
77 stars 39 forks source link

Controlling the BOINC client via RPC #214

Closed namliz closed 7 years ago

namliz commented 7 years ago

Boinc has an XML RPC - "These RPCs send XML request and reply messages over a TCP connection. The XML formats are not documented, but can be inferred from the source code."

$ printf "<boinc_gui_rpc_request>\n<auth1/>\n</boinc_gui_rpc_request>\n\003" | nc localhost $BOINC_PORT

<boinc_gui_rpc_reply>
<nonce>1493056930.050257</nonce>
</boinc_gui_rpc_reply>

It is then necessary to md5(nonce, auth_token) and:

printf "<boinc_gui_rpc_request>\n<auth2>\n<nonce_hash>$md5</nonce_hash>\n</auth2>\n</boinc_gui_rpc_request>\n\003" | nc localhost $BOINC_PORT

At this point the RPC might respond with successful authorization otherwise a new nounce needs to be requested and the process repeated.

The source code to reverse engineer this can be found here: https://github.com/BOINC/boinc/blob/master/lib/gui_rpc_client.cpp#L310

If authorization was successfully brute forced on the same tcp session it then becomes possible to send:

<boinc_gui_rpc_request>
<get_results>
<active_only>0</active_only>
</get_results>
</boinc_gui_rpc_request>

Which is the equivalent of:

boinccmd --get_tasks

======== Tasks ========
1) -----------
   name: ZIKA_000228956_x4mvn_Saur_SplApr_Inhib_chD_A_0058_0
   WU name: ZIKA_000228956_x4mvn_Saur_SplApr_Inhib_chD_A_0058
   project URL: http://www.worldcommunitygrid.org/
   report deadline: Thu May  4 17:50:29 2017
   ready to report: no
   got server ack: no
   final CPU time: 0.000000
   state: downloaded
   scheduler state: scheduled
   exit_status: 0
   signal: 0
   suspended via GUI: no
   active_task_state: EXECUTING
   app version num: 708
   checkpoint CPU time: 1080.540000
   current CPU time: 1121.410000
   fraction done: 0.229641
   swap size: 139 MB
   working set size: 66 MB
   estimated CPU time remaining: 12233.182450

See: Boinccmd command_line_switches.

This information in XML format is marginally easier to work with, however, since the API is not really documented and the information is not really explained in any context it is next to impossible to do something useful with it.