Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

String to non-alphanumerical PHP code Converter

Hey.

I don't know how, but I somehow stumbled upon this tutorial on how to write non-alphanumerical PHP code.

I wasn't sure if a script that converts strings to said code was posted here before. If someone did, I certainly did not invent this technique or so.
I made the script to speed up the process of writing such code and thought I'd share it here.



Example call:
Code
/home//code/python/rce/nonalpha.py phpinfo
Output:
Code
('.' ^ '^').('@' ^ '(').('.' ^ '^').('@' ^ ')').('@' ^ '.').('@' ^ '&').('@' ^ '/')



If you have no idea what the code does, just read the tutorial and it should be clear.

Peace
Yup i did same thing before, was fun.If you dont mind, i change yours just little bit (:

PHP Code

<?php 
#!/usr/bin/python3.4
import sys
from random import choice
 
# define non alpha characters
nonalpha = '^!"$%&/{([)]=}?\\`*+~\'#-_.:,;<>|@'
 
 
# xor characters and return output
def do_xor(char):
    
result = ["('"+x+"')." for x in nonalpha if chr(ord(char) ^ ord(x)) in nonalpha]
    if 
result:
        return 
choice(result)
    else:
        
sys.exit("Unable to convert string into non-alphanumerical representation")
 

if 
len(sys.argv) != 2:
    
sys.exit("Usage: python " + sys.argv[0] + " input_string")
else:
    print 
"".join([do_xor(x) for x in sys.argv[1] if do_xor(x)])[:-1] 
Mind explaining what this does?
(Jun 4, 2016 05:34 AM)█BORNE█ Wrote:  Mind explaining what this does?

I refered to a tutorial in the thread.
However, I found the PHP manual very helpful.

http://php.net/manual/en/language.operators.bitwise.php

Search for the part about XOR on strings. :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by MordiciaNov 15, 2019 07:21 PM 3 210 Nov 15, 2019 07:21 PM
Last Post: Mordicia
[.NET] by ZeakZNov 17, 2018 09:53 AM 22 810 Nov 17, 2018 09:53 AM
Last Post: ZeakZ
[Java] by pureaccaMay 12, 2017 12:57 PM 10 599 May 12, 2017 12:57 PM
Last Post: ComplexEternity