Guest User

kajvanschalk cipher BROKEN

a guest
Apr 20th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Comments left by u/Maxxer500, aka C0deR0gue
  2. 'Comments left to explain what parts are broken/causing undesirable effects, and why
  3. 'Fixes will be demonstrated in comments along with explanations
  4.  
  5. 'The sheer number of empty space in here makes reading this script much more difficult than it has to be. You can bunch related bits together!
  6.  
  7. 'There's some unnecessary bits here making things less readable, and the new line breaks things. That might've been Reddit doing weird formatting
  8. 'Set x = CreateObject("wscript.shell")
  9. set x = WScript.CreateObject("
  10. WScript.Shell")
  11.  
  12. encrypt = inputbox("type text om te versleutelen")
  13.  
  14. 'This line is completely fine, but as mentioned in my "simple 2-way cipher.vbs" uppercase characters won't be picked up by the Replace function and won't be converted. It's fine if that's intentional, but if it isn't just add the following line:
  15. 'encrypt=lcase(encrypt)
  16. encrypt = StrReverse(encrypt)
  17.  
  18. x.Run "%windir%\notepad"
  19.  
  20. wscript.sleep 1000
  21.  
  22. 'In this line you call the encode function, but it hasn't been defined yet! I don't recall if VBScript breaks in this scenario, but I know other coding/scripting languages will. Simply put this line after the "End Function" line
  23. x.sendkeys encode(encrypt)
  24.  
  25. function encode(s)
  26.  
  27. 'From what I can tell this line is unnecessary and iterates the text 25 times
  28. For counter = 1 To 25 Step 1
  29.  
  30. 'The Replace function works on every part of the string by default, so there's no need to run it multiple times
  31. For i = 1 To Len(s)
  32.  
  33. 'I'm confused what the purpose of this line is, and I'm pretty sure it complicates things
  34. newtxt = Mid(s, i, 1)
  35.  
  36. 'Okay this upcoming section has a number of issues. For one, it converts both C and I into N, and N converts to L. There's also a couple characters that don't get converted into, like C. If this is supposed to work 2-ways, each character can only have one corresponding character and corresponding characters need to link back to each other.
  37. 'For a fixed version you can refer to the "simple 2-way cipher.vbs" I'm linking in addition to this script, just look at the cipher function there
  38. newtxt = Replace(newtxt,"a", "w")
  39.  
  40. newtxt = Replace(newtxt,"b", "j")
  41.  
  42. newtxt = Replace(newtxt,"c", "n")
  43.  
  44. newtxt = Replace(newtxt,"d", "s")
  45.  
  46. newtxt = Replace(newtxt,"e", "z")
  47.  
  48. newtxt = Replace(newtxt,"f", "g")
  49.  
  50. newtxt = Replace(newtxt,"g", "q")
  51.  
  52. newtxt = Replace(newtxt,"h", "m")
  53.  
  54. newtxt = Replace(newtxt,"i", "n")
  55.  
  56. newtxt = Replace(newtxt,"j", "a")
  57.  
  58. newtxt = Replace(newtxt,"k", "f")
  59.  
  60. newtxt = Replace(newtxt,"l", "u")
  61.  
  62. newtxt = Replace(newtxt,"m", "o")
  63.  
  64. newtxt = Replace(newtxt,"n", "l")
  65.  
  66. newtxt = Replace(newtxt,"o", "d")
  67.  
  68. newtxt = Replace(newtxt,"p", "h")
  69.  
  70. newtxt = Replace(newtxt,"q", "@")
  71.  
  72. newtxt = Replace(newtxt,"r", "#")
  73.  
  74. 'The carot (^) symbol has a special use in the SendKeys function, so while it won't break here it will cause undesired effects in the text when typed. I believe this can be fixed by encasing it in braces
  75. 'More info at: https://docs.microsoft.com/en-us/office/vba/Language/Reference/user-interface-help/sendkeys-statement
  76. 'newtxt=Replace(newtxt , "s" , "{^}")
  77. newtxt = Replace(newtxt,"s", "^")
  78.  
  79. 'Same issue as the carot, encase it in braces
  80. 'newtxt=Replace(newtxt , "t" , "{%}")
  81. newtxt = Replace(newtxt,"t", "%")
  82.  
  83. newtxt = Replace(newtxt,"u", "€")
  84.  
  85. 'Same issue as the carot, encase it in braces
  86. 'newtxt=Replace(newtxt, "v" , "{~}")
  87. newtxt = Replace(newtxt,"v", "~")
  88.  
  89. newtxt = Replace(newtxt,"w", "&")
  90.  
  91. newtxt = Replace(newtxt,"x", "$")
  92.  
  93. newtxt = Replace(newtxt,"y", "!")
  94.  
  95. newtxt = Replace(newtxt,"z", "e")
  96.  
  97. 'This line right here. This line is what gives you the weird characters that aren't seen anywhere in the script. I believe the & is combining things in some mathematical way, instead of as text. And it's not even necessary! Just output your newtxt variable and things will work.
  98.  
  99. coded = coded & newtxt
  100. 'You have 2 For statements above, but only 1 Next. VBScript kept yelling at me for 20 minutes until I gave it another Next. But we're removing the For statements, so remove the Next statements as well
  101. Next
  102.  
  103. 'After removing the "coded = coded & newtxt" line you need to change coded to newtxt in this line
  104. 'encode=newtxt
  105. encode = coded
  106.  
  107. End function
Advertisement
Add Comment
Please, Sign In to add comment