Small Method for converting characters into unicode encoding

Source: Internet
Author: User

Regarding software system vulnerabilities, the most common one is the cross-site scripting vulnerability. There are a lot of related information on the Internet.

How can I convert the written attack code into unicode encoding to launch an attack? Plaintext attacks are easy to intercept, but the probability of successful escape is relatively high.

However, the information on the Internet is about the attack principles. There are few examples of how to convert the attack code to unicode encoding. The following is a small method written by colleagues for you to write the Interception Function, for testing.

We do not recommend that you use this code for illegal activities! At your own risk.

Package com;/*** convert character to unicode encoding (UTF-16) */public class unicodeutil {public static void main (string [] ARGs) {string STR = "<SCRIPT> "; char [] chars = Str. tochararray (); string ret = ""; for (INT I = 0; I <chars. length; I ++) {RET + = "%"; RET + = transferstr2utf16 (string. valueof (chars [I]);} system. out. println (RET);} Private Static string transferstr2utf16 (string ARGs) {char [] chars = "0123456789 abcdef ". tochararray (); stringbuilder sb = new stringbuilder (""); byte [] BS = args. getbytes (); int bit; For (INT I = 0; I <BS. length; I ++) {bit = (BS [I] & 0x0f0)> 4; sb. append (chars [bit]); bit = BS [I] & 0x0f; sb. append (chars [bit]); sb. append ('');} return sb. tostring (). trim ();}}


Small Method for converting characters into unicode encoding

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.