javascript - 不使用字母即可获取完整字母表

标签 javascript

看到下面的代码后,我开始想知道是否有一种方法可以在不使用任何字母的情况下访问完整的小写字母(下面要应用的条件):

[($=(!0)+'')[0]+$[1]+$[2]+((!1)+'')[3]+$[0],(([]+[])[1]+'')[1]+([]+{})[1],([]+{})[1]+(([]+[])[1]+'')[1]+$[3]].join(' ');
// "trust no one"

使用下面的各种语句可以访问以下字母a b c d e f g i j l m no p r s t u v x y:

// "true" yeilds: e r t u
!0+'';

// "false" yeilds: a f l s
!1+'';

// "[object Object]" yeilds: b c j o t
[]+{}+'';

// "undefined" yeilds: d i n
[][1]+'';

// "Infinity" yeilds: y
1/0+'';

// Using the above statements "constructor" can be spelled
// It has no value by itself but can be coupled with other statements to get more letters
($=[]+{}+'')[5]+$[1]+(([]+[])[1]+'')[1]+((!1)+'')[3]+($=!0+'')[0]+$[1]+$[2]+($=[]+{}+'')[5]+$[6]+$[1]+((!0)+'')[1];

// "function RegExp() { [native code] }" yeilds: g p v x
(/./)[/*constructor" from above*/]+'';

// "function Number() { [native code] }" yeilds: m
(0)[/*"constructor" from above*/]+'';

在应用以下限制的情况下,有哪些方法可以访问剩余的字符 h q w z:

  1. 代码中只能使用非字母字符(符号、数字和标点符号)
  2. 代码中使用的所有字符都必须属于 ASCII 的前 128 个字符
  3. 代码不得依赖环境变量,例如节点的 global、浏览器的 window
  4. 在探索完所有其他途径之前,应避免对字母进行重新编码,例如使用转义变体、八位字节语法等。

最佳答案

啊哈明白了。如果unescape允许,但为了清晰起见未进行编码:

[]['constructor']['constructor']['call']('','return unescape' + '("%68%71%77%7' + 'a' +'")')()

这给了我们 hqwx,当然还可以给我们其他任何东西。

唯一无法到达的位是 '("%68%71%77%7<a goes here>")' ,但这满足符号和数字规则。 a 可以以其他方式构造。

如果我们想避免逃逸,我们可以使用 (828035)['toString'](36) ——“神奇”数字828035是通过使用 parseInt('hqwz',36) 生成的.

并进行编码——为了便于阅读,将大部分内容分解:

// From your post
str_constructor = ($=[]+{}+'')[5]+$[1]+(([]+[])[1]+'')[1]+
    ((!1)+'')[3]+($=!0+'')[0]+$[1]+$[2]+($=[]+{}+'')[5]+
    $[6]+$[1]+((!0)+'')[1];

// call
str_call = ([]+{}+'')[5]+($=!1+'')[1]+$[2]+$[2];

// return unescape ( bonus, not using a literal space character )
ret_unescape = ($=!0+'')[1]+$[3]+$[0]+$[2]+$[1]+($=''[1]+'')[1]+
    ([]+{}+'')[7]+$[0]+$[1]+$[3]+($=!1+'')[3]+([]+{}+'')[5]+$[1]+
     ((/./)[str_constructor]+'')[14]+(!0+'')[3];


// finally
[][str_constructor][str_constructor][str_call]('',ret_unescape + '("%68%71%77%7' + (!1+'')[1] +'")')() // "hqwz"

// or -- toString
str_toString = (!0+'')[0]+([]+{}+'')[1]+($=(('')[str_constructor]+''))[9]+$[10]+$[11]+$[12]+$[13]+$[14]

(828035)[str_toString](36)  // hqwz

奖金-奖金:

如果我们偷偷摸摸,我们甚至可以放弃数字。

true: !![]
false: ![]

0: ![]+![]
1: !![]+![]
2: !![]+!![]
10: (!![]+![]+'')+(![]+![])

因此,我的令人讨厌的魔法常数可能是:

((!![]+!![])*(!![]+!![])*(!![]+!![])+'')+((!![]+!![])+'')+
    ((!![]+!![])*(!![]+!![])*(!![]+!![])+'')+
    (![]+![]+'')+(!![]+!![]+!![]+'')+((!![]+!![])*(!![]+!![])+!![])-![]

关于javascript - 不使用字母即可获取完整字母表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28547205/

相关文章:

javascript - 使用 PHP 从动态创建的输入中收集数据

javascript - 自定义 Handsontable 滚动条设计

javascript - 如何在daterangepicker中设置默认日期?

javascript - 如何解决 "Access Denied: Invalid token, wrong code"的问题?

javascript - 全日历 JavaScript 数组

javascript - 完整日历 "Time Zone Demo"示例

javascript - JSPDF 和 AutoTable 的标题行问题

javascript - iOS 设备上的 ionic 页面问题

javascript - 如何访问 SVG 文档中的 <path>

javascript - While 循环在 Google Chrome 控制台中不断崩溃