首页 > 其他分享 >JS逆向入门篇1

JS逆向入门篇1

时间:2022-09-02 22:46:50浏览次数:82  
标签:c3 逆向 url base64DecodeChars len JS 入门篇 var out

目标网站:https://ac.scmor.com/

第一步 点击关键字

image
visit('U3kwBQctIQAjMHZdVC1xRDs5LVQqURUfKxwQGjQACBZ5VysGVytwfmVgDQBVKSMZYRpbGwxAFhYOKl5JAWZRDw4EXzwWBwMT')

第二步 在控制台输入visit定位image

第三步 观察并且下断点

发现存在传入url的函数,发现可疑的加密函数!

补充知识点 单步跟踪和多行跳image

image

最关键一步 扣js代码--缺啥补啥image

缺base64decode

image

缺base64DecodeChars

image

缺Gword 这个特殊需要写死

image
image
image

成功了

image

中间遇到了一个错误

image
这个错误是由于被调用函数放在最后,调用时找不到该函数,需要把base64DecodeChars函数放在前面

爬取多个网站

image
发现 autourl这个变量,我们继续去断点那看是如何调用的 扣下来
image

然后修改下输出 把输出图片去掉 我们只要url 最后调用
image

最终效果image

参考代码

点击查看代码
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			function strdecode(string) {
			 string = base64decode(string);
			 key = Gword + hn;
			 len = key.length;
			 code = '';
			 for (i = 0; i < string.length; i++) {
			 var k = i % len;
			 code += String.fromCharCode(string.charCodeAt(i) ^ key.charCodeAt(k));
			 }
			 return base64decode(code);
			}
			
			
			var base64DecodeChars = new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1);
			var Gword = '21b5del6oIO57e01a'
			var hn = 'ac.scmor.com'
			//输出至控制台看看缺啥
			//console.log(strdecode('U3kwBQctIQAjMHZdVC1xRDs5LVQqURUfKxwQGjQACBZ5VysGVytwfmVgDQBVKSMZYRpbGwxAFhYOKl5JAWZRDw4EXzwWBwMT'));
			var autourl=["ZAM0RgYmLl0Ne3pZfjZxATgbMlcpJD8HKEMyGDdlfBVsMDcBbzgAf2xjJEhoDDBWYBkAFyE1eAghLA8M","U3kwBQctIQAjMHZdVC1xRDs5LVQqURUfKxwQGjQACBZ5VysGVytwfmVgDQBVKSMZYRpbGwxAFhYOKl5JAWZRDw4EXzwWBwMT","U3kwBQctIQAjMHZPbldbRQApNUc/DlQWKFdWBQ9bCV8=","U3kwBQctIQAjMHZPbhwFRjg2VkUqNyAWP31WBQ8AARQ=","U3kwBQctIQAjMHYGU1ZTRAMmD0cQDisWF31WBzRLBAhXDV1R","U3kwBQctIQAjMHYGU1ZTRAJTLV4pJFRcEEdWBQ9bCAxXHV1R","U3kwBQctIQAjMHZebTJmRgJTNUYQDiMAPkMtBSFFDF8=","U3kwBQctIQAjMHYBVBwFQgJSJR0RIFgZEUMAGQ==","U3kwBQctIQAjMHZPbldYRwMmJVc/DhUHEEM5Bw9cfw1RN1AGVAZxcg=="]
			
			function run() {
			    for (var i = 1; i < autourl.length; i++) {
			        url = autourl[i];
			        if (Gword != '')
			            url = strdecode(url);
			        var st = url.indexOf("//", 1);
			        var _domain = url.substring(st + 1, url.length);
			        var et = _domain.indexOf("/", 1);
			        surl = url.substring(0, et + st + 2);
			        document.write(url+'<br/>');   //<br/> == c语言中的\n
			    }
			}
			
			//调用输出的函数
			run()
			
			function base64decode(str) {
			    var c1, c2, c3, c4;
			    var i, len, out;
			    len = str.length;
			    i = 0;
			    out = "";
			    while (i < len) {
			        do {
			            c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
			        } while (i < len && c1 == -1);
			        if (c1 == -1)
			            break;
			        do {
			            c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
			        } while (i < len && c2 == -1);
			        if (c2 == -1)
			            break;
			        out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
			        do {
			            c3 = str.charCodeAt(i++) & 0xff;
			            if (c3 == 61)
			                return out;
			            c3 = base64DecodeChars[c3];
			        } while (i < len && c3 == -1);
			        if (c3 == -1)
			            break;
			        out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
			        do {
			            c4 = str.charCodeAt(i++) & 0xff;
			            if (c4 == 61)
			                return out;
			            c4 = base64DecodeChars[c4];
			        } while (i < len && c4 == -1);
			        if (c4 == -1)
			            break;
			        out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
			    }
			    return out;
			}
			
			
		</script>
	</body>
</html>

标签:c3,逆向,url,base64DecodeChars,len,JS,入门篇,var,out
From: https://www.cnblogs.com/fengxi110/p/16651561.html

相关文章

  • [Node.js] Setup a Node.js CLI
    CreatingaCLIinNode.jsjusttakesaextrasteportwobecausetheyarereallyjustanordinaryNode.jsappwrappedbehindabincommand.Forthisexercise,......
  • node34-node.js得异步api
     constfs=require('fs');fs.readFile('./1.txt','utf8',(err,result1)=>{console.log(result1);fs.readFile('./2.txt','utf8',(err,result2)......
  • node36-node.js得异步api
    constfs=require('fs');fs.readFile('./1.txt','utf8',(err,result1)=>{console.log(result1);fs.readFile('./2.txt','utf8',(err,result2)=>......
  • nnUNet使用指南(四):json文件的配置
    代码如下fromcollectionsimportOrderedDictimportglobimportosimportreimportjsonfrombatchgenerators.utilities.file_and_folder_operationsimport*d......
  • Python入门系列(八)日期时间、数学、json
    日期时间Python中的日期本身不是数据类型,但我们可以导入一个名为datetime的模块,将日期作为日期对象使用。importdatetimex=datetime.datetime.now()print(x)日期......
  • jszip基本使用及应用实例
    前言网页端操作将一堆文件批量操作打包成一个压缩包一次性下载给用户,现成的插件可以用jszip,需要了解底层可以自行阅读源码这里记录jszip的基本用法及自已项目需求下......
  • 【JS每日刷题】栈与任务队列1
    代码题目来源于前端面试题宝典constfoo=()=>console.log('First')constbar=()=>setTimeout(()=>console.log('Second'))constbaz=()=>console.log('T......
  • 解决报错:vuex.esm-bundler.js?03c9:976 [vuex] unknown mutation type
    记录一个非常让人无语的事情,在使用vuex的时候出现了以下错误vuex.esm-bundler.js?03c9:976[vuex]unknownmutationtype:user/[email protected]?03......
  • 一维JSON转树结构
    consttreeFormat=(arr:any)=>{letmap:any={};//构建map//构建以id为键当前数据为值arr.forEach((item:any)=>{item["children"]=[];......
  • 前端JS-Day17
    JSWebAPIDOM:文档对象模型  DOM树: 获取元素的方法:①根据ID:getElementById()方法.②根据标签名:getElementByTagName()方法.返回元素对象的集合,以伪数组......