Jump to content

HTML Encoder


Richard Robertson
 Share

Recommended Posts

I wrote this quick script to get around different types of web filters. You shoot your HTML file through it, and out comes an HTML file with a small javascript to tell the browser what the page actually contains. I'm sorry this explanation sucks.

$source = FileOpenDialog("Select file", "", "HTML Files (*.html)")
If @error Then Exit
$destination = FileSaveDialog("Save to", "", "HTML Files (*.html)")
If @error Then Exit

$len = FileGetSize($source)

$filein = FileOpen($source, 0)
$fileout = FileOpen($destination, 2)

FileWrite($fileout, '<html><script>document.write(unescape("')

For $a = 1 To $len
    FileWrite($fileout, "%" & Hex(Asc(FileRead($filein, 1)), 2))
Next

FileWrite($fileout, '"));document.close();</script></html>')

FileClose($filein)
FileClose($fileout)

MsgBox(0, "Done", $source & " finshed, output to " & $destination & ".")

Going to describe the program literally now.

1. Asks for input/output filenames.

Loop

2. Reads character by character from source file and converts it to the format %HH where HH is the hexadecimal form of the ASCII value.

3. Puts the %HH into the output file.

Until EOF

4. Lets you know it's finished.

Ask questions if you have them, I really can't think of what else to say.

Edit: Oh, and also your file will get bigger by 3 times plus some more for the javascript. So beware large files.

Edited by Richard Robertson
Link to comment
Share on other sites

  • Moderators

Since you are doing char by char, I would think this to be faster than opening the file up a million times for writing and reading:

$source = FileOpenDialog("Select file", "", "HTML Files (*.html)")
If @error Then Exit
$destination = FileSaveDialog("Save to", "", "HTML Files (*.html)")
If @error Then Exit

$sRead = FileRead($source)
$len = StringLen($sRead)

FileClose(FileOpen($destination, 2))

$sHold = ""

For $a = 1 To $len
    $sHold &= "%" & Hex(Asc(StringMid($sRead, $a, 1)), 2)
Next

FileWrite($destination, '<html><script>document.write(unescape("' & $sHold & '"));document.close();</script></html>')

MsgBox(0, "Done", $source & " finshed, output to " & $destination & ".")oÝ÷ ØÚ-µë-yÑÔáËޮȨ+)®Ún½éßjË^­«­¢+ØÀÌØíͽÕÉô¥±=Á¹¥±½ ÅÕ½ÐíM±Ð¥±ÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí!Q50¥±Ì ¨¹¡Ñµ°¤ÅÕ½Ðì¤)%ÉɽÈQ¡¸á¥Ð(ÀÌØíÍÑ¥¹Ñ¥½¸ô¥±MÙ¥±½ ÅÕ½ÐíMÙѼÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí!Q50¥±Ì ¨¹¡Ñµ°¤ÅÕ½Ðì¤)%ÉɽÈQ¡¸á¥Ð()¥±
±½Í¡¥±=Á¸ ÀÌØíÍÑ¥¹Ñ¥½¸°È¤¤((ÀÌØíÍ!½±ôÅÕ½ÐìÅÕ½Ðì((ÀÌØíÍIô¥±I ÀÌØíͽÕɤ(ÀÌØíÍ!àôMÑÉ¥¹QÉ¥µ1СMÑÉ¥¹Q½   ¥¹Éä ÀÌØíÍI¤°È¤(ÀÌØí±¸ôMÑÉ¥¹1¸ ÀÌØíÍ!à¤()½ÈÀÌØíôÄQ¼ÀÌØí±¸MÑÀÈ($ÀÌØíÍ!½±µÀìôÅÕ½ÐìÅÕ½ÐìµÀìMÑÉ¥¹5¥ ÀÌØíÍ!à°ÀÌØí°È¤)9áÐ()¥±]É¥Ñ ÀÌØíÍÑ¥¹Ñ¥½¸°Ìäì±Ðí¡Ñµ°ÐìØÀíÍÉ¥ÁÐÐí½Õµ¹Ð¹ÝɥѡչÍÁ ÅÕ½ÐìÌäìµÀìÀÌØíÍ!½±µÀìÌäìÅÕ½Ð줤í½Õµ¹Ð¹±½Í ¤ì±Ðì½ÍÉ¥ÁÐÐì±Ð콡ѵ°ÐìÌäì¤()5Í    ½à À°ÅÕ½Ðí½¹ÅÕ½Ðì°ÀÌØíͽÕɵÀìÅÕ½Ð쥹͡°½ÕÑÁÕÐѼÅÕ½ÐìµÀìÀÌØíÍÑ¥¹Ñ¥½¸µÀìÅÕ½Ðì¸ÅÕ½Ðì¤

**Just some food for thought.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Thanks Smoke, I appreciate the gesture, but I wrote this at 11 PM and didn't bother to think about speed.

But yes fear, the filter will just see a bunch of javascript and not see anything worth filtering. Unless it catches javascript that is. If you want to see what it looks like, throw a file through it, then open it up in your browser.

Link to comment
Share on other sites

Nice, do this support ASCII characters only ?

[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Link to comment
Share on other sites

@Dhilip, it only supports ASCII, yes, because javascript's unescape function only loads 2 hexadecimal characters.

@Manadar, I do see a difference, but according to DOM, they are identical with the exception that the other has a script in the head block. I loaded in both Firefox and Internet Explorer and saw different results. I don't know why it does that, all I can say is that the browser is handling the render process. It is still the exact same DOM structure.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...