BoyChai's Blog - 前端 2024-02-19T15:25:00+00:00 Typecho https://blog.boychai.xyz/index.php/feed/atom/category/%E5%89%8D%E7%AB%AF/ <![CDATA[[排错笔记]Vue3+Electron构建报错]]> https://blog.boychai.xyz/index.php/archives/68/ 2024-02-19T15:25:00+00:00 2024-02-19T15:25:00+00:00 BoyChai https://blog.boychai.xyz 使用环境
"Node":"21.6.2"
"@vue/cli-service": "~5.0.0",
"electron": "^13.0.0",

问题一

报错

background.js from Terser
Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:68:19)
    at Object.createHash (node:crypto:138:10)
    at E:\前端\assist\node_modules\vue-cli-plugin-electron-builder\node_modules\webpack\node_modules\terser-webpack-plugin\dist\index.js:217:37
    at Array.forEach (<anonymous>)
    at TerserPlugin.optimizeFn (E:\前端\assist\node_modules\vue-cli-plugin-electron-builder\node_modules\webpack\node_modules\terser-webpack-plugin\dist\index.js:160:259)
    at _next0 (eval at create (E:\前端\assist\node_modules\vue-cli-plugin-electron-builder\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:8:1)
    at eval (eval at create (E:\前端\assist\node_modules\vue-cli-plugin-electron-builder\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:23:1)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

原因

用了高版本的node.js

解决

给NODE_OPTIONS添加环境变量--openssl-legacy-provider,低版本的不需要,默认忽略ssl验证

set NODE_OPTIONS=--openssl-legacy-provider

问题二

报错

Error output:
!include: could not find: "E:\前端\assist\node_modules\app-builder-lib\templates\nsis\include\StdUtils.nsh"
Error in script "<stdin>" on line 1 -- aborting creation process

    at ChildProcess.<anonymous> (E:\前端\assist\node_modules\builder-util\src\util.ts:250:14)
    at Object.onceWrapper (node:events:634:26)
    at ChildProcess.emit (node:events:519:28)
    at ChildProcess.cp.emit (E:\前端\assist\node_modules\builder-util\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (node:internal/child_process:1105:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:305:5) {
  exitCode: 1,
  alreadyLogged: false,
  code: 'ERR_ELECTRON_BUILDER_CANNOT_EXECUTE'
}

原因

路径有中文路径

解决

切换项目目录给copy到个全英路径的位置

问题三

报错

打开页面全白

原因

路由模式用的history

解决

路由模式切换成hash模式

问题四

报错



<router-view>标签不生效

原因

不清楚为什么会这样 反正我这个版本打包后 electron不会进入”/“路径下 但是在本地访问的时候会

解决

在App.vue中直接push到/

import { useRouter } from "vue-router";

const router = useRouter();
router.push(`/`);

要注意的是router.back();路由跳转我这边也不生效了,需要都替换成push('/')

问题五

报错

 • cannot get, wait  error=Get "https://service.electron.build/find-build-agent?no-cache=1it6rqj": dial tcp 51.15.76.176:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
                      attempt=0
                      waitTime=2
  • cannot get, wait  error=Get "https://service.electron.build/find-build-agent?no-cache=1it6rqj": dial tcp 51.15.76.176:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
                      attempt=1
                      waitTime=4
  • cannot get, wait  error=Get "https://service.electron.build/find-build-agent?no-cache=1it6rqj": dial tcp 51.15.76.176:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
                      attempt=2
                      waitTime=6
  ⨯ Get "https://service.electron.build/find-build-agent?no-cache=1it6rqj": dial tcp 51.15.76.176:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

win跨平台构建linux从service.electron.build下载资源失败,换代理也没用

原因

这个站点service.electron.build似乎在2020年就关闭,一直也没人来修这个玩意

解决

换linux主机构建或者采用docker的容器进行构建
ISSUES:https://github.com/electron-userland/electron-build-service/issues/9

]]>
<![CDATA[[代码审计]攻防世界-simple_js]]> https://blog.boychai.xyz/index.php/archives/65/ 2023-10-08T01:26:00+00:00 2023-10-08T01:26:00+00:00 BoyChai https://blog.boychai.xyz 题目叫做simple_js,题目描述为

小宁发现了一个网页,但却一直输不对密码。(Flag格式为 Cyberpeace{xxxxxxxxx} )

打开网页之后是一个输入密码的框,自己随便输入点内容页面显示FAUX PASSWORD HAHA,自己肯定时没密码的,直接看源代码,核心代码如下

function dechiffre(pass_enc){
    var pass = "70,65,85,88,32,80,65,83,83,87,79,82,68,32,72,65,72,65";
    var tab  = pass_enc.split(',');
            var tab2 = pass.split(',');var i,j,k,l=0,m,n,o,p = "";i = 0;j = tab.length;
                    k = j + (l) + (n=0);
                    n = tab2.length;
                    for(i = (o=0); i < (k = j = n); i++ ){o = tab[i-l];p += String.fromCharCode((o = tab2[i]));
                            if(i == 5)break;}
                    for(i = (o=0); i < (k = j = n); i++ ){
                    o = tab[i-l];
                            if(i > 5 && i < k-1)
                                    p += String.fromCharCode((o = tab2[i]));
                    }
    p += String.fromCharCode(tab2[17]);
    pass = p;return pass;
}
String["fromCharCode"](dechiffre("\x35\x35\x2c\x35\x36\x2c\x35\x34\x2c\x37\x39\x2c\x31\x31\x35\x2c\x36\x39\x2c\x31\x31\x34\x2c\x31\x31\x36\x2c\x31\x30\x37\x2c\x34\x39\x2c\x35\x30"));

h = window.prompt('Enter password');
alert( dechiffre(h) );

上面定义了一个dechiffre(pass_enc)的函数,String["fromCharCode"](dechifre("xxx"))这个是把ASCII内容转换成字符串。剩下的就是打开页面之后都会出现的内容,参考意义不大,这里直接分析上面的这个函数
函数里面先定义了一个pass,内容如下

70,65,85,88,32,80,65,83,83,87,79,82,68,32,72,65,72,65

大概率就是ASCII码,之后又定义了一个tab,内容如下

var tab  = pass_enc.split(',');

pass_enc是传入的值,通过split(',')进行切割,现在tab是一个数组,之后定义了一个tab2,内容如下

var tab2 = pass.split(',');

对pass进行分割现在tab2也是个数组,之后定义了其他的一些变量,如下

var i,j,k,l=0,m,n,o,p = "";i = 0;j = tab.length;k = j + (l) + (n=0);n = tab2.length;

这里真是懵,最开始看的时候以为i,j,k,l都是0,一想不对。。。
最开始ijkmno都应该是undefined
之后i又被赋值了0,j被赋值了tab变量的长度,最后就是
k,m,oundefined之后i=0l=0p=""j=tab.lengthk=tab.lengthn=tab2.length,赋完值之后进行了一个for循环,代码如下

for(i = (o=0); i < (k = j = n); i++ ){
    o = tab[i-l];
    p += String.fromCharCode((o = tab2[i]));
    if(i == 5)break;
}
// 精简过后代码如下
for(i=0;i<tab2.length;i++){
//    o=tab[i];  
    p += String.fromCharCode(tab2[i]);
    if(i==5)break;
}

p += String.fromCharCode(tab2[i]);这段主要是这个代码,之后又经过了一个for循环,代码如下

for(i = (o=0); i < (k = j = n); i++ ){
    o = tab[i-l];
    if(i > 5 && i < k-1)
    p += String.fromCharCode((o = tab2[i]));
}
// 精简过后代码如下
for(i=0;i<tab2.length;i++){
//    o = tab[i]
    if (i>5&&i<(tab.length-1))p + = String.fromCharCode(tab2[i]);
}

p += String.fromCharCode(tab2[i]);这段主要是这个代码,和上段基本一样,方法最后返回下面内容

    p += String.fromCharCode(tab2[17]);
    pass = p;return pass;

他把tab2的第17个值转换成了字符串,并返回了p,这代码这是在闹着玩,弄到底也没处理传入的值,我服了😅,这代码的主要的作用就是把上面的ASCII转换成字符,直接转换pass变量发现内容为FAUX PASSWORD HAHA,看样子知道题目的答案就是把传入函数的那传Hex编码转换成字符串

\x35\x35\x2c\x35\x36\x2c\x35\x34\x2c\x37\x39\x2c\x31\x31\x35\x2c\x36\x39\x2c\x31\x31\x34\x2c\x31\x31\x36\x2c\x31\x30\x37\x2c\x34\x39\x2c\x35\x30

转换之后变成这样

55,56,54,79,115,69,114,116,107,49,50

转换成字符串变成这样

786OsErtk12

这道题目的答案即

Cyberpeace{786OsErtk12}
]]>