Make sure nil is not reported in the session fields (breaks XMLRPC).

git-svn-id: file:///home/svn/framework3/trunk@8579 4d416f70-5f16-0410-b530-b9f4589650da
unstable
HD Moore 2010-02-22 17:15:36 +00:00
parent 6414821ea8
commit 2fc9b1d576
1 changed files with 14 additions and 13 deletions

View File

@ -7,49 +7,49 @@ class Session < Base
res = {}
@framework.sessions.each do |sess|
i,s = sess
res[s.sid] = {
'type' => s.type,
'tunnel_local'=> s.tunnel_local,
'tunnel_peer' => s.tunnel_peer,
'via_exploit' => s.via_exploit,
'via_payload' => s.via_payload,
'desc' => s.desc
res[s.sid] = {
'type' => s.type.to_s,
'tunnel_local'=> s.tunnel_local.to_s,
'tunnel_peer' => s.tunnel_peer.to_s,
'via_exploit' => s.via_exploit.to_s,
'via_payload' => s.via_payload.to_s,
'desc' => s.desc.to_s
}
end
res
end
def stop(token, sid)
authenticate(token)
s = _find_session(sid)
s.kill
{ "result" => "success" }
end
def shell_read(token, sid)
authenticate(token)
s = _find_session(sid)
if(s.type != "shell")
raise ::XMLRPC::FaultException.new(403, "session is not a shell")
end
if(not s.rstream.has_read_data?(0))
{ "data" => "" }
else
{ "data" => s.read_shell }
end
end
def shell_write(token, sid, data)
authenticate(token)
s = _find_session(sid)
if(s.type != "shell")
raise ::XMLRPC::FaultException.new(403, "session is not a shell")
end
{ "write_count" => s.write_shell(data) }
end
protected
def _find_session(sid)
@ -63,3 +63,4 @@ protected
end
end
end