Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #5

Merged
merged 9 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ node_modules
*.log
.vercel
out

code_*.js
history_*.js
tmp/*
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
shamefully-hoist=true
strict-peer-dependencies=false
auto-install-peers=true
strict-peer-dependencies=false
11 changes: 8 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
"prettier.enable": false,
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": false
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
"eslint.experimental.useFlatConfig": true
"eslint.experimental.useFlatConfig": true,
"typescript.tsdk": "node_modules/typescript/lib",
"code-runner.executorMap": {
"javascript": "node",
"typescript": "tsx"
}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pnpm i
│ ├── code_2.js # 记录反混淆过程代码 2
│ ├── pretty.js # 可选, 用作美化对比
│ ├── output.js # 最终处理完成的结果
│ ├── evalCode.js # 代注入执行代码
│ ├── setupCode.js # 注入执行代码
│ ├── errorCode.js # 当替换代码导致语法错误, 则将错误代码输出到该文件
```

Expand All @@ -51,5 +51,6 @@ TODO...
## 致谢

- [反爬虫 AST 原理与还原混淆实战](https://book.douban.com/subject/35575838/)
- [j4k0xb/webcrack](https://github.com/j4k0xb/webcrack)
- [sxzz/ast-explorer](https://github.com/sxzz/ast-explorer)

18 changes: 17 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
import { antfu } from '@antfu/eslint-config'

export default antfu({
ignores: ['**/code.js', '**/code copy.js', '**/code_*.js', '**/output.js', '**/pretty.js', '**/errorCode.js', '**/evalCode.js'],
ignores: [
'**/input.js',
'**/output.js',
'**/history_*.js',
'**/pretty.js',
'**/setupCode.js',
'**/errorCode.js',
'tmp/**/*',
'**/*.js',
],
}, {
rules: {
'no-console': 'off',
'no-eval': 'off',
'no-restricted-globals': 'off',
'node/prefer-global/process': 'off',

'curly': 'off',
'unused-imports/no-unused-vars': 'warn',

'ts/consistent-type-imports': 'off',
'ts/no-use-before-define': 'off',
'no-unused-expressions': 'off',
'test/consistent-test-it': 'off',

'antfu/if-newline': 'off',
},
})
59 changes: 0 additions & 59 deletions example/cx/index.js

This file was deleted.

33 changes: 33 additions & 0 deletions example/cx/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import fs from 'node:fs/promises'
import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'

import type { Options } from 'deob'
import { Deob, codePrettier, generate } from 'deob'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

; (async function () {
const options: Options = {
stringArraylength: 100,
isDebug: false,
}

const rawCode = await fs.readFile(`${__dirname}/input.js`, 'utf-8')

const deob = new Deob(rawCode, options)

await fs.writeFile(`${__dirname}/pretty.js`, codePrettier(deob.ast))

const { code, historys, save } = await deob.run()
save(__dirname)

// 输出 ast 处理历史用于调试, 需要 isDebug: true
for (let i = 0; i < historys.length; i++) {
const ast = historys[i]
const code = generate(ast)

await fs.writeFile(`${__dirname}/history_${i}.js`, code)
}
})()
File renamed without changes.
Loading
Loading