CyberSlug Posted May 4, 2004 Posted May 4, 2004 Motivation: Since script decompilers are available, I thought I'd write a script that makes scripts less readable. Also, the AutoIt script compiler does not remove inline comments! Maybe UnTidy is useful if you are paranoid your passphrase could be cracked. You might also get smaller compiled scripts: Some of my scripts compiled in to 200-byte smaller EXEs.What it does- Removes all comments (inline and #cs blocks)- "Flattens" _ line continutations- Removes indention- Renames variable and user-defined functions- Leaves literal strings *mostly* intact; my routine for renaming user-defined functions was added at the last minute and might affect spacing around parentheses in literal strings!Known Limitations:- Was hacked together in 2 hours just for fun, so might contain bugs. Do not expect updates until I finish other projects like AutoBuilder/AutoPad- Might crash on invalid scripts- Does not process #include's- Can break scripts containing Eval, Call, or HotKeySet functions....- Assumes the variable names it generates are unique....Here's the source code for UnTidy expandcollapse popupopt("TrayIconDebug", 1) global $_foo__A = '' $_foo__B = fileopendialog("Open...","", "AutoIt Script( *.au3)",3) $file = fileopen($_foo__B, 0) if $file = -1 then msgbox(0, "Error", "Unable to open file.") exit endif progresson("UnTidy", "Working...", "Reading File") progressset(10) $_foo__C = 0 while 1 $_foo__D = filereadline($file) if @error = -1 then exitloop $_foo__D = stringstripws($_foo__D, 3) if stringleft($_foo__D,15)='#comments-end' or stringleft($_foo__D,3)='#ce' then $_foo__C = 0 continueloop endif if $_foo__C = 0 and $_foo__D <> '' and stringleft($_foo__D,1) <> ';' then if stringleft($_foo__D,15)='#comments-start' or stringleft($_foo__D,3)='#cs' then $_foo__C = 1 else if stringright($_foo__D, 1) = '_' then $_foo__E = "" while 1 $_foo__E = stringstripws( $_foo__E & stringstripws($_foo__D,3) , 3 ) if stringright($_foo__E,1) = '_' then $_foo__E = stringtrimright($_foo__E,1) $_foo__D = filereadline($file) if @error or stringright(stringstripws($_foo__D,3) , 1) <> '_' then $_foo__A = $_foo__A & $_foo__E & stringstripws($_foo__D,3) $_foo__D = '' exitloop endif wend endif $_foo__A = $_foo__A & $_foo__D & @lf endif endif wend fileclose($file) $_foo__A = stringsplit($_foo__A, @lf) $_foo__F = $_foo__A[0] $_foo__G = '' $t = '' $_foo__H = '=& ^*/+-,]) ' $_foo__I = '!' progressset(20 , "Parsing Variables( This is slow...)") for $_foo__J = 1 to $_foo__F for $_foo__K = 1 to stringlen($_foo__A[$_foo__J]) $_foo__L = stringmid($_foo__A[$_foo__J], $_foo__K, 1) if $_foo__L = '"' and $_foo__I = '"' then $_foo__I = '!' $t = $t & $_foo__L continueloop endif if $_foo__L = "'" and $_foo__I = "'" then $_foo__I = '!' $t = $t & $_foo__L continueloop endif if $_foo__I = '!' then if $_foo__L = '"' or $_foo__L = "'" then $_foo__I = $_foo__L $t = $t & $_foo__L continueloop endif endif if $_foo__I = '!' then if $_foo__L = ';' then exitloop if $_foo__L = '$' then $_foo__Ksarray = 0 $_foo__N = "" $_foo__O = $_foo__L $_foo__P = $_foo__K while not stringinstr($_foo__H, $_foo__O) $_foo__N = $_foo__N & $_foo__O $_foo__P = $_foo__P + 1 $_foo__O = stringmid($_foo__A[$_foo__J], $_foo__P, 1) if $_foo__O = "[" then $_foo__Ksarray = 1 endif wend if not $_foo__Ksarray and not stringinstr($_foo__G, $_foo__N) then $_foo__G = $_foo__G & $_foo__N & @lf endif $t = $t & stringlower($_foo__L) else $t = $t & $_foo__L endif next $t = $t & @lf next progressset(60 , "Renaming Variables") $_foo__G = stringsplit($_foo__G, @lf) dim $_foo__Q for $_foo__K = 1 to $_foo__G[0]-1 if $_foo__K <= 26 then $_foo__Q = '$_foo__' & chr($_foo__K+64) else $_foo__Q = '$_foo__' & $_foo__K endif $t = stringreplace($t, $_foo__G[$_foo__K], $_foo__Q) next dim $_foo__A = stringsplit($t, @lf) $_foo__F = ubound($_foo__A) - 1 progressset(70 , "Parsing User-defined functions") $_foo__R = '' for $_foo__J = 1 to $_foo__F $_foo__D = $_foo__A[$_foo__J] if stringleft($_foo__D, 4) = 'Func' then $_foo__S = stringstripws(stringtrimleft($_foo__D,4) , 3 ) $udf = stringleft( $_foo__S, stringinstr($_foo__S,'(') - 1 ) $udf = stringstripws($udf, 3) if not stringinstr($_foo__R, $udf) then $_foo__R = $_foo__R & $udf & @lf endif next progressset(90 , "Renaming User-defined functions") $t = "" for $_foo__K = 1 to $_foo__F $_foo__D = ' ' & $_foo__A[$_foo__K] while 1 $_foo__D = stringreplace($_foo__D, '( ', '( ') if $_foo__A[$_foo__K] = $_foo__D then exitloop $_foo__A[$_foo__K] = $_foo__D $t = $t & $_foo__A[$_foo__K] & @lf wend next $_foo__R = stringsplit($_foo__R, @lf) dim $_foo__Q for $_foo__K = 1 to $_foo__R[0]-1 if $_foo__K <= 26 then $_foo__Q = " _fun__" & chr($_foo__K+64) & '(' else $_foo__Q = " _fun__" & $_foo__K & '(' endif $t = stringreplace($t, " " & $_foo__R[$_foo__K] & "(", $_foo__Q) next $t = stringstripws( stringreplace($t, @lf & " ", @lf), 3 ) clipput($t) progressset(100 , "New script copied to clipboard!", "Finished") sleep(1000) Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
ezzetabi Posted May 5, 2004 Posted May 5, 2004 Motivation: Since script decompilers are available, I thought I'd write a script that makes scripts less readable. Also, the AutoIt script compiler does not remove inline comments! Maybe UnTidy is useful if you are paranoid your passphrase could be cracked. You might also get smaller compiled scripts: Some of my scripts compiled in to 200-byte smaller EXEs.200 bytes smaller? For a about 90 Kb files is not a great deal...
dazzyreil Posted May 5, 2004 Posted May 5, 2004 if you want your scripts messed up a little then try mailing them to urself... the whole scripts becomes 1 line really fcked up
Somerset Posted May 5, 2004 Posted May 5, 2004 Hey CS if the varibles are case sensitive.. ya can optimize it there by a few bites... do ya think uucode could help to?instead of cr?
CyberSlug Posted May 5, 2004 Author Posted May 5, 2004 I forgot to post the link to the full code: here it isThe code is not much prettier, but at least it contains some comments @ezzetabi: True, 200 bytes isn't much. @dazzyreil: Probably because all CRLF's are replaced by just LF's. Same thing happens if you open a script in notepad.@beerman: Not sure what what you mean aoubt uucode. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now