Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for obscure.rex

(view source code of obscure.rex as plain text)

  1. /* Initialize variables */
  2. debug  = 0
  3. ip     = ""
  4. header = "0D0A"X||"Obscure.rex,  Version 1.00"||"0D0A"X,
  5.        ||"Obscure the specified URL by converting the host name to a decimal IP address"||"0D0A"X,
  6.        ||"and by adding a hostname (either vake or valid) as a fake login name."||"0D0A"X
  7. footer = "Note:   Security settings of your browser may block use of decimal addresses"||"0D0A0D0A"X,
  8.        ||"Written by Rob van der Woude"||"0D0A"X||"http://www.robvanderwoude.com"
  9. explan = "Explanation:"||"0D0A"X,
  10.        ||"Let us take the fictional http://somehost.com/sources/ and let's assume"||"0D0A"X,
  11.        ||"somehost.com's IP address is 1.2.3.4. The decimal representation of the"||"0D0A"X,
  12.        ||"IP address is: 1 * 256^3 + 2 * 256^2 + 3 * 256 + 4 = 16909060"||"0D0A"X,
  13.        ||"(try pinging 16909060, it will show 1.2.3.4 as the address being pinged)"||"0D0A"X,
  14.        ||"So the URL could also be written as http://16909060/sources/"||"0D0A"X,
  15.        ||"Any URL may be preceded with a (fake) user ID followed by an @"||"0D0A"X,
  16.        ||"So we can further obscure the URL by adding a (fake) host name:"||"0D0A"X,
  17.        ||"http://fake.host@16909060/sources/ still points to http://somehost.com/sources/"||"0D0A"X
  18.  
  19. /* Hide external commands */
  20. "@ECHO OFF"
  21. Trace Off
  22.  
  23. /* Parse command line arguments */
  24. Parse Arg url debug dummy
  25. If url   =  "" Then Call Syntax
  26. If dummy <> "" Then Call Syntax
  27. If debug <> "" Then Do
  28. 	If Translate( debug ) = "-DEBUG" Then Do
  29. 		debug = 1
  30. 	End
  31. 	Else Do
  32. 		Call Syntax
  33. 	End
  34. End
  35.  
  36. /* Split URL into protocol. host name and path */
  37. Parse Value url With prot"://"host"/"path
  38. If host = "" Then Do
  39. 	prot = ""
  40. 	Parse Value url With host"/"path
  41. End
  42. If path = "" Then Do
  43. 	If Right( url, 1 ) = "/" Then path = "/"
  44. End
  45. Else Do
  46. 	path = "/"||path
  47. End
  48.  
  49. /* Convert host name to IP address using PING command */
  50. "PING "||host||" -n 1 | RXQUEUE"
  51. Do Until Queued() = 0
  52. 	Parse Pull line
  53. 	If Pos( "[", line ) > 0 Then Parse Value line With ."["ip"]".
  54. End
  55.  
  56. /* Slit IP address into 4 octets */
  57. Parse Value ip with ip1"."ip2"."ip3"."ip4
  58.  
  59. /* Error message if no 4 octets */
  60. If ip4 = "" Then Do
  61. 	Say
  62. 	Say "Invalid host name or host not available"
  63. 	Call Syntax "SHORT"
  64. End
  65.  
  66. /* Add leading zeroes to octets if necessary, and concatenate 4 hex octets into 8 digit hex number */
  67. iphex = Right( D2X( ip1 ), 2, "0" )||Right( D2X( ip2 ), 2, "0" )||Right( D2X( ip3 ), 2, "0" )||Right( D2X( ip4 ), 2, "0" )
  68.  
  69. /* Convert hexadecimal IP address to decimal */
  70. Numeric Digits 10
  71. ipdec = X2D( iphex )
  72.  
  73. /* Show intermediate results if requested */
  74. If debug = 1 Then Do
  75. 	Say
  76. 	Say "URL            = "||url
  77. 	Say "Protocol       = "||prot
  78. 	Say "Host name      = "||host
  79. 	Say "IP Address     = "||ip
  80. 	Say "Hexadecimal IP = "||iphex
  81. 	Say "Decimal IP     = "||ipdec
  82. 	Say "Path           = "||path
  83. End
  84.  
  85. If prot <> "" Then prot = prot||"://"
  86.  
  87. Say header
  88. Say footer
  89. Say
  90. Say "Obscured URL examples:"
  91. Say
  92. Say "   "||prot||ipdec||path
  93. Say "   "prot||"www.whateveryoulike.here@"||ipdec||path
  94.  
  95. /* Done */
  96. Exit 0
  97.  
  98.  
  99. Syntax:
  100. 	Say
  101. 	Say header
  102. 	Say
  103. 	Say "Usage:  OBSCURE.REX  url  [ -DEBUG ]"
  104. 	Say
  105. 	Say 'Where:  "url"     can be any valid URL, host name or IP address'
  106. 	Say '        "-DEBUG"  displays intermediate results'
  107. 	Say
  108. 	If Arg( 1 ) <> "SHORT" Then Say explan
  109. 	Say footer
  110. 	Exit 1
  111. Return
  112.  

page last modified: 2024-04-16; loaded in 0.0076 seconds