INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Help with a VBS

Help with a VBS

(OP)
I am new to scripting and am trying to get a script working to change the local admin password. That part works, now I have to obfuscate it. I found a script that is built for doing that and I'm trying to combine the two but its not going very well.
This is my Password changing script:


Set WshNetwork = WScript.CreateObject("WScript.Network")
strComputer = "."
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator,user")
objUser.SetPassword "NEWPASSWORD" ' Enter new password between brackets
objUser.SetInfo

This is the Obfuscating script

Dim sbox(255)
Dim key(255)
Dim Encryptkey
Dim EncryptStr
Dim Encryptedstr

Encryptkey = "ScrambleMe"
EncryptStr = InputBox("String")

Encryptedstr = EnDeCrypt(EncryptStr,Encryptkey)
testresult = InputBox("String","test",Encryptedstr)


Sub RC4Initialize(strPwd)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: This routine called by EnDeCrypt function. Initializes the :::
'::: sbox and the key array) :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

dim tempSwap
dim a
dim b

intLength = len(strPwd)
For a = 0 To 255
key(a) = asc(mid(strpwd, (a mod intLength)+1, 1))
sbox(a) = a
next

b = 0
For a = 0 To 255
b = (b + sbox(a) + key(a)) Mod 256
tempSwap = sbox(a)
sbox(a) = sbox(b)
sbox(b) = tempSwap
Next

End Sub

Function EnDeCrypt(plaintxt, psw)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: This routine does all the work. Call it both to ENcrypt :::
'::: and to DEcrypt your data. :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

dim temp
dim a
dim i
dim j
dim k
dim cipherby
dim cipher

i = 0
j = 0

RC4Initialize psw

For a = 1 To Len(plaintxt)
i = (i + 1) Mod 256
j = (j + sbox(i)) Mod 256
temp = sbox(i)
sbox(i) = sbox(j)
sbox(j) = temp

k = sbox((sbox(i) + sbox(j)) Mod 256)

cipherby = Asc(Mid(plaintxt, a, 1)) Xor k
cipher = cipher & Chr(cipherby)
Next

EnDeCrypt = cipher

End Function


I put the two together but i keep getting errors :

Dim sbox(255)
Dim key(255)
Dim Encryptkey
Dim EncryptStr
Dim Encryptedstr
'Dim PSW
Encryptkey = "ScrambleMe"
'PSW = RC4Initialize("€jW˜nÌc")

Encryptedstr = EnDeCrypt(EncryptStr,Encryptkey)



Set WshNetwork = WScript.CreateObject("WScript.Network")
strComputer = "."
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator,user")
objUser.SetPassword RC4Initialize("€jW˜nÌc") ' Enter new password between brackets
objUser.SetInfo



Sub RC4Initialize(strPwd)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: This routine called by EnDeCrypt function. Initializes the :::
'::: sbox and the key array) :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

dim tempSwap
dim a
dim b

intLength = len(strPwd)
For a = 0 To 255
key(a) = asc(mid(strpwd, (a mod intLength)+1, 1))
sbox(a) = a
next

b = 0
For a = 0 To 255
b = (b + sbox(a) + key(a)) Mod 256
tempSwap = sbox(a)
sbox(a) = sbox(b)
sbox(b) = tempSwap
Next

End Sub

Function EnDeCrypt(plaintxt, psw)
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: This routine does all the work. Call it both to ENcrypt :::
'::: and to DEcrypt your data. :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

dim temp
dim a
dim i
dim j
dim k
dim cipherby
dim cipher

i = 0
j = 0

RC4Initialize psw

For a = 1 To Len(plaintxt)
i = (i + 1) Mod 256
j = (j + sbox(i)) Mod 256
temp = sbox(i)
sbox(i) = sbox(j)
sbox(j) = temp

k = sbox((sbox(i) + sbox(j)) Mod 256)

cipherby = Asc(Mid(plaintxt, a, 1)) Xor k
cipher = cipher & Chr(cipherby)
Next

EnDeCrypt = cipher

End Function
Any help would be greatly appreciated

RE: Help with a VBS

You might want to ask that question in forum329: VBScript. This forum is for the full development tool, VB5/6 which is not the same as VBScript.

Having said that, I'm curious about the need to obfuscate here.; If it is because you feel you don't wasn't o have the admin password in plaintext in the script, well that sounds great - except ... the reason for that would be to prevent someone seeing the password. But if they san see the plaintext it means they can see the script, and if they can see the script they can see how the obfuscation is being done and, more importantly not only how to unobfuscate it, but would actually be able to simply run the code in the script to do so ...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close