在 rails Ruby 中解码
Decode in Ruby on rails
有没有办法解码下面的字符串,
"location.replace(i+\"&utm_content=\"+s)}(document,window,navigator,screen,\"\x68\x74\x74\x70\x3a\x2f\x2f\x6d\x6f\x62\x76\x69\x64\x69\x2e\x6d\x6f\x62\x73\x74\x61\x72\x72\x2e\x63\x6f\x6d\x2f\x3f\x75\x74\x6d\x5f\x74\x65\x72\x6d\x3d\x36\x35\x34\x33\x34\x39\x39\x37\x36\x39\x31\x38\x32\x39\x34\x36\x33\x30\x32\x26\x63\x6c\x69\x63\x6b\x76\x65\x72\x69\x66\x79\x3d\x31\",fi
我试过了,
URI.unescape string
但它不起作用
可能还有另一种方法可以做到这一点,但这是一种方法:
>> hex = "\x68\x74\x74\x70\x3a\x2f\x2f\x6d\x6f\x62\x76\x69\x64\x69\x2e\x6d\x6f\x62\x73\x74\x61\x72\x72\x2e\x63\x6f\x6d\x2f\x3f\x75\x74\x6d\x5f\x74\x65\x72\x6d\x3d\x36\x35\x34\x33\x34\x39\x39\x37\x36\x39\x31\x38\x32\x39\x34\x36\x33\x30\x32\x26\x63\x6c\x69\x63\x6b\x76\x65\x72\x69\x66\x79\x3d\x31"
=> "\x68\x74\x74\x70\x3a\x2f\x2f\x6d\x6f\x62\x76\x69\x64\x69\x2e\x6d\x6f\x62\x73\x74\x61\x72\x72\x2e\x63\x6f\x6d\x2f\x3f\x75\x74\x6d\x5f\x74\x65\x72\x6d\x3d\x36\x35\x34\x33\x34\x39\x39\x37\x36\x39\x31\x38\x32\x39\x34\x36\x33\x30\x32\x26\x63\x6c\x69\x63\x6b\x76\x65\x72\x69\x66\x79\x3d\x31"
>> Array(hex.gsub("\x","")).pack('H*')
=> "http://mobvidi.mobstarr.com/?utm_term=6543499769182946302&clickverify=1"
我为十六进制字符串创建了一个字符串变量,然后删除了反斜杠和 'x' 字符。然后,这被转换成一个数组,这样我们就可以调用 pack
方法(为高半字节第一个十六进制字符串指定大写 H
字符串指令),您可以阅读有关 here.
有没有办法解码下面的字符串,
"location.replace(i+\"&utm_content=\"+s)}(document,window,navigator,screen,\"\x68\x74\x74\x70\x3a\x2f\x2f\x6d\x6f\x62\x76\x69\x64\x69\x2e\x6d\x6f\x62\x73\x74\x61\x72\x72\x2e\x63\x6f\x6d\x2f\x3f\x75\x74\x6d\x5f\x74\x65\x72\x6d\x3d\x36\x35\x34\x33\x34\x39\x39\x37\x36\x39\x31\x38\x32\x39\x34\x36\x33\x30\x32\x26\x63\x6c\x69\x63\x6b\x76\x65\x72\x69\x66\x79\x3d\x31\",fi
我试过了,
URI.unescape string
但它不起作用
可能还有另一种方法可以做到这一点,但这是一种方法:
>> hex = "\x68\x74\x74\x70\x3a\x2f\x2f\x6d\x6f\x62\x76\x69\x64\x69\x2e\x6d\x6f\x62\x73\x74\x61\x72\x72\x2e\x63\x6f\x6d\x2f\x3f\x75\x74\x6d\x5f\x74\x65\x72\x6d\x3d\x36\x35\x34\x33\x34\x39\x39\x37\x36\x39\x31\x38\x32\x39\x34\x36\x33\x30\x32\x26\x63\x6c\x69\x63\x6b\x76\x65\x72\x69\x66\x79\x3d\x31"
=> "\x68\x74\x74\x70\x3a\x2f\x2f\x6d\x6f\x62\x76\x69\x64\x69\x2e\x6d\x6f\x62\x73\x74\x61\x72\x72\x2e\x63\x6f\x6d\x2f\x3f\x75\x74\x6d\x5f\x74\x65\x72\x6d\x3d\x36\x35\x34\x33\x34\x39\x39\x37\x36\x39\x31\x38\x32\x39\x34\x36\x33\x30\x32\x26\x63\x6c\x69\x63\x6b\x76\x65\x72\x69\x66\x79\x3d\x31"
>> Array(hex.gsub("\x","")).pack('H*')
=> "http://mobvidi.mobstarr.com/?utm_term=6543499769182946302&clickverify=1"
我为十六进制字符串创建了一个字符串变量,然后删除了反斜杠和 'x' 字符。然后,这被转换成一个数组,这样我们就可以调用 pack
方法(为高半字节第一个十六进制字符串指定大写 H
字符串指令),您可以阅读有关 here.