出海企业系列风险分析--网站需要验证码吗?

news2024/10/6 20:38:17

最近接待了几位从discuz来的用户,说是想要给自己海外的网站安装验证码,但是discuz境外服务器还要解析安装中心的DNS到境外服务器上,所以基于discuz建站的不好之处就在这里。

而且我们还讨论到一个问题,海外的网站,需要用到滑动验证码吗?

经过激烈的“大战三百回合”,我们得出了结论:必须要

原因有三:

  1. 防止恶意行为:国外的geek可比国内的嚣张多了,各种恶意攻击、刷票、撞库、暴力破解密码等

  2. 保护数据和内容:爬虫什么的,国外格外嚣张,而且各种破解工具开源

  3. 应对垃圾信息和垃圾账号:通过要求用户手动完成滑动验证,可以有效减少无意义的注册和发布垃圾信息的行为。尤其是对于内容类网站,比如说论坛。

所以说,如果想要做国外的网站或者是App,那么做好防护是必须的。而简单好用且便宜的动态验证码是首选。

今天就来教大家怎么去在自己海外的网站上安装验证码。

一、前端

01 找到相应的供应商。

可以在discuz找(如果是基于discuz建站的,那你就只有这一个选项),或者使用极验,或者其他提供免费服务的。我们以一家小公司AiSecruis的abtCaptcha为例(链接我就不放了,大家自行选择合适的即可,有需要可以一起交流:出海交流)。

02 确认自己网站

环境先决条件:兼容IE8+、Chrome、Firefox等主流浏览器。

03 激活服务

激活atbCAPTCHA服务:创建Applcation,获取apiServer、appld、appSecret;

image.png

脚本的使用:

<script src="https://cdn.aisecurius.com/ctu-group/captcha-ui/v5/index.js" crossorigin="anonymous" id="as-captcha-script"></script>

注意:  atbCAPTCHA 脚本经常更新,请务必使用 CDN 上的资源获取最新的安全更新。不要在自己的服务器上使用副本。

04 初始化

以下是 valina JavaScript、React 和 Vue 演示。

1)JavaScript 示例

假设<div id="demo"></div>页面上有a,atbCAPTCHA可以按如下方式初始化。

var myCaptcha = as.Captcha(document.getElementById('demo'), {
  appId: 'your appId', // appId, Obtaining from the console "Application Management" or "Application Configuration" module,
  apiServer: 'https://cap.aisecurius.com',
  // apiServer, The domain name address is obtained in the top left corner of the console page -> atbCAPTCHA -> "Application Management" page. It is a must to fill in it completely, including https://.
  success: function (token) {
    console.log('token:', token)
    // The atbCAPTCHA token is obtained for back-end verification. Note that if the obtained token is a string starting with sl, it is a downgraded token generated by the front-end network blocked. Please check the front-end network and apiServer address.
  }
})

初始化后,abtCAPTCHA 组件将被插入到<div id="demo"></div>.

2) React 示例

假设页面上有<div id="demo"></div>abtCAPTCHA 可以初始化如下:

// class component use componentDidMount
useEffect(() => {
  as.Captcha(document.getElementById('demo'), {
    appId: 'appId',
    apiServer: 'https://xxx.xxx.com',
    success: function (token) {
      console.log('token:', token)
    }
  });
}, [])

初始化后,atbCAPTCHA 组件将被插入到<div id="demo"></div>.

3) Vue 示例

假设页面上有<div ref="demo"></div>abtCAPTCHA 可以初始化如下:

mounted() {
  as.Captcha(this.$refs.demo, {
    appId: 'appId',
    apiServer: 'https://xxx.xxx.com',
    success: function (token) {
      console.log('token:', token)
    }
  });
}

初始化后,atbCAPTCHA 组件将被插入到<div ref="demo"></div>.

4) 外观及尺寸

atbCAPTCHA 有四种样式:

  • embed 嵌入式(默认),这种样式下宽度默认为 300px,可通过初始化时的 width 参数调节,高度为 200px,高度不可调节
  • inline 内联式,这种样式占用面积较小,宽度默认为 300px,可通过初始化时的 width 参数调节,高度为 40px,高度不可调节
  • popup 弹出式,这种样式验证码默认不可见,调用 .show() 方法后将以浮层的形式展现,宽度为 300px,高度为 200px
  • oneclick 触发式,这种样式占用面积较小,宽度默认为 300px,可通过初始化时的 width 参数调节,高度为 40px,高度不可调节

05 Methods

atbCAPTCHA 实例具有以下方法:

reload() :重新加载当前的 atbCAPTCHA

注意!请不要在成功回调中调用reload(),因为开启无感验证时会重复调用成功回调。

例子:

myCaptcha.reload()

show() :显示当前的 atbCAPTCHA

如果显示当前的atbCAPTCHA,“style”为“popup”的验证码,默认隐藏。接入用户需要根据页面逻辑调用show()方法来显示和隐藏当前的atbCAPTCHA。

例子:

myCaptcha.show()

hide() :隐藏当前验证码

例子:

myCaptcha.hide()

06 Event

abtCAPTCHA 可用于通过以下方式监听事件:

myCaptcha.on('ready', function () {
  console.log('captcha is ready!')
})

myCaptcha.on('verifySuccess', function (security_code) {
  console.log('security_code is: ' + security_code)
})

myCaptcha.on('hide', function () {
  console.log('The verification code control is hidden. ')
})

具体的样式与语言也是可以自定义操作的,具体可以根据自己的需求来。

二、后端

01 Java版本

下载Java7及以上版本的SDK。

Maven 依赖

<dependency>
  <groupId>com.aisecurius</groupId>
  <artifactId>ctu-security-sdk</artifactId>
  <version>3.0</version>
</dependency>
/** The initialization parameters are appid and appSecret 
 * The appid is consistent with the appid of the frontend, and the appid can be disclosed 
 * The appSecret is the secret key, please do not disclose it 
 * The token can be obtained after the verification is completed at the frontend and sent to the backend with the your Form/XHR request. The token is valid for two minutes 
 **/
String appId = "appId";
String appSecret = "appSecret";
CaptchaClient captchaClient = new CaptchaClient(appId,appSecret);
CaptchaResponse response = captchaClient.verifyToken(token);
System.out.println(response.getCaptchaStatus());
// A fault-tolerant mechanism is designed in the SDK, response.getResult() will be returned true if there is an exception in the network
if (response.getResult()) {
    /** The token verification passes, to continue other processes **/
} else {
    /** If the token verification fails, you can directly block the request or continue to pop up the CAPTCHA **/
}

02 PHP版本

下载PHP版SDK:  点击下载

include ("CaptchaClient.php");
/** The initialization parameters are appid and appSecret 
 * The appid is consistent with the appid of the frontend, and the appid can be disclosed 
 * The appSecret is the secret key, please do not disclose it 
 * The token can be obtained after the verification is completed at the frontend and sent to the backend with the your Form/XHR request. The token is valid for two minutes 
 **/
$appId = "appId";
$appSecret = "appSecret";
$client = new CaptchaClient($appId,$appSecret);
$client->setTimeOut(2);      // Set the timeout, 2 seconds by default; 
$response = $client->verifyToken(token);  // ; The token refers to the value passed from the frontend, that is, the token issued after the verification code is successfully verified
echo $response->serverStatus;
// A fault-tolerant mechanism is designed in the SDK, response.getResult() will be returned true if there is an exception in the network
if($response->result){
    echo "true";
    /** the token verification passes, to continue other processes **/
}else{
    echo "false";
    /** Verification failed **/
}

03 Python版本

Python版本SDK下载:  点击下载

from CaptchaClient import CaptchaClient

if __name__ == '__main__':
    APP_ID = '12610axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    APP_SECRET = 'a3e56cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
    captchaClient = CaptchaClient(APP_ID, APP_SECRET)
    captchaClient.setTimeOut(2)
    # Set the timeout, 2 seconds by default
    response = captchaClient.checkToken("token")
    print response['serverStatus']
    # A fault-tolerant mechanism is designed in the SDK, response.getResult() will be returned true if there is an exception in the network
    print response['result']
    if response['result']:
        # the token verification passes, to continue other processes; 
        pass
    else:
        # If the verification fails, you can directly block the request or continue to pop up the CAPTCHA 
        pass

04 Golang SDK

SDK下载地址

// Version Go 1.13 

import "./captcha-client"

/** The initialization parameters are appid and appSecret 
 * The appid is consistent with the appid of the frontend, and the appid can be disclosed 
 * The appSecret is the secret key, please do not disclose it 
 * The token can be obtained after the verification is completed at the frontend and sent to the backend with the your Form/XHR request. The token is valid for two minutes 
 **/
appId := "appId"
appSecret := "appSecret"
captchaClient := captcha_client.NewCaptchaClient(appId, appSecret)
//captchaClient.SetTimeout(2000)
// Set the timeout, in milliseconds, 2 seconds by default 
captchaResponse := captchaClient.VerifyToken(token)
// A fault-tolerant mechanism is designed in the SDK, response.getResult() will be returned true if there is an exception in the network
//fmt.Println(captchaResponse.Ip)
if captchaResponse.Result {
    /* The verification passes, to continue other processes  */
} else {
    /* If the verification fails, you can directly block the request or continue to pop up the CAPTCHA  */
}

结语

公司出海不容易,或者说,搭一个海外的网站不容易,大家前期的防护一定要做好,不然就很容易直接被人冲了。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/751765.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【线程概念和线程控制】

目录 1 :peach:线程概念 :peach:1.1 :apple:什么是线程&#xff1f;:apple:1.2 :apple:线程的优点和缺点:apple:1.3 :apple:页表的大小:apple:1.4 :apple:线程异常和用途:apple:1.5 :apple:进程VS线程:apple: 2 :peach:线程控制:peach:2.1 :apple:POSIX线程库:apple:2.2 :apple…

tp6的runtime/Logs目录下产生大量日记文件,怎么取消自动生成?

一开始查了好多网上提供的&#xff0c;很幸运都是抄袭别人的&#xff0c;没一个成功&#xff0c;最后无奈只能自己解决方法 其实很简单&#xff0c;不用修改config/log.php文件&#xff0c;没用因为只要有登入错误&#xff0c;警告&#xff0c;消息或者sql错误都会写入 解决方…

windows编译poco c++库

背景 最近有了解到poco c库&#xff0c;这里记录下编译及使用过程。 最开始使用的vs studio 2022 和 poco 1.12.4版本编译&#xff0c;不管openssl 使用哪种版本&#xff0c;都会编译报错&#xff0c;最后妥协了。 参考&#xff1a;https://www.bilibili.com/read/cv1416565…

《语文新读写》期刊简介及投稿邮箱

《语文新读写》期刊简介&#xff1a; 《语文新读写》是“国家期刊奖”获奖期刊&#xff0c;中国期刊方阵双效期刊&#xff0c;中国核心期刊&#xff08;遴选&#xff09;数据库收录期刊&#xff0c;被授予上海市期刊优秀编辑部。杂志的主要读者对象为各大院校、中小学各科教师…

安全帽佩戴检测算法模型训练详细流程

一、任务描述 实际施工现场需要对每个进出的人员进行安全帽监测&#xff0c;对未佩戴安全帽的人员平台进行风险告警&#xff0c;通知工作人员并记录下来。 主要包括三类目标物体&#xff1a;头盔&#xff08;helmet&#xff09;&#xff0c;人&#xff08;person&#xff09;…

100种思维模型之耗散结构理论思维模型-96

避免熵死的方法之一就是建立 耗散结构 。 那么&#xff0c;何谓耗散结构理论&#xff1f; 01、何谓耗散结构思维模型‍‍‍ 一、耗散结构理论 1969年&#xff0c;比利时学者 伊里亚普利高津 在对热力学第二定律研究的基础上&#xff0c;提出了 “耗散结构理论”。 他认…

【导航电子地图(MAP)模块功能】

Map功能&#xff1a;提供导航系统中地图描画、地图操作、地图检索的功能。 地图操作功能&#xff1a;地图滚动等。 地图检索功能&#xff1a;附近名称取得、View内检索等。 地图描画功能&#xff1a;是指从地图Data base中读出地点情报&#xff0c;然后按照一定的风格&#…

Meta提出全新参数高效微调方案,仅需一个RNN,Transformer模型GPU使用量减少84%!

近来&#xff0c;随着ChatGPT和GPT-4模型的不断发展&#xff0c;国内外互联网大厂纷纷推出了自家的大语言模型&#xff0c;例如谷歌的PaLM系列&#xff0c;MetaAI的LLaMA系列&#xff0c;还有国内公司和高校推出的一些大模型&#xff0c;例如百度的文心一言&#xff0c;清华的C…

vue3中通过vue-i18n实现国际化

效果图 前言 突然想在vue3项目中使用国际化功能&#xff0c;查阅相关资料后发现和vue2的用法有些出入&#xff0c;记录一下 使用 下载vue-i18n npm i vue-i18n2、准备语言文件 目前我的项目只支持中英文切换&#xff0c;故准备一份中文文件和一份对应的英译文件 创建langur…

七大排序算法——直接插入排序,通俗易懂的思路讲解与图解(完整Java代码)

文章目录 一、排序的概念排序的概念排序的稳定性七大排序算法 二、直接插入排序核心思想代码实现 三、性能分析四、七大排序算法性能对比 一、排序的概念 排序的概念 排序&#xff1a;所谓排序&#xff0c;就是使一串记录&#xff0c;按照其中的某个或某些关键字的大小&#…

【Java进阶之路】NIO基础

一、NIO基础 Java New IO是从Java1.4版本开始引入的一个新的IO api&#xff0c;可以替代以往的标准IO&#xff0c;NIO相比原来的IO有同样的作用和目的&#xff0c;但是使用的方式完全不一样&#xff0c;NIO是面向缓冲区的&#xff0c;基于通道的IO操作&#xff0c;这也让它比传…

美团外卖智能陪伴型导购的探索与实践

相比于其他电商场景&#xff0c;外卖场景对于实时发现和反馈用户兴趣的能力有着更高的要求。近年来&#xff0c;美团外卖算法团队摸索出了一套适用于外卖场景的智能陪伴型导购架构和策略。这一举措已经取得了显著成效&#xff0c;本文将详细介绍外卖搜索技术团队搭建智能陪伴型…

Redis数据结构 — IntSet

目录 整数集合IntSet结构设计 IntSet的升级操作 升级具体过程 升级具体源码 小结 IntSet是Redis中set集合的一种实现方式&#xff0c;基于整数数组来实现&#xff0c;并且具备长度可变、有序等特征。 整数集合IntSet结构设计 整数集合本质上是一块连续内存空间&#xff…

Ubuntu22.04安装飞书

通过以下教程可以快速的安装飞书。 安装包下载 进入飞书下载官网下载飞书Linux客户端 选择deb格式安装包下载 安装方式 方式一&#xff1a;运行安装包安装 双击deb文件&#xff0c;点击install进行安装 方式二&#xff1a;终端命令安装 到安装目录&#xff0c;然后dpkg你的安…

光速吟唱,Clibor ,批量多次复制依次粘贴工具 快捷输入软件教程

批量多次复制依次粘贴工具 批量复制粘贴工具0.81.exe https://www.aliyundrive.com/s/3sbBaGmHkb8 点击链接保存&#xff0c;或者复制本段内容&#xff0c;打开「阿里云盘」APP &#xff0c;无需下载极速在线查看&#xff0c;视频原画倍速播放。 青县solidworks钣金设计培训 …

Web3.0:重新定义数字资产的所有权和交易方式

随着区块链技术的发展和应用&#xff0c;数字资产的概念已经逐渐深入人心。数字资产不仅包括加密货币&#xff0c;还包括数字艺术品、虚拟土地、游戏道具等各种形式的数字物品。然而&#xff0c;在传统的互联网环境下&#xff0c;数字资产的所有权和交易方式往往受到限制和约束…

二极管总结

目录 1.2.2二极管的伏安特性 1.2.3二极管的主要参数 1.2.4二极管的等效电路 1.2.5稳压二极管 1.2.6其它类型二极管 1.2.2二极管的伏安特性 二极管和PN结伏安特性区别&#xff1a; 相同点&#xff1a;同样具有单向导电性 不同点&#xff1a;二极管存在半导体体电阻和引线电阻…

Android JNI线程的创建 (十二)

🔥 Android Studio 版本 🔥 🔥 创建JNI 🔥 package com.cmake.ndk1.jni;public class JNIThread {static {System.loadLibrary("thread-lib");}public native void createNativeThread();public native void createNativeThreadWithArgs();public native v…

金科威GoldWayUT4000监护仪协议对接

通过网口&#xff0c;成功对接到参数&#xff1a; Sys、Dia、Map、Temp、HR、SPO2、Resp、RR、EtCO2、InCO2等数值。

玩玩两个简单的python的web框架 flask、fastapi

IDEA连接远程解释器&#xff0c;本地代码编辑无法代码提示 一、Flask入门使用 官网 其它参考 注意 1.这里使用linux 192.168.72.126上远程解释器,需要/usr/bin/pip3 install flask&#xff0c;host参数不要使用localhost/127.0.0.1,即只监听本地的访问&#xff0c;会导致wind…