Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
github.com/jack15083/go-websocket-broadcast
golang websocket 服务可通过http接口push消息到web客户端,消息发送采用golang的并发模式发送,并异步记录发送的消息日志。
本项目websocket使用用户token验证连接,这一块验证的逻辑需要根据自己的业务去更改或删除。
例如使用PHP客户端push消息
<?php
/**
* Created by PhpStorm.
* Date: 2019/5/23
* Time: 17:03
*/
require_once 'XHXPushApi.php';
$title = "通知标题pxy";
$content = "测试通知内容,测试通知内容,测试通知内容,测试通知内容,测试通知内容,测试通知内容。";
/** push接口支持的参数
* @param $senderId //发送者id
* @param $senderName //发送者姓名
* @param $msgType //消息类型 1发送在线用户即时消息 2登录后必达消息 3业务内容更新消息
* @param $title //消息标题
* @param $content //消息内容数组或字符串,如果是数组将会被json_encode
* @param $userIds //用户id以,号分隔 msgType为2时userIds必传
* @param $options //弹窗选项目前支持 duration(毫秒), position, type参数(对应elementUi通知组件参数)
* @return array
*/
$res = XHXPushApi::getInstance()->push(1,'god', 2, $title, $content, [44, 63]);
print_r($res);
client.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- import CSS -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
new Vue({
el: '#app',
data() {
return {
visible: false,
ws:'',
interval:'',
retryConnect:false,
}
},
created() {
this.init()
},
methods: {
init() {
if (!window["WebSocket"]) {
console.log('not support websocket')
return
}
var that = this;
this.ws = new WebSocket('ws://127.0.0.1:9002/ws/' + '?token=xxxxx&uid=xxx');
this.ws.onclose = function(e) {
clearInterval(that.interval)
if(!that.retryConnect) {
return
}
console.log('push connection is close, retry connect after 5 seconds')
setTimeout(function() {
that.init()
}, 5000);
}
this.ws.addEventListener('open', function (e) {
});
this.ws.addEventListener("message", function(e) {
let res = JSON.parse(e.data)
//token过期
if(res.error == 100) {
console.log(res)
that.retryConnect = false
return
}
if(res.error != 0) {
console.log(res.msg)
return
}
//client注册消息
if(res.event == 'register') {
console.log('ws connection register success ')
that.interval = setInterval(function() {
//保此常连接心跳
that.ws.send('{}')
}, 60000)
that.retryConnect = true
return;
}
if(res.event == 'message') {
let options = JSON.parse(res.data.options);
that.$notify.info({
title: res.data.title != '' ? res.data.title : '通知',
message: res.data.content,
duration: options.duration,
position: options.position
});
}
})
}
}
})
</script>
</html>
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.