Code morphing
Monday, 21 January 2008
I’ve been working on a small project with the eventual goal of producing random morphing javascript. It’s still early stages at the moment but I’d thought I’d release it now because then I might get some motivation to improve it. I plan to add this functionality into Hackvertor as well as Spambam in future.
At the moment the script has multiple modes, the random mode selects parts of the source to encode and the other modes allow you to continually encode Javascript. The main problem with continually encoding is that the size of the source increases each time, I’ve had some great suggestions from Ronald, Mario and sirdarckcat and I plan to incorporate these into the next release.
Bugs
This is early code so there are quite a few bugs, the random mode doesn’t work all the time because some encoding methods return errors. Variables mode doesn’t work correctly yet as there’s a slight bug. I also need to improve the regular expressions for matching functions and then encoding with unicode. The unicode mode will also support double or maybe even triple encoding using multiple evals to return the desired string, this might take a bit of work to do but I think it will be worth it π
Check it out here:-
Code morpher
No. 1 — January 22nd, 2008 at 1:08 am
Looks like it still has some bugs in some of the random methods? I put in:
alert(“this is a test of the code”);
Ran random once and got:
alert(x_0=!6==8?’t’:0,x_1=!6==8?’h’:0,x_2=!6==8?’i’:0,x_3=!6==8?’s’:0,x_4=!6==8?’ ‘:0,x_5=!6==8?’i’:0,x_6=!6==8?’s’:0,x_7=!6==8?’ ‘:0,x_8=!6==8?’a’:0,x_9=!6==8?’ ‘:0,x_10=!6==8?’t’:0,x_11=!6==8?’e’:0,x_12=!6==8?’s’:0,x_13=!6==8?’t’:0,x_14=!6==8?’ ‘:0,x_15=!6==8?’o’:0,x_16=!6==8?’f’:0,x_17=!6==8?’ ‘:0,x_18=!6==8?’t’:0,x_19=!6==8?’h’:0,x_20=!6==8?’e’:0,x_21=!6==8?’ ‘:0,x_22=!6==8?’c’:0,x_23=!6==8?’o’:0,x_24=!6==8?’d’:0,x_25=!6==8?’e’:0,x_26=x_0+x_1+x_2+x_3+x_4+x_5+x_6+x_7+x_8+x_9+x_10+x_11+x_12+x_13+x_14+x_15+x_16+x_17+x_18+x_19+x_20+x_21+x_22+x_23+x_24+x_25);
Which produces an alert of “0” only.
I don’t have more time right now to troubleshoot it or I’d look into it more closely. Here’s hoping the code isn’t already in SpamBam and will block this comment. π
Hah! The first try /did/ get caught by SpamBam. Here’s hoping the next one gets through…
No. 2 — January 22nd, 2008 at 1:10 am
*sigh*
One day I’ll learn to read entire posts before jumping up and responding. You know, like the section that explicitly stated that method had bugs. Whoops!
No. 3 — January 22nd, 2008 at 1:17 am
@jordan
No worries π
I’m going to improve it further soon, the idea of the tovariables function is to scan for text assigned to variables and then splitting the content into pieces.
At the moment it splits the code up but doesn’t perform a correct regular expression.
Sorry about Spambam btw, a new version is in the pipeline (Geez all this code to do and so little time π )
No. 4 — January 22nd, 2008 at 4:17 am
Wow. I wish I would have copied the random mutated code before i ran it. It crahed IE7 good. Interesting as I know that was not the intended result.