Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Python url encoder script


ghost's Avatar
0 0

ok, I have it MOSTLY working, but I need a small fix, it doesn't return the right characters, like < returns %3%63 instead of %3c. My second attempt at a script, maybe it can be helpful to someone for xss once it works. Thanks to anyone that helps! I'm starting to get the hang of it. The other one I made was for trig that calculates the radius of the circle and its sin cos tan sec csc and cot values, if anyone wants it I'll post it later.

print &quot;URL encoder - by Lemur&quot;
x = 1
while x == 1:
    convert = raw_input (&quot;Enter the string to convert here : &quot;)
    convert = [item.replace(&#39; &#39;, &#39;%20&#39;) for item in convert]
    convert = [item.replace(&#39;!&#39;, &#39;%21&#39;) for item in convert]
    convert = [item.replace(&#39;&quot;&#39;, &#39;%22&#39;) for item in convert]
    convert = [item.replace(&#39;#&#39;, &#39;%23&#39;) for item in convert]
    convert = [item.replace(&#39;$&#39;, &#39;%24&#39;) for item in convert]
    convert = [item.replace(&#39;%&#39;, &#39;%25&#39;) for item in convert]
    convert = [item.replace(&#39;&&#39;, &#39;%26&#39;) for item in convert]
    convert = [item.replace(&#39;&#92;&#39;&#39;, &#39;%27&#39;) for item in convert]
    convert = [item.replace(&#39;(&#39;, &#39;%28&#39;) for item in convert]
    convert = [item.replace(&#39;)&#39;, &#39;%29&#39;) for item in convert]
    convert = [item.replace(&#39;*&#39;, &#39;%2a&#39;) for item in convert]
    convert = [item.replace(&#39;+&#39;, &#39;%2b&#39;) for item in convert]
    convert = [item.replace(&#39;-&#39;, &#39;%2d&#39;) for item in convert]
    convert = [item.replace(&#39;.&#39;, &#39;%2e&#39;) for item in convert]
    convert = [item.replace(&#39;/&#39;, &#39;%2f&#39;) for item in convert]
    convert = [item.replace(&#39;0&#39;, &#39;%30&#39;) for item in convert]
    convert = [item.replace(&#39;1&#39;, &#39;%31&#39;) for item in convert]
    convert = [item.replace(&#39;2&#39;, &#39;%32&#39;) for item in convert]
    convert = [item.replace(&#39;3&#39;, &#39;%33&#39;) for item in convert]
    convert = [item.replace(&#39;4&#39;, &#39;%34&#39;) for item in convert]
    convert = [item.replace(&#39;5&#39;, &#39;%35&#39;) for item in convert]
    convert = [item.replace(&#39;6&#39;, &#39;%36&#39;) for item in convert]
    convert = [item.replace(&#39;7&#39;, &#39;%37&#39;) for item in convert]
    convert = [item.replace(&#39;8&#39;, &#39;%38&#39;) for item in convert]
    convert = [item.replace(&#39;9&#39;, &#39;%39&#39;) for item in convert]
    convert = [item.replace(&#39;:&#39;, &#39;%3a&#39;) for item in convert]
    convert = [item.replace(&#39;;&#39;, &#39;%3b&#39;) for item in convert]
    convert = [item.replace(&#39;&lt;&#39;, &#39;%3c&#39;) for item in convert]
    convert = [item.replace(&#39;=&#39;, &#39;%3d&#39;) for item in convert]
    convert = [item.replace(&#39;&gt;&#39;, &#39;%3e&#39;) for item in convert]
    convert = [item.replace(&#39;?&#39;, &#39;%3f&#39;) for item in convert]
    convert = [item.replace(&#39;@&#39;, &#39;%40&#39;) for item in convert]
    convert = [item.replace(&#39;A&#39;, &#39;%41&#39;) for item in convert]
    convert = [item.replace(&#39;B&#39;, &#39;%42&#39;) for item in convert]
    convert = [item.replace(&#39;C&#39;, &#39;%43&#39;) for item in convert]
    convert = [item.replace(&#39;D&#39;, &#39;%44&#39;) for item in convert]
    convert = [item.replace(&#39;E&#39;, &#39;%45&#39;) for item in convert]
    convert = [item.replace(&#39;F&#39;, &#39;%46&#39;) for item in convert]
    convert = [item.replace(&#39;G&#39;, &#39;%47&#39;) for item in convert]
    convert = [item.replace(&#39;H&#39;, &#39;%48&#39;) for item in convert]
    convert = [item.replace(&#39;I&#39;, &#39;%49&#39;) for item in convert]
    convert = [item.replace(&#39;J&#39;, &#39;%4a&#39;) for item in convert]
    convert = [item.replace(&#39;K&#39;, &#39;%4b&#39;) for item in convert]
    convert = [item.replace(&#39;L&#39;, &#39;%4c&#39;) for item in convert]
    convert = [item.replace(&#39;M&#39;, &#39;%4d&#39;) for item in convert]
    convert = [item.replace(&#39;N&#39;, &#39;%4e&#39;) for item in convert]
    convert = [item.replace(&#39;O&#39;, &#39;%4f&#39;) for item in convert]
    convert = [item.replace(&#39;P&#39;, &#39;%50&#39;) for item in convert]
    convert = [item.replace(&#39;Q&#39;, &#39;%51&#39;) for item in convert]
    convert = [item.replace(&#39;R&#39;, &#39;%52&#39;) for item in convert]
    convert = [item.replace(&#39;S&#39;, &#39;%53&#39;) for item in convert]
    convert = [item.replace(&#39;T&#39;, &#39;%54&#39;) for item in convert]
    convert = [item.replace(&#39;U&#39;, &#39;%55&#39;) for item in convert]
    convert = [item.replace(&#39;V&#39;, &#39;%56&#39;) for item in convert]
    convert = [item.replace(&#39;W&#39;, &#39;%57&#39;) for item in convert]
    convert = [item.replace(&#39;X&#39;, &#39;%58&#39;) for item in convert]
    convert = [item.replace(&#39;Y&#39;, &#39;%59&#39;) for item in convert]
    convert = [item.replace(&#39;Z&#39;, &#39;%5a&#39;) for item in convert]
    convert = [item.replace(&#39;[&#39;, &#39;%5b&#39;) for item in convert]
    convert = [item.replace(&#39;&#92;&#92;&#39;, &#39;%5c&#39;) for item in convert]
    convert = [item.replace(&#39;]&#39;, &#39;%5d&#39;) for item in convert]
    convert = [item.replace(&#39;^&#39;, &#39;%5e&#39;) for item in convert]
    convert = [item.replace(&#39;_&#39;, &#39;%5f&#39;) for item in convert]
    convert = [item.replace(&#39;`&#39;, &#39;%60&#39;) for item in convert]
    convert = [item.replace(&#39;a&#39;, &#39;%61&#39;) for item in convert]
    convert = [item.replace(&#39;b&#39;, &#39;%62&#39;) for item in convert]
    convert = [item.replace(&#39;c&#39;, &#39;%63&#39;) for item in convert]
    convert = [item.replace(&#39;d&#39;, &#39;%64&#39;) for item in convert]
    convert = [item.replace(&#39;e&#39;, &#39;%65&#39;) for item in convert]
    convert = [item.replace(&#39;f&#39;, &#39;%66&#39;) for item in convert]
    convert = [item.replace(&#39;g&#39;, &#39;%67&#39;) for item in convert]
    convert = [item.replace(&#39;h&#39;, &#39;%68&#39;) for item in convert]
    convert = [item.replace(&#39;i&#39;, &#39;%69&#39;) for item in convert]
    convert = [item.replace(&#39;j&#39;, &#39;%6a&#39;) for item in convert]
    convert = [item.replace(&#39;k&#39;, &#39;%6b&#39;) for item in convert]
    convert = [item.replace(&#39;l&#39;, &#39;%6c&#39;) for item in convert]
    convert = [item.replace(&#39;m&#39;, &#39;%6d&#39;) for item in convert]
    convert = [item.replace(&#39;n&#39;, &#39;%6e&#39;) for item in convert]
    convert = [item.replace(&#39;o&#39;, &#39;%6f&#39;) for item in convert]
    convert = [item.replace(&#39;p&#39;, &#39;%70&#39;) for item in convert]
    convert = [item.replace(&#39;q&#39;, &#39;%71&#39;) for item in convert]
    convert = [item.replace(&#39;r&#39;, &#39;%72&#39;) for item in convert]
    convert = [item.replace(&#39;s&#39;, &#39;%73&#39;) for item in convert]
    convert = [item.replace(&#39;t&#39;, &#39;%74&#39;) for item in convert]
    convert = [item.replace(&#39;u&#39;, &#39;%75&#39;) for item in convert]
    convert = [item.replace(&#39;v&#39;, &#39;%76&#39;) for item in convert]
    convert = [item.replace(&#39;w&#39;, &#39;%77&#39;) for item in convert]
    convert = [item.replace(&#39;x&#39;, &#39;%78&#39;) for item in convert]
    convert = [item.replace(&#39;y&#39;, &#39;%79&#39;) for item in convert]
    convert = [item.replace(&#39;z&#39;, &#39;%7a&#39;) for item in convert]
    convert = [item.replace(&#39;{&#39;, &#39;%7b&#39;) for item in convert]
    convert = [item.replace(&#39;|&#39;, &#39;%7c&#39;) for item in convert]
    convert = [item.replace(&#39;}&#39;, &#39;%7d&#39;) for item in convert]
    convert = [item.replace(&#39;~&#39;, &#39;%7e&#39;) for item in convert]
    print convert
    print &quot;Please select one of the following&quot;
    print &quot;1. Again&quot;
    print &quot;2. Exit&quot;
    x = input(&quot;1 or 2: &quot;)
    if x == 2:
        import sys 
        sys.exit()
    else:
        print &quot;Next?&quot;
    

edit- holy crap that's a lot of smiles, replace with backwards parenthesis, sorry about that


ghost's Avatar
0 0

First: There's a handy little thing called "disable smileys in this post" at the bottom, it helps. ;D

Second: Code is a little messy, and a little silly, seeing that python already has a urlencode() function.

But it works, yes.


ghost's Avatar
0 0

0_0 wow I wish I knew that earlier… Ah well, practice at least.