Dave Heavy Industries » ASP http://www.daveheavyindustries.com Dave Heavy Industries - blog Mon, 12 Aug 2013 00:24:10 +0000 en-US hourly 1 http://wordpress.org/?v=3.6 Decoding Windows Script Encoder encoded scripts http://www.daveheavyindustries.com/2011/04/28/decoding-windows-script-encoder-encoded-scripts/ http://www.daveheavyindustries.com/2011/04/28/decoding-windows-script-encoder-encoded-scripts/#comments Thu, 28 Apr 2011 05:34:08 +0000 admin http://wp.daveheavyindustries.com/?p=145 Decoding Windows Script Encoder encoded scripts

isn't that a mouthful? Microsoft released this in 2001 - http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e7877f67-c447-4873-b1b0-21f0626a6329 which is a way of obscurifying vbscript (like ASP) scripts so that people can't change or copy your code. Great, right? well, as with most script encoding  (zend encoder aside, others I'm sure), it doesn't do a very good job of it, and more makes it annoying to debug asp pages when the developers encode their includes.

I ran into this particular problem when dealing with ProductCart by EarlyImpact. I ran into some issues integrating with their XMLtools, opened it up and to my surprise was presented with gibberish like below..

<snip><%#@~^K6gAAA==@#@&@#@&UE(PZ4+1V?Mm6D9+.d:lokc#@#@&fbh~Z4k^NHW[nk~dYMHW9+SOsw1G[1C:SD:2gW9+.mV!n~D:2.mV;n</snip>

small amount of reading later, discovered Microsoft script encoder, decided that this can't be the end of it, and googled microsoft script decoder, hit the I'm feeling lucky button and blamo! success :D

http://www.greymagic.com/security/tools/decoder/

there's also a downloadble program to do the same thing if you have a lot of scripts to decode - http://www.virtualconspiracy.com/index.php?page=scrdec/intro

within minutes I'd discovered where I was going wrong with my REST request xml and was back to being productive. happy days.

hope I've saved someone some headaches.

disclaimer - proof of concept as to why you shouldn't trust your IP to the microsoft script encoder, not a way to rip off your competitors, extend your trials or anything of the similar.

 

]]>
http://www.daveheavyindustries.com/2011/04/28/decoding-windows-script-encoder-encoded-scripts/feed/ 0
Distance between two points with curvature http://www.daveheavyindustries.com/2011/02/25/distance-between-two-points-with-curvature/ http://www.daveheavyindustries.com/2011/02/25/distance-between-two-points-with-curvature/#comments Fri, 25 Feb 2011 05:19:06 +0000 admin http://wp.daveheavyindustries.com/?p=120 The earth isn't flat. Sometimes you feel like over engineering a simple problem just because you can.

Late last year I put together a mobile web interface and used google maps for a store locator. I also had to use ASP Classic.
In the mids of this it struck me that a customer might find they were a few meters off from the actual distance from their current position, to what I'm reporting. Clearly this just won't do -so I re-worked it to compensate....in ASP CLASSIC, where most of the math is non existent.

enjoy!

Const M_PI = 3.14159265358979323846
Const earth_radius = 6371
Function Log2(X)
Log2 = Log(X) / Log(2)
End Function
function deg2rad(x)
deg2rad = x * M_PI / 180
end function
function rad2deg(x)
rad2deg = x * 180 / M_PI
end function
Function atan2(ys,xs)
Dim theta
If xs <> 0 Then
theta = Atn(ys / xs)
If xs < 0 Then
theta = theta + pi
End If
Else
If ys < 0 Then
theta = 3 * pi / 2 '90
Else
theta = pi / 2 '270
End If
End If
atan2 = theta
End Function
function distance_between(a_lat,a_lon,b_lat,b_lon)
dim dLat, dLon
dLat = deg2rad(a_lat - b_lat)
dLon = deg2rad(a_lon - b_lon)
dim a, c, r, a1
a = (sin(dLat/2) * sin(dLat/2)) + ( cos( deg2rad(a_lat) ) * cos( deg2rad(b_lat))) * ( sin(dLon/2 ) * sin(dLon/2) )
aa = 1-a
c = 2 * atan2 ( a^(1/2), aa^(1/2) )
d = earth_radius * c
distance_between = d
end function

[facebook_ilike]

]]>
http://www.daveheavyindustries.com/2011/02/25/distance-between-two-points-with-curvature/feed/ 0