added API call for extracting keystrokes from client.ui.keyscan_dump
git-svn-id: file:///home/svn/framework3/trunk@12323 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
9ac36d6e0a
commit
904e7af88b
|
@ -219,6 +219,38 @@ class UI < Rex::Post::UI
|
|||
return response.get_tlv_value(TLV_TYPE_KEYS_DUMP);
|
||||
end
|
||||
|
||||
#
|
||||
# Extract the keystroke from the buffer data
|
||||
#
|
||||
def keyscan_extract(buffer_data)
|
||||
outp = ""
|
||||
buffer_data.unpack("n*").each do |inp|
|
||||
fl = (inp & 0xff00) >> 8
|
||||
vk = (inp & 0xff)
|
||||
kc = VirtualKeyCodes[vk]
|
||||
|
||||
f_shift = fl & (1<<1)
|
||||
f_ctrl = fl & (1<<2)
|
||||
f_alt = fl & (1<<3)
|
||||
|
||||
if(kc)
|
||||
name = ((f_shift != 0 and kc.length > 1) ? kc[1] : kc[0])
|
||||
case name
|
||||
when /^.$/
|
||||
outp << name
|
||||
when /shift|click/i
|
||||
when 'Space'
|
||||
outp << " "
|
||||
else
|
||||
outp << " <#{name}> "
|
||||
end
|
||||
else
|
||||
outp << " <0x%.2x> " % vk
|
||||
end
|
||||
end
|
||||
return outp
|
||||
end
|
||||
|
||||
protected
|
||||
attr_accessor :client # :nodoc:
|
||||
|
||||
|
|
|
@ -277,32 +277,7 @@ class Console::CommandDispatcher::Stdapi::Ui
|
|||
def cmd_keyscan_dump(*args)
|
||||
print_line("Dumping captured keystrokes...")
|
||||
data = client.ui.keyscan_dump
|
||||
outp = ""
|
||||
data.unpack("n*").each do |inp|
|
||||
fl = (inp & 0xff00) >> 8
|
||||
vk = (inp & 0xff)
|
||||
kc = VirtualKeyCodes[vk]
|
||||
|
||||
f_shift = fl & (1<<1)
|
||||
f_ctrl = fl & (1<<2)
|
||||
f_alt = fl & (1<<3)
|
||||
|
||||
if(kc)
|
||||
name = ((f_shift != 0 and kc.length > 1) ? kc[1] : kc[0])
|
||||
case name
|
||||
when /^.$/
|
||||
outp << name
|
||||
when /shift|click/i
|
||||
when 'Space'
|
||||
outp << " "
|
||||
else
|
||||
outp << " <#{name}> "
|
||||
end
|
||||
else
|
||||
outp << " <0x%.2x> " % vk
|
||||
end
|
||||
end
|
||||
print_line(outp)
|
||||
print_line(client.ui.keyscan_extract(data))
|
||||
|
||||
return true
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue