JavaScript for hackers

java源码hacker-JavaScript-for-Hackers:源代码 java源码 hacker 立即下载

Introduction

I love to use JavaScript in unexpected ways, to create code that looks like it shouldn't work but does, or produces some unexpected behavior. This may sound trivial, but the results I've found lead to some very useful techniques. Each of the techniques described can be used for XSS filter evasion, which was my original intention when developing them. However, learning such JavaScript can dramatically increase your knowledge of the language, helping you become better at cleaning up input, and increase web application security.

So read on and enjoy my weird and wonderful JavaScript hacks.

RegExp replace can execute code

When using regular expressions with replace the second argument supports a function assignment. In Opera it seems you can use this argument to execute code. For example, check out the code snippet below:

'XSS'.replace(/XSS/g,alert)

This results in alert('XSS') ; this works because the match from the RegExp is passed to the alert function as an argument. Normally you would use a function to perform another routine on the matched text, like so:

'somestring'.replace(/some/,function($1){//do something with some})

But as you can see in the first example in this section, instead of a user defined function we are executing a native alert call, and the arguments are passed to the native call from the regular expression. It's a cool trick and could be used to evade some XSS filters, for example if you inject a string then proceed with a dot you can then call any function you like.

To see how this is used in a XSS context, imagine we have an unfiltered " in the string in which an injection occurs, such as a JavaScript event or a script tag. First we inject our payload alert(1) , then we break out of the quotes - " - and continue our regular expression:

.replace(/.+/,eval)//

Notice I use eval here to execute any code I like and the regular expression matches everything so that the full payload is passed to eval .

If I put all the code together and show you the output of the page it is easier to understand what is going on:

Page output:

<script>somevariableUnfiltered="YOUR INPUT"</script>

The above code is common in analytics scripts where your search string is stored by an advertising company. You often don't see these scripts but if you view the source of a web page you'll find that they are a regular occurrence; forums are another place where they are prevalent. "YOUR INPUT" is the string you have control of; this is also referred to as DOM based XSS if the input isn't filtered correctly.

Input:

alert(1)".replace(/.+/,eval)//

Resulting output:

<script>somevariableUnfiltered="alert(1)".replace(/.+/,eval)//"</script>

Notice the single line comment used to remove the trailing quote.

Unicode escapes

Although it's not possible to use parentheses when escaping unicode characters, you can escape the name of the function being called, for example:

/u0061/u006c/u0065/u0072/u0074(1)

This calls alert(1) ; /u indicates it's a unicode escape and the hex number after specifies the character. /u0061 is "a" and so on.

Mixing and matching unicode escapes is possible with normal characters; the example below demonstrates this:

/u0061lert(1)

You can also include them in strings and even evaluate them using eval . Unicode escapes are different to normal hex or octal escapes because they can be included in a string, or a reference to a function, variable or object.

The example below shows how to use unicode escapes that are evaluated and split into separate parts:

eval('//u'+'0061'+'lert(1)')

By avoiding normal function names like alert , we can fool XSS filters into injecting our code. This very example was used to bypass PHPIDS (an open source IDS system), which resulted in the rules subsequently being made much stronger. If you are considering decoding JavaScript for malware analysis at runtime you need to consider the possible ways that multiple levels of encoding can work; as you can see from this example it won't be a easy task.

JavaScript parser engine

JavaScript is a very dynamic language. It can execute a surprising amount of code that at first glance doesn't look valid, however once you know how the parsers work, you begin to understand the logic behind it.

JavaScript doesn't know the result of a function until it is executed, and obviously it has to call the function to return the variable type. This leads to an interesting quirk - for example, if the returning function doesn't return a valid value for the code block, a syntax error will occur after the execution of the function.

What does this mean in English? Well, code speaks louder than words - check this example out

+alert(1)--

The alert function executes and returns undefined but by that time it is too late - the decrement operator is expecting a number and therefore raises an error.

Here's a few more valid examples that don't raise errors but are interesting nevertheless.

+alert(1)

1/alert(1)

alert(1)>>>/abc/

You might think the above examples are pointless but in fact they offer great insight into how Javascript works. Once you understand the small details the bigger picture becomes clear and the way that your code executes can help you understand how the parser works. I find these sort of examples useful when tracking down syntax errors and DOM based XSS, and exploiting XSS Filters.

Throw, Delete what?

You can use the delete operator in ways that you wouldn't at first expect, which results in some pretty wacky syntax. Lets see what happens if we combine the throw , delete , not and typeof operators?

throw delete~typeof~alert(1)

Even though you'd think it couldn't possibly work, it's possible to call delete on a function call and it still executes:

delete alert(1)

Here are a few more examples

delete~[a=alert]/delete a(1)

delete [a=alert],delete a(1)

At first glance you'd think that they would raise a syntax error but when examining the code further it sorta makes sense. The parser finds a variable assignment first within a array, performs the assignment and then deletes the array. Likewise the delete is performed after a function call because it needs to know the result of the function before it can delete the returned object, even if it is null.

Again these examples have been used to defeat XSS filters because they are often trying to match valid syntax and they don't expect the obscure nature of the code. You should consider such examples when programming your application data validation.

Global objects are statements

In certain instances of XSS filter evasion, it can be useful to send English-like text hidden within a vector. Clever systems like PHPIDS use English and vector comparisons to determine if a request is an attack or not, so it is a useful way to test these systems.

Using global objects/functions on their own can produce English-like code blocks. In fact, on the sla.ckers security forum we had a little game to produce English-like sentences in JavaScript. To get an idea of how it works, check out the following example:

stop, open, print && alert(1)

I coined the name Javascriptlish because it's possible to produce some crazy looking code:

javascript : /is/^{ a : ' weird ' }[' & wonderful ']/" language "

the_fun: ['never '] + stop['s']

We use the regular expression /is/ with the operator ^ and then create a object { a : 'weird'} (which has a property a and an assignment of weird .) Then we look for a property ' & wonderful ' within the object we just created, which is then divided by a string of language .

Next we use a label called the_fun and an array with never , use a global function called stop and check for a property of s ... all of which is valid syntax.

Getters/Setters fun

When Firefox added the custom syntax for setters it enabled some interesting XSS vectors that didn't use parentheses. Opera doesn't support a custom syntax yet - this is good from a security point of view but not from a JavaScript hacker's perspective.

Opera does however support the standard defineSetter syntax. This enables us to call functions via assignments, which still has some use for XSS filter evasion:

defineSetter('x',alert); x=1;

In case you're not aware of setters/getters, the example above creates a setter for the global variable x . A setter is called whenever a variable is set with something and the argument is supplied from whatever has been assigned. The second argument is the function to be called on assignment, which is alert . Then, when x is assigned the value of 1 , the alert function is called with 1 as the argument.

Location allows url encoding

The location object allows url encoding within the JavaScript code. This allows you to further obfuscate XSS vectors by double encoding them.

location='javascript:%61%6c%65%72%74%28%31%29'

Combining them with unicode escapes can hide strings quite nicely:</ p>

location='javascript:%5c%75%30%30%36%31%5c%75%30%30%36%63%5c %75%30%30%36%35%5c%75%30%30%37%32%5c%75%30%30%37%34(1)'

The first example works because the URL bar in Opera accepts urlencoded strings - you can hide JavaScript syntax by url encoding it. This is useful because when it is passed within a XSS vector you can double url encode it to help further with filter evasion.

The second example combines the first technique with the unicode escape technique mentioned previously. So when you decode the string it results in the unicode representation of alert which is /u0061/u006c/u0065/u0072/u0074 .

Hackvertor: Your second brain

As a JavaScript hacker I couldn't possibly remember every single encoding method that's possible with JavaScript, so I decided to create a open source tool to do the hard work for me. In the last example the string is double encoded, which can sometimes make it hard to understand. Using my Hackvertor tool makes it a piece of cake and it works nicely in Opera too.

Hackvertor works by using tags to perform multiple levels of conversion; this is similar to HTML tags but it runs code instead of changing the display of the containing text. It converts from the innermost tag outwards, eg to convert the last vector it url decodes and then decodes the unicode escapes, which results in javascript:alert (1) .


from: http://dev.opera.com/articles/view/opera-javascript-for-hackers-1/

UG\NX二次开发 获取对象的层、颜色、隐藏状态、线宽、线型、高亮显示状态 获取对象的层、颜色、隐藏状态、线宽、线型、高亮显示状态。 阅读详情

相关推荐

向量数据库安全实战:从Embedding反推到检索越权的全链路防护

随着RAG应用在企业中的普及,向量数据库已成为知识库系统的核心组件。但许多团队对向量数据的安全认知仍停留在传统数据库的账号密码、网络隔离和磁盘加密上。事实上,向量化并非加密,而是一种有损压缩的语义映射,向量本身可以被反推模型还原出原文关键信息,形成高保真的语义泄露通道。同时,相似度检索的模糊匹配特性打破了传统行列权限模型,使得越权检索和成员推断攻击成为新的安全威胁。理解这些原理,有助于企业在数据采集、向量化、索引构建、检索查询等环节构建分层防护体系,包括脱敏、扰动、过滤下推、网关控制等手段。本文从基础概念出

weixin_29323551的博客 267

《JavaScript for hackers》:带你从黑客的视角看JavaScript

在PortSwigger的日常生活中,Gareth经常被发现创建新的XSS矢量,研究攻击网络应用程序的新技术,并准备在全球各地的会议上发言。最近的一个亮点是他在2023年OWASP Global AppSec Dublin的演讲“服务器端原型污染:没有DoS的黑盒检测”。Gareth是两个好女孩的父亲,也是一位了不起的妻子的丈夫,也是利物浦足球俱乐部的忠实粉丝。这本书有所有的细节。我们平时大都是用它来构建应用,那么从黑客的角度来看,怎样能用它来开黑呢,这本书就讲述了黑客是怎样使用JavaScript的。

关于智能、智能体及AI时代工作方式的一些思考 335

6.4 构网型储能的需求与配置

摘要: 构网型储能是新型电力系统的关键支撑技术,通过提供电压/频率形成、惯性和稳定控制能力,解决同步机退出导致的系统稳定性问题。其配置需遵循三大原则:1)容量配置以支撑需求为主导,兼顾能量服务;2)优先布局于电网薄弱点、稳定问题突出区域;3)采用自适应控制策略实现全工况优化。核心应用场景包括新能源送出通道稳定、负荷中心调频、黑启动电源等。规划方法需结合系统分析、量化指标和成本效益评估,实现技术经济最优。未来需重点关注构网/跟网混合系统的临界容量占比及自适应控制技术发展。

技术工作者 1156

Hacking with JavaScript——在浏览器之内,网页之外,运行JavaScript

引言端口扫描、内存溢出、安全漏洞……这些大概是很多人提到黑客时会想到的。他们用的语言自然也是汇编、C这些贴近底层的高级语言。JavaScript似乎与这一切毫不相关,自诞生起相当长一段时间内,这门在浏览器内执行一些简单的校验和互动的脚本语言,是职业程序员看不上眼的玩具。然而,本文就是要谈谈Hacking with JavaScript——以JavaScript来“黑客”。这之所以能成为一个题目,有

JavaScript 8307

安卓逆向实战:用Batch Apktool 3.8.0快速汉化APK的完整流程

本文详细解析了如何使用Batch Apktool 3.8.0进行安卓APK汉化的完整流程,包括环境配置、反编译、资源解析、深度汉化、重构建与签名优化等关键步骤。通过这款集成化逆向工具,开发者可以高效完成APK汉化,提升工作效率。

s1t2u3的博客 1123

反序列化漏洞详解

目录 一、什么是序列化和反序列化 二、什么是反序列化漏洞 三、序列化函数(serialize) 四、反序列化(unserialize) ​五、什么是PHP魔术方法 六、一些常见的魔术方法 七、魔术方法的利用 八、反序列化漏洞的利用 1.__destruct()函数 2.__wakeup() 3.toString() ​九、反序列化漏洞的防御 一、什么是序列化和反序列化 序列化是将对象转换为字符串以便存储传输的一种方式。而反序列化恰好就是序列化的逆过程,反序列化会将字符串.

LJH1999ZN的博客 3万+

13 岁女学生因两行 JavaScript 代码被捕!

作者 | 伍杏玲 出品 | 极客宝宝(ID:geek_baby) 那些学了 Python 的程序员,编程能力都“退化”成什么样了? https://edu.csdn.net/topic/ai30?utm_source=cxrs_bw 13岁,在中国正是上初中的年纪,中学生们正忙于做不完的作业和补不完的习。 可最近在日本刈谷市,一名13岁的女学生因为将一段JavaScri...

程序人生的博客 2914

基于计算机视觉的无人便利店技术:从算法到部署的系统化实战指南

摘要:本文系统介绍了基于计算机视觉的无人便利店技术方案,提出"商品检测-跟踪-动作识别-防损-结算"五段式流水线架构。详细阐述了YOLOv8-Seg商品检测、OC-Sort多目标跟踪、3D-CNN+ST-GCN动作识别等核心算法实现,并完成NVIDIA Jetson Xavier NX边缘端的优化部署。通过TensorRT量化、DeepStream加速等技术手段,系统在保持94.7%动作识别准确率的同时,将漏单率降至0.8%,单店云端算力成本较行业平均降低84%。所有代码已开源,可直接应

博客 637

Hackers中的网络层优化:异步处理与错误恢复策略终极指南

在iOS开发中,构建稳定高效的网络层是提升应用体验的关键。Hackers作为一个优雅的Hacker News阅读应用,其网络层设计充分体现了现代Swift开发的最佳实践。本文将深入解析Hackers应用的**网络层优化策略**、**异步处理机制**和**错误恢复方案**,帮助开发者掌握构建可靠iOS应用的核心技术。 ## 📱 Hackers应用架构概览 Hackers采用模块化架构设计,网络

gitblog_00782的博客 1002

概念解析 | 雷达动态范围

这里存在一个动态范围的问题:强雷达发射信号和弱目标反射信号存在非常大的功率差异,比如传统的脉冲多普勒雷达动态范围可达90dB以上。随着上述技术的发展,预计未来十年雷达接收机动态范围将达到120dB以上,届时雷达的监视能力将得到极大增强。简单来说,雷达动态范围越大,表示接收机噪声越低,对强信号过载保护能力越强,就越能检测到弱信号目标。此外,部分新概念雷达对动态范围提出新的需求,如被动雷达动态范围需大于100dB。当前,随着阵列雷达和数字雷达技术的发展,对雷达接收机动态范围提出了更高要求。

NLOS的博客 1057

复旦微实现串口在线升级BOOT.BIN

将该 demo 生成的 app(升级用)和 fsbl、最简化 bit 文件(可选)打包成 BOOT.BIN,作为 golden image 烧写在 qspi flash 偏移 0 地址开始的位置,其中最简化 bit 文件为在线升级功能提供必要的物理通道(如果不需要,可以不打包该文件),golden image 一旦发布基本不需要进行升级,由该 golden image 负责和上位机进行通信交互,完成业务 app、业务 bit 文件、uboot 以及操作系统 image 等文件在线升级,在qspi flash

wangjie36的博客 3181

惊呆了!竟因两行 JavaScript 代码被捕!

点击上方“Python大本营”,选择“置顶公众号”Python大本营 IT人的职业提升平台 作者 | 伍杏玲出品 | 极客宝宝(ID:geek_bab...

Python大本营的博客 296

SPICE仿真软件:HSPICE_(20).HSPICE仿真结果的后处理

HSPICE仿真结果的后处理是一个多步骤的过程,包括读取结果文件、可视化、分析和导出。通过使用命令行工具、Python脚本和HSPICE内置工具,可以高效、准确地完成这些任务。Python脚本的灵活性和强大的数据分析能力使其成为后处理的理想选择。自动化处理可以显著提高工作效率,减少人为错误,而高级分析方法可以更深入地理解仿真结果,为电路设计提供有力支持。

kkchenjj的博客 1393

Ant Colony Optimization For Hackers

http://www.theprojectspot.com/tutorial-post/ant-colony-optimization-for-hackers/10 Originally proposed in 1992 by Marco Dorigo, ant colony optimization (ACO) is an optimization technique inspired

Criss@陈磊 1278

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Bash-Hackers Wiki 开源项目常见问题解决方案

Bash-Hackers Wiki 开源项目常见问题解决方案 1. 项目基础介绍和主要编程语言 Bash-Hackers Wiki是一个致力于提供关于Bash脚本编程全面信息的项目。该项目的目的是为用户提供一个详尽的资源库,让所有级别的Bash脚本编写者都能从中学习和获取帮助。 该开源项目的主要编程语言是Bash,同时在文档的编写和管理上使用了DokuWiki标记语言,以及用于网页前端的HTML、...

gitblog_00467的博客 315

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

ChatGPT-hackers:探索AI技术前沿的社区平台

ChatGPT-hackers:探索AI技术前沿的社区平台 项目介绍 ChatGPT-hackers 是一个专注于AI技术交流的社区平台。该平台汇聚了来自全球的开发者、研究人员和AI爱好者,共同致力于在人工智能领域的创新和探索。通过这个平台,用户可以分享最新的AI研究成果、讨论技术难题、交流项目经验,推动AI技术的发展。 项目技术分析 ChatGPT-hackers 项目采用了现代化的前端和后端技...

gitblog_01137的博客 387

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

The Hackers Labs - Cuento

摘要:本文记录了一次完整的渗透测试过程。首先通过ARP扫描发现目标IP 192.168.81.61,使用Nmap扫描发现开放了22(SSH)和8080(HTTP)端口。利用AWVS扫描发现Next.js存在任意文件读取漏洞,成功读取/etc/passwd文件获取用户列表。通过读取/proc/self/environ环境变量发现密码"ratonguaton",成功SSH登录raton用户。提权过程中发现sudo权限漏洞,利用Python脚本劫持提权至churrumais用户。最后通过分析.

qq_67215806的博客 1039

揭秘设计魔法:Indie Hackers的顶尖设计资源宝库

国内外顶尖设计资源大汇总!这个项目是一个GitHub仓库,专门精选了众多国内和国际间卓越的设计工具资源。涵盖了动画范例、插画库、图标集、Logo生成器、设计学习材料以及动画设计资源等丰富内容。专为独立开发者量身打造,提供源源不断的产品设计灵感。每周五都会更新,精彩还在继续!

woaiyiyi20230812的博客 1502

foobox-cn 新手上手:十分钟装好 foobar2000 的播放列表、封面与歌词界面

默认 foobar2000 装完像半成品,官方文档又是纯英文,新手最容易卡在这一步。foobox-cn 是一套 foobar2000 的 DUI 界面皮肤配置,基于 JSplitter 组件,把播放列表管理、专辑封面浏览、歌词联动这些常用面板直接配好,解压即用。 [![foobox-cn foobar2000 播放列表与歌词界面浅色主题截图,专辑封面、同步歌词分栏显示](https://raw.

gitblog_00265的博客 663

The Hackers Labs - Mermelada

然后就很简单了,先看开放了那些端口,发现3306就去找wp-config.php中找数据库密码了,最后就直接用sudo拿到了root。将这个用户进行爆破,结果没有成功!扫描到了一个uploads目录下又几个php文件。看到wp框架的web页面,就可以直接使用。访问80端口,在该页面没有可用信息!那就用dirsearch爆破一下目录。然后就可以利用这个拿到shell了。这可能是一个上传的shell,用。没有用户和密码先放一边,里的base64编码信息。

qq_67215806的博客 437

开源项目 `noob-hackers/tunnel` 使用教程

开源项目 noob-hackers/tunnel 使用教程 1. 项目的目录结构及介绍 tunnel/ ├── boot ├── dodo ├── hackserv ├── instalr ├── mover ├── revert ├── starter ├── tone ├── update ├── LICENSE ├── README.md └── tunnel.sh boot: 包含启动...

gitblog_00020的博客 399

The Hackers Labs - Castor

查看uploads没有文件,在upload.php中发现了xml文件的提示,看到这个第一反应就是尝试一下。本来打算读取其它文件,发现没有读到什么有用的信息,那就先爆破一下ssh吧!然后就成功拿到了用户。访问一下80端口看看,发现这是一个没什么功能的页面,也没有用任何信息。爆破一下目录看看,发现了一个uploads和upload.php。然后就读取到了/etc/passwd文件。没有删除,直接就能拿到提权方案。尝试了一下发现存在xxe漏洞。上来后就简单了,发现日志文件。

qq_67215806的博客 204

读《The.Web.Application.Hackers.Handbook》

Authentication与Access Control。我一直觉得这两个安全概念是一样的,结果书上,或者很多书上,都区分了两者。Authentication就是识别身份,Access Control则是访问控制。一般来说,我认为两者是同时需要同时发挥作用。input validation感觉每一层的安全界的出口处进行validate是最好的。页面上JS检测。JSP在写入数据库,或者返回页面时在validate。这样其实不错。这个挺有意思,如果程序中过滤

buptisc_txy的专栏 826

JavaScript专项算法题(2):函数式编程

commutative会返回一个布尔值,从而表明运行第一个回调函数于输入值,再将得到的返回值输入到第二个回调函数中运行,得到的结果与逆序操作是否相同(即运行输入值于第二个回调函数,得到的返回值再输入到第一个回调函数中)。构建delay函数,作用为接受一个回调函数作为第一个参数,一个数值n(单位为毫秒)作为第二个参数,返回一个特定函数。pipe会将输入值输入到数组的第一个函数中,然后再将得到的输出值输入到第二个函数中,然后输出值又再输入到第三个函数中,一直下去,直到得到数组的最后一个函数的输出值。

U_L的博客 1143

2026年,想做独立开发者?这些网站帮你把“想法”落地成“产品”

2026年的清晨,当你对着电脑敲下第一行代码时,“独立开发者”早已不是“孤胆英雄”的浪漫标签——它是的生活方式。但新手常卡在“第一步”:该去哪找靠谱的信息?哪些平台能帮自己避开坑、接住机会?这篇文章整理了覆盖的全链路资源,最后会带你走进一个“藏着独立开发密码”的地方——。

m0_58421973的博客 1467
上一篇: 使用过的Firefox插件
下一篇: 使用META的 X-UA-Compatible 设置网页兼容模式(转)
FuDesign2008
博客等级 码龄18年 44粉丝 119原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址