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/hulutech-web/goravel-captcha
一个go语言开发的,基于goravel框架的行为验证码。
go get github.com/hulutech-web/goravel-captcha
项目的config/app.go
下
"github.com/hulutech-web/goravel-captcha"
"providers": []foundation.ServiceProvider{
...
&captcha.ServiceProvider{},
}
系统默认提供了2个验证码路由,一个是获取验证码,一个是校验验证码 扩展包captcha/routers/router.go
route.Get("api/captcha", captchaController.GetCaptcha)
route.Post("api/captcha", captchaController.PostCaptcha)
GetCaptchaRequest
type GetCaptchaRequest struct {
Image string `json:"image"` //base64图片数据
ThumbImage string `json:"thumb_image"` //缩略图数据,base64
Key string `json:"key"` //验证码唯一的key
Dots map[int]Capt.CharDot `json:"dots"` //文字坐标点
}
type CharDot struct {
// 顺序索引
Index int
// x,y位置
Dx int
Dy int
// 字体大小
Size int
// 字体宽
Width int
// 字体高
Height int
// 字符文本
Text string
// 字体角度
Angle int
// 颜色
Color string
// 颜色2
Color2 string
}
CaptchaReq
,该类型由前端配套组件goravel-captcha-vue提供,无需自行实现type CaptchaReq struct {
Dots string `json:"dots"`
Key string `json:"key"`
}
captcha_controller已封装到扩展包中,代码如下:
package controllers
import (
"github.com/goravel/framework/contracts/http"
Capt "github.com/hulutech-web/goravel-captcha"
)
type CaptchaController struct {
}
func NewCaptchaController() *CaptchaController {
return &CaptchaController{}
}
func (c *CaptchaController) GetCaptcha(ctx http.Context) http.Response {
type GetCaptchaRequest struct {
Image string `json:"image"` //base64图片数据
ThumbImage string `json:"thumb_image"` //缩略图数据,base64
Key string `json:"key"` //验证码唯一的key
Dots map[int]Capt.CharDot `json:"dots"` //文字坐标点
}
dots, b64, tb64, key, err := Capt.MakeCaptcha()
if err != nil {
return ctx.Response().Json(http.StatusInternalServerError, http.Json{
"errors": err,
})
}
var req GetCaptchaRequest
req.Dots = dots.(map[int]Capt.CharDot)
req.Image = b64
req.ThumbImage = tb64
req.Key = key
return ctx.Response().Success().Json(req)
}
func (c *CaptchaController) PostCaptcha(ctx http.Context) http.Response {
type CaptchaReq struct {
Dots string `json:"dots"`
Key string `json:"key"`
}
var req CaptchaReq
if err := ctx.Request().Bind(&req); err != nil {
return ctx.Response().Json(http.StatusInternalServerError, http.Json{
"error": "参数错误",
})
}
checked := Capt.VerifyCaptcha(req.Key, req.Dots)
if checked {
return ctx.Response().Success().Json(http.Json{
"message": "验证成功",
"code": 200,
})
}
return ctx.Response().Json(http.StatusInternalServerError, http.Json{
"error": "验证失败",
})
}
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.