当前位置:网站首页>Dynamically debug JS code
Dynamically debug JS code
2022-07-21 04:43:00 【Jelly cavalierly】
Preface
In some CTF In the race , Often some topics are given a coded JavaScript Code , In the end there will be eval() A function like this .
eval() function
eval Function evaluates a string as a numeric expression , Its grammar is :
eval(expr)
here expr Is a string parameter that is evaluated .
If the string is an expression ,eval Find the value of the expression ;
If this parameter represents one or more JavaScript sentence , that eval Execute these statements .
eval Function can be used to convert a date from a format ( Always string ) Convert to a numeric expression or number .
eval(expr)
here expr Is a string parameter that is evaluated .
If the string is an expression ,eval Find the value of the expression ;
If this parameter represents one or more JavaScript sentence , that eval Execute these statements .
eval Function can be used to convert a date from a format ( Always string ) Convert to a numeric expression or number .
The following is Hetian CTF Here's an example , Give a very messy JS Code , But in execution JavaScript In the process of code , It can be done to eval Function down , Check the decoded JS Code .
First , take js Code compilation html Webpage , for example
<html>
<head>
<title>js Code debugging </title>
<script>_='function $(){e=getEleById("c").value;length==16^be0f23233ace98aa$c7be9){tfls_aie}na_h0lnrg{e_0iit\'_ns=[t,n,r,i];for(o=0;o<13;++o){ [0]);.splice(0,1)}}} \'<input id="c">< οnclick=$()>Ok</>\');delete _var ","docu.)match(/"];/)!=null=[" write(s[o%4]buttonif(e.ment';for(Y in $=' ')with(_.split($[Y]))_=join(pop());
eval(_)</script>
</head>
<body>
</body>
</html>
stay Chrome Execute this web page in the browser , Then open the firebug 

<script>_='function $(){e=getEleById("c").value;length==16^be0f23233ace98aa$c7be9){tfls_aie}na_h0lnrg{e_0iit\'_ns=[t,n,r,i];for(o=0;o<13;++o){ [0]);.splice(0,1)}}} \'<input id="c">< οnclick=$()>Ok</>\');delete _var ","docu.)match(/"];/)!=null=[" write(s[o%4]buttonif(e.ment';for(Y in $=' ')with(_.split($[Y]))_=join(pop());eval(_)</script>
stay eval After the function breaks , Reload this page , You can go to VM231 See the decoded js Code , as follows function $()
{var e=document.getElementById("c").value;
if(e.length==16)
if(e.match(/^be0f23/)!=null)
if(e.match(/233ac/)!=null)
if(e.match(/e98aa$/)!=null)
if(e.match(/c7be9/)!=null)
{var t=["fl","s_a","i","e}"];
var n=["a","_h0l","n"];
var r=["g{","e","_0"];
var i=["it'","_","n"];
var s=[t,n,r,i];
for(var o=0;o<13;++o){
document.write(s[o%4][0]);s[o%4].splice(0,1)}
}}document.write('<input id="c"><button οnclick=$()>Ok</button>');delete _
flag{it's_a_h0le_in_0ne}
边栏推荐
- Fun guessing game (not binary search! Four digits)
- Quota of disks
- Jupyternotebook plug-in management and installation
- Dynamic routing protocol rip experiment
- MySQL installation
- Quickly understand shell scripts
- HDLC PAP chap mGRE comprehensive experiment
- Access数据库对象包括哪六个?Access与 Excel 最重要的区别是什么?
- testApi(node写测试接口无需数据库,有基础数据)
- JS笔试题--随机数,数组去重
猜你喜欢
随机推荐
目录和文件管理
FigDraw 14. SCI 文章绘图之和弦图及文章复现(Chord Diagram)
RNA 20. SCI 文章中单样本免疫浸润分析 (ssGSEA)
MySQL installation
Check if the average CPU load is too high (iowait load is high)
Game improvement of smart people: Lesson 2 of Chapter 3: number of factors (dcount)
Bond network mode
C語言基本概念——每天一遍小知識
Become a blogger in a year? To! Struggling oneself
最新UPX3.91-支持win64/PE-加/脱壳
来自一个菜鸟的爬虫分析过程(文末附代码)
SCS【1】今天开启单细胞之旅,述说单细胞测序的前世今生
RAID disk array
Dynamic routing protocol rip experiment
VRRP虚拟路由器冗余协议
安全开发之IP地址伪造
「Object.defineProperty」【面试业务必备】
Hibernate防止SQL注入攻击的方法
ibatis与SQL注入
JS笔试题--原型,new,this综合题